"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[529],{82719:(F,u,e)=>{e.d(u,{Z:()=>o,v:()=>i});var s=e(66681),t=e(85960),M=e(83105),p=e(81223),E=e(92369),c=e(43183),T=e(90857),g=e(66596),y=e(51637),h=e(20519),O=e(27436),P=e(57445),I=e(76310),U=e(38797),b=e(34364),A=e(29165),D=e(33808),L=e(66399),n=e(95329),R=e(9675),S=e(76831),x=e(63510);function W(){const m=R.a2.map(a=>({value:a.code,label:a.name}));return[{value:"",label:(0,n.t)("common.locale.default","Default")},...m]}class i extends t.PureComponent{constructor(r){super(r),this.onSubmitForm=async()=>{if(this.props.onConfirm?await this.props.onConfirm():!0){const{homeDashboardUID:z,theme:B,timezone:K,weekStart:_,language:v,queryHistory:C}=this.state;await this.service.update({homeDashboardUID:z,theme:B,timezone:K,weekStart:_,language:v,queryHistory:C}),window.location.reload()}},this.onThemeChanged=a=>{this.setState({theme:a.value}),a.value&&(0,x.L)(a.value,!0)},this.onTimeZoneChanged=a=>{typeof a=="string"&&this.setState({timezone:a})},this.onWeekStartChanged=a=>{this.setState({weekStart:a})},this.onHomeDashboardChanged=a=>{this.setState({homeDashboardUID:a})},this.onLanguageChanged=a=>{this.setState({language:a}),(0,c.ff)("grafana_preferences_language_changed",{toLanguage:a,preferenceType:this.props.preferenceType})},this.service=new S.y(r.resourceUri),this.state={theme:"",timezone:"",weekStart:"",language:"",queryHistory:{homeTab:""}},this.themeOptions=(0,M.d)(T.config.featureToggles.extraThemes).map(a=>({value:a.id,label:l(a)})),this.themeOptions.unshift({value:"",label:(0,n.t)("shared-preferences.theme.default-label","Default")})}async componentDidMount(){const r=await this.service.load();this.setState({homeDashboardUID:r.homeDashboardUID,theme:r.theme,timezone:r.timezone,weekStart:r.weekStart,language:r.language,queryHistory:r.queryHistory})}render(){const{theme:r,timezone:a,weekStart:z,homeDashboardUID:B,language:K}=this.state,{disabled:_}=this.props,v=f(),C=W(),V=this.themeOptions.find(d=>d.value===r)??this.themeOptions[0];return t.createElement(g.l,{onSubmit:this.onSubmitForm},()=>t.createElement(t.Fragment,null,t.createElement(y.C,{label:t.createElement(n.cC,{i18nKey:"shared-preferences.title"},"Preferences"),disabled:_},t.createElement(h.g,{label:(0,n.t)("shared-preferences.fields.theme-label","Interface theme")},t.createElement(O.Ph,{options:this.themeOptions,value:V,onChange:this.onThemeChanged,inputId:"shared-preferences-theme-select"})),t.createElement(h.g,{label:t.createElement(P._,{htmlFor:"home-dashboard-select"},t.createElement("span",{className:v.labelText},t.createElement(n.cC,{i18nKey:"shared-preferences.fields.home-dashboard-label"},"Home Dashboard"))),"data-testid":"User preferences home dashboard drop down"},t.createElement(L.o,{value:B,onChange:d=>this.onHomeDashboardChanged(d?.uid??""),defaultOptions:!0,isClearable:!0,placeholder:(0,n.t)("shared-preferences.fields.home-dashboard-placeholder","Default dashboard"),inputId:"home-dashboard-select"})),t.createElement(h.g,{label:(0,n.t)("shared-dashboard.fields.timezone-label","Timezone"),"data-testid":E.wl.components.TimeZonePicker.containerV2},t.createElement(I.O,{includeInternal:!0,value:a,onChange:this.onTimeZoneChanged,inputId:"shared-preferences-timezone-picker"})),t.createElement(h.g,{label:(0,n.t)("shared-preferences.fields.week-start-label","Week start"),"data-testid":E.wl.components.WeekStartPicker.containerV2},t.createElement(U.z,{value:z||"",onChange:this.onWeekStartChanged,inputId:"shared-preferences-week-start-picker"})),t.createElement(h.g,{label:t.createElement(P._,{htmlFor:"locale-select"},t.createElement("span",{className:v.labelText},t.createElement(n.cC,{i18nKey:"shared-preferences.fields.locale-label"},"Language")),t.createElement(b.a,{featureState:p.CQ.beta})),"data-testid":"User preferences language drop down"},t.createElement(O.Ph,{value:C.find(d=>d.value===K),onChange:d=>this.onLanguageChanged(d.value??""),options:C,placeholder:(0,n.t)("shared-preferences.fields.locale-placeholder","Choose language"),inputId:"locale-select"}))),t.createElement(A.zx,{type:"submit",variant:"primary","data-testid":E.wl.components.UserProfile.preferencesSaveButton},t.createElement(n.cC,{i18nKey:"common.save"},"Save"))))}}const o=i,f=(0,D.B)(()=>({labelText:(0,s.css)`
      margin-right: 6px;
    `}));function l(m){switch(m.id){case"dark":return(0,n.t)("shared.preferences.theme.dark-label","Dark");case"light":return(0,n.t)("shared.preferences.theme.light-label","Light");case"system":return(0,n.t)("shared.preferences.theme.system-label","System preference");default:return m.name}}},54447:(F,u,e)=>{e.r(u),e.d(u,{OrgDetailsPage:()=>n,default:()=>W});var s=e(85960),t=e(36752),M=e(74042),p=e(20989),E=e(82719),c=e(49683),T=e(87947),g=e(95162),y=e(14914),h=e(66596),O=e(51637),P=e(20519),I=e(24956),U=e(29165);const A=({onSubmit:i,orgName:o})=>{const f=c.Vt.hasPermission(g.AccessControlAction.OrgsWrite);return s.createElement(h.l,{defaultValues:{orgName:o},onSubmit:({orgName:l})=>i(l)},({register:l})=>s.createElement(O.C,{label:"Organization profile",disabled:!f},s.createElement(P.g,{label:"Organization name"},s.createElement(I.I,{id:"org-name-input",type:"text",...l("orgName",{required:!0})})),s.createElement(U.zx,{type:"submit"},"Update organization name")))};var D=e(58796),L=e(60025);class n extends s.PureComponent{constructor(){super(...arguments),this.onUpdateOrganization=o=>{this.props.setOrganizationName(o),this.props.updateOrganization()},this.handleConfirm=()=>new Promise(o=>{c.h$.publish(new y.VJ({title:"Confirm preferences update",text:"This will update the preferences for the whole organization. Are you sure you want to update the preferences?",yesText:"Save",yesButtonVariant:"primary",onConfirm:async()=>o(!0),onDismiss:async()=>o(!1)}))})}async componentDidMount(){await this.props.loadOrganization()}render(){const{navModel:o,organization:f}=this.props,l=Object.keys(f).length===0,m=c.Vt.hasPermission(g.AccessControlAction.OrgsRead),r=c.Vt.hasPermission(g.AccessControlAction.OrgsPreferencesRead),a=c.Vt.hasPermission(g.AccessControlAction.OrgsPreferencesWrite);return s.createElement(p.T,{navModel:o},s.createElement(p.T.Contents,{isLoading:l},!l&&s.createElement(M.wc,{spacing:"lg"},m&&s.createElement(A,{onSubmit:this.onUpdateOrganization,orgName:f.name}),r&&s.createElement(E.Z,{resourceUri:"org",disabled:!a,preferenceType:"org",onConfirm:this.handleConfirm}))))}}function R(i){return{navModel:(0,T.ht)(i.navIndex,"org-settings"),organization:i.organization.organization}}const S={loadOrganization:D.RF,setOrganizationName:L.xR,updateOrganization:D.FV},W=(0,t.connect)(R,S)(n)}}]);

//# sourceMappingURL=OrgDetailsPage.0d2b8e4961a84a9f6fab.js.map