mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
parent
3f554f58bd
commit
f16696a069
@ -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…
Reference in New Issue
Block a user