@fleetbase/ember-core 0.2.2 → 0.2.3

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.
@@ -268,6 +268,42 @@ export default class UniverseService extends Service.extend(Evented) {
268
268
  return this;
269
269
  }
270
270
 
271
+ /**
272
+ * Creates multiple registries from a given array of registries. Each registry can be either a string or an array.
273
+ * If a registry is an array, it expects two elements: the registry name (string) and registry options (object).
274
+ * If a registry is a string, only the registry name is needed.
275
+ *
276
+ * The function iterates over each element in the `registries` array and creates a registry using the `createRegistry` method.
277
+ * It supports two types of registry definitions:
278
+ * 1. Array format: [registryName, registryOptions] - where registryOptions is an optional object.
279
+ * 2. String format: "registryName" - in this case, only the name is provided and the registry is created with default options.
280
+ *
281
+ * @param {Array} registries - An array of registries to be created. Each element can be either a string or an array.
282
+ * @action
283
+ * @memberof YourComponentOrClassName
284
+ */
285
+ @action createRegistries(registries = []) {
286
+ if (!isArray(registries)) {
287
+ throw new Error('`createRegistries()` method must take an array.');
288
+ }
289
+
290
+ for (let i = 0; i < registries.length; i++) {
291
+ const registry = registries[i];
292
+
293
+ if (isArray(registry) && registry.length === 2) {
294
+ let registryName = registry[0];
295
+ let registryOptions = registry[1] ?? {};
296
+
297
+ this.createRegistry(registryName, registryOptions);
298
+ continue;
299
+ }
300
+
301
+ if (typeof registry === 'string') {
302
+ this.createRegistry(registry);
303
+ }
304
+ }
305
+ }
306
+
271
307
  /**
272
308
  * Triggers an event on for a universe registry.
273
309
  *
@@ -741,7 +777,19 @@ export default class UniverseService extends Service.extend(Evented) {
741
777
  */
742
778
  _createDashboardWidget(widget) {
743
779
  // Extract properties from the widget object
744
- const { did, name, description, icon, component, grid_options, options } = widget;
780
+ let { did, name, description, icon, component, grid_options, options } = widget;
781
+
782
+ // If component is a definition register to host application
783
+ if (typeof component === 'function') {
784
+ const owner = getOwner(this);
785
+
786
+ if (owner) {
787
+ owner.register(`component:${component.name}`, component);
788
+
789
+ // Update component name
790
+ component = component.name;
791
+ }
792
+ }
745
793
 
746
794
  // Create a new widget object with the extracted properties
747
795
  const newWidget = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetbase/ember-core",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Provides all the core services, decorators and utilities for building a Fleetbase extension for the Console.",
5
5
  "keywords": [
6
6
  "fleetbase-core",