"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8715],{21090:(T,l,e)=>{e.d(l,{f:()=>o});var a=e(39953),i=e(65489),s=e(21308),_=e(57721),m=e(35430),n=e(4171);const o=({teamId:t,roleOptions:E,disabled:c,onApplyRoles:d,pendingRoles:P,apply:r=!1,maxWidth:u})=>{const[{loading:v,value:M=[]},D]=(0,i.Z)(async()=>{try{if(r&&P?.length)return P;if(s.Vt.hasPermission(_.AccessControlAction.ActionTeamsRolesList))return await(0,n._C)(t)}catch(O){console.error("Error loading options",O)}return[]},[t,P]);(0,a.useEffect)(()=>{D()},[t,D,P]);const f=async O=>{r?d&&d(O):(await(0,n.u7)(O,t),await D())},C=s.Vt.hasPermission(_.AccessControlAction.ActionTeamsRolesAdd)&&s.Vt.hasPermission(_.AccessControlAction.ActionTeamsRolesRemove);return a.createElement(m.I,{apply:r,onRolesChange:f,roleOptions:E,appliedRoles:M,isLoading:v,disabled:c,basicRoleDisabled:!0,canUpdateRoles:C,maxWidth:u})}},38957:(T,l,e)=>{e.d(l,{C:()=>n});var a=e(39953),i=e(99292),s=e(21308),_=e(57721),m=e(4171);const n=o=>{const[t,E]=(0,a.useState)(o),{value:c=[]}=(0,i.Z)(async()=>s.Vt.licensedAccessControlEnabled()&&s.Vt.hasPermission(_.AccessControlAction.ActionRolesList)?(0,m.ul)(t):Promise.resolve([]),[t]);return[{roleOptions:c},E]}},20713:(T,l,e)=>{e.r(l),e.d(l,{CreateTeam:()=>M,default:()=>D});var a=e(39953),i=e(4148),s=e(13601),_=e(85830),m=e(2827),n=e(96227),o=e(38637),t=e(4919),E=e(13253),c=e(21090),d=e(4171),P=e(38957),r=e(21308),u=e(57721);const v={icon:"users-alt",id:"team-new",text:"New team",subTitle:"Create a new team. Teams let you grant permissions to a group of users."},M=()=>{const f=r.Vt.user.orgId,[C,O]=(0,a.useState)([]),[{roleOptions:I}]=(0,P.C)(f),U=r.Vt.hasPermission(u.AccessControlAction.ActionUserRolesAdd)&&r.Vt.hasPermission(u.AccessControlAction.ActionUserRolesRemove),g=async R=>{const A=await(0,i.i)().post("/api/teams",R);if(A.teamId){try{await r.Vt.fetchUserPermissions(),r.Vt.licensedAccessControlEnabled()&&U&&await(0,d.u7)(C,A.teamId,A.orgId)}catch(L){console.error(L)}s.E1.push(`/org/teams/edit/${A.teamId}`)}};return a.createElement(E.T,{navId:"teams",pageNav:v},a.createElement(E.T.Contents,null,a.createElement(_.l,{onSubmit:g},({register:R,errors:A})=>a.createElement(a.Fragment,null,a.createElement(m.C,null,a.createElement(n.g,{label:"Name",required:!0,invalid:!!A.name,error:"Team name is required"},a.createElement(o.I,{...R("name",{required:!0}),id:"team-name"})),r.Vt.licensedAccessControlEnabled()&&a.createElement(n.g,{label:"Role"},a.createElement(c.f,{teamId:0,roleOptions:I,disabled:!1,apply:!0,onApplyRoles:O,pendingRoles:C,maxWidth:"100%"})),a.createElement(n.g,{label:"Email",description:"This is optional and is primarily used for allowing custom team avatars."},a.createElement(o.I,{...R("email"),type:"email",id:"team-email",placeholder:"email@test.com"}))),a.createElement(t.zx,{type:"submit",variant:"primary"},"Create")))))},D=M},99292:(T,l,e)=>{var a;a={value:!0};var i=e(52732),s=e(39953),_=i.__importDefault(e(95681));function m(n,o){o===void 0&&(o=[]);var t=_.default(n,o,{loading:!0}),E=t[0],c=t[1];return s.useEffect(function(){c()},[c]),E}l.Z=m}}]);

//# sourceMappingURL=CreateTeam.1b16f2a5a7db3f49367c.js.map