grafana/public/app/features/search/components/SearchWrapper.tsx
Ashley Harrison a861c10f1b
Navigation: Integrate search into topnav (#54925)
* behaviour mostly there

* slight performance improvement

* slightly nicer...

* refactor search and add it to the store

* add comments about removing old component

* remove unneeded logic

* small design tweak

* More small tweaks

* Restore top margin

* add onCloseSearch/onSelectSearchItem to useSearchQuery

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2022-09-09 11:01:31 +01:00

25 lines
709 B
TypeScript

import React, { FC, memo } from 'react';
import { config } from '@grafana/runtime';
import { useUrlParams } from 'app/core/navigation/hooks';
import { DashboardSearch } from './DashboardSearch';
import { DashboardSearchModal } from './DashboardSearchModal';
export const SearchWrapper: FC = memo(() => {
const [params] = useUrlParams();
const isOpen = params.get('search') === 'open';
const isTopnav = config.featureToggles.topnav;
return isOpen ? (
isTopnav ? (
<DashboardSearchModal isOpen={isOpen} />
) : (
// TODO: remove this component when we turn on the topnav feature toggle
<DashboardSearch />
)
) : null;
});
SearchWrapper.displayName = 'SearchWrapper';