Skip to content

Commit f5835a0

Browse files
tylerjmchughjodygarnett
authored andcommitted
Add support for top-level submenu icons
1 parent 7e13e32 commit f5835a0

3 files changed

Lines changed: 49 additions & 17 deletions

File tree

docs/manual/docs/customizing-application/adding-static-pages.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,13 @@ Insert a page as a simple menu using the page identifier or as a submenu using a
6868
["gn-site-name-menu",
6969
"gn-portal-switcher",
7070
"gn-search-menu",
71-
{"quickSearch": [
72-
"searchForAfrica",
73-
"forReview"
74-
]},
71+
{"quickSearch": {
72+
"icon": "fa-search",
73+
"items": [
74+
"searchForAfrica",
75+
"forReview"
76+
]
77+
}},
7578
"gn-map-menu",
7679
"gn-contribute-menu",
7780
"gn-admin-menu",
@@ -100,10 +103,13 @@ As with the top toolbar, insert a page as a simple menu using the page identifie
100103

101104
``` json
102105
["gn-recordview-edit-menu",
103-
{"quickSearch": [
104-
"documentation",
105-
"forReview"
106-
]},
106+
{"quickSearch": {
107+
"icon": "fa-search",
108+
"items": [
109+
"documentation",
110+
"forReview"
111+
]
112+
}},
107113
"gn-recordview-delete-menu",
108114
"gn-recordview-manage-menu",
109115
"gn-recordview-download-menu",

web-ui/src/main/resources/catalog/components/pages/GnStaticPagesService.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,39 @@
5252
);
5353
}
5454
} else if (angular.isObject(menu)) {
55-
var key = Object.keys(menu)[0],
56-
submenu = {
57-
label: key,
58-
type: "submenu",
59-
pages: []
60-
};
61-
buildMenu(submenu.pages, staticPages, menu[key]);
55+
var key = Object.keys(menu)[0];
56+
var value = menu[key];
57+
58+
var submenu = {
59+
label: key,
60+
icon: undefined,
61+
type: "submenu",
62+
pages: []
63+
};
64+
65+
var menuItems;
66+
67+
// If the submenu is using the legacy array format
68+
if (angular.isArray(value)) {
69+
menuItems = value;
70+
// If the submenu is using the new object format with an items array and optional icon
71+
} else if (angular.isObject(value)) {
72+
if (angular.isArray(value.items)) {
73+
menuItems = value.items;
74+
}
75+
if (angular.isDefined(value.icon)) {
76+
submenu.icon = value.icon;
77+
}
78+
} else {
79+
console.warn(
80+
"Invalid menu configuration for " +
81+
key +
82+
". Expected an array of page identifiers or an object with an items array."
83+
);
84+
return;
85+
}
86+
87+
buildMenu(submenu.pages, staticPages, menuItems);
6288
pagesMenu.push(submenu);
6389
}
6490
});

web-ui/src/main/resources/catalog/locales/en-admin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,9 +1574,9 @@
15741574
"staticPageRemoved": "Static page removed",
15751575
"chooseStaticPageFile": "Choose or drop static page file here",
15761576
"ui-topCustomMenu": "Header custom menu items",
1577-
"ui-topCustomMenu-help": "List of static page IDs associated with the header section to display: <ul><li>When a list is provided, the links are displayed in the order provided and only for the pages listed.</li><li>When a list is not provided, all static pages configured for the header section are displayed, with no guaranteed order.</li><li>Pages can be inserted in between catalogue default menu which are: <pre>[\"gn-site-name-menu\",\n \"gn-portal-switcher\",\n \"gn-search-menu\",\n \"gn-map-menu\",\n \"gn-contribute-menu\",\n \"gn-admin-menu\"]</pre></li><li>Insert a page as a simple menu using its id eg. \"documentation\" or as a submenu using an object: <pre>{\"quickSearch\": [\n \"searchForAfrica\", \n \"forReview\"\n]}</pre></li><li>The submenu object key defines the top-level label and can be a translation key, or literal text if the text is not defined in the translations.</li><li>If a translation is defined for \"quickSearch\", the submenu label is translated automatically for each language.</li></ul>",
1577+
"ui-topCustomMenu-help": "List of static page IDs associated with the header section to display: <ul><li>When a list is provided, the links are displayed in the order provided and only for the pages listed.</li><li>When a list is not provided, all static pages configured for the header section are displayed, with no guaranteed order.</li><li>Pages can be inserted in between catalogue default menus which are: <pre>[\"gn-site-name-menu\",\n \"gn-portal-switcher\",\n \"gn-search-menu\",\n \"gn-map-menu\",\n \"gn-contribute-menu\",\n \"gn-admin-menu\"]</pre></li><li>Insert a page as a simple menu using its id eg. \"documentation\" or as a submenu using an object: <pre>{\"quickSearch\": {\n \"icon\": \"fa-search\",\n \"items\": [\n \"searchForAfrica\",\n \"forReview\"\n ]\n}}</pre></li><li>The submenu object key defines the top-level label and can be a translation key, or literal text if the text is not defined in the translations.</li><li>If a translation is defined for \"quickSearch\", the submenu label is translated automatically for each language.</li></ul>",
15781578
"ui-recordviewCustomMenu": "Record View custom menu items",
1579-
"ui-recordviewCustomMenu-help": "List of static page IDs associated with the record view section to display: <ul><li>When a list is provided, the links are displayed in the order provided and only for the pages listed.</li><li>When a list is not provided, all static pages configured for the record view section are displayed, with no guaranteed order.</li><li>Pages can be inserted in between catalogue default menus which are: <pre>[\"gn-recordview-edit-menu\",\n \"gn-recordview-delete-menu\",\n \"gn-recordview-manage-menu\",\n \"gn-recordview-download-menu\",\n \"gn-recordview-display-menu\"]</pre></li><li>Insert a page as a simple menu using its id eg. \"documentation\" or as a submenu using an object: <pre>{\"quickSearch\": [\n \"searchForAfrica\", \n \"forReview\"\n]}</pre></li><li>The submenu object key defines the top-level label and can be a translation key, or literal text if the text is not defined in the translations.</li><li>If a translation is defined for \"quickSearch\", the submenu label is translated automatically for each language.</li></ul>",
1579+
"ui-recordviewCustomMenu-help": "List of static page IDs associated with the record view section to display: <ul><li>When a list is provided, the links are displayed in the order provided and only for the pages listed.</li><li>When a list is not provided, all static pages configured for the record view section are displayed, with no guaranteed order.</li><li>Pages can be inserted in between catalogue default menus which are: <pre>[\"gn-recordview-edit-menu\",\n \"gn-recordview-delete-menu\",\n \"gn-recordview-manage-menu\",\n \"gn-recordview-download-menu\",\n \"gn-recordview-display-menu\"]</pre></li><li>Insert a page as a simple menu using its id eg. \"documentation\" or as a submenu using an object: <pre>{\"quickSearch\": {\n \"icon\": \"fa-search\",\n \"items\": [\n \"searchForAfrica\",\n \"forReview\"\n ]\n}}</pre></li><li>The submenu object key defines the top-level label and can be a translation key, or literal text if the text is not defined in the translations.</li><li>If a translation is defined for \"quickSearch\", the submenu label is translated automatically for each language.</li></ul>",
15801580
"ui-footerCustomMenu": "Footer custom menu items",
15811581
"ui-footerCustomMenu-help": "List of static page IDs associated with the footer section to display: <ul><li>When a list is provided, the links are displayed in the order provided and only for the pages listed.</li><li>When a list is not provided, all static pages configured for the footer section are displayed, with no guaranteed order.</li>",
15821582
"es.url": "Elasticsearch server",

0 commit comments

Comments
 (0)