mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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';
|
import { HelpModal } from '../../help/HelpModal';
|
||||||
|
|
||||||
export const enrichHelpItem = (helpItem: NavModelItem) => {
|
export const enrichHelpItem = (helpItem: NavModelItem) => {
|
||||||
const onOpenShortcuts = () => {
|
|
||||||
appEvents.publish(new ShowModalReactEvent({ component: HelpModal }));
|
|
||||||
};
|
|
||||||
|
|
||||||
let menuItems = helpItem.children || [];
|
let menuItems = helpItem.children || [];
|
||||||
|
|
||||||
if (helpItem.id === 'help') {
|
if (helpItem.id === 'help') {
|
||||||
|
const onOpenShortcuts = () => {
|
||||||
|
appEvents.publish(new ShowModalReactEvent({ component: HelpModal }));
|
||||||
|
};
|
||||||
helpItem.children = [
|
helpItem.children = [
|
||||||
...menuItems,
|
...menuItems,
|
||||||
...getFooterLinks(),
|
...getFooterLinks(),
|
||||||
|
@ -26,7 +26,8 @@ export const TopSearchBar = React.memo(function TopSearchBar() {
|
|||||||
const navIndex = useSelector((state) => state.navIndex);
|
const navIndex = useSelector((state) => state.navIndex);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const helpNode = enrichHelpItem(cloneDeep(navIndex['help']));
|
const helpNode = cloneDeep(navIndex['help']);
|
||||||
|
const enrichedHelpNode = helpNode ? enrichHelpItem(helpNode) : undefined;
|
||||||
const profileNode = navIndex['profile'];
|
const profileNode = navIndex['profile'];
|
||||||
|
|
||||||
let homeUrl = config.appSubUrl || '/';
|
let homeUrl = config.appSubUrl || '/';
|
||||||
@ -49,8 +50,8 @@ export const TopSearchBar = React.memo(function TopSearchBar() {
|
|||||||
|
|
||||||
<TopSearchBarSection align="right">
|
<TopSearchBarSection align="right">
|
||||||
<QuickAdd />
|
<QuickAdd />
|
||||||
{helpNode && (
|
{enrichedHelpNode && (
|
||||||
<Dropdown overlay={() => <TopNavBarMenu node={helpNode} />} placement="bottom-end">
|
<Dropdown overlay={() => <TopNavBarMenu node={enrichedHelpNode} />} placement="bottom-end">
|
||||||
<ToolbarButton iconOnly icon="question-circle" aria-label="Help" />
|
<ToolbarButton iconOnly icon="question-circle" aria-label="Help" />
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user