"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[529],{"./public/app/core/components/SharedPreferences/SharedPreferences.tsx":(e,a,t)=>{t.d(a,{v:()=>p,Z:()=>g});var n,r,s=t("./node_modules/react/index.js"),o=t("./node_modules/@emotion/css/dist/emotion-css.esm.js"),i=t("./packages/grafana-ui/src/index.ts"),d=t("./packages/grafana-e2e-selectors/src/index.ts"),l=t("./public/app/core/services/backend_srv.ts"),c=t("./public/app/core/services/PreferencesService.ts"),h=t("./node_modules/react/jsx-runtime.js");function u(e,a,t){return a in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}const m=[{value:"",label:"Default"},{value:"dark",label:"Dark"},{value:"light",label:"Light"}];class p extends s.PureComponent{constructor(e){super(e),u(this,"service",void 0),u(this,"onSubmitForm",(async()=>{const{homeDashboardId:e,theme:a,timezone:t}=this.state;await this.service.update({homeDashboardId:e,theme:a,timezone:t}),window.location.reload()})),u(this,"onThemeChanged",(e=>{this.setState({theme:e})})),u(this,"onTimeZoneChanged",(e=>{e&&this.setState({timezone:e})})),u(this,"onHomeDashboardChanged",(e=>{this.setState({homeDashboardId:e})})),u(this,"getFullDashName",(e=>void 0===e.folderTitle||""===e.folderTitle?e.title:e.folderTitle+" / "+e.title)),this.service=new c.y(e.resourceUri),this.state={homeDashboardId:0,theme:"",timezone:"",dashboards:[]}}async componentDidMount(){const e=await this.service.load(),a=await l.ae.search({starred:!0});if(e.homeDashboardId>0&&!a.find((a=>a.id===e.homeDashboardId))){const t=await l.ae.search({dashboardIds:[e.homeDashboardId]});t&&t.length>0&&a.push(t[0])}this.setState({homeDashboardId:e.homeDashboardId,theme:e.theme,timezone:e.timezone,dashboards:[{id:0,title:"Default",tags:[],type:"",uid:"",uri:"",url:"",folderId:0,folderTitle:"",folderUid:"",folderUrl:"",isStarred:!1,slug:"",items:[]},...a]})}render(){const{theme:e,timezone:a,homeDashboardId:t,dashboards:s}=this.state,o=b();return(0,h.jsx)(i.Form,{onSubmit:this.onSubmitForm,children:()=>{var l;return(0,h.jsxs)(i.FieldSet,{label:"Preferences",children:[(0,h.jsx)(i.Field,{label:"UI Theme",children:(0,h.jsx)(i.RadioButtonGroup,{options:m,value:null===(l=m.find((a=>a.value===e)))||void 0===l?void 0:l.value,onChange:this.onThemeChanged})}),(0,h.jsx)(i.Field,{label:(0,h.jsxs)(i.Label,{htmlFor:"home-dashboard-select",children:[(0,h.jsx)("span",{className:o.labelText,children:"Home Dashboard"}),n||(n=(0,h.jsx)(i.Tooltip,{content:"Not finding the dashboard you want? Star it first, then it should appear in this select box.",children:(0,h.jsx)(i.Icon,{name:"info-circle"})}))]}),"aria-label":"User preferences home dashboard drop down",children:(0,h.jsx)(i.Select,{menuShouldPortal:!0,value:s.find((e=>e.id===t)),getOptionValue:e=>e.id,getOptionLabel:this.getFullDashName,onChange:e=>this.onHomeDashboardChanged(e.id),options:s,placeholder:"Choose default dashboard",inputId:"home-dashboard-select"})}),(0,h.jsx)(i.Field,{label:"Timezone","aria-label":d.wl.components.TimeZonePicker.container,children:(0,h.jsx)(i.TimeZonePicker,{includeInternal:!0,value:a,onChange:this.onTimeZoneChanged})}),r||(r=(0,h.jsx)("div",{className:"gf-form-button-row",children:(0,h.jsx)(i.Button,{variant:"primary","aria-label":"User preferences save button",children:"Save"})}))]})}})}}const g=p,b=(0,i.stylesFactory)((()=>({labelText:o.css`
      margin-right: 6px;
    `})))},"./public/app/features/org/OrgDetailsPage.tsx":(e,a,t)=>{t.r(a),t.d(a,{OrgDetailsPage:()=>f,default:()=>v});var n,r=t("./node_modules/react/index.js"),s=t("./node_modules/react-redux/es/index.js"),o=t("./public/app/core/components/Page/Page.tsx"),i=t("./packages/grafana-ui/src/index.ts"),d=t("./node_modules/react/jsx-runtime.js");const l=({onSubmit:e,orgName:a})=>(0,d.jsx)(i.Form,{defaultValues:{orgName:a},onSubmit:({orgName:a})=>e(a),children:({register:e})=>(0,d.jsxs)(i.FieldSet,{label:"Organization profile",children:[(0,d.jsx)(i.Field,{label:"Organization name",children:(0,d.jsx)(i.Input,Object.assign({id:"org-name-input",type:"text"},e("orgName",{required:!0})))}),n||(n=(0,d.jsx)(i.Button,{type:"submit",children:"Update organization name"}))]})});var c=t("./public/app/core/components/SharedPreferences/SharedPreferences.tsx"),h=t("./packages/grafana-runtime/src/index.ts"),u=t("./public/app/features/org/state/reducers.ts"),m=t("./public/app/core/actions/index.ts");function p(e={getBackendSrv:h.getBackendSrv}){return async a=>{const t=await e.getBackendSrv().get("/api/org");return a((0,u.jR)(t)),t}}var g,b=t("./public/app/core/selectors/navModel.ts");class f extends r.PureComponent{constructor(...e){var a,t,n;super(...e),n=e=>{this.props.setOrganizationName(e),this.props.updateOrganization()},(t="onUpdateOrganization")in(a=this)?Object.defineProperty(a,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):a[t]=n}async componentDidMount(){await this.props.loadOrganization()}render(){const{navModel:e,organization:a}=this.props,t=0===Object.keys(a).length;return(0,d.jsx)(o.Z,{navModel:e,children:(0,d.jsx)(o.Z.Contents,{isLoading:t,children:!t&&(0,d.jsxs)(i.VerticalGroup,{spacing:"lg",children:[(0,d.jsx)(l,{onSubmit:this.onUpdateOrganization,orgName:a.name}),g||(g=(0,d.jsx)(c.Z,{resourceUri:"org"}))]})})})}}const x={loadOrganization:p,setOrganizationName:u.xR,updateOrganization:function(e={getBackendSrv:h.getBackendSrv}){return async(a,t)=>{const n=t().organization.organization;await e.getBackendSrv().put("/api/org",{name:n.name}),a((0,m.H7)(n.name)),a(p(e))}}},v=(0,s.connect)((function(e){return{navModel:(0,b.h)(e.navIndex,"org-settings"),organization:e.organization.organization}}),x)(f)}}]);
//# sourceMappingURL=OrgDetailsPage.8128b05ac04b15cbf98d.js.map