TopSearchBar: Fix TopSearchBar if [help] enabled = false (#68249)

Fix TopSearchBar for disabled help
This commit is contained in:
Buger-od-ua 2023-05-10 21:58:19 +03:00 committed by GitHub
parent cb293ecf1c
commit 64c89dc4e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -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(),

View File

@ -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>
)}