"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5436],{31084:(L,E,e)=>{e.d(E,{Y:()=>l});var a=e(96540),m=e(41053),s=e(10096),r=e(80348),O=e(37425),o=e(85927);const l=({teamId:n,roleOptions:c,disabled:D,roles:i,onApplyRoles:d,pendingRoles:t,apply:P=!1,maxWidth:C,width:T,isLoading:v})=>{const[{loading:u,value:M=i||[]},A]=(0,m.A)(async()=>{try{if(i)return i;if(P&&t?.length)return t;if(s.TP.hasPermission(r.AccessControlAction.ActionTeamsRolesList))return await(0,o.xN)(n)}catch(_){console.error("Error loading options",_)}return[]},[n,t,i]);(0,a.useEffect)(()=>{A()},[A]);const I=async _=>{P?d&&d(_):(await(0,o.G3)(_,n),await A())},U=s.TP.hasPermission(r.AccessControlAction.ActionTeamsRolesAdd)&&s.TP.hasPermission(r.AccessControlAction.ActionTeamsRolesRemove);return a.createElement(O.n,{apply:P,onRolesChange:I,roleOptions:c,appliedRoles:M,isLoading:u||v,disabled:D,basicRoleDisabled:!0,canUpdateRoles:U,maxWidth:C,width:T})}},54939:(L,E,e)=>{e.d(E,{o:()=>o});var a=e(96540),m=e(24705),s=e(10096),r=e(80348),O=e(85927);const o=l=>{const[n,c]=(0,a.useState)(l),{value:D=[]}=(0,m.A)(async()=>s.TP.licensedAccessControlEnabled()&&s.TP.hasPermission(r.AccessControlAction.ActionRolesList)?(0,O.RL)(n):Promise.resolve([]),[n]);return[{roleOptions:D},c]}},80011:(L,E,e)=>{e.r(E),e.d(E,{CreateTeam:()=>T,default:()=>v});var a=e(96540),m=e(49785),s=e(17172),r=e(12131),O=e(84167),o=e(88575),l=e(10354),n=e(55852),c=e(36830),D=e(31084),i=e(85927),d=e(54939),t=e(10096),P=e(80348);const C={icon:"users-alt",id:"team-new",text:"New team",subTitle:"Create a new team. Teams let you grant permissions to a group of users."},T=()=>{const u=t.TP.user.orgId,[M,A]=(0,a.useState)([]),[{roleOptions:I}]=(0,d.o)(u),{handleSubmit:U,register:_,formState:{errors:f}}=(0,m.mN)(),p=t.TP.hasPermission(P.AccessControlAction.ActionUserRolesAdd)&&t.TP.hasPermission(P.AccessControlAction.ActionUserRolesRemove),W=async g=>{const R=await(0,s.AI)().post("/api/teams",g);if(R.teamId){try{await t.TP.fetchUserPermissions(),t.TP.licensedAccessControlEnabled()&&p&&await(0,i.G3)(M,R.teamId,R.orgId)}catch(B){console.error(B)}r.Ny.push(`/org/teams/edit/${R.teamId}`)}};return a.createElement(c.Y,{navId:"teams",pageNav:C},a.createElement(c.Y.Contents,null,a.createElement("form",{onSubmit:U(W),style:{maxWidth:"600px"}},a.createElement(O.n,null,a.createElement(o.D,{label:"Name",required:!0,invalid:!!f.name,error:"Team name is required"},a.createElement(l.p,{..._("name",{required:!0}),id:"team-name"})),t.TP.licensedAccessControlEnabled()&&a.createElement(o.D,{label:"Role"},a.createElement(D.Y,{teamId:0,roleOptions:I,disabled:!1,apply:!0,onApplyRoles:A,pendingRoles:M,maxWidth:"100%"})),a.createElement(o.D,{label:"Email",description:"This is optional and is primarily used for allowing custom team avatars."},a.createElement(l.p,{..._("email"),type:"email",id:"team-email",placeholder:"email@test.com"}))),a.createElement(n.$n,{type:"submit",variant:"primary"},"Create"))))},v=T}}]);

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