Orgs: move redirection logic to components (#43160)

* Orgs: move redirection logic to components

* removes error notification since it's been handled under the hood
This commit is contained in:
Uchechukwu Obasi 2021-12-15 17:15:16 +01:00 committed by GitHub
parent 3f554f58bd
commit f16696a069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import { StoreState } from 'app/types';
import { connect, ConnectedProps } from 'react-redux'; import { connect, ConnectedProps } from 'react-redux';
import { getNavModel } from '../../core/selectors/navModel'; import { getNavModel } from '../../core/selectors/navModel';
import { createOrganization } from './state/actions'; import { createOrganization } from './state/actions';
import { getConfig } from 'app/core/config';
const validateOrg = async (orgName: string) => { const validateOrg = async (orgName: string) => {
try { try {
@ -37,8 +38,9 @@ interface CreateOrgFormDTO {
} }
export const NewOrgPage: FC<Props> = ({ navModel, createOrganization }) => { export const NewOrgPage: FC<Props> = ({ navModel, createOrganization }) => {
const createOrg = (newOrg: { name: string }) => { const createOrg = async (newOrg: { name: string }) => {
createOrganization(newOrg); await createOrganization(newOrg);
window.location.href = getConfig().appSubUrl + '/org';
}; };
return ( return (

View File

@ -34,7 +34,7 @@ export const SelectOrgPage: FC<Props> = ({ setUserOrganization }) => {
const [orgs, setOrgs] = useState<UserOrg[]>(); const [orgs, setOrgs] = useState<UserOrg[]>();
const setUserOrg = async (org: UserOrg) => { const setUserOrg = async (org: UserOrg) => {
setUserOrganization(org.orgId); await setUserOrganization(org.orgId);
window.location.href = config.appSubUrl + '/'; window.location.href = config.appSubUrl + '/';
}; };

View File

@ -2,7 +2,6 @@ import { ThunkResult } from 'app/types';
import { getBackendSrv } from '@grafana/runtime'; import { getBackendSrv } from '@grafana/runtime';
import { organizationLoaded } from './reducers'; import { organizationLoaded } from './reducers';
import { updateConfigurationSubtitle } from 'app/core/actions'; import { updateConfigurationSubtitle } from 'app/core/actions';
import { getConfig } from 'app/core/config';
type OrganizationDependencies = { getBackendSrv: typeof getBackendSrv }; type OrganizationDependencies = { getBackendSrv: typeof getBackendSrv };
@ -49,6 +48,5 @@ export function createOrganization(
const result = await dependencies.getBackendSrv().post('/api/orgs/', newOrg); const result = await dependencies.getBackendSrv().post('/api/orgs/', newOrg);
dispatch(setUserOrganization(result.orgId)); dispatch(setUserOrganization(result.orgId));
window.location.href = getConfig().appSubUrl + '/org';
}; };
} }