Skip to content

Commit f7d8e3a

Browse files
authored
Merge pull request #70 from fleetbase/dev-v0.3.10
Remove usage of `window.Fleetbase`
2 parents ac75087 + b967b46 commit f7d8e3a

File tree

8 files changed

+32
-35
lines changed

8 files changed

+32
-35
lines changed

addon/library/subject-custom-fields.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export default class SubjectCustomFields {
242242
let existingMany = subject.hasMany?.('custom_field_values')?.value?.() ?? null;
243243

244244
// If asked or not loaded, fetch from API (scoped to subject)
245-
if (reloadExisting || !existingMany) {
245+
if ((reloadExisting || !existingMany) && subjectId) {
246246
try {
247247
existingMany = await this.store.query('custom-field-value', {
248248
subject_uuid: subjectId,

addon/services/legacy-universe.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ export default class LegacyUniverseService extends Service.extend(Evented) {
155155
* @return {void}
156156
*/
157157
setApplicationInstance(instance) {
158-
window.Fleetbase = instance;
159158
this.applicationInstance = instance;
160159
}
161160

addon/services/universe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export default class UniverseService extends Service.extend(Evented) {
212212
* @returns {ApplicationInstance} The application instance
213213
*/
214214
getApplicationInstance() {
215-
return this.applicationInstance ?? window.Fleetbase;
215+
return this.applicationInstance;
216216
}
217217

218218
/**

addon/services/universe/extension-manager.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Service from '@ember/service';
1+
import Service, { inject as service } from '@ember/service';
22
import Evented from '@ember/object/evented';
33
import { tracked } from '@glimmer/tracking';
44
import { getOwner } from '@ember/application';
@@ -22,6 +22,7 @@ import ExtensionBootState from '../../contracts/extension-boot-state';
2222
* @extends Service
2323
*/
2424
export default class ExtensionManagerService extends Service.extend(Evented) {
25+
@service universe;
2526
/**
2627
* Reference to the root Ember Application Instance.
2728
* Used for registering components/services to the application container
@@ -84,14 +85,14 @@ export default class ExtensionManagerService extends Service.extend(Evented) {
8485
* @returns {Application}
8586
*/
8687
#getApplication() {
87-
// First priority: use applicationInstance if set
88-
if (this.applicationInstance) {
89-
return this.applicationInstance;
88+
// First priority use the universe application instance
89+
if (this.universe.applicationInstance) {
90+
return this.universe.applicationInstance;
9091
}
9192

92-
// Second priority: window.Fleetbase
93-
if (typeof window !== 'undefined' && window.Fleetbase) {
94-
return window.Fleetbase;
93+
// Second priority: use applicationInstance if set
94+
if (this.applicationInstance) {
95+
return this.applicationInstance;
9596
}
9697

9798
// Third priority: try to get application from owner

addon/services/universe/hook-service.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Service from '@ember/service';
1+
import Service, { inject as service } from '@ember/service';
22
import { tracked } from '@glimmer/tracking';
33
import { getOwner } from '@ember/application';
44
import Hook from '../../contracts/hook';
@@ -14,6 +14,8 @@ import HookRegistry from '../../contracts/hook-registry';
1414
* @extends Service
1515
*/
1616
export default class HookService extends Service {
17+
@service universe;
18+
1719
/**
1820
* Reference to the root Ember Application Instance.
1921
* Used for registering components/services to the application container
@@ -69,14 +71,14 @@ export default class HookService extends Service {
6971
* @returns {Application}
7072
*/
7173
#getApplication() {
72-
// First priority: use applicationInstance if set
73-
if (this.applicationInstance) {
74-
return this.applicationInstance;
74+
// First priority use the universe application instance
75+
if (this.universe.applicationInstance) {
76+
return this.universe.applicationInstance;
7577
}
7678

77-
// Second priority: window.Fleetbase
78-
if (typeof window !== 'undefined' && window.Fleetbase) {
79-
return window.Fleetbase;
79+
// Second priority: use applicationInstance if set
80+
if (this.applicationInstance) {
81+
return this.applicationInstance;
8082
}
8183

8284
// Third priority: try to get application from owner

addon/services/universe/registry-service.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,16 @@ export default class RegistryService extends Service {
8282
let application = this.applicationInstance;
8383

8484
if (!application) {
85-
// Second priority: window.Fleetbase
86-
if (typeof window !== 'undefined' && window.Fleetbase) {
87-
application = window.Fleetbase;
85+
// Second priority: try to get from owner
86+
const owner = getOwner(this);
87+
if (owner && owner.application) {
88+
application = owner.application;
8889
} else {
89-
// Third priority: try to get from owner
90-
const owner = getOwner(this);
91-
if (owner && owner.application) {
92-
application = owner.application;
93-
} else {
94-
warn('[RegistryService] Could not find application instance for registry initialization', {
95-
id: 'registry-service.no-application',
96-
});
97-
// Return a new instance as fallback (won't be shared)
98-
return new UniverseRegistry();
99-
}
90+
warn('[RegistryService] Could not find application instance for registry initialization', {
91+
id: 'registry-service.no-application',
92+
});
93+
// Return a new instance as fallback (won't be shared)
94+
return new UniverseRegistry();
10095
}
10196
}
10297

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

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

544539
if (!owner) {
545540
return null;

addon/utils/inject-engine-service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function automaticServiceResolution(service, target, owner) {
3535
}
3636

3737
function _getOwner(target) {
38-
return window.Fleetbase ?? getOwner(target);
38+
return getOwner(target);
3939
}
4040

4141
export default function injectEngineService(target, engineName, serviceName, options = {}) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fleetbase/ember-core",
3-
"version": "0.3.9",
3+
"version": "0.3.10",
44
"description": "Provides all the core services, decorators and utilities for building a Fleetbase extension for the Console.",
55
"keywords": [
66
"fleetbase-core",

0 commit comments

Comments
 (0)