handle page refresh when switching teams
This commit is contained in:
parent
d71d8c42c6
commit
dd77596447
3 changed files with 11 additions and 4 deletions
|
|
@ -135,7 +135,7 @@ export const Root = observer((props: AppRootProps) => {
|
|||
|
||||
return (
|
||||
<DefaultPageLayout {...props}>
|
||||
<GrafanaTeamSelect />
|
||||
<GrafanaTeamSelect currentPage={page} />
|
||||
<Page {...props} path={pathWithoutLeadingSlash} />
|
||||
</DefaultPageLayout>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ interface PluginLinkProps extends LocationUpdate {
|
|||
disabled?: boolean;
|
||||
className?: string;
|
||||
wrap?: boolean;
|
||||
children: any
|
||||
children: any;
|
||||
}
|
||||
|
||||
const cx = cn.bind(styles);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import React from 'react';
|
||||
|
||||
import { SelectableValue } from '@grafana/data';
|
||||
import { getLocationSrv } from '@grafana/runtime';
|
||||
import { HorizontalGroup, Icon, IconButton, Label, Tooltip } from '@grafana/ui';
|
||||
import cn from 'classnames/bind';
|
||||
import { observer } from 'mobx-react';
|
||||
|
|
@ -18,11 +19,14 @@ import styles from './GrafanaTeamSelect.module.css';
|
|||
|
||||
const cx = cn.bind(styles);
|
||||
|
||||
interface GrafanaTeamSelectProps {}
|
||||
interface GrafanaTeamSelectProps {
|
||||
currentPage: string;
|
||||
}
|
||||
|
||||
const GrafanaTeamSelect = observer((props: GrafanaTeamSelectProps) => {
|
||||
const store = useStore();
|
||||
|
||||
const { currentPage } = props;
|
||||
const { userStore, grafanaTeamStore } = store;
|
||||
const grafanaTeams = grafanaTeamStore.getSearchResult();
|
||||
const user = userStore.currentUser;
|
||||
|
|
@ -33,7 +37,10 @@ const GrafanaTeamSelect = observer((props: GrafanaTeamSelectProps) => {
|
|||
|
||||
const onTeamChange = async (teamId: GrafanaTeam['id']) => {
|
||||
await userStore.updateCurrentUser({ current_team: teamId });
|
||||
window.location.reload();
|
||||
|
||||
const queryParams = new URLSearchParams();
|
||||
queryParams.set('page', currentPage);
|
||||
window.location.search = queryParams.toString();
|
||||
};
|
||||
|
||||
return document.getElementsByClassName('page-header__inner')[0]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue