"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[529],{37727:(F,u,e)=>{e.d(u,{Z:()=>f,v:()=>o});var s=e(41407),t=e(39953),M=e(54112),p=e(96083),E=e(28888),l=e(72639),T=e(32688),g=e(85830),y=e(2827),c=e(96227),O=e(9558),P=e(36495),I=e(87783),U=e(76843),x=e(5217),A=e(4919),D=e(64084),L=e(56516),n=e(62679),R=e(80214),S=e(88960),W=e(54977);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(t.Fragment,null,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(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}}},90940:(F,u,e)=>{e.r(u),e.d(u,{OrgDetailsPage:()=>n,default:()=>W});var s=e(39953),t=e(89772),M=e(12223),p=e(13253),E=e(37727),l=e(21308),T=e(45015),g=e(57721),y=e(73431),c=e(85830),O=e(2827),P=e(96227),I=e(38637),U=e(4919);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(72700),L=e(25430);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.7f8f1fd63421af2d21d5.js.map