"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[529],{"./public/app/core/components/SharedPreferences/SharedPreferences.tsx":(e,a,t)=>{t.d(a,{v:()=>v,Z:()=>x});var r,s,n,i,o=t("./.yarn/__virtual__/@lingui-react-virtual-edf7967b4d/3/opt/drone/yarncache/@lingui-react-npm-3.13.0-279ef69307-ca97bd3e80.zip/node_modules/@lingui/react/esm/index.js"),d=t("../../opt/drone/yarncache/@lingui-core-npm-3.13.0-aa863e2651-6108eb43fa.zip/node_modules/@lingui/core/esm/index.js"),c=t("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),l=t("./.yarn/__virtual__/@emotion-css-virtual-72c314ddb1/3/opt/drone/yarncache/@emotion-css-npm-11.7.1-25ff8755a7-ac1f56656f.zip/node_modules/@emotion/css/dist/emotion-css.esm.js"),h=t("./packages/grafana-ui/src/index.ts"),p=t("./packages/grafana-e2e-selectors/src/index.ts"),u=t("./public/app/core/services/backend_srv.ts"),m=t("./public/app/core/services/PreferencesService.ts"),g=t("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");function b(e,a,t){return a in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}const f=[{value:"",label:d.ag._({id:"shared-preferences.theme.default-label",message:"Default"})},{value:"dark",label:d.ag._({id:"shared-preferences.theme.dark-label",message:"Dark"})},{value:"light",label:d.ag._({id:"shared-preferences.theme.light-label",message:"Light"})}];class v extends c.PureComponent{constructor(e){super(e),b(this,"service",void 0),b(this,"onSubmitForm",(async()=>{const{homeDashboardId:e,theme:a,timezone:t,weekStart:r}=this.state;await this.service.update({homeDashboardId:e,theme:a,timezone:t,weekStart:r}),window.location.reload()})),b(this,"onThemeChanged",(e=>{this.setState({theme:e})})),b(this,"onTimeZoneChanged",(e=>{e&&this.setState({timezone:e})})),b(this,"onWeekStartChanged",(e=>{this.setState({weekStart:e})})),b(this,"onHomeDashboardChanged",(e=>{this.setState({homeDashboardId:e})})),b(this,"getFullDashName",(e=>void 0===e.folderTitle||""===e.folderTitle?e.title:e.folderTitle+" / "+e.title)),this.service=new m.y(e.resourceUri),this.state={homeDashboardId:0,theme:"",timezone:"",weekStart:"",dashboards:[]}}async componentDidMount(){const e=await this.service.load(),a=await u.ae.search({starred:!0});if(e.homeDashboardId>0&&!a.find((a=>a.id===e.homeDashboardId))){const t=await u.ae.search({dashboardIds:[e.homeDashboardId]});t&&t.length>0&&a.push(t[0])}this.setState({homeDashboardId:e.homeDashboardId,theme:e.theme,timezone:e.timezone,weekStart:e.weekStart,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,weekStart:t,homeDashboardId:c,dashboards:l}=this.state,{disabled:u}=this.props,m=k(),b=r||(r=(0,g.jsx)(h.Tooltip,{content:(0,g.jsx)(o.cC,{id:"shared-preferences.fields.home-dashboard-tooltip"}),children:(0,g.jsx)(h.Icon,{name:"info-circle"})}));return(0,g.jsx)(h.Form,{onSubmit:this.onSubmitForm,children:()=>{var r;return(0,g.jsxs)(h.FieldSet,{label:s||(s=(0,g.jsx)(o.cC,{id:"shared-preferences.title"})),disabled:u,children:[(0,g.jsx)(h.Field,{label:d.ag._({id:"shared-preferences.fields.theme-label",message:"UI Theme"}),children:(0,g.jsx)(h.RadioButtonGroup,{options:f,value:null===(r=f.find((a=>a.value===e)))||void 0===r?void 0:r.value,onChange:this.onThemeChanged})}),(0,g.jsx)(h.Field,{label:(0,g.jsxs)(h.Label,{htmlFor:"home-dashboard-select",children:[(0,g.jsx)("span",{className:m.labelText,children:n||(n=(0,g.jsx)(o.cC,{id:"shared-preferences.fields.home-dashboard-label"}))}),b]}),"data-testid":"User preferences home dashboard drop down",children:(0,g.jsx)(h.Select,{menuShouldPortal:!0,value:l.find((e=>e.id===c)),getOptionValue:e=>e.id,getOptionLabel:this.getFullDashName,onChange:e=>this.onHomeDashboardChanged(e.id),options:l,placeholder:d.ag._({id:"shared-preferences.fields.home-dashboard-placeholder",message:"Choose default dashboard"}),inputId:"home-dashboard-select"})}),(0,g.jsx)(h.Field,{label:d.ag._({id:"shared-dashboard.fields.timezone-label",message:"Timezone"}),"data-testid":p.wl.components.TimeZonePicker.containerV2,children:(0,g.jsx)(h.TimeZonePicker,{includeInternal:!0,value:a,onChange:this.onTimeZoneChanged,inputId:"shared-preferences-timezone-picker"})}),(0,g.jsx)(h.Field,{label:d.ag._({id:"shared-preferences.fields.week-start-label",message:"Week start"}),"data-testid":p.wl.components.WeekStartPicker.containerV2,children:(0,g.jsx)(h.WeekStartPicker,{value:t,onChange:this.onWeekStartChanged,inputId:"shared-preferences-week-start-picker"})}),(0,g.jsx)("div",{className:"gf-form-button-row",children:(0,g.jsx)(h.Button,{variant:"primary","data-testid":p.wl.components.UserProfile.preferencesSaveButton,children:i||(i=(0,g.jsx)(o.cC,{id:"common.save"}))})})]})}})}}const x=v,k=(0,h.stylesFactory)((()=>({labelText:l.css`
      margin-right: 6px;
    `})))},"./public/app/features/org/OrgDetailsPage.tsx":(e,a,t)=>{t.r(a),t.d(a,{OrgDetailsPage:()=>b,default:()=>v});var r,s=t("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),n=t("./.yarn/__virtual__/react-redux-virtual-7ad20a440e/3/opt/drone/yarncache/react-redux-npm-7.2.6-134f5ed64d-0bf142ce0d.zip/node_modules/react-redux/es/index.js"),i=t("./public/app/core/components/Page/Page.tsx"),o=t("./packages/grafana-ui/src/index.ts"),d=t("./public/app/core/core.ts"),c=t("./public/app/types/index.ts"),l=t("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const h=e=>{let{onSubmit:a,orgName:t}=e;const s=d.Vt.hasPermission(c.bW.OrgsWrite);return(0,l.jsx)(o.Form,{defaultValues:{orgName:t},onSubmit:e=>{let{orgName:t}=e;return a(t)},children:e=>{let{register:a}=e;return(0,l.jsxs)(o.FieldSet,{label:"Organization profile",disabled:!s,children:[(0,l.jsx)(o.Field,{label:"Organization name",children:(0,l.jsx)(o.Input,Object.assign({id:"org-name-input",type:"text"},a("orgName",{required:!0})))}),r||(r=(0,l.jsx)(o.Button,{type:"submit",children:"Update organization name"}))]})}})};var p=t("./public/app/core/components/SharedPreferences/SharedPreferences.tsx"),u=t("./public/app/features/org/state/actions.ts"),m=t("./public/app/core/selectors/navModel.ts"),g=t("./public/app/features/org/state/reducers.ts");class b extends s.PureComponent{constructor(){var e,a,t;super(...arguments),t=e=>{this.props.setOrganizationName(e),this.props.updateOrganization()},(a="onUpdateOrganization")in(e=this)?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t}async componentDidMount(){await this.props.loadOrganization()}render(){const{navModel:e,organization:a}=this.props,t=0===Object.keys(a).length,r=d.Vt.hasPermission(c.bW.OrgsRead),s=d.Vt.hasPermission(c.bW.OrgsPreferencesRead),n=d.Vt.hasPermission(c.bW.OrgsPreferencesWrite);return(0,l.jsx)(i.Z,{navModel:e,children:(0,l.jsx)(i.Z.Contents,{isLoading:t,children:!t&&(0,l.jsxs)(o.VerticalGroup,{spacing:"lg",children:[r&&(0,l.jsx)(h,{onSubmit:this.onUpdateOrganization,orgName:a.name}),s&&(0,l.jsx)(p.Z,{resourceUri:"org",disabled:!n})]})})})}}const f={loadOrganization:u.RF,setOrganizationName:g.xR,updateOrganization:u.FV},v=(0,n.connect)((function(e){return{navModel:(0,m.h)(e.navIndex,"org-settings"),organization:e.organization.organization}}),f)(b)},"./public/app/features/org/state/actions.ts":(e,a,t)=>{t.d(a,{RF:()=>i,FV:()=>o,Q$:()=>d,Yi:()=>c,JE:()=>l});var r=t("./packages/grafana-runtime/src/index.ts"),s=t("./public/app/features/org/state/reducers.ts"),n=t("./public/app/core/actions/index.ts");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{getBackendSrv:r.getBackendSrv};return async a=>{const t=await e.getBackendSrv().get("/api/org");return a((0,s.jR)(t)),t}}function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{getBackendSrv:r.getBackendSrv};return async(a,t)=>{const r=t().organization.organization;await e.getBackendSrv().put("/api/org",{name:r.name}),a((0,n.H7)(r.name)),a(i(e))}}function d(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{getBackendSrv:r.getBackendSrv};return async t=>{const r=await a.getBackendSrv().post("/api/user/using/"+e);t((0,n.H7)(r.name))}}function c(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{getBackendSrv:r.getBackendSrv};return async t=>{t(d((await a.getBackendSrv().post("/api/orgs/",e)).orgId))}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{getBackendSrv:r.getBackendSrv};return async a=>{const t=await e.getBackendSrv().get("/api/user/orgs");return a((0,s.IM)(t)),t}}}}]);
//# sourceMappingURL=OrgDetailsPage.cd4ada1146b53ad3284f.js.map