) {
+ const sort = state.sort || this.state.sort || localStorage.getItem(SEARCH_SELECTED_SORT) || undefined;
+
+ const query = state.query ?? this.state.query;
+ const tags = state.tag ?? this.state.tag;
+
+ // When the user clears the search, and we revert back to list listing all
+ const clearResults = query.length === 0 && tags.length === 0;
+
+ // Set internal state
+ this.setState({
+ sort,
+ result: clearResults ? undefined : this.state.result,
+ ...state,
+ });
+
+ // Update url state
+ this.updateLocation({
+ query: this.state.query.length === 0 ? null : this.state.query,
+ tag: this.state.tag,
+ datasource: this.state.datasource,
+ panel_type: this.state.panel_type,
+ starred: this.state.starred ? this.state.starred : null,
+ sort: this.state.sort,
+ });
+
+ // Prevent searching when user is only clearing the input.
+ // We don't show these results anyway
+ if (this.hasSearchFilters()) {
+ this.doSearchWithDebounce();
+ }
+ }
+}
+
+let recentlyDeletedStateManager: TrashStateManager;
function getRecentlyDeletedStateManager() {
if (!recentlyDeletedStateManager) {
- recentlyDeletedStateManager = new SearchStateManager({ ...initialState, includePanels: false, deleted: true });
+ recentlyDeletedStateManager = new TrashStateManager({ ...initialState, includePanels: false, deleted: true });
}
return recentlyDeletedStateManager;
diff --git a/public/app/features/browse-dashboards/components/RecentlyDeletedEmptyState.tsx b/public/app/features/browse-dashboards/components/RecentlyDeletedEmptyState.tsx
new file mode 100644
index 00000000000..8415b7551fa
--- /dev/null
+++ b/public/app/features/browse-dashboards/components/RecentlyDeletedEmptyState.tsx
@@ -0,0 +1,22 @@
+import { EmptyState } from '@grafana/ui';
+import { t } from 'app/core/internationalization';
+import { SearchState } from 'app/features/search/types';
+
+interface RecentlyDeletedEmptyStateProps {
+ searchState: SearchState;
+}
+
+export const RecentlyDeletedEmptyState = ({ searchState }: RecentlyDeletedEmptyStateProps) => {
+ const userIsSearching = Boolean(searchState.query || searchState.tag.length);
+ return (
+
+ );
+};
diff --git a/public/app/features/browse-dashboards/components/SearchView.tsx b/public/app/features/browse-dashboards/components/SearchView.tsx
index 2893f0abea6..ce28108c706 100644
--- a/public/app/features/browse-dashboards/components/SearchView.tsx
+++ b/public/app/features/browse-dashboards/components/SearchView.tsx
@@ -1,4 +1,4 @@
-import { useCallback } from 'react';
+import { ReactNode, useCallback } from 'react';
import { DataFrameView, toDataFrame } from '@grafana/data';
import { Button, EmptyState } from '@grafana/ui';
@@ -17,9 +17,10 @@ interface SearchViewProps {
canSelect: boolean;
searchState: SearchState;
searchStateManager: SearchStateManager;
+ emptyState?: ReactNode;
}
-const NUM_PLACEHOLDER_ROWS = 50;
+const NUM_PLACEHOLDER_ROWS = 25;
const initialLoadingView = {
view: new DataFrameView(
toDataFrame({
@@ -49,6 +50,7 @@ export function SearchView({
canSelect,
searchState,
searchStateManager: stateManager,
+ emptyState: emptyStateProp,
}: SearchViewProps) {
const dispatch = useDispatch();
const selectedItems = useSelector((wholeState) => wholeState.browseDashboards.selectedItems);
@@ -94,20 +96,20 @@ export function SearchView({
);
if (value.totalRows === 0) {
- return (
-
-
- Clear search and filters
-
- }
- message={t('browse-dashboards.no-results.text', 'No results found for your query')}
- variant="not-found"
- role="alert"
- />
-
+ const emptyState = emptyStateProp ?? (
+
+ Clear search and filters
+
+ }
+ message={t('browse-dashboards.no-results.text', 'No results found for your query')}
+ variant="not-found"
+ role="alert"
+ />
);
+
+ return {emptyState}
;
}
const props: SearchResultsProps = {
diff --git a/public/app/features/search/state/SearchStateManager.ts b/public/app/features/search/state/SearchStateManager.ts
index f07c12e6038..8ee43e438ea 100644
--- a/public/app/features/search/state/SearchStateManager.ts
+++ b/public/app/features/search/state/SearchStateManager.ts
@@ -197,14 +197,14 @@ export class SearchStateManager extends StateManagerBase {
};
hasSearchFilters() {
- return (
+ return Boolean(
this.state.query ||
- this.state.tag.length ||
- this.state.starred ||
- this.state.panel_type ||
- this.state.sort ||
- this.state.deleted ||
- this.state.layout === SearchLayout.List
+ this.state.tag.length ||
+ this.state.starred ||
+ this.state.panel_type ||
+ this.state.sort ||
+ this.state.deleted ||
+ this.state.layout === SearchLayout.List
);
}
diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json
index 695e13df35b..9885a315581 100644
--- a/public/locales/en-US/grafana.json
+++ b/public/locales/en-US/grafana.json
@@ -1731,7 +1731,8 @@
"restore": "Restore"
},
"page": {
- "empty-state": "You haven't deleted any dashboards recently."
+ "no-deleted-dashboards": "You haven't deleted any dashboards recently.",
+ "no-search-result": "No results found for your query"
},
"permanently-delete-modal": {
"confirm-text": "Delete",
diff --git a/public/locales/pseudo-LOCALE/grafana.json b/public/locales/pseudo-LOCALE/grafana.json
index 9357e02114c..4b0ac98fbba 100644
--- a/public/locales/pseudo-LOCALE/grafana.json
+++ b/public/locales/pseudo-LOCALE/grafana.json
@@ -1731,7 +1731,8 @@
"restore": "Ŗęşŧőřę"
},
"page": {
- "empty-state": "Ÿőū ĥävęʼn'ŧ đęľęŧęđ äʼny đäşĥþőäřđş řęčęʼnŧľy."
+ "no-deleted-dashboards": "Ÿőū ĥävęʼn'ŧ đęľęŧęđ äʼny đäşĥþőäřđş řęčęʼnŧľy.",
+ "no-search-result": "Ńő řęşūľŧş ƒőūʼnđ ƒőř yőūř qūęřy"
},
"permanently-delete-modal": {
"confirm-text": "Đęľęŧę",