Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addon/library/subject-custom-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class SubjectCustomFields {
let existingMany = subject.hasMany?.('custom_field_values')?.value?.() ?? null;

// If asked or not loaded, fetch from API (scoped to subject)
if (reloadExisting || !existingMany) {
if ((reloadExisting || !existingMany) && subjectId) {
try {
existingMany = await this.store.query('custom-field-value', {
subject_uuid: subjectId,
Expand Down
1 change: 0 additions & 1 deletion addon/services/legacy-universe.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export default class LegacyUniverseService extends Service.extend(Evented) {
* @return {void}
*/
setApplicationInstance(instance) {
window.Fleetbase = instance;
this.applicationInstance = instance;
}

Expand Down
2 changes: 1 addition & 1 deletion addon/services/universe.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export default class UniverseService extends Service.extend(Evented) {
* @returns {ApplicationInstance} The application instance
*/
getApplicationInstance() {
return this.applicationInstance ?? window.Fleetbase;
return this.applicationInstance;
}

/**
Expand Down
15 changes: 8 additions & 7 deletions addon/services/universe/extension-manager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Service from '@ember/service';
import Service, { inject as service } from '@ember/service';
import Evented from '@ember/object/evented';
import { tracked } from '@glimmer/tracking';
import { getOwner } from '@ember/application';
Expand All @@ -22,6 +22,7 @@ import ExtensionBootState from '../../contracts/extension-boot-state';
* @extends Service
*/
export default class ExtensionManagerService extends Service.extend(Evented) {
@service universe;
/**
* Reference to the root Ember Application Instance.
* Used for registering components/services to the application container
Expand Down Expand Up @@ -84,14 +85,14 @@ export default class ExtensionManagerService extends Service.extend(Evented) {
* @returns {Application}
*/
#getApplication() {
// First priority: use applicationInstance if set
if (this.applicationInstance) {
return this.applicationInstance;
// First priority use the universe application instance
if (this.universe.applicationInstance) {
return this.universe.applicationInstance;
}

// Second priority: window.Fleetbase
if (typeof window !== 'undefined' && window.Fleetbase) {
return window.Fleetbase;
// Second priority: use applicationInstance if set
if (this.applicationInstance) {
return this.applicationInstance;
}

// Third priority: try to get application from owner
Expand Down
16 changes: 9 additions & 7 deletions addon/services/universe/hook-service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Service from '@ember/service';
import Service, { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { getOwner } from '@ember/application';
import Hook from '../../contracts/hook';
Expand All @@ -14,6 +14,8 @@ import HookRegistry from '../../contracts/hook-registry';
* @extends Service
*/
export default class HookService extends Service {
@service universe;

/**
* Reference to the root Ember Application Instance.
* Used for registering components/services to the application container
Expand Down Expand Up @@ -69,14 +71,14 @@ export default class HookService extends Service {
* @returns {Application}
*/
#getApplication() {
// First priority: use applicationInstance if set
if (this.applicationInstance) {
return this.applicationInstance;
// First priority use the universe application instance
if (this.universe.applicationInstance) {
return this.universe.applicationInstance;
}

// Second priority: window.Fleetbase
if (typeof window !== 'undefined' && window.Fleetbase) {
return window.Fleetbase;
// Second priority: use applicationInstance if set
if (this.applicationInstance) {
return this.applicationInstance;
}

// Third priority: try to get application from owner
Expand Down
27 changes: 11 additions & 16 deletions addon/services/universe/registry-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,16 @@ export default class RegistryService extends Service {
let application = this.applicationInstance;

if (!application) {
// Second priority: window.Fleetbase
if (typeof window !== 'undefined' && window.Fleetbase) {
application = window.Fleetbase;
// Second priority: try to get from owner
const owner = getOwner(this);
if (owner && owner.application) {
application = owner.application;
} else {
// Third priority: try to get from owner
const owner = getOwner(this);
if (owner && owner.application) {
application = owner.application;
} else {
warn('[RegistryService] Could not find application instance for registry initialization', {
id: 'registry-service.no-application',
});
// Return a new instance as fallback (won't be shared)
return new UniverseRegistry();
}
warn('[RegistryService] Could not find application instance for registry initialization', {
id: 'registry-service.no-application',
});
// Return a new instance as fallback (won't be shared)
return new UniverseRegistry();
}
}

Expand Down Expand Up @@ -489,7 +484,7 @@ export default class RegistryService extends Service {
* );
*/
async registerHelper(helperName, helperClassOrTemplateHelper, options = {}) {
const owner = this.applicationInstance || (typeof window !== 'undefined' && window.Fleetbase) || getOwner(this);
const owner = this.applicationInstance || getOwner(this);

if (!owner) {
warn('No owner available for helper registration. Cannot register helper.', {
Expand Down Expand Up @@ -539,7 +534,7 @@ export default class RegistryService extends Service {
* @returns {Promise<Function|Class|null>} The loaded helper or null if failed
*/
async #loadHelperFromEngine(templateHelper) {
const owner = this.applicationInstance || (typeof window !== 'undefined' && window.Fleetbase) || getOwner(this);
const owner = this.applicationInstance || getOwner(this);

if (!owner) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion addon/utils/inject-engine-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function automaticServiceResolution(service, target, owner) {
}

function _getOwner(target) {
return window.Fleetbase ?? getOwner(target);
return getOwner(target);
}

export default function injectEngineService(target, engineName, serviceName, options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/ember-core",
"version": "0.3.9",
"version": "0.3.10",
"description": "Provides all the core services, decorators and utilities for building a Fleetbase extension for the Console.",
"keywords": [
"fleetbase-core",
Expand Down
Loading