"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8715],{35710:(I,_,e)=>{e.d(_,{f:()=>l});var a=e(65237),P=e(98866),o=e(63969),r=e(3315),O=e(52647),n=e(11563);const l=({teamId:s,roleOptions:E,disabled:D,onApplyRoles:d,pendingRoles:c,apply:t=!1,maxWidth:M})=>{const[{loading:u,value:C=[]},A]=(0,P.Z)(async()=>{try{if(t&&Boolean(c?.length))return c;if(o.Vt.hasPermission(r.AccessControlAction.ActionTeamsRolesList))return await(0,n._C)(s)}catch(i){console.error("Error loading options",i)}return[]},[s,c]);(0,a.useEffect)(()=>{A()},[s,A,c]);const v=async i=>{t?d&&d(i):(await(0,n.u7)(i,s),await A())},R=o.Vt.hasPermission(r.AccessControlAction.ActionTeamsRolesAdd)&&o.Vt.hasPermission(r.AccessControlAction.ActionTeamsRolesRemove);return a.createElement(O.I,{apply:t,onRolesChange:v,roleOptions:E,appliedRoles:C,isLoading:u,disabled:D,basicRoleDisabled:!0,canUpdateRoles:R,maxWidth:M})}},47468:(I,_,e)=>{e.d(_,{C:()=>n});var a=e(65237),P=e(37843),o=e(63969),r=e(3315),O=e(11563);const n=l=>{const[s,E]=(0,a.useState)(l),{value:D=[]}=(0,P.Z)(async()=>o.Vt.licensedAccessControlEnabled()&&o.Vt.hasPermission(r.AccessControlAction.ActionRolesList)?(0,O.ul)(s):Promise.resolve([]),[s]);return[{roleOptions:D},E]}},51659:(I,_,e)=>{e.r(_),e.d(_,{CreateTeam:()=>C,default:()=>A});var a=e(65237),P=e(55041),o=e(38002),r=e(46181),O=e(37885),n=e(5263),l=e(96682),s=e(48389),E=e(38992),D=e(35710),d=e(11563),c=e(47468),t=e(63969),M=e(3315);const u={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"}]},C=()=>{const v=t.Vt.user.orgId,[R,i]=(0,a.useState)([]),[{roleOptions:f}]=(0,c.C)(v),g=t.Vt.hasPermission(M.AccessControlAction.ActionUserRolesAdd)&&t.Vt.hasPermission(M.AccessControlAction.ActionUserRolesRemove),U=async T=>{const m=await(0,P.i)().post("/api/teams",T);if(m.teamId){try{await t.Vt.fetchUserPermissions(),t.Vt.licensedAccessControlEnabled()&&g&&await(0,d.u7)(R,m.teamId,m.orgId)}catch(L){console.error(L)}o.E1.push(`/org/teams/edit/${m.teamId}`)}};return a.createElement(E.T,{navId:"teams",pageNav:u},a.createElement(E.T.Contents,null,a.createElement(r.l,{onSubmit:U},({register:T,errors:m})=>a.createElement(O.C,null,a.createElement(n.g,{label:"Name",required:!0,invalid:!!m.name,error:"Team name is required"},a.createElement(l.I,{...T("name",{required:!0}),id:"team-name"})),t.Vt.licensedAccessControlEnabled()&&a.createElement(n.g,{label:"Role"},a.createElement(D.f,{teamId:0,roleOptions:f,disabled:!1,apply:!0,onApplyRoles:i,pendingRoles:R,maxWidth:"100%"})),a.createElement(n.g,{label:"Email",description:"This is optional and is primarily used for allowing custom team avatars."},a.createElement(l.I,{...T("email"),type:"email",id:"team-email",placeholder:"email@test.com"})),a.createElement("div",{className:"gf-form-button-row"},a.createElement(s.zx,{type:"submit",variant:"primary"},"Create"))))))},A=C}}]);

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