"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[529],{67833:(e,a,t)=>{t.d(a,{Z:()=>B,v:()=>_});var n,s,r,i,o=t(25235),l=t(19309),d=t(27549),c=t(68404),h=t(38536),g=t(68694),m=t(48147),u=t(61692),p=t(64624),b=t(84719),v=t(96380),f=t(4546),x=t(15601),j=t(53427),S=t(71428),k=t(2563),w=t(40920),z=t(40882),C=t(49248),y=t(57512),D=t(76187),O=t(45916);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;
    `})))},36199:(e,a,t)=>{t.r(a),t.d(a,{OrgDetailsPage:()=>S,default:()=>w});var n,s=t(68404),r=t(1485),i=t(25049),o=t(90894),l=t(67833),d=t(98163),c=t(8674),h=t(47570),g=t(61692),m=t(64624),u=t(84719),p=t(1652),b=t(40920),v=t(45916);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(57192),j=t(41078);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)},57192:(e,a,t)=>{t.d(a,{FV:()=>o,JE:()=>c,Q$:()=>l,RF:()=>i,Yi:()=>d});var n=t(6932),s=t(36537),r=t(41078);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.a799636d2dc45e3993eb.js.map