mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
BrowseDashboards: Update results when starred param changes (#89944)
* BrowseDashboards: Trigger update results when starred param changes * Use LocationService * Use locationService directly
This commit is contained in:
parent
e568b86ac0
commit
0500b596db
@ -3,7 +3,7 @@ import { memo, useEffect, useMemo } from 'react';
|
||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { reportInteraction } from '@grafana/runtime';
|
||||
import { locationService, reportInteraction } from '@grafana/runtime';
|
||||
import { FilterInput, useStyles2 } from '@grafana/ui';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
||||
@ -39,6 +39,7 @@ const BrowseDashboardsPage = memo(({ match }: Props) => {
|
||||
const styles = useStyles2(getStyles);
|
||||
const [searchState, stateManager] = useSearchStateManager();
|
||||
const isSearching = stateManager.hasSearchFilters();
|
||||
const search = locationService.getSearch();
|
||||
|
||||
useEffect(() => {
|
||||
stateManager.initStateFromUrl(folderUID);
|
||||
@ -52,6 +53,11 @@ const BrowseDashboardsPage = memo(({ match }: Props) => {
|
||||
);
|
||||
}, [dispatch, folderUID, stateManager]);
|
||||
|
||||
// Trigger search when "starred" query param changes
|
||||
useEffect(() => {
|
||||
stateManager.onSetStarred(search.has('starred'));
|
||||
}, [search, stateManager]);
|
||||
|
||||
useEffect(() => {
|
||||
// Clear the search results when we leave SearchView to prevent old results flashing
|
||||
// when starting a new search
|
||||
|
@ -161,6 +161,12 @@ export class SearchStateManager extends StateManagerBase<SearchState> {
|
||||
this.setStateAndDoSearch({ starred: false });
|
||||
};
|
||||
|
||||
onSetStarred = (starred: boolean) => {
|
||||
if (starred !== this.state.starred) {
|
||||
this.setStateAndDoSearch({ starred });
|
||||
}
|
||||
};
|
||||
|
||||
onSortChange = (sort: string | undefined) => {
|
||||
if (sort) {
|
||||
localStorage.setItem(SEARCH_SELECTED_SORT, sort);
|
||||
|
Loading…
Reference in New Issue
Block a user