mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
TopSearchBar: Fix TopSearchBar if [help] enabled = false (#68249)
Fix TopSearchBar for disabled help
This commit is contained in:
parent
cb293ecf1c
commit
64c89dc4e6
@ -8,13 +8,12 @@ import { getFooterLinks } from '../../Footer/Footer';
|
||||
import { HelpModal } from '../../help/HelpModal';
|
||||
|
||||
export const enrichHelpItem = (helpItem: NavModelItem) => {
|
||||
const onOpenShortcuts = () => {
|
||||
appEvents.publish(new ShowModalReactEvent({ component: HelpModal }));
|
||||
};
|
||||
|
||||
let menuItems = helpItem.children || [];
|
||||
|
||||
if (helpItem.id === 'help') {
|
||||
const onOpenShortcuts = () => {
|
||||
appEvents.publish(new ShowModalReactEvent({ component: HelpModal }));
|
||||
};
|
||||
helpItem.children = [
|
||||
...menuItems,
|
||||
...getFooterLinks(),
|
||||
|
@ -26,7 +26,8 @@ export const TopSearchBar = React.memo(function TopSearchBar() {
|
||||
const navIndex = useSelector((state) => state.navIndex);
|
||||
const location = useLocation();
|
||||
|
||||
const helpNode = enrichHelpItem(cloneDeep(navIndex['help']));
|
||||
const helpNode = cloneDeep(navIndex['help']);
|
||||
const enrichedHelpNode = helpNode ? enrichHelpItem(helpNode) : undefined;
|
||||
const profileNode = navIndex['profile'];
|
||||
|
||||
let homeUrl = config.appSubUrl || '/';
|
||||
@ -49,8 +50,8 @@ export const TopSearchBar = React.memo(function TopSearchBar() {
|
||||
|
||||
<TopSearchBarSection align="right">
|
||||
<QuickAdd />
|
||||
{helpNode && (
|
||||
<Dropdown overlay={() => <TopNavBarMenu node={helpNode} />} placement="bottom-end">
|
||||
{enrichedHelpNode && (
|
||||
<Dropdown overlay={() => <TopNavBarMenu node={enrichedHelpNode} />} placement="bottom-end">
|
||||
<ToolbarButton iconOnly icon="question-circle" aria-label="Help" />
|
||||
</Dropdown>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user