"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[529],{54569:(F,u,e)=>{e.d(u,{Z:()=>f,v:()=>o});var s=e(42844),t=e(27702),M=e(11391),p=e(62247),E=e(74639),l=e(86312),T=e(34667),g=e(23839),y=e(5229),c=e(22209),O=e(28580),P=e(79978),I=e(15672),U=e(63014),x=e(96198),A=e(66670),D=e(80402),L=e(81290),n=e(65322),R=e(16832),S=e(97662),W=e(70828);function h(){const m=R.a2.map(a=>({value:a.code,label:a.name}));return[{value:"",label:(0,n.t)("common.locale.default","Default")},...m]}class o extends t.PureComponent{constructor(r){super(r),this.onSubmitForm=async()=>{if(this.props.onConfirm?await this.props.onConfirm():!0){const{homeDashboardUID:B,theme:K,timezone:_,weekStart:b,language:v,queryHistory:C}=this.state;await this.service.update({homeDashboardUID:B,theme:K,timezone:_,weekStart:b,language:v,queryHistory:C}),window.location.reload()}},this.onThemeChanged=a=>{this.setState({theme:a.value}),a.value&&(0,W.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,l.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:z(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:B,homeDashboardUID:K,language:_}=this.state,{disabled:b}=this.props,v=i(),C=h(),V=this.themeOptions.find(d=>d.value===r)??this.themeOptions[0];return t.createElement(g.l,{onSubmit:this.onSubmitForm},()=>t.createElement(y.C,{label:t.createElement(n.cC,{i18nKey:"shared-preferences.title"},"Preferences"),disabled:b},t.createElement(c.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(c.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:K,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(c.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(c.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:B||"",onChange:this.onWeekStartChanged,inputId:"shared-preferences-week-start-picker"})),t.createElement(c.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(x.a,{featureState:p.CQ.beta})),"data-testid":"User preferences language drop down"},t.createElement(O.Ph,{value:C.find(d=>d.value===_),onChange:d=>this.onLanguageChanged(d.value??""),options:C,placeholder:(0,n.t)("shared-preferences.fields.locale-placeholder","Choose language"),inputId:"locale-select"})),t.createElement("div",{className:"gf-form-button-row"},t.createElement(A.zx,{type:"submit",variant:"primary","data-testid":E.wl.components.UserProfile.preferencesSaveButton},t.createElement(n.cC,{i18nKey:"common.save"},"Save")))))}}const f=o,i=(0,D.B)(()=>({labelText:(0,s.css)`
      margin-right: 6px;
    `}));function z(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}}},832:(F,u,e)=>{e.r(u),e.d(u,{OrgDetailsPage:()=>n,default:()=>W});var s=e(27702),t=e(27173),M=e(64022),p=e(44644),E=e(54569),l=e(66574),T=e(86809),g=e(18771),y=e(43620),c=e(23839),O=e(5229),P=e(22209),I=e(1128),U=e(66670);const A=({onSubmit:h,orgName:o})=>{const f=l.Vt.hasPermission(g.AccessControlAction.OrgsWrite);return s.createElement(c.l,{defaultValues:{orgName:o},onSubmit:({orgName:i})=>h(i)},({register:i})=>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",...i("orgName",{required:!0})})),s.createElement(U.zx,{type:"submit"},"Update organization name")))};var D=e(30284),L=e(73796);class n extends s.PureComponent{constructor(){super(...arguments),this.onUpdateOrganization=o=>{this.props.setOrganizationName(o),this.props.updateOrganization()},this.handleConfirm=()=>new Promise(o=>{l.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,i=Object.keys(f).length===0,z=l.Vt.hasPermission(g.AccessControlAction.OrgsRead),m=l.Vt.hasPermission(g.AccessControlAction.OrgsPreferencesRead),r=l.Vt.hasPermission(g.AccessControlAction.OrgsPreferencesWrite);return s.createElement(p.T,{navModel:o},s.createElement(p.T.Contents,{isLoading:i},!i&&s.createElement(M.wc,{spacing:"lg"},z&&s.createElement(A,{onSubmit:this.onUpdateOrganization,orgName:f.name}),m&&s.createElement(E.Z,{resourceUri:"org",disabled:!r,preferenceType:"org",onConfirm:this.handleConfirm}))))}}function R(h){return{navModel:(0,T.ht)(h.navIndex,"org-settings"),organization:h.organization.organization}}const S={loadOrganization:D.RF,setOrganizationName:L.xR,updateOrganization:D.FV},W=(0,t.connect)(R,S)(n)}}]);

//# sourceMappingURL=OrgDetailsPage.672ffd83332f7ab84371.js.map