@fleetbase/ember-ui 0.3.20 → 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 = [
@@ -275,6 +252,20 @@ export default class LayoutHeaderComponent extends Component {
275
252
  // Push support menu items
276
253
  menuItems.pushObjects(supportMenuItems);
277
254
 
255
+ // Push items from universe registry
256
+ const universeUserMenuItems = this.universe.userMenuItems;
257
+ if (isArray(universeUserMenuItems) && universeUserMenuItems.length) {
258
+ menuItems.pushObjects([
259
+ {
260
+ seperator: true,
261
+ },
262
+ ...universeUserMenuItems,
263
+ {
264
+ seperator: true,
265
+ },
266
+ ]);
267
+ }
268
+
278
269
  // Push provided menu items
279
270
  menuItems.pushObjects(userMenuItems);
280
271
 
@@ -4,6 +4,7 @@ import { inject as service } from '@ember/service';
4
4
  import { action } from '@ember/object';
5
5
  import { debug } from '@ember/debug';
6
6
  import intlTelInput from 'intl-tel-input';
7
+ import lookupUserIp from '@fleetbase/ember-core/utils/lookup-user-ip';
7
8
 
8
9
  export default class PhoneInputComponent extends Component {
9
10
  @service fetch;
@@ -15,13 +16,20 @@ export default class PhoneInputComponent extends Component {
15
16
  initialCountry: 'auto',
16
17
  separateDialCode: true,
17
18
  formatAsYouType: true,
18
- geoIpLookup: async (success, failure) => {
19
+ geoIpLookup: async (success) => {
19
20
  try {
20
- const { country_code } = await this.fetch.get('lookup/whois');
21
- success(country_code);
21
+ const ipData = await lookupUserIp();
22
+ if (ipData && ipData.country_code) {
23
+ success(ipData.country_code);
24
+ } else {
25
+ // Fallback to US if no country code in response
26
+ debug('No country code in IP lookup response, defaulting to US');
27
+ success('us');
28
+ }
22
29
  } catch (error) {
23
- debug('Failed to lookup country code with whois API.');
24
- failure(error);
30
+ // Always succeed with US fallback on error
31
+ debug('Failed to lookup country code, defaulting to US: ' + error.message);
32
+ success('us');
25
33
  }
26
34
  },
27
35
  utilsScript: '/assets/libphonenumber/utils.js',
@@ -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";