@fleetbase/ember-ui 0.3.21 → 0.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,27 +7,22 @@
7
7
  <Layout::Header::SidebarToggle class="mr-2" @onToggle={{@onSidebarToggle}} @disabled={{not @sidebarToggleEnabled}} />
8
8
  {{/if}}
9
9
  {{#unless (media "isMobile")}}
10
- <div role="menu" class="next-catalog-menu-items flex mr-4">
11
- {{#each this.menuItems as |menuItem|}}
12
- <LinkToExternal
13
- @route={{menuItem.route}}
14
- id={{concat (dasherize menuItem.route) "-header-button"}}
15
- class="next-view-header-item truncate {{menuItem.class}}"
16
- role="menuitem"
17
- >
18
- <div class="w-6">
19
- {{#if menuItem.iconComponent}}
20
- {{component (lazy-engine-component menuItem.iconComponent) options=menuItem.iconComponentOptions}}
21
- {{else}}
22
- <FaIcon @icon={{menuItem.icon}} @prefix={{menuItem.iconPrefix}} @size="sm" />
23
- {{/if}}
24
- </div>
25
- <div>
26
- <span>{{menuItem.title}}</span>
27
- </div>
28
- </LinkToExternal>
29
- {{/each}}
30
- </div>
10
+ {{!--
11
+ SmartNavMenu replaces the static `next-catalog-menu-items` div.
12
+ It implements the Priority+ overflow pattern: up to `@maxVisible`
13
+ (default 5) extensions are shown inline; the rest collapse into a
14
+ "More" dropdown. A gear icon opens the customiser panel where
15
+ users can pin and reorder their favourite extensions.
16
+
17
+ Pass `@maxVisible={{n}}` to override the default cap of 5.
18
+ Pass `@mutateMenuItems={{fn}}` to mutate items before rendering
19
+ (same contract as the previous static implementation).
20
+ --}}
21
+ <Layout::Header::SmartNavMenu
22
+ class="next-catalog-menu-items mr-4"
23
+ @maxVisible={{or @maxVisibleNavItems 5}}
24
+ @mutateMenuItems={{@mutateMenuItems}}
25
+ />
31
26
  {{/unless}}
32
27
  <div id="view-header-left-content-a"></div>
33
28
  {{yield}}
@@ -22,41 +22,18 @@ export default class LayoutHeaderComponent extends Component {
22
22
  @service abilities;
23
23
  @service fetch;
24
24
  @tracked company;
25
- @tracked menuItems = [];
26
25
  @tracked organizationMenuItems = [];
27
26
  @tracked userMenuItems = [];
28
27
  @tracked extensions = [];
29
28
 
30
- constructor(owner, { menuItems = [], organizationMenuItems = [], userMenuItems = [] }) {
29
+ constructor(owner, { organizationMenuItems = [], userMenuItems = [] }) {
31
30
  super(...arguments);
32
31
  this.extensions = getOwner(this).application.extensions ?? [];
33
32
  this.company = this.currentUser.getCompany();
34
- this.menuItems = this.mergeMenuItems(menuItems);
35
33
  this.organizationMenuItems = this.mergeOrganizationMenuItems(organizationMenuItems);
36
34
  this.userMenuItems = this.mergeUserMenuItems(userMenuItems);
37
35
  }
38
36
 
39
- mergeMenuItems(menuItems = []) {
40
- const headerMenuItems = this.universe.headerMenuItems;
41
- const visibleMenuItems = [];
42
- for (let i = 0; i < headerMenuItems.length; i++) {
43
- const menuItem = headerMenuItems[i];
44
- if (this.abilities.can(`${menuItem.id} see extension`)) {
45
- visibleMenuItems.pushObject(menuItem);
46
- }
47
- }
48
-
49
- // Merge additionals
50
- visibleMenuItems.pushObjects(menuItems);
51
-
52
- // Callback to allow mutation of menu items
53
- if (typeof this.args.mutateMenuItems === 'function') {
54
- this.args.mutateMenuItems(menuItems);
55
- }
56
-
57
- return visibleMenuItems;
58
- }
59
-
60
37
  mergeOrganizationMenuItems(organizationMenuItems = []) {
61
38
  // Prepare menuItems
62
39
  const menuItems = [
@@ -52,6 +52,7 @@
52
52
  @import 'components/report-builder.css';
53
53
  @import 'components/query-builder.css';
54
54
  @import 'components/activity-log.css';
55
+ @import 'components/smart-nav-menu.css';
55
56
 
56
57
  /** Third party */
57
58
  @import "ember-basic-dropdown/vendor/ember-basic-dropdown.css";