"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[529],{18885:(F,f,e)=>{e.d(f,{Z:()=>E,v:()=>o});var s=e(9892),t=e(68404),D=e(40400),d=e(68183),C=e(35645),i=e(41818),M=e(94270),g=e(13393),c=e(24799),T=e(2594),u=e(64353),y=e(52566),U=e(80124),I=e(26338),_=e(53217),A=e(31403),p=e(7804),S=e(99661),n=e(35287),L=e(19719),R=e(42454);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;
    `}))},23242:(F,f,e)=>{e.r(f),e.d(f,{OrgDetailsPage:()=>n,default:()=>W});var s=e(68404),t=e(36635),D=e(52081),d=e(79396),C=e(18885),i=e(77582),M=e(86245),g=e(81168),c=e(45984),T=e(94270),u=e(13393),y=e(24799),U=e(46967),I=e(31403);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(2183),S=e(17283);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.f3a8f66389aab2e8fb7a.js.map