"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8612],{67833:(e,t,s)=>{s.d(t,{Z:()=>j,v:()=>x});var a,n,r,i,o=s(69501),d=s(17092),l=s(36636),c=s(68404),m=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:d.ag._({id:"shared-preferences.theme.default-label",message:"Default"})},{value:"dark",label:d.ag._({id:"shared-preferences.theme.dark-label",message:"Dark"})},{value:"light",label:d.ag._({id:"shared-preferences.theme.light-label",message:"Light"})}];class x extends c.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:c}=this.state,{disabled:u}=this.props,g=v(),b=a||(a=(0,p.jsx)(h.Tooltip,{content:(0,p.jsx)(o.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)(o.cC,{id:"shared-preferences.title"})),disabled:u,children:[(0,p.jsx)(h.Field,{label:d.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)(o.cC,{id:"shared-preferences.fields.home-dashboard-label"}))}),b]}),"data-testid":"User preferences home dashboard drop down",children:(0,p.jsx)(h.Select,{value:c.find((e=>e.id===l)),getOptionValue:e=>e.id,getOptionLabel:this.getFullDashName,onChange:e=>this.onHomeDashboardChanged(e.id),options:c,placeholder:d.ag._({id:"shared-preferences.fields.home-dashboard-placeholder",message:"Choose default dashboard"}),inputId:"home-dashboard-select"})}),(0,p.jsx)(h.Field,{label:d.ag._({id:"shared-dashboard.fields.timezone-label",message:"Timezone"}),"data-testid":m.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:d.ag._({id:"shared-preferences.fields.week-start-label",message:"Week start"}),"data-testid":m.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":m.wl.components.UserProfile.preferencesSaveButton,children:i||(i=(0,p.jsx)(o.cC,{id:"common.save"}))})})]})}})}}const j=x,v=(0,h.stylesFactory)((()=>({labelText:l.css`
      margin-right: 6px;
    `})))},65623:(e,t,s)=>{s.d(t,{d:()=>n});var a=s(90923);const n=()=>function(){var e;const t=null===(e=a.config.licenseInfo)||void 0===e?void 0:e.trialExpiry;return!!(t&&t>0)}()&&a.config.featureToggles.featureHighlights},85642:(e,t,s)=>{s.r(t),s.d(t,{TeamPages:()=>we,default:()=>Ie});var a=s(82897),n=s(68404),r=s(18745),i=s(90923),o=s(69783),d=s(33801),l=s(36636),c=s(45916);const m=["featureName","className","children","text","featureId","eventVariant","size"];const h=e=>{let{featureName:t,className:s,text:a,featureId:r,eventVariant:d="",size:h="md"}=e,g=function(e,t){if(null==e)return{};var s,a,n={},r=Object.keys(e);for(a=0;a<r.length;a++)s=r[a],t.indexOf(s)>=0||(n[s]=e[s]);return n}(e,m);const p=(0,o.useStyles2)((e=>u(e,h)));return(0,n.useEffect)((()=>{(0,i.reportExperimentView)(`feature-highlights-${r}`,"test",d)}),[d,r]),(0,c.jsxs)("div",Object.assign({className:(0,l.cx)(p.box,s)},g,{children:[(0,c.jsx)(o.Icon,{name:"rocket",className:p.icon}),(0,c.jsxs)("div",{className:p.inner,children:[(0,c.jsxs)("p",{className:p.text,children:["You’ve discovered a Pro feature! ",a||`Get the Grafana Pro plan to access ${t}.`]}),(0,c.jsx)(o.LinkButton,{variant:"secondary",size:h,className:p.button,href:"https://grafana.com/profile/org/subscription",target:"__blank",rel:"noopener noreferrer",children:"Upgrade"})]})]}))},u=(e,t)=>{const s=e.shape.borderRadius(2),a="md"===t?"body":"bodySmall";return{box:l.css`
      display: flex;
      align-items: center;
      position: relative;
      border-radius: ${s};
      background: ${e.colors.success.transparent};
      padding: ${e.spacing(2)};
      color: ${e.colors.success.text};
      font-size: ${e.typography[a].fontSize};
      text-align: left;
      line-height: 16px;
      margin: ${e.spacing(0,"auto",3,"auto")};
      max-width: ${e.breakpoints.values.xxl}px;
      width: 100%;
    `,inner:l.css`
      display: flex;
      align-items: center;
      width: 100%;
      justify-content: space-between;
    `,text:l.css`
      margin: 0;
    `,button:l.css`
      background-color: ${e.colors.success.main};
      font-weight: ${e.typography.fontWeightLight};
      color: white;

      &:hover {
        background-color: ${e.colors.success.main};
      }

      &:focus-visible {
        box-shadow: none;
        color: ${e.colors.text.primary};
        outline: 2px solid ${e.colors.primary.main};
      }
    `,icon:l.css`
      margin: ${e.spacing(.5,1,.5,.5)};
    `}},g=e=>{let{listItems:t,image:s,featureUrl:a,featureName:n,description:r,caption:i,action:d}=e;const l=(0,o.useStyles2)(p);return(0,c.jsxs)("div",{className:l.container,children:[(0,c.jsxs)("div",{className:l.content,children:[(0,c.jsxs)("h3",{className:l.title,children:["Get started with ",n]}),r&&(0,c.jsx)("h6",{className:l.description,children:r}),(0,c.jsx)("ul",{className:l.list,children:t.map(((e,t)=>(0,c.jsxs)("li",{children:[(0,c.jsx)(o.Icon,{name:"check",size:"xl",className:l.icon})," ",e]},t)))}),(null==d?void 0:d.link)&&(0,c.jsx)(o.LinkButton,{variant:"primary",href:d.link,children:d.text}),(null==d?void 0:d.onClick)&&(0,c.jsx)(o.Button,{variant:"primary",onClick:d.onClick,children:d.text}),a&&(0,c.jsx)(o.LinkButton,{fill:"text",href:a,className:l.link,target:"_blank",rel:"noreferrer noopener",children:"Learn more"})]}),(0,c.jsxs)("div",{className:l.media,children:[(0,c.jsx)("img",{src:b(s),alt:"Feature screenshot"}),i&&(0,c.jsx)("p",{className:l.caption,children:i})]})]})},p=e=>({container:l.css`
      display: flex;
      justify-content: space-between;
    `,content:l.css`
      width: 45%;
      margin-right: ${e.spacing(4)};
    `,media:l.css`
      width: 55%;

      img {
        width: 100%;
      }
    `,title:l.css`
      color: ${e.colors.text.maxContrast};
    `,description:l.css`
      color: ${e.colors.text.primary};
      font-weight: ${e.typography.fontWeightLight};
    `,list:l.css`
      list-style: none;
      margin: ${e.spacing(4,0,2,0)};

      li {
        display: flex;
        align-items: flex-start;
        color: ${e.colors.text.primary};
        padding: ${e.spacing(1,0)};
      }
    `,icon:l.css`
      color: ${e.colors.success.main};
      margin-right: ${e.spacing(1)};
    `,link:l.css`
      margin-left: ${e.spacing(2)};
    `,caption:l.css`
      font-weight: ${e.typography.fontWeightLight};
      margin: ${e.spacing(1,0,0)};
    `}),b=e=>e.startsWith("http")?e:"/public/img/enterprise/highlights/"+e;var f,x,j,v,y,T,w,I=s(78837),k=s(8674),A=s(61959),C=s(58170),S=s(72779),P=s(6347),N=s(28436),$=s(65623),L=s(44083),M=s(71181);function G(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function U(e){return{groups:(0,M.JB)(e.team)}}const B={loadTeamGroups:L.j_,addTeamGroup:L.A_,removeTeamGroup:L.P5},V=((0,r.connect)(U,B),"Sync LDAP or OAuth groups with your Grafana teams.");class F extends n.PureComponent{constructor(e){super(e),G(this,"onToggleAdding",(()=>{this.setState({isAdding:!this.state.isAdding})})),G(this,"onNewGroupIdChanged",(e=>{this.setState({newGroupId:e.target.value})})),G(this,"onAddGroup",(e=>{e.preventDefault(),this.props.addTeamGroup(this.state.newGroupId),this.setState({isAdding:!1,newGroupId:""})})),G(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,c.jsxs)("tr",{children:[(0,c.jsx)("td",{children:e.groupId}),(0,c.jsx)("td",{style:{width:"1%"},children:(0,c.jsx)(o.Button,{size:"sm",variant:"destructive",onClick:()=>this.onRemoveGroup(e),disabled:t,"aria-label":`Remove group ${e.groupId}`,children:f||(f=(0,c.jsx)(o.Icon,{name:"times"}))})})]},e.groupId)}render(){const{isAdding:e,newGroupId:t}=this.state,{groups:s,isReadOnly:a}=this.props;return(0,c.jsxs)("div",{children:[(0,$.d)()&&(x||(x=(0,c.jsx)(h,{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,c.jsxs)("div",{className:"page-action-bar",children:[(!(0,$.d)()||s.length>0)&&(0,c.jsxs)(c.Fragment,{children:[j||(j=(0,c.jsx)("h3",{className:"page-sub-heading",children:"External group sync"})),v||(v=(0,c.jsx)(o.Tooltip,{placement:"auto",content:V,children:(0,c.jsx)(o.Icon,{className:"icon--has-hover page-sub-heading-icon",name:"question-circle"})}))]}),y||(y=(0,c.jsx)("div",{className:"page-action-bar__spacer"})),s.length>0&&(0,c.jsxs)(o.Button,{className:"pull-right",onClick:this.onToggleAdding,disabled:a,children:[T||(T=(0,c.jsx)(o.Icon,{name:"plus"}))," Add group"]})]}),(0,c.jsx)(S.s,{in:e,children:(0,c.jsxs)("div",{className:"cta-form",children:[(0,c.jsx)(P.P,{onClick:this.onToggleAdding}),(0,c.jsx)("form",{onSubmit:this.onAddGroup,children:(0,c.jsxs)(o.InlineFieldRow,{children:[(0,c.jsx)(o.InlineField,{label:"Add External Group",children:(0,c.jsx)(o.Input,{type:"text",id:"add-external-group",value:t,onChange:this.onNewGroupIdChanged,placeholder:"cn=ops,ou=groups,dc=grafana,dc=org",disabled:a})}),(0,c.jsx)(o.Button,{type:"submit",disabled:a||!this.isNewGroupValid(),style:{marginLeft:4},children:"Add group"})]})})]})}),0===s.length&&!e&&((0,$.d)()?(0,c.jsx)(D,{action:{onClick:this.onToggleAdding,text:"Add group"}}):(0,c.jsx)(N.Z,{onClick:this.onToggleAdding,buttonIcon:"users-alt",title:"There are no external groups to sync with",buttonTitle:"Add group",proTip:V,proTipLinkTitle:"Learn more",proTipLink:"https://docs.grafana.org/auth/enhanced_ldap/",proTipTarget:"_blank",buttonDisabled:a})),s.length>0&&(0,c.jsx)("div",{className:"admin-list-table",children:(0,c.jsxs)("table",{className:"filter-table filter-table--hover form-inline",children:[(0,c.jsx)("thead",{children:(0,c.jsxs)("tr",{children:[w||(w=(0,c.jsx)("th",{children:"External Group ID"})),(0,c.jsx)("th",{style:{width:"1%"}})]})}),(0,c.jsx)("tbody",{children:s.map((e=>this.renderGroup(e)))})]})})]})}}const D=e=>{let{action:t}=e;const s=(0,o.useTheme2)();return(0,c.jsx)(g,{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."})},E=(0,r.connect)(U,B)(F);var _=s(28909),R=s(87261);const z=e=>{let{featureToggle:t,children:s}=e;return!0===t?(0,c.jsx)(c.Fragment,{children:s}):null};var O;const{Select:W}=o.LegacyForms,Z={removeTeamMember:L.zT,updateTeamMember:L.zZ},Q=(0,r.connect)(null,Z);class H extends n.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=C.eL.find((t=>t.value===e.permission));return(0,c.jsx)(z,{featureToggle:t,children:(0,c.jsx)("td",{className:"width-5 team-permissions",children:(0,c.jsxs)("div",{className:"gf-form",children:[s&&(0,c.jsx)(W,{isSearchable:!1,options:C.eL,onChange:t=>this.onPermissionChange(t,e),className:"gf-form-select-box__control--menu-right",value:a}),!s&&(0,c.jsx)("span",{children:a.label})]})})})}renderLabels(e){return e?(0,c.jsx)("td",{children:e.map((e=>(0,c.jsx)(R.e,{label:e,removeIcon:!1,count:0,onClick:()=>{}},e)))}):O||(O=(0,c.jsx)("td",{}))}render(){const{member:e,syncEnabled:t,signedInUserIsTeamAdmin:s}=this.props;return(0,c.jsxs)("tr",{children:[(0,c.jsx)("td",{className:"width-4 text-center",children:(0,c.jsx)("img",{"aria-label":`Avatar for team member "${e.name}"`,className:"filter-table__avatar",src:e.avatarUrl})}),(0,c.jsx)("td",{children:e.login}),(0,c.jsx)("td",{children:e.email}),(0,c.jsx)("td",{children:e.name}),this.renderPermissions(e),t&&this.renderLabels(e.labels),(0,c.jsx)("td",{className:"text-right",children:(0,c.jsx)(o.DeleteButton,{"aria-label":"Remove team member",size:"sm",disabled:!s,onConfirm:()=>this.onRemoveMember(e)})})]},e.userId)}}const q=Q(H);var Y,J,X,K,ee,te,se,ae,ne=s(99574);function re(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const ie={addTeamMember:L.Lt,setSearchMemberQuery:ne.UD},oe=(0,r.connect)((function(e){return{searchMemberQuery:(0,M.xc)(e.team),editorsCanAdmin:I.vc.editorsCanAdmin,signedInUser:A.Vt.user}}),ie);class de extends n.PureComponent{constructor(e){super(e),re(this,"onSearchQueryChange",(e=>{this.props.setSearchMemberQuery(e)})),re(this,"onToggleAdding",(()=>{this.setState({isAdding:!this.state.isAdding})})),re(this,"onUserSelected",(e=>{this.setState({newTeamMember:e})})),re(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,c.jsx)("td",{children:e.map((e=>(0,c.jsx)(R.e,{label:e,removeIcon:!1,count:0,onClick:()=>{}},e)))}):Y||(Y=(0,c.jsx)("td",{}))}render(){const{isAdding:e}=this.state,{searchMemberQuery:t,members:s,syncEnabled:a,editorsCanAdmin:n,signedInUser:r}=this.props,i=(0,M.vt)({members:s,editorsCanAdmin:n,signedInUser:r});return(0,c.jsxs)("div",{children:[(0,c.jsxs)("div",{className:"page-action-bar",children:[(0,c.jsx)("div",{className:"gf-form gf-form--grow",children:(0,c.jsx)(o.FilterInput,{placeholder:"Search members",value:t,onChange:this.onSearchQueryChange})}),(0,c.jsx)(o.Button,{className:"pull-right",onClick:this.onToggleAdding,disabled:e||!i,children:"Add member"})]}),(0,c.jsx)(S.s,{in:e,children:(0,c.jsxs)("div",{className:"cta-form",children:[(0,c.jsx)(P.P,{"aria-label":"Close 'Add team member' dialogue",onClick:this.onToggleAdding}),J||(J=(0,c.jsx)(o.Label,{htmlFor:"user-picker",children:"Add team member"})),(0,c.jsxs)("div",{className:"gf-form-inline",children:[(0,c.jsx)(_.f,{inputId:"user-picker",onSelected:this.onUserSelected,className:"min-width-30"}),this.state.newTeamMember&&(0,c.jsx)(o.Button,{type:"submit",onClick:this.onAddUserToTeam,children:"Add to team"})]})]})}),(0,c.jsx)("div",{className:"admin-list-table",children:(0,c.jsxs)("table",{className:"filter-table filter-table--hover form-inline",children:[(0,c.jsx)("thead",{children:(0,c.jsxs)("tr",{children:[X||(X=(0,c.jsx)("th",{})),K||(K=(0,c.jsx)("th",{children:"Login"})),ee||(ee=(0,c.jsx)("th",{children:"Email"})),te||(te=(0,c.jsx)("th",{children:"Name"})),(0,c.jsx)(z,{featureToggle:n,children:se||(se=(0,c.jsx)("th",{children:"Permission"}))}),a&&(ae||(ae=(0,c.jsx)("th",{}))),(0,c.jsx)("th",{style:{width:"1%"}})]})}),(0,c.jsx)("tbody",{children:s&&s.map((e=>(0,c.jsx)(q,{member:e,syncEnabled:a,editorsCanAdmin:n,signedInUserIsTeamAdmin:i},e.userId)))})]})})]})}}const le=oe(de);var ce=s(83654);const me=e=>{const t=A.Vt.hasPermissionInMetadata(C.bW.ActionTeamsPermissionsWrite,e.team);return(0,c.jsx)(ce.P,{title:"Members",addPermissionTitle:"Add member",buttonLabel:"Add member",resource:"teams",resourceId:e.team.id,canSetPermissions:t})};var he=s(67833),ue=s(98163);const ge={updateTeam:L.fs},pe=(0,r.connect)(null,ge)((e=>{let{team:t,updateTeam:s}=e;const a=ue.Vt.hasPermissionInMetadata(C.bW.ActionTeamsWrite,t);return(0,c.jsxs)(o.VerticalGroup,{children:[(0,c.jsx)(o.FieldSet,{label:"Team settings",children:(0,c.jsx)(o.Form,{defaultValues:Object.assign({},t),onSubmit:e=>{s(e.name,e.email)},disabled:!a,children:e=>{let{register:t}=e;return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(o.Field,{label:"Name",disabled:!a,children:(0,c.jsx)(o.Input,Object.assign({},t("name",{required:!0}),{id:"name-input"}))}),(0,c.jsx)(o.Field,{label:"Email",description:"This is optional and is primarily used to set the team profile avatar (via gravatar service).",disabled:!a,children:(0,c.jsx)(o.Input,Object.assign({},t("email"),{placeholder:"team@email.com",type:"email",id:"email-input"}))}),(0,c.jsx)(o.Button,{type:"submit",disabled:!a,children:"Update"})]})}})}),(0,c.jsx)(he.v,{resourceUri:`teams/${t.id}`,disabled:!a})]})}));var be,fe,xe,je=s(91574);function ve(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"}(xe||(xe={}));const ye={loadTeam:L.QX,loadTeamMembers:L.ei},Te=(0,r.connect)((function(e,t){var s;const a=parseInt(t.match.params.id,10),n=(0,M.VP)(e.team,a);let r="members";A.Vt.accessControlEnabled()&&(n&&A.Vt.hasPermissionInMetadata(C.bW.ActionTeamsPermissionsRead,n)||(r="settings"));const i=null!==(s=t.match.params.page)&&void 0!==s?s:r,o=(0,je.o)(i);return{navModel:(0,k.h)(e.navIndex,`team-${i}-${a}`,o),teamId:a,pageName:i,team:n,members:(0,M.YY)(e.team),editorsCanAdmin:I.ZP.editorsCanAdmin,signedInUser:A.Vt.user}}),ye);class we extends n.PureComponent{constructor(e){super(e),ve(this,"textsAreEqual",((e,t)=>!e&&!t||!(!e||!t)&&e.toLocaleLowerCase()===t.toLocaleLowerCase())),ve(this,"hideTabsFromNonTeamAdmin",((e,t)=>(A.Vt.accessControlEnabled()||!t&&e.main&&e.main.children&&e.main.children.filter((e=>!this.textsAreEqual(e.text,xe.Members))).map((e=>{e.hideFromTabs=!0})),e))),this.state={isLoading:!1,isSyncEnabled:(0,i.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 A.Vt.accessControlEnabled()||await this.props.loadTeamMembers(),this.setState({isLoading:!1}),s}getCurrentPage(){const e=["members","settings","groupsync"],t=this.props.pageName;return(0,a.includes)(e,t)?t:e[0]}renderPage(e){const{isSyncEnabled:t}=this.state,{members:s,team:a}=this.props,n=this.getCurrentPage(),r=A.Vt.hasAccessInMetadata(C.bW.ActionTeamsRead,a,e),i=A.Vt.hasAccessInMetadata(C.bW.ActionTeamsPermissionsRead,a,e),o=A.Vt.hasAccessInMetadata(C.bW.ActionTeamsPermissionsWrite,a,e);switch(n){case xe.Members:return A.Vt.accessControlEnabled()?(0,c.jsx)(me,{team:a}):(0,c.jsx)(le,{syncEnabled:t,members:s});case xe.Settings:return r&&(0,c.jsx)(pe,{team:a});case xe.GroupSync:if(t){if(i)return(0,c.jsx)(E,{isReadOnly:!o})}else if(I.ZP.featureToggles.featureHighlights)return(0,c.jsxs)(c.Fragment,{children:[be||(be=(0,c.jsx)(h,{featureName:"team sync",featureId:"team-sync"})),fe||(fe=(0,c.jsx)(D,{}))]})}return null}render(){const{team:e,navModel:t,members:s,editorsCanAdmin:a,signedInUser:n}=this.props,r=(0,M.vt)({members:s,editorsCanAdmin:a,signedInUser:n});return(0,c.jsx)(d.Z,{navModel:this.hideTabsFromNonTeamAdmin(t,r),children:(0,c.jsx)(d.Z.Contents,{isLoading:this.state.isLoading,children:e&&0!==Object.keys(e).length&&this.renderPage(r)})})}}const Ie=Te((0,o.withTheme2)(we))},44083:(e,t,s)=>{s.d(t,{A_:()=>f,Lt:()=>u,P5:()=>x,QX:()=>m,ei:()=>h,fC:()=>j,fs:()=>p,jI:()=>c,j_:()=>b,zT:()=>g,zZ:()=>v});var a=s(90923),n=s(36537),r=s(98163),i=s(66728),o=s(58170),d=s(91574),l=s(99574);function c(){return async e=>{if(!r.Vt.hasPermission(o.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 m(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,d.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(m(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(c())}}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:()=>c,o:()=>m});var a=s(90923),n=s(17963),r=s(78837),i=s(61959),o=s(65623),d=s(58170);const l={avatarUrl:"public/img/user_profile.png",id:1,name:"Loading",email:"loading",memberCount:0,permission:d.hw.Member};function c(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(d.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`},c=e===l;return(0,o.d)()&&(s.tabSuffix=()=>(0,n.Z)({experimentId:c?"":"feature-highlights-team-sync-badge",eventVariant:"trial"})),(0,a.featureEnabled)("teamsync")?(c||i.Vt.hasPermissionInMetadata(d.bW.ActionTeamsPermissionsRead,e))&&t.children.push(s):r.ZP.featureToggles.featureHighlights&&t.children.push(Object.assign({},s,{tabSuffix:()=>(0,n.Z)({experimentId:c?"":"feature-highlights-team-sync-badge"})})),t}function m(e){const t=c(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:()=>c,VP:()=>l,YY:()=>m,_u:()=>d,kC:()=>u,uP:()=>n,v7:()=>o,vt:()=>h,xc:()=>r});var a=s(58170);const n=e=>e.searchQuery,r=e=>e.searchMemberQuery,i=e=>e.groups,o=e=>e.teams.length,d=e=>e.searchPage,l=(e,t)=>e.team.id===parseInt(t,10)?e.team:null,c=e=>{const t=RegExp(e.searchQuery,"i");return e.teams.filter((e=>t.test(e.name)))},m=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}}}]);
//# sourceMappingURL=TeamPages.bed220b831fa9f19cea4.js.map