1234 |
- "use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7323],{67833:(e,s,r)=>{r.d(s,{Z:()=>b,v:()=>p});var a,i,t,n,o=r(69501),d=r(17092),l=r(36636),c=r(68404),h=r(16695),u=r(69783),m=r(76187),g=r(28659),x=r(45916);function f(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}const j=[{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 p extends c.PureComponent{constructor(e){super(e),f(this,"service",void 0),f(this,"onSubmitForm",(async()=>{const{homeDashboardId:e,theme:s,timezone:r,weekStart:a,queryHistory:i}=this.state;await this.service.update({homeDashboardId:e,theme:s,timezone:r,weekStart:a,queryHistory:i}),window.location.reload()})),f(this,"onThemeChanged",(e=>{this.setState({theme:e})})),f(this,"onTimeZoneChanged",(e=>{e&&this.setState({timezone:e})})),f(this,"onWeekStartChanged",(e=>{this.setState({weekStart:e})})),f(this,"onHomeDashboardChanged",(e=>{this.setState({homeDashboardId:e})})),f(this,"getFullDashName",(e=>void 0===e.folderTitle||""===e.folderTitle?e.title:e.folderTitle+" / "+e.title)),this.service=new m.y(e.resourceUri),this.state={homeDashboardId:0,theme:"",timezone:"",weekStart:"",dashboards:[],queryHistory:{homeTab:""}}}async componentDidMount(){const e=await this.service.load(),s=await g.ae.search({starred:!0});if(e.homeDashboardId>0&&!s.find((s=>s.id===e.homeDashboardId))){const r=await g.ae.search({dashboardIds:[e.homeDashboardId]});r&&r.length>0&&s.push(r[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:[]},...s],queryHistory:e.queryHistory})}render(){const{theme:e,timezone:s,weekStart:r,homeDashboardId:l,dashboards:c}=this.state,{disabled:m}=this.props,g=v(),f=a||(a=(0,x.jsx)(u.Tooltip,{content:(0,x.jsx)(o.cC,{id:"shared-preferences.fields.home-dashboard-tooltip"}),children:(0,x.jsx)(u.Icon,{name:"info-circle"})}));return(0,x.jsx)(u.Form,{onSubmit:this.onSubmitForm,children:()=>{var a;return(0,x.jsxs)(u.FieldSet,{label:i||(i=(0,x.jsx)(o.cC,{id:"shared-preferences.title"})),disabled:m,children:[(0,x.jsx)(u.Field,{label:d.ag._({id:"shared-preferences.fields.theme-label",message:"UI Theme"}),children:(0,x.jsx)(u.RadioButtonGroup,{options:j,value:null===(a=j.find((s=>s.value===e)))||void 0===a?void 0:a.value,onChange:this.onThemeChanged})}),(0,x.jsx)(u.Field,{label:(0,x.jsxs)(u.Label,{htmlFor:"home-dashboard-select",children:[(0,x.jsx)("span",{className:g.labelText,children:t||(t=(0,x.jsx)(o.cC,{id:"shared-preferences.fields.home-dashboard-label"}))}),f]}),"data-testid":"User preferences home dashboard drop down",children:(0,x.jsx)(u.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,x.jsx)(u.Field,{label:d.ag._({id:"shared-dashboard.fields.timezone-label",message:"Timezone"}),"data-testid":h.wl.components.TimeZonePicker.containerV2,children:(0,x.jsx)(u.TimeZonePicker,{includeInternal:!0,value:s,onChange:this.onTimeZoneChanged,inputId:"shared-preferences-timezone-picker"})}),(0,x.jsx)(u.Field,{label:d.ag._({id:"shared-preferences.fields.week-start-label",message:"Week start"}),"data-testid":h.wl.components.WeekStartPicker.containerV2,children:(0,x.jsx)(u.WeekStartPicker,{value:r,onChange:this.onWeekStartChanged,inputId:"shared-preferences-week-start-picker"})}),(0,x.jsx)("div",{className:"gf-form-button-row",children:(0,x.jsx)(u.Button,{type:"submit",variant:"primary","data-testid":h.wl.components.UserProfile.preferencesSaveButton,children:n||(n=(0,x.jsx)(o.cC,{id:"common.save"}))})})]})}})}}const b=p,v=(0,u.stylesFactory)((()=>({labelText:l.css`
- margin-right: 6px;
- `})))},92795:(e,s,r)=>{r.r(s),r.d(s,{UserProfileEditPage:()=>R,default:()=>$});var a,i,t,n,o,d=r(68404),l=r(18745),c=r(57686),h=r(69783),u=r(33801),m=r(67833),g=r(8674),x=r(69501),f=r(16695),j=r(45916);class p extends d.PureComponent{render(){const{isLoading:e,orgs:s,user:r}=this.props;return e?a||(a=(0,j.jsx)(h.LoadingPlaceholder,{text:"Loading organizations..."})):0===s.length?null:(0,j.jsxs)("div",{children:[i||(i=(0,j.jsx)("h3",{className:"page-sub-heading",children:(0,j.jsx)(x.cC,{id:"user-orgs.title"})})),(0,j.jsx)("div",{className:"gf-form-group",children:(0,j.jsxs)("table",{className:"filter-table form-inline","data-testid":f.wl.components.UserProfile.orgsTable,children:[t||(t=(0,j.jsx)("thead",{children:(0,j.jsxs)("tr",{children:[(0,j.jsx)("th",{children:(0,j.jsx)(x.cC,{id:"user-orgs.name-column"})}),(0,j.jsx)("th",{children:(0,j.jsx)(x.cC,{id:"user-orgs.role-column"})}),(0,j.jsx)("th",{})]})})),(0,j.jsx)("tbody",{children:s.map(((e,s)=>(0,j.jsxs)("tr",{children:[(0,j.jsx)("td",{children:e.name}),(0,j.jsx)("td",{children:e.role}),(0,j.jsx)("td",{className:"text-right",children:e.orgId===(null==r?void 0:r.orgId)?n||(n=(0,j.jsx)(h.Button,{variant:"secondary",size:"sm",disabled:!0,children:(0,j.jsx)(x.cC,{id:"user-orgs.current-org-button"})})):(0,j.jsx)(h.Button,{variant:"secondary",size:"sm",onClick:()=>{this.props.setUserOrg(e)},children:o||(o=(0,j.jsx)(x.cC,{id:"user-orgs.select-org-button"}))})})]},s)))})]})})]})}}const b=p;var v,w,C,k,y,S,U,P,I=r(17092),L=r(78837);const{disableLoginForm:z}=L.ZP,N=e=>{let{user:s,isSavingUser:r,updateProfile:a}=e;return(0,j.jsx)(h.Form,{onSubmit:e=>{a(e)},validateOn:"onBlur",children:e=>{var a,i,t;let{register:n,errors:o}=e;return(0,j.jsxs)(h.FieldSet,{label:v||(v=(0,j.jsx)(x.cC,{id:"user-profile.title"})),children:[(0,j.jsx)(h.Field,{label:I.ag._({id:"user-profile.fields.name-label",message:"Name"}),invalid:!!o.name,error:w||(w=(0,j.jsx)(x.cC,{id:"user-profile.fields.name-error"})),disabled:z,children:(0,j.jsx)(h.Input,Object.assign({},n("name",{required:!0}),{id:"edit-user-profile-name",placeholder:I.ag._({id:"user-profile.fields.name-label",message:"Name"}),defaultValue:null!==(a=null==s?void 0:s.name)&&void 0!==a?a:"",suffix:C||(C=(0,j.jsx)(T,{}))}))}),(0,j.jsx)(h.Field,{label:I.ag._({id:"user-profile.fields.email-label",message:"Email"}),invalid:!!o.email,error:k||(k=(0,j.jsx)(x.cC,{id:"user-profile.fields.email-error"})),disabled:z,children:(0,j.jsx)(h.Input,Object.assign({},n("email",{required:!0}),{id:"edit-user-profile-email",placeholder:I.ag._({id:"user-profile.fields.email-label",message:"Email"}),defaultValue:null!==(i=null==s?void 0:s.email)&&void 0!==i?i:"",suffix:y||(y=(0,j.jsx)(T,{}))}))}),(0,j.jsx)(h.Field,{label:I.ag._({id:"user-profile.fields.username-label",message:"Username"}),disabled:z,children:(0,j.jsx)(h.Input,Object.assign({},n("login"),{id:"edit-user-profile-username",defaultValue:null!==(t=null==s?void 0:s.login)&&void 0!==t?t:"",placeholder:I.ag._({id:"user-profile.fields.username-label",message:"Username"}),suffix:S||(S=(0,j.jsx)(T,{}))}))}),(0,j.jsx)("div",{className:"gf-form-button-row",children:(0,j.jsx)(h.Button,{variant:"primary",disabled:r,"data-testid":f.wl.components.UserProfile.profileSaveButton,type:"submit",children:U||(U=(0,j.jsx)(x.cC,{id:"common.save"}))})})]})}})},T=()=>z?P||(P=(0,j.jsx)(h.Tooltip,{content:"Login details locked because they are managed in another system.",children:(0,j.jsx)(h.Icon,{name:"lock"})})):null;var D,F,_,A,O;class Z extends d.PureComponent{render(){const{isLoading:e,sessions:s,revokeUserSession:r,i18n:a}=this.props;return e?D||(D=(0,j.jsx)(h.LoadingPlaceholder,{text:(0,j.jsx)(x.cC,{id:"user-sessions.loading"})})):(0,j.jsx)("div",{children:s.length>0&&(0,j.jsxs)(j.Fragment,{children:[F||(F=(0,j.jsx)("h3",{className:"page-sub-heading",children:"Sessions"})),(0,j.jsx)("div",{className:"gf-form-group",children:(0,j.jsxs)("table",{className:"filter-table form-inline","data-testid":f.wl.components.UserProfile.sessionsTable,children:[_||(_=(0,j.jsx)("thead",{children:(0,j.jsxs)("tr",{children:[(0,j.jsx)("th",{children:(0,j.jsx)(x.cC,{id:"user-session.seen-at-column"})}),(0,j.jsx)("th",{children:(0,j.jsx)(x.cC,{id:"user-session.created-at-column"})}),(0,j.jsx)("th",{children:(0,j.jsx)(x.cC,{id:"user-session.ip-column"})}),(0,j.jsx)("th",{children:(0,j.jsx)(x.cC,{id:"user-session.browser-column"})}),(0,j.jsx)("th",{})]})})),(0,j.jsx)("tbody",{children:s.map(((e,s)=>(0,j.jsxs)("tr",{children:[e.isActive?A||(A=(0,j.jsx)("td",{children:"Now"})):(0,j.jsx)("td",{children:e.seenAt}),(0,j.jsx)("td",{children:a.date(e.createdAt,{dateStyle:"long"})}),(0,j.jsx)("td",{children:e.clientIp}),(0,j.jsxs)("td",{children:[e.browser," on ",e.os," ",e.osVersion]}),(0,j.jsx)("td",{children:(0,j.jsx)(h.Button,{size:"sm",variant:"destructive",onClick:()=>r(e.id),"aria-label":a._({id:"user-session.revoke",message:"Revoke user session"}),children:O||(O=(0,j.jsx)(h.Icon,{name:"power"}))})})]},s)))})]})})]})})}}const B=(0,x.GV)()(Z);var V,q,H;class M extends d.PureComponent{render(){const{isLoading:e,teams:s}=this.props;return e?V||(V=(0,j.jsx)(h.LoadingPlaceholder,{text:"Loading teams..."})):0===s.length?null:(0,j.jsxs)("div",{children:[q||(q=(0,j.jsx)("h3",{className:"page-sub-heading",children:"Teams"})),(0,j.jsx)("div",{className:"gf-form-group",children:(0,j.jsxs)("table",{className:"filter-table form-inline","aria-label":"User teams table",children:[H||(H=(0,j.jsx)("thead",{children:(0,j.jsxs)("tr",{children:[(0,j.jsx)("th",{}),(0,j.jsx)("th",{children:"Name"}),(0,j.jsx)("th",{children:"Email"}),(0,j.jsx)("th",{children:"Members"})]})})),(0,j.jsx)("tbody",{children:s.map(((e,s)=>(0,j.jsxs)("tr",{children:[(0,j.jsx)("td",{className:"width-4 text-center",children:(0,j.jsx)("img",{className:"filter-table__avatar",src:e.avatarUrl,alt:""})}),(0,j.jsx)("td",{children:e.name}),(0,j.jsx)("td",{children:e.email}),(0,j.jsx)("td",{children:e.memberCount})]},s)))})]})})]})}}var W,E=r(86706);const G={initUserProfilePage:E.PA,revokeUserSession:E.cc,changeUserOrg:E.hz,updateUserProfile:E.Lj};function R(e){let{navModel:s,orgsAreLoading:r,sessionsAreLoading:a,teamsAreLoading:i,initUserProfilePage:t,orgs:n,sessions:o,teams:d,isUpdating:l,user:g,revokeUserSession:x,changeUserOrg:f,updateUserProfile:p}=e;return(0,c.Z)((()=>t())),(0,j.jsx)(u.Z,{navModel:s,children:(0,j.jsx)(u.Z.Contents,{isLoading:!g,children:(0,j.jsxs)(h.VerticalGroup,{spacing:"md",children:[(0,j.jsx)(N,{updateProfile:p,isSavingUser:l,user:g}),W||(W=(0,j.jsx)(m.Z,{resourceUri:"user"})),(0,j.jsx)(M,{isLoading:i,teams:d}),(0,j.jsx)(b,{isLoading:r,setUserOrg:f,orgs:n,user:g}),(0,j.jsx)(B,{isLoading:a,revokeUserSession:x,sessions:o})]})})})}const $=(0,l.connect)((function(e){const s=e.user,{user:r,teams:a,orgs:i,sessions:t,teamsAreLoading:n,orgsAreLoading:o,sessionsAreLoading:d,isUpdating:l}=s;return{navModel:(0,g.h)(e.navIndex,"profile-settings"),orgsAreLoading:o,sessionsAreLoading:d,teamsAreLoading:n,orgs:i,sessions:t,teams:a,isUpdating:l,user:r}}),G)(R)},86706:(e,s,r)=>{r.d(s,{Cp:()=>n,II:()=>d,Lj:()=>h,PA:()=>o,cc:()=>l,hz:()=>c});var a=r(90923),i=r(67220),t=r(10603);function n(e){return async function(s){s((0,t.zc)({updating:!0})),await i.h.changePassword(e),s((0,t.zc)({updating:!1}))}}function o(){return async function(e){await e(d()),e((async function(e){e((0,t.qD)());const s=await i.h.loadTeams();e((0,t.PL)({teams:s}))})),e((async function(e){e((0,t.$S)());const s=await i.h.loadOrgs();e((0,t.Ns)({orgs:s}))})),e((async function(e){e((0,t.Uk)());const s=await i.h.loadSessions();e((0,t.z0)({sessions:s}))}))}}function d(){return async function(e){const s=await i.h.loadUser();e((0,t.aw)({user:s}))}}function l(e){return async function(s){s((0,t.zc)({updating:!0})),await i.h.revokeUserSession(e),s((0,t.p$)({tokenId:e}))}}function c(e){return async function(s){s((0,t.zc)({updating:!0})),await i.h.setUserOrg(e),window.location.href=a.config.appSubUrl+"/profile"}}function h(e){return async function(s){s((0,t.zc)({updating:!0})),await i.h.updateUserProfile(e),await s(d()),s((0,t.zc)({updating:!1}))}}},57686:(e,s,r)=>{r.d(s,{Z:()=>i});var a=r(37784);const i=function(e){(0,a.Z)((function(){e()}))}}}]);
- //# sourceMappingURL=UserProfileEditPage.fd5296a04be330f55ad8.js.map
|