97183 Workaround: reorder admin sidebar sections

The issue described at https://github.com/DSpace/dspace-angular/issues/1643 was
no longer reproducible: The menu component ultimately retrieves menu section
information from the store, but in the `MenuComponent#ngOnInit` method, this
information is piped through `distinctUntilChanged(compareArraysUsingIds())`,
which discards an update that sets these menu elements to be visible.

The behavior of this pipe is probably incorrect, but a proper fix is out of
scope for the current task. For now, we work around the problem by adding
top-level menu sections _after_ their children while initializing the menu
section store, which side-steps this issue.
This commit is contained in:
Koen Pauwels
2022-11-30 15:25:36 +01:00
parent ca864379c8
commit 627da93e23

View File

@@ -171,17 +171,6 @@ export class MenuResolver implements Resolve<boolean> {
]).subscribe(([isCollectionAdmin, isCommunityAdmin, isSiteAdmin]) => { ]).subscribe(([isCollectionAdmin, isCommunityAdmin, isSiteAdmin]) => {
const menuList = [ const menuList = [
/* News */ /* News */
{
id: 'new',
active: false,
visible: true,
model: {
type: MenuItemType.TEXT,
text: 'menu.section.new'
} as TextMenuItemModel,
icon: 'plus',
index: 0
},
{ {
id: 'new_community', id: 'new_community',
parentID: 'new', parentID: 'new',
@@ -232,6 +221,17 @@ export class MenuResolver implements Resolve<boolean> {
link: '/processes/new' link: '/processes/new'
} as LinkMenuItemModel, } as LinkMenuItemModel,
}, },
{
id: 'new',
active: false,
visible: true,
model: {
type: MenuItemType.TEXT,
text: 'menu.section.new'
} as TextMenuItemModel,
icon: 'plus',
index: 0
},
// TODO: enable this menu item once the feature has been implemented // TODO: enable this menu item once the feature has been implemented
// { // {
// id: 'new_item_version', // id: 'new_item_version',
@@ -246,17 +246,6 @@ export class MenuResolver implements Resolve<boolean> {
// }, // },
/* Edit */ /* Edit */
{
id: 'edit',
active: false,
visible: true,
model: {
type: MenuItemType.TEXT,
text: 'menu.section.edit'
} as TextMenuItemModel,
icon: 'pencil-alt',
index: 1
},
{ {
id: 'edit_community', id: 'edit_community',
parentID: 'edit', parentID: 'edit',
@@ -296,6 +285,17 @@ export class MenuResolver implements Resolve<boolean> {
} }
} as OnClickMenuItemModel, } as OnClickMenuItemModel,
}, },
{
id: 'edit',
active: false,
visible: true,
model: {
type: MenuItemType.TEXT,
text: 'menu.section.edit'
} as TextMenuItemModel,
icon: 'pencil-alt',
index: 1
},
/* Statistics */ /* Statistics */
// TODO: enable this menu item once the feature has been implemented // TODO: enable this menu item once the feature has been implemented