"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[529],{72855:(e,a,t)=>{t.d(a,{Z:()=>B,v:()=>_});var n,s,r,i,o=t(2907),l=t(41243),d=t(77813),c=t(76687),h=t(91996),g=t(28441),m=t(67273),u=t(56481),p=t(72660),b=t(45550),v=t(81377),f=t(13627),x=t(83695),j=t(6712),S=t(93631),k=t(62533),w=t(55312),z=t(20821),C=t(55516),y=t(42025),D=t(7209),O=t(52010);function I(e,a,t){return a in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}const P=[{value:"",label:l.ag._({id:"shared-preferences.theme.default-label",message:"Default"})},{value:"dark",label:l.ag._({id:"shared-preferences.theme.dark-label",message:"Dark"})},{value:"light",label:l.ag._({id:"shared-preferences.theme.light-label",message:"Light"})}],U=[{value:"",label:l.ag._({id:"common.locale.default",message:"Default"})},{value:y.cV,label:l.ag._({id:"common.locale.en",message:"English"})},{value:y.Hc,label:l.ag._({id:"common.locale.es",message:"Spanish"})},{value:y.jW,label:l.ag._({id:"common.locale.fr",message:"French"})}],T=Boolean(m.v.featureToggles.internationalization);class _ extends c.PureComponent{constructor(e){super(e),I(this,"service",void 0),I(this,"onSubmitForm",(async()=>{const{homeDashboardUID:e,theme:a,timezone:t,weekStart:n,locale:s,queryHistory:r}=this.state;await this.service.update({homeDashboardUID:e,theme:a,timezone:t,weekStart:n,locale:s,queryHistory:r}),window.location.reload()})),I(this,"onThemeChanged",(e=>{this.setState({theme:e})})),I(this,"onTimeZoneChanged",(e=>{e&&this.setState({timezone:e})})),I(this,"onWeekStartChanged",(e=>{this.setState({weekStart:e})})),I(this,"onHomeDashboardChanged",(e=>{this.setState({homeDashboardUID:e})})),I(this,"onLocaleChanged",(e=>{this.setState({locale:e})})),this.service=new D.y(e.resourceUri),this.state={theme:"",timezone:"",weekStart:"",locale:"",queryHistory:{homeTab:""}}}async componentDidMount(){const e=await this.service.load();this.setState({homeDashboardUID:e.homeDashboardUID,theme:e.theme,timezone:e.timezone,weekStart:e.weekStart,locale:e.locale,queryHistory:e.queryHistory})}render(){const{theme:e,timezone:a,weekStart:t,homeDashboardUID:d,locale:c}=this.state,{disabled:m}=this.props,z=W();return(0,O.jsx)(u.l,{onSubmit:this.onSubmitForm,children:()=>{var u;return(0,O.jsxs)(p.C,{label:n||(n=(0,O.jsx)(o.cC,{id:"shared-preferences.title"})),disabled:m,children:[(0,O.jsx)(b.g,{label:l.ag._({id:"shared-preferences.fields.theme-label",message:"UI Theme"}),children:(0,O.jsx)(v.S,{options:P,value:null===(u=P.find((a=>a.value===e)))||void 0===u?void 0:u.value,onChange:this.onThemeChanged})}),(0,O.jsx)(b.g,{label:(0,O.jsx)(f._,{htmlFor:"home-dashboard-select",children:(0,O.jsx)("span",{className:z.labelText,children:s||(s=(0,O.jsx)(o.cC,{id:"shared-preferences.fields.home-dashboard-label"}))})}),"data-testid":"User preferences home dashboard drop down",children:(0,O.jsx)(C.o,{value:d,onChange:e=>{var a;return this.onHomeDashboardChanged(null!==(a=null==e?void 0:e.uid)&&void 0!==a?a:"")},defaultOptions:!0,isClearable:!0,placeholder:l.ag._({id:"shared-preferences.fields.home-dashboard-placeholder",message:"Default dashboard"}),inputId:"home-dashboard-select"})}),(0,O.jsx)(b.g,{label:l.ag._({id:"shared-dashboard.fields.timezone-label",message:"Timezone"}),"data-testid":g.wl.components.TimeZonePicker.containerV2,children:(0,O.jsx)(x.O,{includeInternal:!0,value:a,onChange:this.onTimeZoneChanged,inputId:"shared-preferences-timezone-picker"})}),(0,O.jsx)(b.g,{label:l.ag._({id:"shared-preferences.fields.week-start-label",message:"Week start"}),"data-testid":g.wl.components.WeekStartPicker.containerV2,children:(0,O.jsx)(j.z,{value:t,onChange:this.onWeekStartChanged,inputId:"shared-preferences-week-start-picker"})}),T?(0,O.jsx)(b.g,{label:(0,O.jsxs)(f._,{htmlFor:"locale-select",children:[(0,O.jsx)("span",{className:z.labelText,children:r||(r=(0,O.jsx)(o.cC,{id:"shared-preferences.fields.locale-label"}))}),(0,O.jsx)(S.a,{featureState:h.CQ.alpha})]}),"data-testid":"User preferences language drop down",children:(0,O.jsx)(k.Ph,{value:U.find((e=>e.value===c)),onChange:e=>{var a;return this.onLocaleChanged(null!==(a=e.value)&&void 0!==a?a:"")},options:U,placeholder:l.ag._({id:"shared-preferences.fields.locale-placeholder",message:"Choose language"}),inputId:"locale-select"})}):null,(0,O.jsx)("div",{className:"gf-form-button-row",children:(0,O.jsx)(w.zx,{type:"submit",variant:"primary","data-testid":g.wl.components.UserProfile.preferencesSaveButton,children:i||(i=(0,O.jsx)(o.cC,{id:"common.save"}))})})]})}})}}const B=_,W=(0,z.B)((()=>({labelText:d.css`
      margin-right: 6px;
    `})))},64995:(e,a,t)=>{t.r(a),t.d(a,{OrgDetailsPage:()=>S,default:()=>w});var n,s=t(76687),r=t(30415),i=t(7053),o=t(28781),l=t(72855),d=t(31271),c=t(3276),h=t(352),g=t(56481),m=t(72660),u=t(45550),p=t(9120),b=t(55312),v=t(52010);const f=e=>{let{onSubmit:a,orgName:t}=e;const s=d.Vt.hasPermission(h.bW.OrgsWrite);return(0,v.jsx)(g.l,{defaultValues:{orgName:t},onSubmit:e=>{let{orgName:t}=e;return a(t)},children:e=>{let{register:a}=e;return(0,v.jsxs)(m.C,{label:"Organization profile",disabled:!s,children:[(0,v.jsx)(u.g,{label:"Organization name",children:(0,v.jsx)(p.I,Object.assign({id:"org-name-input",type:"text"},a("orgName",{required:!0})))}),n||(n=(0,v.jsx)(b.zx,{type:"submit",children:"Update organization name"}))]})}})};var x=t(22399),j=t(30587);class S extends s.PureComponent{constructor(){var e,a,t;super(...arguments),t=e=>{this.props.setOrganizationName(e),this.props.updateOrganization()},(a="onUpdateOrganization")in(e=this)?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t}async componentDidMount(){await this.props.loadOrganization()}render(){const{navModel:e,organization:a}=this.props,t=0===Object.keys(a).length,n=d.Vt.hasPermission(h.bW.OrgsRead),s=d.Vt.hasPermission(h.bW.OrgsPreferencesRead),r=d.Vt.hasPermission(h.bW.OrgsPreferencesWrite);return(0,v.jsx)(o.T,{navModel:e,children:(0,v.jsx)(o.T.Contents,{isLoading:t,children:!t&&(0,v.jsxs)(i.wc,{spacing:"lg",children:[n&&(0,v.jsx)(f,{onSubmit:this.onUpdateOrganization,orgName:a.name}),s&&(0,v.jsx)(l.Z,{resourceUri:"org",disabled:!r})]})})})}}const k={loadOrganization:x.RF,setOrganizationName:j.xR,updateOrganization:x.FV},w=(0,r.connect)((function(e){return{navModel:(0,c.h)(e.navIndex,"org-settings"),organization:e.organization.organization}}),k)(S)},22399:(e,a,t)=>{t.d(a,{FV:()=>o,JE:()=>c,Q$:()=>l,RF:()=>i,Yi:()=>d});var n=t(5205),s=t(29877),r=t(30587);function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{getBackendSrv:n.i};return async a=>{const t=await e.getBackendSrv().get("/api/org");return a((0,r.jR)(t)),t}}function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{getBackendSrv:n.i};return async(a,t)=>{const n=t().organization.organization;await e.getBackendSrv().put("/api/org",{name:n.name}),a((0,s.H7)(n.name)),a(i(e))}}function l(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{getBackendSrv:n.i};return async t=>{const n=await a.getBackendSrv().post("/api/user/using/"+e);t((0,s.H7)(n.name))}}function d(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{getBackendSrv:n.i};return async t=>{t(l((await a.getBackendSrv().post("/api/orgs/",e)).orgId))}}function c(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{getBackendSrv:n.i};return async a=>{const t=await e.getBackendSrv().get("/api/user/orgs");return a((0,r.IM)(t)),t}}}}]);
//# sourceMappingURL=OrgDetailsPage.fa084d6023b45a414a85.js.map