mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Search: connect DashboardSearch * Search: set url params * Search: handle tag params * Search: handle sort params * Search: use getLocationQuery * Search: fix type errors * Docs: Save query params for manage dashboards * Search: extract connect * Search: add layout to URL params * Search: update options * Search: simplify options loading * Search: Fix strict null errors * Search: Change params order * Search: Add tests * Search: handle folder query
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import { MapDispatchToProps, MapStateToProps } from 'react-redux';
|
|
import { connectWithStore } from 'app/core/utils/connectWithReduxStore';
|
|
import { StoreState } from 'app/types';
|
|
import { getLocationQuery } from 'app/core/selectors/location';
|
|
import { updateLocation } from 'app/core/reducers/location';
|
|
import { parseRouteParams } from './utils';
|
|
import { DashboardQuery } from './types';
|
|
import { Props as DashboardSearchProps } from './components/DashboardSearch';
|
|
import { Props as ManageDashboardsProps } from './components/ManageDashboards';
|
|
|
|
export interface ConnectProps {
|
|
params: Partial<DashboardQuery>;
|
|
}
|
|
|
|
export interface DispatchProps {
|
|
updateLocation: typeof updateLocation;
|
|
}
|
|
|
|
type Props = DashboardSearchProps | ManageDashboardsProps;
|
|
|
|
const mapStateToProps: MapStateToProps<ConnectProps, Props, StoreState> = state => {
|
|
const { query, starred, sort, tag, layout, folder } = getLocationQuery(state.location);
|
|
return parseRouteParams(
|
|
{
|
|
query,
|
|
tag,
|
|
starred,
|
|
sort,
|
|
layout,
|
|
},
|
|
folder
|
|
);
|
|
};
|
|
|
|
const mapDispatchToProps: MapDispatchToProps<DispatchProps, Props> = {
|
|
updateLocation,
|
|
};
|
|
|
|
export const connectWithRouteParams = (Component: React.FC) =>
|
|
connectWithStore(Component, mapStateToProps, mapDispatchToProps);
|