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IAA4BF,EAAajB,OAClDa,EAASL,EAAiBC,KAIvB,SAASW,EACdC,GAEkB,IADlBZ,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOtB,MAAAA,IACL,MAAMuB,QAA6BF,EAAaC,gBAAgBY,KAAK,mBAAqBD,GAE1FR,GAASM,EAAAA,EAAAA,IAA4BR,EAAqBX,QAIvD,SAASvB,EACdY,GAEkB,IADlBoB,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOtB,MAAAA,IAGLyB,EAASO,SAFYX,EAAaC,gBAAgBY,KAAK,aAAcjC,IAEjCgC,SAIjC,SAASE,IAEI,IADlBd,EACkB,uDADuB,CAAEC,cAAeA,EAAAA,eAE1D,OAAOtB,MAAAA,IACL,MAAMoC,QAAef,EAAaC,gBAAgBE,IAAI,kBAGtD,OAFAC,GAASY,EAAAA,EAAAA,IAAwBD,IAE1BA","sources":["webpack://grafana/./public/app/features/org/NewOrgPage.tsx","webpack://grafana/./public/app/features/org/state/actions.ts"],"sourcesContent":["import React, { FC } from 'react';\nimport { connect, ConnectedProps } from 'react-redux';\n\nimport { Button, Input, Field, Form } from '@grafana/ui';\nimport Page from 'app/core/components/Page/Page';\nimport { getConfig } from 'app/core/config';\nimport { StoreState } from 'app/types';\n\nimport { getNavModel } from '../../core/selectors/navModel';\n\nimport { createOrganization } from './state/actions';\n\nconst mapStateToProps = (state: StoreState) => {\n return { navModel: getNavModel(state.navIndex, 'global-orgs') };\n};\n\nconst mapDispatchToProps = {\n createOrganization,\n};\n\nconst connector = connect(mapStateToProps, mapDispatchToProps);\n\ntype Props = ConnectedProps<typeof connector>;\n\ninterface CreateOrgFormDTO {\n name: string;\n}\n\nexport const NewOrgPage: FC<Props> = ({ navModel, createOrganization }) => {\n const createOrg = async (newOrg: { name: string }) => {\n await createOrganization(newOrg);\n window.location.href = getConfig().appSubUrl + '/org';\n };\n\n return (\n <Page navModel={navModel}>\n <Page.Contents>\n <h3 className=\"page-sub-heading\">New organization</h3>\n\n <p className=\"playlist-description\">\n Each organization contains their own dashboards, data sources, and configuration, which cannot be shared\n shared between organizations. While users might belong to more than one organization, multiple organizations\n are most frequently used in multi-tenant deployments.{' '}\n </p>\n\n <Form<CreateOrgFormDTO> onSubmit={createOrg}>\n {({ register, errors }) => {\n return (\n <>\n <Field label=\"Organization name\" invalid={!!errors.name} error={errors.name && errors.name.message}>\n <Input\n placeholder=\"Org name\"\n {...register('name', {\n required: 'Organization name is required',\n })}\n />\n </Field>\n <Button type=\"submit\">Create</Button>\n </>\n );\n }}\n </Form>\n </Page.Contents>\n </Page>\n );\n};\n\nexport default connector(NewOrgPage);\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":["mapDispatchToProps","createOrganization","connector","connect","state","navModel","getNavModel","navIndex","NewOrgPage","className","Form","onSubmit","async","newOrg","window","location","href","getConfig","appSubUrl","register","errors","Field","label","invalid","name","error","message","Input","placeholder","required","Button","type","loadOrganization","dependencies","getBackendSrv","organizationResponse","get","dispatch","organizationLoaded","updateOrganization","getStore","organization","put","updateConfigurationSubtitle","setUserOrganization","orgId","post","getUserOrganizations","result","userOrganizationsLoaded"],"sourceRoot":""}
|