"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8715],{77830:(v,l,e)=>{e.d(l,{f:()=>n});var a=e(66111),i=e(13821),s=e(77582),_=e(27876),m=e(17069),o=e(11630);const n=({teamId:t,roleOptions:c,disabled:E,onApplyRoles:A,pendingRoles:P,apply:r=!1,maxWidth:D})=>{const[{loading:T,value:M=[]},u]=(0,i.Z)(async()=>{try{if(r&&Boolean(P?.length))return P;if(s.Vt.hasPermission(_.AccessControlAction.ActionTeamsRolesList))return await(0,o._C)(t)}catch(O){console.error("Error loading options",O)}return[]},[t,P]);(0,a.useEffect)(()=>{u()},[t,u,P]);const f=async O=>{r?A&&A(O):(await(0,o.u7)(O,t),await u())},C=s.Vt.hasPermission(_.AccessControlAction.ActionTeamsRolesAdd)&&s.Vt.hasPermission(_.AccessControlAction.ActionTeamsRolesRemove);return a.createElement(m.I,{apply:r,onRolesChange:f,roleOptions:c,appliedRoles:M,isLoading:T,disabled:E,basicRoleDisabled:!0,canUpdateRoles:C,maxWidth:D})}},58693:(v,l,e)=>{e.d(l,{C:()=>o});var a=e(66111),i=e(42638),s=e(77582),_=e(27876),m=e(11630);const o=n=>{const[t,c]=(0,a.useState)(n),{value:E=[]}=(0,i.Z)(async()=>s.Vt.licensedAccessControlEnabled()&&s.Vt.hasPermission(_.AccessControlAction.ActionRolesList)?(0,m.ul)(t):Promise.resolve([]),[t]);return[{roleOptions:E},c]}},39874:(v,l,e)=>{e.r(l),e.d(l,{CreateTeam:()=>M,default:()=>u});var a=e(66111),i=e(54899),s=e(37932),_=e(94270),m=e(13393),o=e(24799),n=e(46967),t=e(31403),c=e(8412),E=e(77830),A=e(11630),P=e(58693),r=e(77582),D=e(27876);const T={icon:"users-alt",id:"team-new",text:"New team",subTitle:"Create a new team. Teams let you grant permissions to a group of users.",breadcrumbs:[{title:"Configuration",url:"org/teams"}]},M=()=>{const f=r.Vt.user.orgId,[C,O]=(0,a.useState)([]),[{roleOptions:I}]=(0,P.C)(f),g=r.Vt.hasPermission(D.AccessControlAction.ActionUserRolesAdd)&&r.Vt.hasPermission(D.AccessControlAction.ActionUserRolesRemove),U=async R=>{const d=await(0,i.i)().post("/api/teams",R);if(d.teamId){try{await r.Vt.fetchUserPermissions(),r.Vt.licensedAccessControlEnabled()&&g&&await(0,A.u7)(C,d.teamId,d.orgId)}catch(L){console.error(L)}s.E1.push(`/org/teams/edit/${d.teamId}`)}};return a.createElement(c.T,{navId:"teams",pageNav:T},a.createElement(c.T.Contents,null,a.createElement(_.l,{onSubmit:U},({register:R,errors:d})=>a.createElement(m.C,null,a.createElement(o.g,{label:"Name",required:!0,invalid:!!d.name,error:"Team name is required"},a.createElement(n.I,{...R("name",{required:!0}),id:"team-name"})),r.Vt.licensedAccessControlEnabled()&&a.createElement(o.g,{label:"Role"},a.createElement(E.f,{teamId:0,roleOptions:I,disabled:!1,apply:!0,onApplyRoles:O,pendingRoles:C,maxWidth:"100%"})),a.createElement(o.g,{label:"Email",description:"This is optional and is primarily used for allowing custom team avatars."},a.createElement(n.I,{...R("email"),type:"email",id:"team-email",placeholder:"email@test.com"})),a.createElement("div",{className:"gf-form-button-row"},a.createElement(t.zx,{type:"submit",variant:"primary"},"Create"))))))},u=M},42638:(v,l,e)=>{var a;a={value:!0};var i=e(9683),s=e(66111),_=i.__importDefault(e(55986));function m(o,n){n===void 0&&(n=[]);var t=_.default(o,n,{loading:!0}),c=t[0],E=t[1];return s.useEffect(function(){E()},[E]),c}l.Z=m}}]);

//# sourceMappingURL=CreateTeam.a0b49e2f7923ca44e06e.js.map