Orgs: move redirection logic to components (#43160)

* Orgs: move redirection logic to components

* removes error notification since it's been handled under the hood
pull/43159/head
Uchechukwu Obasi 4 years ago committed by GitHub
parent 3f554f58bd
commit f16696a069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      public/app/features/org/NewOrgPage.tsx
  2. 2
      public/app/features/org/SelectOrgPage.tsx
  3. 2
      public/app/features/org/state/actions.ts

@ -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<Props> = ({ 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 (

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

@ -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';
};
}

Loading…
Cancel
Save