"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8715],{78481:(v,l,e)=>{e.d(l,{f:()=>n});var a=e(27702),i=e(26811),s=e(66574),_=e(18771),m=e(3718),o=e(11349);const n=({teamId:t,roleOptions:E,disabled:c,onApplyRoles:D,pendingRoles:P,apply:r=!1,maxWidth:u})=>{const[{loading:T,value:M=[]},A]=(0,i.Z)(async()=>{try{if(r&&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)(()=>{A()},[t,A,P]);const f=async O=>{r?D&&D(O):(await(0,o.u7)(O,t),await A())},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:T,disabled:c,basicRoleDisabled:!0,canUpdateRoles:C,maxWidth:u})}},35817:(v,l,e)=>{e.d(l,{C:()=>o});var a=e(27702),i=e(80601),s=e(66574),_=e(18771),m=e(11349);const o=n=>{const[t,E]=(0,a.useState)(n),{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]}},35451:(v,l,e)=>{e.r(l),e.d(l,{CreateTeam:()=>M,default:()=>A});var a=e(27702),i=e(73289),s=e(26129),_=e(23839),m=e(5229),o=e(22209),n=e(1128),t=e(66670),E=e(44644),c=e(78481),D=e(11349),P=e(35817),r=e(66574),u=e(18771);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."},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 d=await(0,i.i)().post("/api/teams",R);if(d.teamId){try{await r.Vt.fetchUserPermissions(),r.Vt.licensedAccessControlEnabled()&&U&&await(0,D.u7)(C,d.teamId,d.orgId)}catch(L){console.error(L)}s.E1.push(`/org/teams/edit/${d.teamId}`)}};return a.createElement(E.T,{navId:"teams",pageNav:T},a.createElement(E.T.Contents,null,a.createElement(_.l,{onSubmit:g},({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(c.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"))))))},A=M},80601:(v,l,e)=>{var a;a={value:!0};var i=e(48314),s=e(27702),_=i.__importDefault(e(58281));function m(o,n){n===void 0&&(n=[]);var t=_.default(o,n,{loading:!0}),E=t[0],c=t[1];return s.useEffect(function(){c()},[c]),E}l.Z=m}}]);

//# sourceMappingURL=CreateTeam.0558e9fb44ce09ca26e8.js.map