1234 |
- "use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[529],{67833:(e,t,a)=>{a.d(t,{Z:()=>k,v:()=>v});var r,n,s,i,o=a(69501),d=a(17092),l=a(36636),h=a(68404),c=a(16695),g=a(69783),m=a(76187),u=a(28659),p=a(45916);function b(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,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 v extends h.PureComponent{constructor(e){super(e),b(this,"service",void 0),b(this,"onSubmitForm",(async()=>{const{homeDashboardId:e,theme:t,timezone:a,weekStart:r,queryHistory:n}=this.state;await this.service.update({homeDashboardId:e,theme:t,timezone:a,weekStart:r,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 m.y(e.resourceUri),this.state={homeDashboardId:0,theme:"",timezone:"",weekStart:"",dashboards:[],queryHistory:{homeTab:""}}}async componentDidMount(){const e=await this.service.load(),t=await u.ae.search({starred:!0});if(e.homeDashboardId>0&&!t.find((t=>t.id===e.homeDashboardId))){const a=await u.ae.search({dashboardIds:[e.homeDashboardId]});a&&a.length>0&&t.push(a[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:a,homeDashboardId:l,dashboards:h}=this.state,{disabled:m}=this.props,u=S(),b=r||(r=(0,p.jsx)(g.Tooltip,{content:(0,p.jsx)(o.cC,{id:"shared-preferences.fields.home-dashboard-tooltip"}),children:(0,p.jsx)(g.Icon,{name:"info-circle"})}));return(0,p.jsx)(g.Form,{onSubmit:this.onSubmitForm,children:()=>{var r;return(0,p.jsxs)(g.FieldSet,{label:n||(n=(0,p.jsx)(o.cC,{id:"shared-preferences.title"})),disabled:m,children:[(0,p.jsx)(g.Field,{label:d.ag._({id:"shared-preferences.fields.theme-label",message:"UI Theme"}),children:(0,p.jsx)(g.RadioButtonGroup,{options:f,value:null===(r=f.find((t=>t.value===e)))||void 0===r?void 0:r.value,onChange:this.onThemeChanged})}),(0,p.jsx)(g.Field,{label:(0,p.jsxs)(g.Label,{htmlFor:"home-dashboard-select",children:[(0,p.jsx)("span",{className:u.labelText,children:s||(s=(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)(g.Select,{value:h.find((e=>e.id===l)),getOptionValue:e=>e.id,getOptionLabel:this.getFullDashName,onChange:e=>this.onHomeDashboardChanged(e.id),options:h,placeholder:d.ag._({id:"shared-preferences.fields.home-dashboard-placeholder",message:"Choose default dashboard"}),inputId:"home-dashboard-select"})}),(0,p.jsx)(g.Field,{label:d.ag._({id:"shared-dashboard.fields.timezone-label",message:"Timezone"}),"data-testid":c.wl.components.TimeZonePicker.containerV2,children:(0,p.jsx)(g.TimeZonePicker,{includeInternal:!0,value:t,onChange:this.onTimeZoneChanged,inputId:"shared-preferences-timezone-picker"})}),(0,p.jsx)(g.Field,{label:d.ag._({id:"shared-preferences.fields.week-start-label",message:"Week start"}),"data-testid":c.wl.components.WeekStartPicker.containerV2,children:(0,p.jsx)(g.WeekStartPicker,{value:a,onChange:this.onWeekStartChanged,inputId:"shared-preferences-week-start-picker"})}),(0,p.jsx)("div",{className:"gf-form-button-row",children:(0,p.jsx)(g.Button,{type:"submit",variant:"primary","data-testid":c.wl.components.UserProfile.preferencesSaveButton,children:i||(i=(0,p.jsx)(o.cC,{id:"common.save"}))})})]})}})}}const k=v,S=(0,g.stylesFactory)((()=>({labelText:l.css`
- margin-right: 6px;
- `})))},36199:(e,t,a)=>{a.r(t),a.d(t,{OrgDetailsPage:()=>b,default:()=>v});var r,n=a(68404),s=a(18745),i=a(69783),o=a(33801),d=a(67833),l=a(98163),h=a(8674),c=a(58170),g=a(45916);const m=e=>{let{onSubmit:t,orgName:a}=e;const n=l.Vt.hasPermission(c.bW.OrgsWrite);return(0,g.jsx)(i.Form,{defaultValues:{orgName:a},onSubmit:e=>{let{orgName:a}=e;return t(a)},children:e=>{let{register:t}=e;return(0,g.jsxs)(i.FieldSet,{label:"Organization profile",disabled:!n,children:[(0,g.jsx)(i.Field,{label:"Organization name",children:(0,g.jsx)(i.Input,Object.assign({id:"org-name-input",type:"text"},t("orgName",{required:!0})))}),r||(r=(0,g.jsx)(i.Button,{type:"submit",children:"Update organization name"}))]})}})};var u=a(57192),p=a(41078);class b extends n.PureComponent{constructor(){var e,t,a;super(...arguments),a=e=>{this.props.setOrganizationName(e),this.props.updateOrganization()},(t="onUpdateOrganization")in(e=this)?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a}async componentDidMount(){await this.props.loadOrganization()}render(){const{navModel:e,organization:t}=this.props,a=0===Object.keys(t).length,r=l.Vt.hasPermission(c.bW.OrgsRead),n=l.Vt.hasPermission(c.bW.OrgsPreferencesRead),s=l.Vt.hasPermission(c.bW.OrgsPreferencesWrite);return(0,g.jsx)(o.Z,{navModel:e,children:(0,g.jsx)(o.Z.Contents,{isLoading:a,children:!a&&(0,g.jsxs)(i.VerticalGroup,{spacing:"lg",children:[r&&(0,g.jsx)(m,{onSubmit:this.onUpdateOrganization,orgName:t.name}),n&&(0,g.jsx)(d.Z,{resourceUri:"org",disabled:!s})]})})})}}const f={loadOrganization:u.RF,setOrganizationName:p.xR,updateOrganization:u.FV},v=(0,s.connect)((function(e){return{navModel:(0,h.h)(e.navIndex,"org-settings"),organization:e.organization.organization}}),f)(b)},57192:(e,t,a)=>{a.d(t,{FV:()=>o,JE:()=>h,Q$:()=>d,RF:()=>i,Yi:()=>l});var r=a(90923),n=a(36537),s=a(41078);function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{getBackendSrv:r.getBackendSrv};return async t=>{const a=await e.getBackendSrv().get("/api/org");return t((0,s.jR)(a)),a}}function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{getBackendSrv:r.getBackendSrv};return async(t,a)=>{const r=a().organization.organization;await e.getBackendSrv().put("/api/org",{name:r.name}),t((0,n.H7)(r.name)),t(i(e))}}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{getBackendSrv:r.getBackendSrv};return async a=>{const r=await t.getBackendSrv().post("/api/user/using/"+e);a((0,n.H7)(r.name))}}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{getBackendSrv:r.getBackendSrv};return async a=>{a(d((await t.getBackendSrv().post("/api/orgs/",e)).orgId))}}function h(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{getBackendSrv:r.getBackendSrv};return async t=>{const a=await e.getBackendSrv().get("/api/user/orgs");return t((0,s.IM)(a)),a}}}}]);
- //# sourceMappingURL=OrgDetailsPage.04367fd6e232ef3fc13b.js.map
|