TeamPages.e119b2547fd7d5579f18.js 21 KB

1234
  1. "use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8612],{67833:(e,t,s)=>{s.d(t,{Z:()=>j,v:()=>x});var a,n,r,i,d=s(69501),o=s(17092),l=s(36636),m=s(68404),c=s(16695),h=s(69783),u=s(76187),g=s(28659),p=s(45916);function b(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const f=[{value:"",label:o.ag._({id:"shared-preferences.theme.default-label",message:"Default"})},{value:"dark",label:o.ag._({id:"shared-preferences.theme.dark-label",message:"Dark"})},{value:"light",label:o.ag._({id:"shared-preferences.theme.light-label",message:"Light"})}];class x extends m.PureComponent{constructor(e){super(e),b(this,"service",void 0),b(this,"onSubmitForm",(async()=>{const{homeDashboardId:e,theme:t,timezone:s,weekStart:a,queryHistory:n}=this.state;await this.service.update({homeDashboardId:e,theme:t,timezone:s,weekStart:a,queryHistory:n}),window.location.reload()})),b(this,"onThemeChanged",(e=>{this.setState({theme:e})})),b(this,"onTimeZoneChanged",(e=>{e&&this.setState({timezone:e})})),b(this,"onWeekStartChanged",(e=>{this.setState({weekStart:e})})),b(this,"onHomeDashboardChanged",(e=>{this.setState({homeDashboardId:e})})),b(this,"getFullDashName",(e=>void 0===e.folderTitle||""===e.folderTitle?e.title:e.folderTitle+" / "+e.title)),this.service=new u.y(e.resourceUri),this.state={homeDashboardId:0,theme:"",timezone:"",weekStart:"",dashboards:[],queryHistory:{homeTab:""}}}async componentDidMount(){const e=await this.service.load(),t=await g.ae.search({starred:!0});if(e.homeDashboardId>0&&!t.find((t=>t.id===e.homeDashboardId))){const s=await g.ae.search({dashboardIds:[e.homeDashboardId]});s&&s.length>0&&t.push(s[0])}this.setState({homeDashboardId:e.homeDashboardId,theme:e.theme,timezone:e.timezone,weekStart:e.weekStart,dashboards:[{id:0,title:"Default",tags:[],type:"",uid:"",uri:"",url:"",folderId:0,folderTitle:"",folderUid:"",folderUrl:"",isStarred:!1,slug:"",items:[]},...t],queryHistory:e.queryHistory})}render(){const{theme:e,timezone:t,weekStart:s,homeDashboardId:l,dashboards:m}=this.state,{disabled:u}=this.props,g=v(),b=a||(a=(0,p.jsx)(h.Tooltip,{content:(0,p.jsx)(d.cC,{id:"shared-preferences.fields.home-dashboard-tooltip"}),children:(0,p.jsx)(h.Icon,{name:"info-circle"})}));return(0,p.jsx)(h.Form,{onSubmit:this.onSubmitForm,children:()=>{var a;return(0,p.jsxs)(h.FieldSet,{label:n||(n=(0,p.jsx)(d.cC,{id:"shared-preferences.title"})),disabled:u,children:[(0,p.jsx)(h.Field,{label:o.ag._({id:"shared-preferences.fields.theme-label",message:"UI Theme"}),children:(0,p.jsx)(h.RadioButtonGroup,{options:f,value:null===(a=f.find((t=>t.value===e)))||void 0===a?void 0:a.value,onChange:this.onThemeChanged})}),(0,p.jsx)(h.Field,{label:(0,p.jsxs)(h.Label,{htmlFor:"home-dashboard-select",children:[(0,p.jsx)("span",{className:g.labelText,children:r||(r=(0,p.jsx)(d.cC,{id:"shared-preferences.fields.home-dashboard-label"}))}),b]}),"data-testid":"User preferences home dashboard drop down",children:(0,p.jsx)(h.Select,{value:m.find((e=>e.id===l)),getOptionValue:e=>e.id,getOptionLabel:this.getFullDashName,onChange:e=>this.onHomeDashboardChanged(e.id),options:m,placeholder:o.ag._({id:"shared-preferences.fields.home-dashboard-placeholder",message:"Choose default dashboard"}),inputId:"home-dashboard-select"})}),(0,p.jsx)(h.Field,{label:o.ag._({id:"shared-dashboard.fields.timezone-label",message:"Timezone"}),"data-testid":c.wl.components.TimeZonePicker.containerV2,children:(0,p.jsx)(h.TimeZonePicker,{includeInternal:!0,value:t,onChange:this.onTimeZoneChanged,inputId:"shared-preferences-timezone-picker"})}),(0,p.jsx)(h.Field,{label:o.ag._({id:"shared-preferences.fields.week-start-label",message:"Week start"}),"data-testid":c.wl.components.WeekStartPicker.containerV2,children:(0,p.jsx)(h.WeekStartPicker,{value:s,onChange:this.onWeekStartChanged,inputId:"shared-preferences-week-start-picker"})}),(0,p.jsx)("div",{className:"gf-form-button-row",children:(0,p.jsx)(h.Button,{type:"submit",variant:"primary","data-testid":c.wl.components.UserProfile.preferencesSaveButton,children:i||(i=(0,p.jsx)(d.cC,{id:"common.save"}))})})]})}})}}const j=x,v=(0,h.stylesFactory)((()=>({labelText:l.css`
  2. margin-right: 6px;
  3. `})))},6467:(e,t,s)=>{s.r(t),s.d(t,{TeamPages:()=>fe,default:()=>xe});var a,n,r,i,d,o,l,m=s(82897),c=s(68404),h=s(18745),u=s(90923),g=s(69783),p=s(33801),b=s(51211),f=s(78837),x=s(8674),j=s(61959),v=s(58170),y=s(72779),T=s(6347),I=s(28436),w=s(65623),A=s(44083),C=s(71181),S=s(45916);function P(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function k(e){return{groups:(0,C.JB)(e.team)}}const M={loadTeamGroups:A.j_,addTeamGroup:A.A_,removeTeamGroup:A.P5},L=((0,h.connect)(k,M),"Sync LDAP or OAuth groups with your Grafana teams.");class N extends c.PureComponent{constructor(e){super(e),P(this,"onToggleAdding",(()=>{this.setState({isAdding:!this.state.isAdding})})),P(this,"onNewGroupIdChanged",(e=>{this.setState({newGroupId:e.target.value})})),P(this,"onAddGroup",(e=>{e.preventDefault(),this.props.addTeamGroup(this.state.newGroupId),this.setState({isAdding:!1,newGroupId:""})})),P(this,"onRemoveGroup",(e=>{this.props.removeTeamGroup(e.groupId)})),this.state={isAdding:!1,newGroupId:""}}componentDidMount(){this.fetchTeamGroups()}async fetchTeamGroups(){await this.props.loadTeamGroups()}isNewGroupValid(){return this.state.newGroupId.length>1}renderGroup(e){const{isReadOnly:t}=this.props;return(0,S.jsxs)("tr",{children:[(0,S.jsx)("td",{children:e.groupId}),(0,S.jsx)("td",{style:{width:"1%"},children:(0,S.jsx)(g.Button,{size:"sm",variant:"destructive",onClick:()=>this.onRemoveGroup(e),disabled:t,"aria-label":`Remove group ${e.groupId}`,children:a||(a=(0,S.jsx)(g.Icon,{name:"times"}))})})]},e.groupId)}render(){const{isAdding:e,newGroupId:t}=this.state,{groups:s,isReadOnly:a}=this.props;return(0,S.jsxs)("div",{children:[(0,w.d)()&&(n||(n=(0,S.jsx)(b.Xz,{featureId:"team-sync",eventVariant:"trial",featureName:"team sync",text:"Add a group to enable team sync for free during your trial of Grafana Pro."}))),(0,S.jsxs)("div",{className:"page-action-bar",children:[(!(0,w.d)()||s.length>0)&&(0,S.jsxs)(S.Fragment,{children:[r||(r=(0,S.jsx)("h3",{className:"page-sub-heading",children:"External group sync"})),i||(i=(0,S.jsx)(g.Tooltip,{placement:"auto",content:L,children:(0,S.jsx)(g.Icon,{className:"icon--has-hover page-sub-heading-icon",name:"question-circle"})}))]}),d||(d=(0,S.jsx)("div",{className:"page-action-bar__spacer"})),s.length>0&&(0,S.jsxs)(g.Button,{className:"pull-right",onClick:this.onToggleAdding,disabled:a,children:[o||(o=(0,S.jsx)(g.Icon,{name:"plus"}))," Add group"]})]}),(0,S.jsx)(y.s,{in:e,children:(0,S.jsxs)("div",{className:"cta-form",children:[(0,S.jsx)(T.P,{onClick:this.onToggleAdding}),(0,S.jsx)("form",{onSubmit:this.onAddGroup,children:(0,S.jsxs)(g.InlineFieldRow,{children:[(0,S.jsx)(g.InlineField,{label:"Add External Group",children:(0,S.jsx)(g.Input,{type:"text",id:"add-external-group",value:t,onChange:this.onNewGroupIdChanged,placeholder:"cn=ops,ou=groups,dc=grafana,dc=org",disabled:a})}),(0,S.jsx)(g.Button,{type:"submit",disabled:a||!this.isNewGroupValid(),style:{marginLeft:4},children:"Add group"})]})})]})}),0===s.length&&!e&&((0,w.d)()?(0,S.jsx)(G,{action:{onClick:this.onToggleAdding,text:"Add group"}}):(0,S.jsx)(I.Z,{onClick:this.onToggleAdding,buttonIcon:"users-alt",title:"There are no external groups to sync with",buttonTitle:"Add group",proTip:L,proTipLinkTitle:"Learn more",proTipLink:"https://docs.grafana.org/auth/enhanced_ldap/",proTipTarget:"_blank",buttonDisabled:a})),s.length>0&&(0,S.jsx)("div",{className:"admin-list-table",children:(0,S.jsxs)("table",{className:"filter-table filter-table--hover form-inline",children:[(0,S.jsx)("thead",{children:(0,S.jsxs)("tr",{children:[l||(l=(0,S.jsx)("th",{children:"External Group ID"})),(0,S.jsx)("th",{style:{width:"1%"}})]})}),(0,S.jsx)("tbody",{children:s.map((e=>this.renderGroup(e)))})]})})]})}}const G=e=>{let{action:t}=e;const s=(0,g.useTheme2)();return(0,S.jsx)(b.TA,{action:t,listItems:["Stop managing user access in two places - assign users to groups in SAML, LDAP or Oauth, and manage access at a Team level in Grafana","Update users’ permissions immediately when you add or remove them from an LDAP group, with no need for them to sign out and back in"],image:`team-sync-${s.isLight?"light":"dark"}.png`,featureName:"team sync",featureUrl:"https://grafana.com/docs/grafana/latest/enterprise/team-sync",description:"Team Sync makes it easier for you to manage users’ access in Grafana, by immediately updating each user’s Grafana teams and permissions based on their single sign-on group membership, instead of when users sign in."})},U=(0,h.connect)(k,M)(N);var D=s(28909),F=s(87261);const V=e=>{let{featureToggle:t,children:s}=e;return!0===t?(0,S.jsx)(S.Fragment,{children:s}):null};var B;const{Select:$}=g.LegacyForms,E={removeTeamMember:A.zT,updateTeamMember:A.zZ},R=(0,h.connect)(null,E);class _ extends c.PureComponent{constructor(e){var t,s,a;super(e),a=(e,t)=>{const s=e.value,a=Object.assign({},t,{permission:s});this.props.updateTeamMember(a)},(s="onPermissionChange")in(t=this)?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,this.renderLabels=this.renderLabels.bind(this),this.renderPermissions=this.renderPermissions.bind(this)}onRemoveMember(e){this.props.removeTeamMember(e.userId)}renderPermissions(e){const{editorsCanAdmin:t,signedInUserIsTeamAdmin:s}=this.props,a=v.eL.find((t=>t.value===e.permission));return(0,S.jsx)(V,{featureToggle:t,children:(0,S.jsx)("td",{className:"width-5 team-permissions",children:(0,S.jsxs)("div",{className:"gf-form",children:[s&&(0,S.jsx)($,{isSearchable:!1,options:v.eL,onChange:t=>this.onPermissionChange(t,e),className:"gf-form-select-box__control--menu-right",value:a}),!s&&(0,S.jsx)("span",{children:a.label})]})})})}renderLabels(e){return e?(0,S.jsx)("td",{children:e.map((e=>(0,S.jsx)(F.e,{label:e,removeIcon:!1,count:0,onClick:()=>{}},e)))}):B||(B=(0,S.jsx)("td",{}))}render(){const{member:e,syncEnabled:t,signedInUserIsTeamAdmin:s}=this.props;return(0,S.jsxs)("tr",{children:[(0,S.jsx)("td",{className:"width-4 text-center",children:(0,S.jsx)("img",{"aria-label":`Avatar for team member "${e.name}"`,className:"filter-table__avatar",src:e.avatarUrl})}),(0,S.jsx)("td",{children:e.login}),(0,S.jsx)("td",{children:e.email}),(0,S.jsx)("td",{children:e.name}),this.renderPermissions(e),t&&this.renderLabels(e.labels),(0,S.jsx)("td",{className:"text-right",children:(0,S.jsx)(g.DeleteButton,{"aria-label":"Remove team member",size:"sm",disabled:!s,onConfirm:()=>this.onRemoveMember(e)})})]},e.userId)}}const O=R(_);var z,W,Z,Q,q,H,X,Y,J=s(99574);function K(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const ee={addTeamMember:A.Lt,setSearchMemberQuery:J.UD},te=(0,h.connect)((function(e){return{searchMemberQuery:(0,C.xc)(e.team),editorsCanAdmin:f.vc.editorsCanAdmin,signedInUser:j.Vt.user}}),ee);class se extends c.PureComponent{constructor(e){super(e),K(this,"onSearchQueryChange",(e=>{this.props.setSearchMemberQuery(e)})),K(this,"onToggleAdding",(()=>{this.setState({isAdding:!this.state.isAdding})})),K(this,"onUserSelected",(e=>{this.setState({newTeamMember:e})})),K(this,"onAddUserToTeam",(async()=>{this.props.addTeamMember(this.state.newTeamMember.id),this.setState({newTeamMember:null})})),this.state={isAdding:!1,newTeamMember:null}}renderLabels(e){return e?(0,S.jsx)("td",{children:e.map((e=>(0,S.jsx)(F.e,{label:e,removeIcon:!1,count:0,onClick:()=>{}},e)))}):z||(z=(0,S.jsx)("td",{}))}render(){const{isAdding:e}=this.state,{searchMemberQuery:t,members:s,syncEnabled:a,editorsCanAdmin:n,signedInUser:r}=this.props,i=(0,C.vt)({members:s,editorsCanAdmin:n,signedInUser:r});return(0,S.jsxs)("div",{children:[(0,S.jsxs)("div",{className:"page-action-bar",children:[(0,S.jsx)("div",{className:"gf-form gf-form--grow",children:(0,S.jsx)(g.FilterInput,{placeholder:"Search members",value:t,onChange:this.onSearchQueryChange})}),(0,S.jsx)(g.Button,{className:"pull-right",onClick:this.onToggleAdding,disabled:e||!i,children:"Add member"})]}),(0,S.jsx)(y.s,{in:e,children:(0,S.jsxs)("div",{className:"cta-form",children:[(0,S.jsx)(T.P,{"aria-label":"Close 'Add team member' dialogue",onClick:this.onToggleAdding}),W||(W=(0,S.jsx)(g.Label,{htmlFor:"user-picker",children:"Add team member"})),(0,S.jsxs)("div",{className:"gf-form-inline",children:[(0,S.jsx)(D.f,{inputId:"user-picker",onSelected:this.onUserSelected,className:"min-width-30"}),this.state.newTeamMember&&(0,S.jsx)(g.Button,{type:"submit",onClick:this.onAddUserToTeam,children:"Add to team"})]})]})}),(0,S.jsx)("div",{className:"admin-list-table",children:(0,S.jsxs)("table",{className:"filter-table filter-table--hover form-inline",children:[(0,S.jsx)("thead",{children:(0,S.jsxs)("tr",{children:[Z||(Z=(0,S.jsx)("th",{})),Q||(Q=(0,S.jsx)("th",{children:"Login"})),q||(q=(0,S.jsx)("th",{children:"Email"})),H||(H=(0,S.jsx)("th",{children:"Name"})),(0,S.jsx)(V,{featureToggle:n,children:X||(X=(0,S.jsx)("th",{children:"Permission"}))}),a&&(Y||(Y=(0,S.jsx)("th",{}))),(0,S.jsx)("th",{style:{width:"1%"}})]})}),(0,S.jsx)("tbody",{children:s&&s.map((e=>(0,S.jsx)(O,{member:e,syncEnabled:a,editorsCanAdmin:n,signedInUserIsTeamAdmin:i},e.userId)))})]})})]})}}const ae=te(se);var ne=s(83654);const re=e=>{const t=j.Vt.hasPermissionInMetadata(v.bW.ActionTeamsPermissionsWrite,e.team);return(0,S.jsx)(ne.P,{title:"Members",addPermissionTitle:"Add member",buttonLabel:"Add member",resource:"teams",resourceId:e.team.id,canSetPermissions:t})};var ie=s(67833),de=s(98163);const oe={updateTeam:A.fs},le=(0,h.connect)(null,oe)((e=>{let{team:t,updateTeam:s}=e;const a=de.Vt.hasPermissionInMetadata(v.bW.ActionTeamsWrite,t);return(0,S.jsxs)(g.VerticalGroup,{children:[(0,S.jsx)(g.FieldSet,{label:"Team settings",children:(0,S.jsx)(g.Form,{defaultValues:Object.assign({},t),onSubmit:e=>{s(e.name,e.email)},disabled:!a,children:e=>{let{register:t}=e;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(g.Field,{label:"Name",disabled:!a,children:(0,S.jsx)(g.Input,Object.assign({},t("name",{required:!0}),{id:"name-input"}))}),(0,S.jsx)(g.Field,{label:"Email",description:"This is optional and is primarily used to set the team profile avatar (via gravatar service).",disabled:!a,children:(0,S.jsx)(g.Input,Object.assign({},t("email"),{placeholder:"team@email.com",type:"email",id:"email-input"}))}),(0,S.jsx)(g.Button,{type:"submit",disabled:!a,children:"Update"})]})}})}),(0,S.jsx)(ie.v,{resourceUri:`teams/${t.id}`,disabled:!a})]})}));var me,ce,he,ue=s(91574);function ge(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}!function(e){e.Members="members",e.Settings="settings",e.GroupSync="groupsync"}(he||(he={}));const pe={loadTeam:A.QX,loadTeamMembers:A.ei},be=(0,h.connect)((function(e,t){var s;const a=parseInt(t.match.params.id,10),n=(0,C.VP)(e.team,a);let r="members";j.Vt.accessControlEnabled()&&(n&&j.Vt.hasPermissionInMetadata(v.bW.ActionTeamsPermissionsRead,n)||(r="settings"));const i=null!==(s=t.match.params.page)&&void 0!==s?s:r,d=(0,ue.o)(i);return{navModel:(0,x.h)(e.navIndex,`team-${i}-${a}`,d),teamId:a,pageName:i,team:n,members:(0,C.YY)(e.team),editorsCanAdmin:f.ZP.editorsCanAdmin,signedInUser:j.Vt.user}}),pe);class fe extends c.PureComponent{constructor(e){super(e),ge(this,"textsAreEqual",((e,t)=>!e&&!t||!(!e||!t)&&e.toLocaleLowerCase()===t.toLocaleLowerCase())),ge(this,"hideTabsFromNonTeamAdmin",((e,t)=>(j.Vt.accessControlEnabled()||!t&&e.main&&e.main.children&&e.main.children.filter((e=>!this.textsAreEqual(e.text,he.Members))).map((e=>{e.hideFromTabs=!0})),e))),this.state={isLoading:!1,isSyncEnabled:(0,u.featureEnabled)("teamsync")}}async componentDidMount(){await this.fetchTeam()}async fetchTeam(){const{loadTeam:e,teamId:t}=this.props;this.setState({isLoading:!0});const s=await e(t);return j.Vt.accessControlEnabled()||await this.props.loadTeamMembers(),this.setState({isLoading:!1}),s}getCurrentPage(){const e=["members","settings","groupsync"],t=this.props.pageName;return(0,m.includes)(e,t)?t:e[0]}renderPage(e){const{isSyncEnabled:t}=this.state,{members:s,team:a}=this.props,n=this.getCurrentPage(),r=j.Vt.hasAccessInMetadata(v.bW.ActionTeamsRead,a,e),i=j.Vt.hasAccessInMetadata(v.bW.ActionTeamsPermissionsRead,a,e),d=j.Vt.hasAccessInMetadata(v.bW.ActionTeamsPermissionsWrite,a,e);switch(n){case he.Members:return j.Vt.accessControlEnabled()?(0,S.jsx)(re,{team:a}):(0,S.jsx)(ae,{syncEnabled:t,members:s});case he.Settings:return r&&(0,S.jsx)(le,{team:a});case he.GroupSync:if(t){if(i)return(0,S.jsx)(U,{isReadOnly:!d})}else if(f.ZP.featureToggles.featureHighlights)return(0,S.jsxs)(S.Fragment,{children:[me||(me=(0,S.jsx)(b.Xz,{featureName:"team sync",featureId:"team-sync"})),ce||(ce=(0,S.jsx)(G,{}))]})}return null}render(){const{team:e,navModel:t,members:s,editorsCanAdmin:a,signedInUser:n}=this.props,r=(0,C.vt)({members:s,editorsCanAdmin:a,signedInUser:n});return(0,S.jsx)(p.Z,{navModel:this.hideTabsFromNonTeamAdmin(t,r),children:(0,S.jsx)(p.Z.Contents,{isLoading:this.state.isLoading,children:e&&0!==Object.keys(e).length&&this.renderPage(r)})})}}const xe=be((0,g.withTheme2)(fe))},44083:(e,t,s)=>{s.d(t,{A_:()=>f,Lt:()=>u,P5:()=>x,QX:()=>c,ei:()=>h,fC:()=>j,fs:()=>p,jI:()=>m,j_:()=>b,zT:()=>g,zZ:()=>v});var a=s(90923),n=s(36537),r=s(98163),i=s(66728),d=s(58170),o=s(91574),l=s(99574);function m(){return async e=>{if(!r.Vt.hasPermission(d.bW.ActionTeamsRead))return void e((0,l.PL)([]));const t=await(0,a.getBackendSrv)().get("/api/teams/search",(0,i.y)({perpage:1e3,page:1}));e((0,l.PL)(t.teams))}}function c(e){return async t=>{const s=await(0,a.getBackendSrv)().get(`/api/teams/${e}`,(0,i.y)());t((0,l.y$)(s)),t((0,n.RL)((0,o.B)(s)))}}function h(){return async(e,t)=>{const s=t().team.team,n=await(0,a.getBackendSrv)().get(`/api/teams/${s.id}/members`);e((0,l.n2)(n))}}function u(e){return async(t,s)=>{const n=s().team.team;await(0,a.getBackendSrv)().post(`/api/teams/${n.id}/members`,{userId:e}),t(h())}}function g(e){return async(t,s)=>{const n=s().team.team;await(0,a.getBackendSrv)().delete(`/api/teams/${n.id}/members/${e}`),t(h())}}function p(e,t){return async(s,n)=>{const r=n().team.team;await(0,a.getBackendSrv)().put(`/api/teams/${r.id}`,{name:e,email:t}),s(c(r.id))}}function b(){return async(e,t)=>{const s=t().team.team,n=await(0,a.getBackendSrv)().get(`/api/teams/${s.id}/groups`);e((0,l.iI)(n))}}function f(e){return async(t,s)=>{const n=s().team.team;await(0,a.getBackendSrv)().post(`/api/teams/${n.id}/groups`,{groupId:e}),t(b())}}function x(e){return async(t,s)=>{const n=s().team.team;await(0,a.getBackendSrv)().delete(`/api/teams/${n.id}/groups/${encodeURIComponent(e)}`),t(b())}}function j(e){return async t=>{await(0,a.getBackendSrv)().delete(`/api/teams/${e}`),await r.Vt.fetchUserPermissions(),t(m())}}function v(e){return async t=>{await(0,a.getBackendSrv)().put(`/api/teams/${e.teamId}/members/${e.userId}`,{permission:e.permission}),t(h())}}},91574:(e,t,s)=>{s.d(t,{B:()=>m,o:()=>c});var a=s(90923),n=s(17963),r=s(78837),i=s(61959),d=s(65623),o=s(58170);const l={avatarUrl:"public/img/user_profile.png",id:1,name:"Loading",email:"loading",memberCount:0,permission:o.hw.Member};function m(e){const t={img:e.avatarUrl,id:"team-"+e.id,subTitle:"Manage members and settings",url:"",text:e.name,breadcrumbs:[{title:"Teams",url:"org/teams"}],children:[{active:!1,icon:"sliders-v-alt",id:`team-settings-${e.id}`,text:"Settings",url:`org/teams/edit/${e.id}/settings`}]};(e===l||i.Vt.hasPermissionInMetadata(o.bW.ActionTeamsPermissionsRead,e))&&t.children.unshift({active:!1,icon:"users-alt",id:`team-members-${e.id}`,text:"Members",url:`org/teams/edit/${e.id}/members`});const s={active:!1,icon:"sync",id:`team-groupsync-${e.id}`,text:"External group sync",url:`org/teams/edit/${e.id}/groupsync`},m=e===l;return(0,d.d)()&&(s.tabSuffix=()=>(0,n.Z)({experimentId:m?"":"feature-highlights-team-sync-badge",eventVariant:"trial"})),(0,a.featureEnabled)("teamsync")?(m||i.Vt.hasPermissionInMetadata(o.bW.ActionTeamsPermissionsRead,e))&&t.children.push(s):r.ZP.featureToggles.featureHighlights&&t.children.push(Object.assign({},s,{tabSuffix:()=>(0,n.Z)({experimentId:m?"":"feature-highlights-team-sync-badge"})})),t}function c(e){const t=m(l);let s;for(const a of t.children)if(a.id.indexOf(e)>0){a.active=!0,s=a;break}return{main:t,node:s}}},71181:(e,t,s)=>{s.d(t,{JB:()=>i,LK:()=>m,VP:()=>l,YY:()=>c,_u:()=>o,kC:()=>u,uP:()=>n,v7:()=>d,vt:()=>h,xc:()=>r});var a=s(58170);const n=e=>e.searchQuery,r=e=>e.searchMemberQuery,i=e=>e.groups,d=e=>e.teams.length,o=e=>e.searchPage,l=(e,t)=>e.team.id===parseInt(t,10)?e.team:null,m=e=>{const t=RegExp(e.searchQuery,"i");return e.teams.filter((e=>t.test(e.name)))},c=e=>{const t=RegExp(e.searchMemberQuery,"i");return e.members.filter((e=>t.test(e.login)||t.test(e.email)||t.test(e.name)))},h=e=>{const{members:t,signedInUser:s,editorsCanAdmin:n}=e,r=t.find((e=>e.userId===s.id)),i=r?r.permission:a.hw.Member;return u({permission:i,signedInUser:s,editorsCanAdmin:n})},u=e=>{const{permission:t,signedInUser:s,editorsCanAdmin:n}=e,r=s.isGrafanaAdmin||s.orgRole===a.B5.Admin,i=t===a.hw.Admin;return r||i||!n}}}]);
  4. //# sourceMappingURL=TeamPages.e119b2547fd7d5579f18.js.map