"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8715],{77830:(I,_,e)=>{e.d(_,{f:()=>l});var a=e(68404),P=e(671),o=e(77582),r=e(81168),O=e(17069),n=e(11630);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})}},58693:(I,_,e)=>{e.d(_,{C:()=>n});var a=e(68404),P=e(50700),o=e(77582),r=e(81168),O=e(11630);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]}},39874:(I,_,e)=>{e.r(_),e.d(_,{CreateTeam:()=>C,default:()=>A});var a=e(68404),P=e(54899),o=e(37932),r=e(94270),O=e(13393),n=e(24799),l=e(46967),s=e(31403),E=e(79396),D=e(77830),d=e(11630),c=e(58693),t=e(77582),M=e(81168);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.17a90506935d6cab1986.js.map