mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Search: Add FixedSizeList for result items * Search: Move SectionHeader to a separate file * Search: Add useListHeight hook * Search: Fix horizontal scrollbar * Search: Remove custom scrollbar * Search: Do not fetch dashboard folder on route change * Search: Update tests * Search: Remove extra checkbox renders * Search: Move wrapper ref outside search results * Search: Fix param type * Search: Fix merge conflicts * Search: Virtualize dashboard list * Search: Update layout * Search: Pass wrapper to search results * Search: Update dashboard redirect * Search: Remove unused css * Search: Revert config * Search: Use AutoSizer * Search: Remove redundant appEvents call * Search: Use List layout in folder view
21 lines
641 B
TypeScript
21 lines
641 B
TypeScript
import { useEffect, useState } from 'react';
|
|
import { DashboardQuery, SearchLayout } from '../types';
|
|
|
|
export const layoutOptions = [
|
|
{ label: 'Folders', value: SearchLayout.Folders, icon: 'folder' },
|
|
{ label: 'List', value: SearchLayout.List, icon: 'list-ul' },
|
|
];
|
|
|
|
export const useSearchLayout = (query: DashboardQuery, defaultLayout = SearchLayout.Folders) => {
|
|
const [layout, setLayout] = useState<string>(defaultLayout);
|
|
|
|
useEffect(() => {
|
|
if (query.sort) {
|
|
const list = layoutOptions.find(opt => opt.value === SearchLayout.List);
|
|
setLayout(list!.value);
|
|
}
|
|
}, [query]);
|
|
|
|
return { layout, setLayout };
|
|
};
|