diff --git a/addon/components/layout/top-bar.hbs b/addon/components/layout/top-bar.hbs index 7052e948..940b3f3d 100644 --- a/addon/components/layout/top-bar.hbs +++ b/addon/components/layout/top-bar.hbs @@ -70,6 +70,9 @@
+ {{#each @accountLinks as |link|}} + + {{/each}} diff --git a/addon/components/layout/top-bar.js b/addon/components/layout/top-bar.js index bee84a62..53b488df 100644 --- a/addon/components/layout/top-bar.js +++ b/addon/components/layout/top-bar.js @@ -29,6 +29,9 @@ export const THEMES = Object.freeze([ * - `@registerNotificationTrayApi`, `@onClickNotification` — passed to the * notification tray. * - `@timezones` — the time zones offered (defaults to the browser's list). + * - `@accountLinks` — extra account menu links, listed above Sign out: + * `[{ id, label, action, params? }]`. Choosing one closes the menu and calls + * `@onAction(action, ...params)`. */ export default class LayoutTopBarComponent extends Component { @service currentUser; @@ -138,8 +141,8 @@ export default class LayoutTopBarComponent extends Component { this.docsPanel.open('https://www.fleetbase.io/docs', { title: 'Fleetbase Documentation', source: 'account-menu' }); } - @action menuAction(menu, name) { + @action menuAction(menu, name, params = []) { menu.close(); - this.runAction(name); + this.runAction(name, ...params); } } diff --git a/tests/integration/components/layout/top-bar-test.js b/tests/integration/components/layout/top-bar-test.js index 6190c9ae..4d2b976c 100644 --- a/tests/integration/components/layout/top-bar-test.js +++ b/tests/integration/components/layout/top-bar-test.js @@ -229,6 +229,25 @@ module('Integration | Component | layout/top-bar', function (hooks) { }); }); + test('extra account links sit above Sign out and run through @onAction', async function (assert) { + this.links = [ + { id: 'layout', label: 'Switch to classic layout', action: 'switchLayout', params: ['classic'] }, + { id: 'plain', label: 'Plain', action: 'plainAction' }, + ]; + await render(hbs`