Skip to content

fix(smart-nav-menu): use parent extension id for shortcut permission check#122

Merged
roncodes merged 2 commits intomainfrom
fix/smart-nav-menu-shortcut-permission
Mar 26, 2026
Merged

fix(smart-nav-menu): use parent extension id for shortcut permission check#122
roncodes merged 2 commits intomainfrom
fix/smart-nav-menu-shortcut-permission

Conversation

@roncodes
Copy link
Copy Markdown
Member

Problem

Shortcuts registered via registerHeaderMenuItem() are stored as first-class items in the universe registry with _isShortcut: true and _parentId pointing to the parent extension.

The allItems getter in smart-nav-menu.js was running the ability check against the shortcut's own id (e.g. ledger-sc-transactions see extension), which has no registered ability. This caused every shortcut to always fall through to the catch block and be unconditionally included — regardless of whether the user actually has permission to see the parent extension.

Fix

When an item is a shortcut (_isShortcut && _parentId), use _parentId as the ability subject instead of item.id:

const abilityId = item._isShortcut && item._parentId ? item._parentId : item.id;
if (this.abilities.can(`${abilityId} see extension`)) { ... }

This means a shortcut is visible if and only if its parent extension is visible, which is the correct behaviour. If the parent extension has no registered ability (catch block), the shortcut is also included by default — consistent with how parent extensions are handled.

Ronald A Richardson and others added 2 commits March 26, 2026 03:07
…check

Shortcuts registered via registerHeaderMenuItem() are stored as first-class
items in the universe registry with _isShortcut: true and _parentId pointing
to the parent extension.  The allItems getter was running the ability check
against the shortcut's own id (e.g. 'ledger-sc-transactions see extension'),
which has no registered ability and therefore always fell through to the catch
block, making every shortcut unconditionally visible regardless of whether the
user can see the parent extension.

Fix: when an item is a shortcut (_isShortcut && _parentId), use _parentId as
the ability subject instead of item.id.  This means a shortcut is visible if
and only if its parent extension is visible, which is the correct behaviour.
@roncodes roncodes merged commit 95341e0 into main Mar 26, 2026
3 checks passed
@roncodes roncodes deleted the fix/smart-nav-menu-shortcut-permission branch March 26, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant