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B,SAASxB,EACdgB,GAEkB,IADlBQ,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOV,MAAAA,IACL,MAAMW,QAA6BF,EAAaC,gBAAgBS,KAAK,mBAAqBlB,GAE1FY,GAASK,EAAAA,EAAAA,IAA4BP,EAAqBJ,QAIvD,SAASa,EACdC,GAEkB,IADlBZ,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOV,MAAAA,IAGLa,EAAS5B,SAFYwB,EAAaC,gBAAgBS,KAAK,aAAcE,IAEjCpB,SAIjC,SAASf,IAEI,IADlBuB,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOV,MAAAA,IACL,MAAMsB,QAAeb,EAAaC,gBAAgBE,IAAI,kBAGtD,OAFAC,GAASU,EAAAA,EAAAA,IAAwBD,IAE1BA","sources":["webpack://grafana/./public/app/features/org/SelectOrgPage.tsx","webpack://grafana/./public/app/features/org/state/actions.ts"],"sourcesContent":["import React, { FC } from 'react';\nimport { connect, ConnectedProps } from 'react-redux';\nimport { useEffectOnce } from 'react-use';\n\nimport { config } from '@grafana/runtime';\nimport { Button, HorizontalGroup } from '@grafana/ui';\nimport Page from 'app/core/components/Page/Page';\nimport { StoreState, UserOrg } from 'app/types';\n\nimport { getUserOrganizations, setUserOrganization } from './state/actions';\n\nconst navModel = {\n main: {\n icon: 'grafana',\n subTitle: 'Preferences',\n text: 'Select active organization',\n },\n node: {\n text: 'Select active organization',\n },\n};\n\nconst mapStateToProps = (state: StoreState) => {\n return {\n userOrgs: state.organization.userOrgs,\n };\n};\n\nconst mapDispatchToProps = {\n setUserOrganization,\n getUserOrganizations,\n};\n\nconst connector = connect(mapStateToProps, mapDispatchToProps);\n\ntype Props = ConnectedProps<typeof connector>;\n\nexport const SelectOrgPage: FC<Props> = ({ setUserOrganization, getUserOrganizations, userOrgs }) => {\n const setUserOrg = async (org: UserOrg) => {\n await setUserOrganization(org.orgId);\n window.location.href = config.appSubUrl + '/';\n };\n\n useEffectOnce(() => {\n getUserOrganizations();\n });\n\n return (\n <Page navModel={navModel}>\n <Page.Contents>\n <div>\n <p>\n You have been invited to another organization! Please select which organization that you want to use right\n now. You can change this later at any time.\n </p>\n <HorizontalGroup wrap>\n {userOrgs &&\n userOrgs.map((org) => (\n <Button key={org.orgId} icon=\"signin\" onClick={() => setUserOrg(org)}>\n {org.name}\n </Button>\n ))}\n </HorizontalGroup>\n </div>\n </Page.Contents>\n </Page>\n );\n};\n\nexport default connector(SelectOrgPage);\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<any> {\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<any> {\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<any> {\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<any> {\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<any> {\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":["navModel","main","icon","subTitle","text","node","mapDispatchToProps","setUserOrganization","getUserOrganizations","connector","connect","state","userOrgs","organization","SelectOrgPage","useEffectOnce","HorizontalGroup","wrap","map","org","Button","onClick","async","orgId","window","location","href","config","setUserOrg","name","loadOrganization","dependencies","getBackendSrv","organizationResponse","get","dispatch","organizationLoaded","updateOrganization","getStore","put","updateConfigurationSubtitle","post","createOrganization","newOrg","result","userOrganizationsLoaded"],"sourceRoot":""}