From f16696a06940c57b5653a0b756e424181ad31d49 Mon Sep 17 00:00:00 2001 From: Uchechukwu Obasi Date: Wed, 15 Dec 2021 17:15:16 +0100 Subject: [PATCH] Orgs: move redirection logic to components (#43160) * Orgs: move redirection logic to components * removes error notification since it's been handled under the hood --- public/app/features/org/NewOrgPage.tsx | 6 ++++-- public/app/features/org/SelectOrgPage.tsx | 2 +- public/app/features/org/state/actions.ts | 2 -- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/app/features/org/NewOrgPage.tsx b/public/app/features/org/NewOrgPage.tsx index ec54b6303ff..c5aa6c8c151 100644 --- a/public/app/features/org/NewOrgPage.tsx +++ b/public/app/features/org/NewOrgPage.tsx @@ -6,6 +6,7 @@ import { StoreState } from 'app/types'; import { connect, ConnectedProps } from 'react-redux'; import { getNavModel } from '../../core/selectors/navModel'; import { createOrganization } from './state/actions'; +import { getConfig } from 'app/core/config'; const validateOrg = async (orgName: string) => { try { @@ -37,8 +38,9 @@ interface CreateOrgFormDTO { } export const NewOrgPage: FC = ({ navModel, createOrganization }) => { - const createOrg = (newOrg: { name: string }) => { - createOrganization(newOrg); + const createOrg = async (newOrg: { name: string }) => { + await createOrganization(newOrg); + window.location.href = getConfig().appSubUrl + '/org'; }; return ( diff --git a/public/app/features/org/SelectOrgPage.tsx b/public/app/features/org/SelectOrgPage.tsx index 7dde6c5fde0..01295c13742 100644 --- a/public/app/features/org/SelectOrgPage.tsx +++ b/public/app/features/org/SelectOrgPage.tsx @@ -34,7 +34,7 @@ export const SelectOrgPage: FC = ({ setUserOrganization }) => { const [orgs, setOrgs] = useState(); const setUserOrg = async (org: UserOrg) => { - setUserOrganization(org.orgId); + await setUserOrganization(org.orgId); window.location.href = config.appSubUrl + '/'; }; diff --git a/public/app/features/org/state/actions.ts b/public/app/features/org/state/actions.ts index d33aa71f915..554f153b8b2 100644 --- a/public/app/features/org/state/actions.ts +++ b/public/app/features/org/state/actions.ts @@ -2,7 +2,6 @@ import { ThunkResult } from 'app/types'; import { getBackendSrv } from '@grafana/runtime'; import { organizationLoaded } from './reducers'; import { updateConfigurationSubtitle } from 'app/core/actions'; -import { getConfig } from 'app/core/config'; type OrganizationDependencies = { getBackendSrv: typeof getBackendSrv }; @@ -49,6 +48,5 @@ export function createOrganization( const result = await dependencies.getBackendSrv().post('/api/orgs/', newOrg); dispatch(setUserOrganization(result.orgId)); - window.location.href = getConfig().appSubUrl + '/org'; }; }