@fleetbase/ember-core 0.0.8 → 0.1.0

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.
@@ -94,16 +94,29 @@ export default class ApplicationAdapter extends RESTAdapter {
94
94
  */
95
95
  getHeaders() {
96
96
  const headers = {};
97
- const isAuthenticated = this.session.isAuthenticated;
98
97
  const userId = this.session.data.authenticated.user;
99
98
  const userOptions = getUserOptions();
100
99
  const isSandbox = get(userOptions, `${userId}:sandbox`) === true;
101
100
  const testKey = get(userOptions, `${userId}:testKey`);
101
+ let isAuthenticated = this.session.isAuthenticated;
102
+ let { token } = this.session.data.authenticated;
103
+
104
+ // If the session data is not yet available, check localStorage
105
+ if (!isAuthenticated) {
106
+ const localStorageSession = JSON.parse(window.localStorage.getItem('ember_simple_auth-session'));
107
+ if (localStorageSession) {
108
+ const { authenticated } = localStorageSession;
109
+ token = authenticated.token;
110
+
111
+ // Check isAuthenticated again
112
+ isAuthenticated = !!token;
113
+ }
114
+ }
102
115
 
103
116
  headers['Content-Type'] = 'application/json';
104
117
 
105
118
  if (isAuthenticated) {
106
- headers['Authorization'] = `Bearer ${this.session.data.authenticated.token}`;
119
+ headers['Authorization'] = `Bearer ${token}`;
107
120
  }
108
121
 
109
122
  if (isAuthenticated && isSandbox) {
@@ -13,6 +13,7 @@ const hostServices = [
13
13
  'crud',
14
14
  'notifications',
15
15
  'fileQueue',
16
+ 'universe',
16
17
  { hostRouter: 'router' },
17
18
  ];
18
19
 
@@ -14,6 +14,7 @@ const services = [
14
14
  'notifications',
15
15
  'hostRouter',
16
16
  'fileQueue',
17
+ 'universe',
17
18
  ];
18
19
 
19
20
  export default services;
@@ -0,0 +1,530 @@
1
+ import Service from '@ember/service';
2
+ import Evented from '@ember/object/evented';
3
+ import { tracked } from '@glimmer/tracking';
4
+ import { inject as service } from '@ember/service';
5
+ import { computed, action } from '@ember/object';
6
+ import { isBlank } from '@ember/utils';
7
+ import { isArray } from '@ember/array';
8
+ import { dasherize } from '@ember/string';
9
+ import { getOwner } from '@ember/application';
10
+ import { assert } from '@ember/debug';
11
+ import RSVP from 'rsvp';
12
+
13
+ export default class UniverseService extends Service.extend(Evented) {
14
+ @service router;
15
+ @tracked headerMenuItems = [];
16
+ @tracked organizationMenuItems = [];
17
+ @tracked userMenuItems = [];
18
+ @tracked adminRegistry = {
19
+ menuItems: [],
20
+ menuPanels: [],
21
+ };
22
+ @tracked accountRegistry = {
23
+ menuItems: [],
24
+ menuPanels: [],
25
+ };
26
+ @tracked settingsRegistry = {
27
+ menuItems: [],
28
+ menuPanels: [],
29
+ };
30
+
31
+ /**
32
+ * Computed property that returns all administrative menu items.
33
+ *
34
+ * @computed adminMenuItems
35
+ * @public
36
+ * @readonly
37
+ * @memberof UniverseService
38
+ * @returns {Array} Array of administrative menu items
39
+ */
40
+ @computed('adminRegistry.menuItems.[]') get adminMenuItems() {
41
+ return this.adminRegistry.menuItems;
42
+ }
43
+
44
+ /**
45
+ * Computed property that returns all administrative menu panels.
46
+ *
47
+ * @computed adminMenuPanels
48
+ * @public
49
+ * @readonly
50
+ * @memberof UniverseService
51
+ * @returns {Array} Array of administrative menu panels
52
+ */
53
+ @computed('adminRegistry.menuPanels.[]') get adminMenuPanels() {
54
+ return this.adminRegistry.menuPanels;
55
+ }
56
+
57
+ /**
58
+ * Computed property that returns all settings menu items.
59
+ *
60
+ * @computed settingsMenuItems
61
+ * @public
62
+ * @readonly
63
+ * @memberof UniverseService
64
+ * @returns {Array} Array of administrative menu items
65
+ */
66
+ @computed('settingsRegistry.menuItems.[]') get settingsMenuItems() {
67
+ return this.settingsRegistry.menuItems;
68
+ }
69
+
70
+ /**
71
+ * Computed property that returns all settings menu panels.
72
+ *
73
+ * @computed settingsMenuPanels
74
+ * @public
75
+ * @readonly
76
+ * @memberof UniverseService
77
+ * @returns {Array} Array of administrative menu panels
78
+ */
79
+ @computed('settingsRegistry.menuPanels.[]') get settingsMenuPanels() {
80
+ return this.settingsRegistry.menuPanels;
81
+ }
82
+
83
+ /**
84
+ * Action to transition to a specified route based on the provided menu item.
85
+ *
86
+ * The route transition will include the 'slug' as a dynamic segment, and
87
+ * the 'view' as an optional dynamic segment if it is defined.
88
+ *
89
+ * @action
90
+ * @memberof UniverseService
91
+ * @param {string} route - The target route to transition to.
92
+ * @param {Object} menuItem - The menu item containing the transition parameters.
93
+ * @param {string} menuItem.slug - The 'slug' dynamic segment for the route.
94
+ * @param {string} [menuItem.view] - The 'view' dynamic segment for the route, if applicable.
95
+ *
96
+ * @returns {Transition} Returns a Transition object representing the transition to the route.
97
+ */
98
+ @action transitionMenuItem(route, menuItem) {
99
+ const { slug, view } = menuItem;
100
+
101
+ if (view) {
102
+ return this.router.transitionTo(route, slug, view);
103
+ }
104
+
105
+ return this.router.transitionTo(route, slug, 'index');
106
+ }
107
+
108
+ /**
109
+ * Loads a component from the specified registry based on a given slug and view.
110
+ *
111
+ * @param {string} registryName - The name of the registry where the component is located.
112
+ * @param {string} slug - The slug of the menu item.
113
+ * @param {string} [view=null] - The view of the menu item, if applicable.
114
+ *
115
+ * @returns {Promise} Returns a Promise that resolves with the component if it is found, or null.
116
+ */
117
+ loadComponentFromRegistry(registryName, slug, view = null) {
118
+ const registry = this[`${registryName}Registry`];
119
+
120
+ if (isBlank(registry)) {
121
+ return null;
122
+ }
123
+
124
+ return new Promise((resolve) => {
125
+ let component = null;
126
+
127
+ // check menu items first
128
+ for (let i = 0; i < registry.menuItems.length; i++) {
129
+ const menuItem = registry.menuItems[i];
130
+
131
+ // no view hack
132
+ if (menuItem && menuItem.slug === slug && menuItem.view === null && view === 'index') {
133
+ component = menuItem.component;
134
+ break;
135
+ }
136
+
137
+ if (menuItem && menuItem.slug === slug && menuItem.view === view) {
138
+ component = menuItem.component;
139
+ break;
140
+ }
141
+ }
142
+
143
+ // check menu panels
144
+ for (let i = 0; i < registry.menuPanels.length; i++) {
145
+ const menuPanel = registry.menuPanels[i];
146
+
147
+ if (menuPanel && isArray(menuPanel.items)) {
148
+ for (let j = 0; j < menuPanel.items.length; j++) {
149
+ const menuItem = menuPanel.items[j];
150
+
151
+ // no view hack
152
+ if (menuItem && menuItem.slug === slug && menuItem.view === null && view === 'index') {
153
+ component = menuItem.component;
154
+ break;
155
+ }
156
+
157
+ if (menuItem && menuItem.slug === slug && menuItem.view === view) {
158
+ component = menuItem.component;
159
+ break;
160
+ }
161
+ }
162
+ }
163
+ }
164
+
165
+ resolve(component);
166
+ });
167
+ }
168
+
169
+ /**
170
+ * Looks up a menu item from the specified registry based on a given slug and view.
171
+ *
172
+ * @param {string} registryName - The name of the registry where the menu item is located.
173
+ * @param {string} slug - The slug of the menu item.
174
+ * @param {string} [view=null] - The view of the menu item, if applicable.
175
+ *
176
+ * @returns {Promise} Returns a Promise that resolves with the menu item if it is found, or null.
177
+ */
178
+ lookupMenuItemFromRegistry(registryName, slug, view = null) {
179
+ const registry = this[`${registryName}Registry`];
180
+
181
+ if (isBlank(registry)) {
182
+ return null;
183
+ }
184
+
185
+ return new Promise((resolve) => {
186
+ let foundMenuItem = null;
187
+
188
+ // check menu items first
189
+ for (let i = 0; i < registry.menuItems.length; i++) {
190
+ const menuItem = registry.menuItems[i];
191
+
192
+ // no view hack
193
+ if (menuItem && menuItem.slug === slug && menuItem.view === null && view === 'index') {
194
+ foundMenuItem = menuItem;
195
+ break;
196
+ }
197
+
198
+ if (menuItem && menuItem.slug === slug && menuItem.view === view) {
199
+ foundMenuItem = menuItem;
200
+ break;
201
+ }
202
+ }
203
+
204
+ // check menu panels
205
+ for (let i = 0; i < registry.menuPanels.length; i++) {
206
+ const menuPanel = registry.menuPanels[i];
207
+
208
+ if (menuPanel && isArray(menuPanel.items)) {
209
+ for (let j = 0; j < menuPanel.items.length; j++) {
210
+ const menuItem = menuPanel.items[j];
211
+
212
+ // no view hack
213
+ if (menuItem && menuItem.slug === slug && menuItem.view === null && view === 'index') {
214
+ foundMenuItem = menuItem;
215
+ break;
216
+ }
217
+
218
+ if (menuItem && menuItem.slug === slug && menuItem.view === view) {
219
+ foundMenuItem = menuItem;
220
+ break;
221
+ }
222
+ }
223
+ }
224
+ }
225
+
226
+ resolve(foundMenuItem);
227
+ });
228
+ }
229
+
230
+ /**
231
+ * Registers a new menu panel in a registry.
232
+ *
233
+ * @method registerMenuPanel
234
+ * @public
235
+ * @memberof UniverseService
236
+ * @param {String} registryName The name of the registry to use
237
+ * @param {String} title The title of the panel
238
+ * @param {Array} items The items of the panel
239
+ * @param {Object} options Additional options for the panel
240
+ */
241
+ registerMenuPanel(registryName, title, items = [], options = {}) {
242
+ const open = this._getOption(options, 'open', true);
243
+ const slug = this._getOption(options, 'slug', dasherize(title));
244
+
245
+ this[`${registryName}Registry`].menuPanels.pushObject({
246
+ title,
247
+ open,
248
+ items: items.map(({ title, route, ...options }) => {
249
+ options.slug = slug;
250
+ options.view = dasherize(title);
251
+
252
+ return this._createMenuItem(title, route, options);
253
+ }),
254
+ });
255
+ }
256
+
257
+ /**
258
+ * Registers a new menu item in a registry.
259
+ *
260
+ * @method registerMenuItem
261
+ * @public
262
+ * @memberof UniverseService
263
+ * @param {String} registryName The name of the registry to use
264
+ * @param {String} title The title of the item
265
+ * @param {String} route The route of the item
266
+ * @param {Object} options Additional options for the item
267
+ */
268
+ registerMenuItem(registryName, title, options = {}) {
269
+ const route = this._getOption(options, 'route', `console.${registryName}.virtual`);
270
+ options.slug = this._getOption(options, 'slug', '~');
271
+ options.view = this._getOption(options, 'view', dasherize(title));
272
+
273
+ // not really a fan of assumptions, but will do this for the timebeing till anyone complains
274
+ if (options.slug === options.view) {
275
+ options.view = null;
276
+ }
277
+
278
+ this[`${registryName}Registry`].menuItems.pushObject(this._createMenuItem(title, route, options));
279
+ }
280
+
281
+ /**
282
+ * Registers a new administrative menu panel.
283
+ *
284
+ * @method registerAdminMenuPanel
285
+ * @public
286
+ * @memberof UniverseService
287
+ * @param {String} title The title of the panel
288
+ * @param {Array} items The items of the panel
289
+ * @param {Object} options Additional options for the panel
290
+ */
291
+ registerAdminMenuPanel(title, items = [], options = {}) {
292
+ options.section = this._getOption(options, 'section', 'admin');
293
+ this.registerMenuPanel('admin', title, items, options);
294
+ }
295
+
296
+ /**
297
+ * Registers a new administrative menu item.
298
+ *
299
+ * @method registerAdminMenuItem
300
+ * @public
301
+ * @memberof UniverseService
302
+ * @param {String} title The title of the item
303
+ * @param {Object} options Additional options for the item
304
+ */
305
+ registerAdminMenuItem(title, options = {}) {
306
+ this.registerMenuItem('admin', title, options);
307
+ }
308
+
309
+ /**
310
+ * Registers a new settings menu panel.
311
+ *
312
+ * @method registerSettingsMenuPanel
313
+ * @public
314
+ * @memberof UniverseService
315
+ * @param {String} title The title of the panel
316
+ * @param {Array} items The items of the panel
317
+ * @param {Object} options Additional options for the panel
318
+ */
319
+ registerSettingsMenuPanel(title, items = [], options = {}) {
320
+ this.registerMenuPanel('settings', title, items, options);
321
+ }
322
+
323
+ /**
324
+ * Registers a new settings menu item.
325
+ *
326
+ * @method registerSettingsMenuItem
327
+ * @public
328
+ * @memberof UniverseService
329
+ * @param {String} title The title of the item
330
+ * @param {Object} options Additional options for the item
331
+ */
332
+ registerSettingsMenuItem(title, options = {}) {
333
+ this.registerMenuItem('settings', title, options);
334
+ }
335
+
336
+ /**
337
+ * Registers a new header menu item.
338
+ *
339
+ * @method registerHeaderMenuItem
340
+ * @public
341
+ * @memberof UniverseService
342
+ * @param {String} title The title of the item
343
+ * @param {String} route The route of the item
344
+ * @param {Object} options Additional options for the item
345
+ */
346
+ registerHeaderMenuItem(title, route, options = {}) {
347
+ this.headerMenuItems.pushObject(this._createMenuItem(title, route, options));
348
+ this.headerMenuItems.sort((a, b) => a.priority - b.priority);
349
+ }
350
+
351
+ /**
352
+ * Registers a new organization menu item.
353
+ *
354
+ * @method registerOrganizationMenuItem
355
+ * @public
356
+ * @memberof UniverseService
357
+ * @param {String} title The title of the item
358
+ * @param {String} route The route of the item
359
+ * @param {Object} options Additional options for the item
360
+ */
361
+ registerOrganizationMenuItem(title, options = {}) {
362
+ const route = this._getOption(options, 'route', 'console.virtual');
363
+ options.index = this._getOption(options, 'index', 0);
364
+ options.section = this._getOption(options, 'section', 'settings');
365
+
366
+ this.organizationMenuItems.pushObject(this._createMenuItem(title, route, options));
367
+ }
368
+
369
+ /**
370
+ * Registers a new organization menu item.
371
+ *
372
+ * @method registerOrganizationMenuItem
373
+ * @public
374
+ * @memberof UniverseService
375
+ * @param {String} title The title of the item
376
+ * @param {String} route The route of the item
377
+ * @param {Object} options Additional options for the item
378
+ */
379
+ registerUserMenuItem(title, options = {}) {
380
+ const route = this._getOption(options, 'route', 'console.virtual');
381
+ options.index = this._getOption(options, 'index', 0);
382
+ options.section = this._getOption(options, 'section', 'account');
383
+
384
+ this.userMenuItems.pushObject(this._createMenuItem(title, route, options));
385
+ }
386
+
387
+ /**
388
+ * Returns the value of a given key on a target object, with a default value.
389
+ *
390
+ * @method _getOption
391
+ * @private
392
+ * @memberof UniverseService
393
+ * @param {Object} target The target object
394
+ * @param {String} key The key to get value for
395
+ * @param {*} defaultValue The default value if the key does not exist
396
+ * @returns {*} The value of the key or default value
397
+ */
398
+ _getOption(target, key, defaultValue = null) {
399
+ return target[key] !== undefined ? target[key] : defaultValue;
400
+ }
401
+
402
+ /**
403
+ * Creates a new menu item with the provided information.
404
+ *
405
+ * @method _createMenuItem
406
+ * @private
407
+ * @memberof UniverseService
408
+ * @param {String} title The title of the item
409
+ * @param {String} route The route of the item
410
+ * @param {Object} options Additional options for the item
411
+ * @returns {Object} A new menu item object
412
+ */
413
+ _createMenuItem(title, route, options = {}) {
414
+ const priority = this._getOption(options, 'priority', 9);
415
+ const icon = this._getOption(options, 'icon', 'circle-dot');
416
+ const items = this._getOption(options, 'items');
417
+ const component = this._getOption(options, 'component');
418
+ const componentParams = this._getOption(options, 'componentParams', {});
419
+ const slug = this._getOption(options, 'slug', dasherize(title));
420
+ const view = this._getOption(options, 'view');
421
+ const queryParams = this._getOption(options, 'queryParams', {});
422
+ const index = this._getOption(options, 'index', 0);
423
+ const onClick = this._getOption(options, 'onClick', null);
424
+ const section = this._getOption(options, 'section', null);
425
+
426
+ // todo: create menu item class
427
+ const menuItem = {
428
+ title,
429
+ route,
430
+ icon,
431
+ priority,
432
+ items,
433
+ component,
434
+ componentParams,
435
+ slug,
436
+ queryParams,
437
+ view,
438
+ index,
439
+ section,
440
+ };
441
+
442
+ // send default params into onClick
443
+ if (typeof onClick === 'function') {
444
+ menuItem.onClick = () => {
445
+ return onClick(menuItem);
446
+ };
447
+ }
448
+
449
+ return menuItem;
450
+ }
451
+
452
+ /**
453
+ * Load the specified engine. If it is not loaded yet, it will use assetLoader
454
+ * to load it and then register it to the router.
455
+ *
456
+ * @method loadEngine
457
+ * @public
458
+ * @memberof UniverseService
459
+ * @param {String} name The name of the engine to load
460
+ * @returns {Promise} A promise that resolves with the constructed engine instance
461
+ */
462
+ loadEngine(name) {
463
+ const router = getOwner(this).lookup('router:main');
464
+ const instanceId = 'manual'; // Arbitrary instance id, should be unique per engine
465
+ const mountPoint = null; // No mount point for manually loaded engines
466
+
467
+ if (!router._enginePromises[name]) {
468
+ router._enginePromises[name] = Object.create(null);
469
+ }
470
+
471
+ let enginePromise = router._enginePromises[name][instanceId];
472
+
473
+ // We already have a Promise for this engine instance
474
+ if (enginePromise) {
475
+ return enginePromise;
476
+ }
477
+
478
+ if (router._engineIsLoaded(name)) {
479
+ // The Engine is loaded, but has no Promise
480
+ enginePromise = RSVP.resolve();
481
+ } else {
482
+ // The Engine is not loaded and has no Promise
483
+ enginePromise = router._assetLoader.loadBundle(name).then(
484
+ () => router._registerEngine(name),
485
+ (error) => {
486
+ router._enginePromises[name][instanceId] = undefined;
487
+ throw error;
488
+ }
489
+ );
490
+ }
491
+
492
+ return (router._enginePromises[name][instanceId] = enginePromise.then(() => {
493
+ return this.constructEngineInstance(name, instanceId, mountPoint);
494
+ }));
495
+ }
496
+
497
+ /**
498
+ * Construct an engine instance. If the instance does not exist yet, it will be created.
499
+ *
500
+ * @method constructEngineInstance
501
+ * @public
502
+ * @memberof UniverseService
503
+ * @param {String} name The name of the engine
504
+ * @param {String} instanceId The id of the engine instance
505
+ * @param {String} mountPoint The mount point of the engine
506
+ * @returns {Promise} A promise that resolves with the constructed engine instance
507
+ */
508
+ constructEngineInstance(name, instanceId, mountPoint) {
509
+ const owner = getOwner(this);
510
+
511
+ assert("You attempted to load the engine '" + name + "', but the engine cannot be found.", owner.hasRegistration(`engine:${name}`));
512
+
513
+ let engineInstances = owner.lookup('router:main')._engineInstances;
514
+
515
+ if (!engineInstances[name]) {
516
+ engineInstances[name] = Object.create(null);
517
+ }
518
+
519
+ let engineInstance = owner.buildChildEngineInstance(name, {
520
+ routable: true,
521
+ mountPoint,
522
+ });
523
+
524
+ engineInstances[name][instanceId] = engineInstance;
525
+
526
+ return engineInstance.boot().then(() => {
527
+ return engineInstance;
528
+ });
529
+ }
530
+ }
@@ -1,6 +1,18 @@
1
1
  import { dasherize } from '@ember/string';
2
2
  import hostServices from '../exports/host-services';
3
3
 
4
+ function routeNameFromExtension(extension) {
5
+ const mountName = extension.name.split('/')[1];
6
+ const mountPath = mountName.replace('-engine', '');
7
+ let route = mountPath;
8
+
9
+ if (extension.fleetbase && extension.fleetbase.route) {
10
+ route = extension.fleetbase.route;
11
+ }
12
+
13
+ return dasherize(route);
14
+ }
15
+
4
16
  export default function mapEngines(extensions, withServices = []) {
5
17
  const engines = {};
6
18
  const externalRoutes = {
@@ -10,9 +22,9 @@ export default function mapEngines(extensions, withServices = []) {
10
22
 
11
23
  for (let i = 0; i < extensions.length; i++) {
12
24
  const extension = extensions[i];
13
- const path = dasherize(extension.extension);
25
+ const route = routeNameFromExtension(extension);
14
26
 
15
- externalRoutes[path] = `console.${path}`;
27
+ externalRoutes[route] = `console.${route}`;
16
28
  }
17
29
 
18
30
  for (let i = 0; i < extensions.length; i++) {
@@ -0,0 +1 @@
1
+ export { default } from '@fleetbase/ember-core/services/universe';
package/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "@fleetbase/ember-core",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
4
4
  "description": "Provides all the core services, decorators and utilities for building a Fleetbase extension for the Console.",
5
5
  "keywords": [
6
- "fleetbase-extension",
7
6
  "fleetbase-core",
8
7
  "fleetbase-services",
9
8
  "fleetbase",
10
- "ember-addon",
11
- "ember-engine"
9
+ "ember-addon"
12
10
  ],
13
11
  "repository": "https://github.com/fleetbase/ember-core",
14
12
  "license": "MIT",
@@ -1,47 +0,0 @@
1
- import { classify } from '@ember/string';
2
-
3
- export default function getPermissionAction(permissionName) {
4
- const permissionNameParts = permissionName.split(':');
5
- const fullActionName = permissionNameParts.lastObject;
6
- const actions = [
7
- 'create',
8
- 'update',
9
- 'delete',
10
- 'deactivate',
11
- 'get',
12
- 'list',
13
- 'cancel',
14
- 'optimize',
15
- 'roll',
16
- 'export',
17
- 'batch_delete',
18
- 'batch_cancel',
19
- 'notify',
20
- 'assign_vehicle',
21
- 'assign_order_to',
22
- 'dispatch_order_to',
23
- 'dispatch',
24
- 'assign',
25
- 'attach',
26
- 'sub_contract',
27
- 'create_order_for',
28
- ];
29
-
30
- if (permissionName.startsWith('auth')) {
31
- return fullActionName;
32
- }
33
-
34
- if (fullActionName === '*') {
35
- return 'All';
36
- }
37
-
38
- for (let i = 0; i < actions.length; i++) {
39
- const action = actions.objectAt(i);
40
-
41
- if (fullActionName.toLowerCase().startsWith(classify(action).toLowerCase())) {
42
- return classify(action);
43
- }
44
- }
45
-
46
- return 'N/A';
47
- }
@@ -1,16 +0,0 @@
1
- import getPermissionAction from './get-permission-action';
2
- import { classify } from '@ember/string';
3
- import { singularize } from 'ember-inflector';
4
-
5
- export default function getPermissionResource(permissionName = '') {
6
- if (permissionName.startsWith('auth')) {
7
- return 'N/A';
8
- }
9
-
10
- const permissionNameParts = permissionName.split(':');
11
- const fullActionName = permissionNameParts.lastObject;
12
- const actionName = getPermissionAction(permissionName);
13
- const resourceName = fullActionName.replace(actionName, '');
14
-
15
- return singularize(classify(resourceName));
16
- }
@@ -1,21 +0,0 @@
1
- // import { classify } from '@ember/string';
2
-
3
- export default function getServiceName(serviceName) {
4
- if (serviceName.toLowerCase().startsWith('fleet')) {
5
- return 'Fleet Ops';
6
- }
7
-
8
- if (serviceName.toLowerCase().startsWith('iam') || serviceName.toLowerCase().startsWith('identity')) {
9
- return 'IAM';
10
- }
11
-
12
- if (serviceName.toLowerCase().startsWith('auth')) {
13
- return 'Auth';
14
- }
15
-
16
- if (serviceName === 'developers' || serviceName.toLowerCase().startsWith('developers')) {
17
- return 'Developers Console';
18
- }
19
-
20
- return 'N/A';
21
- }
@@ -1 +0,0 @@
1
- export { default } from '@fleetbase/ember-core/utils/get-permission-action';
@@ -1 +0,0 @@
1
- export { default } from '@fleetbase/ember-core/utils/get-permission-resource';
@@ -1 +0,0 @@
1
- export { default } from '@fleetbase/ember-core/utils/get-service-name';