"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[529],{13178:(F,f,e)=>{e.d(f,{Z:()=>E,v:()=>o});var s=e(60234),t=e(65237),D=e(71534),d=e(92917),C=e(49784),i=e(28704),M=e(46181),g=e(37885),c=e(5263),T=e(12007),u=e(42505),y=e(30385),U=e(32741),I=e(10683),_=e(94795),A=e(48389),p=e(48954),S=e(70786),n=e(96662),L=e(90531),R=e(47683);function W(){const O=L.a2.map(a=>({value:a.code,label:a.name}));return[{value:"",label:(0,n.t)("common.locale.default","Default")},...O]}const h=Boolean(C.v.featureToggles.internationalization);class o 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:b,language:P,queryHistory:v}=this.state;await this.service.update({homeDashboardUID:z,theme:B,timezone:K,weekStart:b,language:P,queryHistory:v}),window.location.reload()}},this.onThemeChanged=a=>{this.setState({theme:a})},this.onTimeZoneChanged=a=>{a&&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,i.ff)("grafana_preferences_language_changed",{toLanguage:a,preferenceType:this.props.preferenceType})},this.service=new R.y(r.resourceUri),this.state={theme:"",timezone:"",weekStart:"",language:"",queryHistory:{homeTab:""}},this.themeOptions=[{value:"",label:(0,n.t)("shared-preferences.theme.default-label","Default")},{value:"dark",label:(0,n.t)("shared-preferences.theme.dark-label","Dark")},{value:"light",label:(0,n.t)("shared-preferences.theme.light-label","Light")},{value:"system",label:(0,n.t)("shared-preferences.theme.system-label","System")}]}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:b}=this.props,P=l(),v=W();let x=this.themeOptions[0].value;return r?.length&&(x=this.themeOptions.find(m=>m.value===r)?.value),t.createElement(M.l,{onSubmit:this.onSubmitForm},()=>t.createElement(g.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","UI Theme")},t.createElement(T.S,{options:this.themeOptions,value:x,onChange:this.onThemeChanged})),t.createElement(c.g,{label:t.createElement(u._,{htmlFor:"home-dashboard-select"},t.createElement("span",{className:P.labelText},t.createElement(n.cC,{i18nKey:"shared-preferences.fields.home-dashboard-label"},"Home Dashboard"))),"data-testid":"User preferences home dashboard drop down"},t.createElement(S.o,{value:B,onChange:m=>this.onHomeDashboardChanged(m?.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":d.wl.components.TimeZonePicker.containerV2},t.createElement(y.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":d.wl.components.WeekStartPicker.containerV2},t.createElement(U.z,{value:z||"",onChange:this.onWeekStartChanged,inputId:"shared-preferences-week-start-picker"})),h?t.createElement(c.g,{label:t.createElement(u._,{htmlFor:"locale-select"},t.createElement("span",{className:P.labelText},t.createElement(n.cC,{i18nKey:"shared-preferences.fields.locale-label"},"Language")),t.createElement(I.a,{featureState:D.CQ.beta})),"data-testid":"User preferences language drop down"},t.createElement(_.Ph,{value:v.find(m=>m.value===K),onChange:m=>this.onLanguageChanged(m.value??""),options:v,placeholder:(0,n.t)("shared-preferences.fields.locale-placeholder","Choose language"),inputId:"locale-select"})):null,t.createElement("div",{className:"gf-form-button-row"},t.createElement(A.zx,{type:"submit",variant:"primary","data-testid":d.wl.components.UserProfile.preferencesSaveButton},t.createElement(n.cC,{i18nKey:"common.save"},"Save")))))}}const E=o,l=(0,p.B)(()=>({labelText:s.css`
      margin-right: 6px;
    `}))},38109:(F,f,e)=>{e.r(f),e.d(f,{OrgDetailsPage:()=>n,default:()=>W});var s=e(65237),t=e(37149),D=e(6741),d=e(38992),C=e(13178),i=e(63969),M=e(85938),g=e(3315),c=e(91063),T=e(46181),u=e(37885),y=e(5263),U=e(96682),I=e(48389);const A=({onSubmit:h,orgName:o})=>{const E=i.Vt.hasPermission(g.AccessControlAction.OrgsWrite);return s.createElement(T.l,{defaultValues:{orgName:o},onSubmit:({orgName:l})=>h(l)},({register:l})=>s.createElement(u.C,{label:"Organization profile",disabled:!E},s.createElement(y.g,{label:"Organization name"},s.createElement(U.I,{id:"org-name-input",type:"text",...l("orgName",{required:!0})})),s.createElement(I.zx,{type:"submit"},"Update organization name")))};var p=e(47570),S=e(53820);class n extends s.PureComponent{constructor(){super(...arguments),this.onUpdateOrganization=o=>{this.props.setOrganizationName(o),this.props.updateOrganization()},this.handleConfirm=()=>new Promise(o=>{i.h$.publish(new c.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:E}=this.props,l=Object.keys(E).length===0,O=i.Vt.hasPermission(g.AccessControlAction.OrgsRead),r=i.Vt.hasPermission(g.AccessControlAction.OrgsPreferencesRead),a=i.Vt.hasPermission(g.AccessControlAction.OrgsPreferencesWrite);return s.createElement(d.T,{navModel:o},s.createElement(d.T.Contents,{isLoading:l},!l&&s.createElement(D.wc,{spacing:"lg"},O&&s.createElement(A,{onSubmit:this.onUpdateOrganization,orgName:E.name}),r&&s.createElement(C.Z,{resourceUri:"org",disabled:!a,preferenceType:"org",onConfirm:this.handleConfirm}))))}}function L(h){return{navModel:(0,M.ht)(h.navIndex,"org-settings"),organization:h.organization.organization}}const R={loadOrganization:p.RF,setOrganizationName:S.xR,updateOrganization:p.FV},W=(0,t.connect)(L,R)(n)}}]);

//# sourceMappingURL=OrgDetailsPage.d342661e6eb79d470d65.js.map