mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix tab switching
This commit is contained in:
parent
565edc1ed3
commit
ee1d4ce0e2
@ -1,6 +1,7 @@
|
||||
import { Action } from 'app/core/actions/location';
|
||||
import { LocationState } from 'app/types';
|
||||
import { renderUrl } from 'app/core/utils/url';
|
||||
import _ from 'lodash';
|
||||
|
||||
export const initialState: LocationState = {
|
||||
url: '',
|
||||
@ -12,11 +13,17 @@ export const initialState: LocationState = {
|
||||
export const locationReducer = (state = initialState, action: Action): LocationState => {
|
||||
switch (action.type) {
|
||||
case 'UPDATE_LOCATION': {
|
||||
const { path, query, routeParams } = action.payload;
|
||||
const { path, routeParams } = action.payload;
|
||||
let query = action.payload.query || state.query;
|
||||
|
||||
if (action.payload.partial) {
|
||||
query = _.defaults(query, state.query);
|
||||
}
|
||||
|
||||
return {
|
||||
url: renderUrl(path || state.path, query),
|
||||
path: path || state.path,
|
||||
query: query || state.query,
|
||||
query: query,
|
||||
routeParams: routeParams || state.routeParams,
|
||||
};
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ export class PanelEditor extends React.Component<PanelEditorProps, any> {
|
||||
store.dispatch(
|
||||
updateLocation({
|
||||
query: { tab: tab.id },
|
||||
partial: true,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
@ -2,6 +2,7 @@ export interface LocationUpdate {
|
||||
path?: string;
|
||||
query?: UrlQueryMap;
|
||||
routeParams?: UrlQueryMap;
|
||||
partial?: boolean;
|
||||
}
|
||||
|
||||
export interface LocationState {
|
||||
|
Loading…
Reference in New Issue
Block a user