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hB,I,2GC5DrD,SAASG,IAEI,IADlBiB,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOjH,MAAAA,IACL,MAAMkH,QAA6BF,EAAaC,gBAAgBE,IAAI,YAGpE,OAFAC,GAASC,EAAAA,EAAAA,IAAmBH,IAErBA,GAIJ,SAASpB,IAEI,IADlBkB,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOjH,MAAOoH,EAAUE,KACtB,MAAMrB,EAAeqB,IAAWrB,aAAaA,mBAEvCe,EAAaC,gBAAgBM,IAAI,WAAY,CAAEpE,KAAM8C,EAAa9C,OAExEiE,GAASI,EAAAA,EAAAA,IAA4BvB,EAAa9C,OAClDiE,EAASrB,EAAiBiB,KAIvB,SAASS,EACdC,GAEkB,IADlBV,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOjH,MAAAA,IACL,MAAMkH,QAA6BF,EAAaC,gBAAgBU,KAAK,mBAAqBD,GAE1FN,GAASI,EAAAA,EAAAA,IAA4BN,EAAqB/D,QAIvD,SAASyE,EACdC,GAEkB,IADlBb,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOjH,MAAAA,IAGLoH,EAASK,SAFYT,EAAaC,gBAAgBU,KAAK,aAAcE,IAEjCH,SAIjC,SAASI,IAEI,IADlBd,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOjH,MAAAA,IACL,MAAM+H,QAAef,EAAaC,gBAAgBE,IAAI,kBAGtD,OAFAC,GAASY,EAAAA,EAAAA,IAAwBD,IAE1BA","sources":["webpack://grafana/./public/app/core/components/SharedPreferences/SharedPreferences.tsx","webpack://grafana/./public/app/features/org/OrgProfile.tsx","webpack://grafana/./public/app/features/org/OrgDetailsPage.tsx","webpack://grafana/./public/app/features/org/state/actions.ts"],"sourcesContent":["import { css } from '@emotion/css';\nimport { t, Trans } from '@lingui/macro';\nimport React, { PureComponent } from 'react';\n\nimport { SelectableValue } from '@grafana/data';\nimport { selectors } from '@grafana/e2e-selectors';\nimport {\n Button,\n Field,\n FieldSet,\n Form,\n Icon,\n Label,\n RadioButtonGroup,\n Select,\n stylesFactory,\n TimeZonePicker,\n Tooltip,\n WeekStartPicker,\n} from '@grafana/ui';\nimport { PreferencesService } from 'app/core/services/PreferencesService';\nimport { backendSrv } from 'app/core/services/backend_srv';\nimport { DashboardSearchHit, DashboardSearchItemType } from 'app/features/search/types';\n\nimport { UserPreferencesDTO } from '../../../types';\n\nexport interface Props {\n resourceUri: string;\n disabled?: boolean;\n}\n\nexport type State = UserPreferencesDTO & {\n dashboards: DashboardSearchHit[];\n};\n\nconst themes: SelectableValue[] = [\n { value: '', label: t({ id: 'shared-preferences.theme.default-label', message: 'Default' }) },\n { value: 'dark', label: t({ id: 'shared-preferences.theme.dark-label', message: 'Dark' }) },\n { value: 'light', label: t({ id: 'shared-preferences.theme.light-label', message: 'Light' }) },\n];\n\nexport class SharedPreferences extends PureComponent {\n service: PreferencesService;\n\n constructor(props: Props) {\n super(props);\n\n this.service = new PreferencesService(props.resourceUri);\n this.state = {\n homeDashboardId: 0,\n theme: '',\n timezone: '',\n weekStart: '',\n dashboards: [],\n queryHistory: { homeTab: '' },\n };\n }\n\n async componentDidMount() {\n const prefs = await this.service.load();\n const dashboards = await backendSrv.search({ starred: true });\n const defaultDashboardHit: DashboardSearchHit = {\n id: 0,\n title: 'Default',\n tags: [],\n type: '' as DashboardSearchItemType,\n uid: '',\n uri: '',\n url: '',\n folderId: 0,\n folderTitle: '',\n folderUid: '',\n folderUrl: '',\n isStarred: false,\n slug: '',\n items: [],\n };\n\n if (prefs.homeDashboardId > 0 && !dashboards.find((d) => d.id === prefs.homeDashboardId)) {\n const missing = await backendSrv.search({ dashboardIds: [prefs.homeDashboardId] });\n if (missing && missing.length > 0) {\n dashboards.push(missing[0]);\n }\n }\n\n this.setState({\n homeDashboardId: prefs.homeDashboardId,\n theme: prefs.theme,\n timezone: prefs.timezone,\n weekStart: prefs.weekStart,\n dashboards: [defaultDashboardHit, ...dashboards],\n queryHistory: prefs.queryHistory,\n });\n }\n\n onSubmitForm = async () => {\n const { homeDashboardId, theme, timezone, weekStart, queryHistory } = this.state;\n await this.service.update({ homeDashboardId, theme, timezone, weekStart, queryHistory });\n window.location.reload();\n };\n\n onThemeChanged = (value: string) => {\n this.setState({ theme: value });\n };\n\n onTimeZoneChanged = (timezone?: string) => {\n if (!timezone) {\n return;\n }\n this.setState({ timezone: timezone });\n };\n\n onWeekStartChanged = (weekStart: string) => {\n this.setState({ weekStart: weekStart });\n };\n\n onHomeDashboardChanged = (dashboardId: number) => {\n this.setState({ homeDashboardId: dashboardId });\n };\n\n getFullDashName = (dashboard: SelectableValue) => {\n if (typeof dashboard.folderTitle === 'undefined' || dashboard.folderTitle === '') {\n return dashboard.title;\n }\n return dashboard.folderTitle + ' / ' + dashboard.title;\n };\n\n render() {\n const { theme, timezone, weekStart, homeDashboardId, dashboards } = this.state;\n const { disabled } = this.props;\n const styles = getStyles();\n\n const homeDashboardTooltip = (\n \n Not finding the dashboard you want? Star it first, then it should appear in this select box.\n \n }\n >\n \n \n );\n\n return (\n
\n {() => {\n return (\n
Preferences} disabled={disabled}>\n \n item.value === theme)?.value}\n onChange={this.onThemeChanged}\n />\n \n\n \n \n Home Dashboard\n \n\n {homeDashboardTooltip}\n \n }\n data-testid=\"User preferences home dashboard drop down\"\n >\n dashboard.id === homeDashboardId)}\n getOptionValue={(i) => i.id}\n getOptionLabel={this.getFullDashName}\n onChange={(dashboard: SelectableValue) =>\n this.onHomeDashboardChanged(dashboard.id)\n }\n options={dashboards}\n placeholder={t({\n id: 'shared-preferences.fields.home-dashboard-placeholder',\n message: 'Choose default dashboard',\n })}\n inputId=\"home-dashboard-select\"\n />\n \n\n \n \n \n\n \n \n \n\n
\n \n Save\n \n
\n
\n );\n }}\n
\n );\n }\n}\n\nexport default SharedPreferences;\n\nconst getStyles = stylesFactory(() => {\n return {\n labelText: css`\n margin-right: 6px;\n `,\n };\n});\n","import React, { FC } from 'react';\n\nimport { Input, Field, FieldSet, Button, Form } from '@grafana/ui';\nimport { contextSrv } from 'app/core/core';\nimport { AccessControlAction } from 'app/types';\n\nexport interface Props {\n orgName: string;\n onSubmit: (orgName: string) => void;\n}\n\ninterface FormDTO {\n orgName: string;\n}\n\nconst OrgProfile: FC = ({ onSubmit, orgName }) => {\n const canWriteOrg = contextSrv.hasPermission(AccessControlAction.OrgsWrite);\n\n return (\n
onSubmit(orgName)}>\n {({ register }) => (\n
\n \n \n \n\n \n
\n )}\n
\n );\n};\n\nexport default OrgProfile;\n","import React, { PureComponent } from 'react';\nimport { connect } from 'react-redux';\n\nimport { NavModel } from '@grafana/data';\nimport { VerticalGroup } from '@grafana/ui';\nimport Page from 'app/core/components/Page/Page';\nimport SharedPreferences from 'app/core/components/SharedPreferences/SharedPreferences';\nimport { contextSrv } from 'app/core/core';\nimport { getNavModel } from 'app/core/selectors/navModel';\nimport { AccessControlAction, Organization, StoreState } from 'app/types';\n\nimport OrgProfile from './OrgProfile';\nimport { loadOrganization, updateOrganization } from './state/actions';\nimport { setOrganizationName } from './state/reducers';\n\nexport interface Props {\n navModel: NavModel;\n organization: Organization;\n loadOrganization: typeof loadOrganization;\n setOrganizationName: typeof setOrganizationName;\n updateOrganization: typeof updateOrganization;\n}\n\nexport class OrgDetailsPage extends PureComponent {\n async componentDidMount() {\n await this.props.loadOrganization();\n }\n\n onUpdateOrganization = (orgName: string) => {\n this.props.setOrganizationName(orgName);\n this.props.updateOrganization();\n };\n\n render() {\n const { navModel, organization } = this.props;\n const isLoading = Object.keys(organization).length === 0;\n const canReadOrg = contextSrv.hasPermission(AccessControlAction.OrgsRead);\n const canReadPreferences = contextSrv.hasPermission(AccessControlAction.OrgsPreferencesRead);\n const canWritePreferences = contextSrv.hasPermission(AccessControlAction.OrgsPreferencesWrite);\n\n return (\n \n \n {!isLoading && (\n \n {canReadOrg && }\n {canReadPreferences && }\n \n )}\n \n \n );\n }\n}\n\nfunction mapStateToProps(state: StoreState) {\n return {\n navModel: getNavModel(state.navIndex, 'org-settings'),\n organization: state.organization.organization,\n };\n}\n\nconst mapDispatchToProps = {\n loadOrganization,\n setOrganizationName,\n updateOrganization,\n};\n\nexport default connect(mapStateToProps, mapDispatchToProps)(OrgDetailsPage);\n","import { getBackendSrv } from '@grafana/runtime';\nimport { updateConfigurationSubtitle } from 'app/core/actions';\nimport { ThunkResult } from 'app/types';\n\nimport { organizationLoaded, userOrganizationsLoaded } from './reducers';\n\ntype OrganizationDependencies = { getBackendSrv: typeof getBackendSrv };\n\nexport function loadOrganization(\n dependencies: OrganizationDependencies = { getBackendSrv: getBackendSrv }\n): ThunkResult {\n return async (dispatch) => {\n const organizationResponse = await dependencies.getBackendSrv().get('/api/org');\n dispatch(organizationLoaded(organizationResponse));\n\n return organizationResponse;\n };\n}\n\nexport function updateOrganization(\n dependencies: OrganizationDependencies = { getBackendSrv: getBackendSrv }\n): ThunkResult {\n return async (dispatch, getStore) => {\n const organization = getStore().organization.organization;\n\n await dependencies.getBackendSrv().put('/api/org', { name: organization.name });\n\n dispatch(updateConfigurationSubtitle(organization.name));\n dispatch(loadOrganization(dependencies));\n };\n}\n\nexport function setUserOrganization(\n orgId: number,\n dependencies: OrganizationDependencies = { getBackendSrv: getBackendSrv }\n): ThunkResult {\n return async (dispatch) => {\n const organizationResponse = await dependencies.getBackendSrv().post('/api/user/using/' + orgId);\n\n dispatch(updateConfigurationSubtitle(organizationResponse.name));\n };\n}\n\nexport function createOrganization(\n newOrg: { name: string },\n dependencies: OrganizationDependencies = { getBackendSrv: getBackendSrv }\n): ThunkResult {\n return async (dispatch) => {\n const result = await dependencies.getBackendSrv().post('/api/orgs/', newOrg);\n\n dispatch(setUserOrganization(result.orgId));\n };\n}\n\nexport function getUserOrganizations(\n dependencies: OrganizationDependencies = { getBackendSrv: getBackendSrv }\n): ThunkResult {\n return async (dispatch) => {\n const result = await dependencies.getBackendSrv().get('/api/user/orgs');\n dispatch(userOrganizationsLoaded(result));\n\n return result;\n };\n}\n"],"names":["themes","value","label","id","SharedPreferences","PureComponent","constructor","props","super","async","homeDashboardId","theme","timezone","weekStart","queryHistory","this","state","service","update","window","location","reload","setState","dashboardId","dashboard","folderTitle","title","PreferencesService","resourceUri","dashboards","homeTab","prefs","load","backendSrv","starred","find","d","missing","dashboardIds","length","push","tags","type","uid","uri","url","folderId","folderUid","folderUrl","isStarred","slug","items","render","disabled","styles","getStyles","homeDashboardTooltip","Tooltip","content","Icon","name","Form","onSubmit","onSubmitForm","FieldSet","Field","RadioButtonGroup","options","item","onChange","onThemeChanged","Label","htmlFor","className","labelText","Select","getOptionValue","i","getOptionLabel","getFullDashName","onHomeDashboardChanged","placeholder","inputId","selectors","TimeZonePicker","includeInternal","onTimeZoneChanged","WeekStartPicker","onWeekStartChanged","Button","variant","stylesFactory","css","orgName","canWriteOrg","contextSrv","AccessControlAction","defaultValues","register","Input","required","OrgDetailsPage","setOrganizationName","updateOrganization","loadOrganization","navModel","organization","isLoading","Object","keys","canReadOrg","canReadPreferences","canWritePreferences","Page","VerticalGroup","spacing","onUpdateOrganization","mapDispatchToProps","connect","getNavModel","navIndex","dependencies","getBackendSrv","organizationResponse","get","dispatch","organizationLoaded","getStore","put","updateConfigurationSubtitle","setUserOrganization","orgId","post","createOrganization","newOrg","getUserOrganizations","result","userOrganizationsLoaded"],"sourceRoot":""}