chore: 🤖 upgrade ember-data to v5.3.11 (#2745)
* chore: 🤖 upgrade ember-data to v5.3.11 * Add missing copyright headers * refactor: 💡 remove comment * chore: 🤖 update yarn.lock due to merge conflict ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * fix: 🐛 undo ember-source upgrade (should be upgraded w/ ember) ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * chore: 🤖 move dep to devDeps & resolve test-helper version ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * fix: 🐛 unique record id error bug fix using store.push ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * refactor: 💡 cleanup ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * Delete old deprecation initializer (#2748) * refactor: 💡 import from'ember-data/store' ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * refactor: 💡 clean up comments ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * refactor: 💡 remove compatWith comment ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 --------- Co-authored-by: Carlos Alcaide Corvo <ccorvo@hashicorp.com>
This commit is contained in:
1 parent
834058ff45
commit
9dd1617b57
30 files changed
+598
-636
No files matched your search
@@ -43,7 +43,10 @@ const fetchControllerData = async (context, next) => {
|
||||
// If we get an error or cache daemon is unavailable, fall back to calling the API
|
||||
context.request.data.query = remainingQuery;
|
||||
const results = await next(context.request);
|
||||
const models = results.content.toArray();
|
||||
|
||||
// As a result of https://rfcs.emberjs.com/id/0846-ember-data-deprecate-proxies/ we cannot use proxy array methods like .toArray
|
||||
// use slice() instead as indicated in the RFC.
|
||||
const models = results.content.slice();
|
||||
|
||||
const paginatedResult = paginateResults(models, page, pageSize);
|
||||
paginatedResult.meta = { totalItems: models.length };
|
||||
|
||||
@@ -244,12 +244,10 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
* @return {object}
|
||||
*/
|
||||
normalizeMissingArrays(store, primaryModelClass, payload) {
|
||||
const attrDefs = store
|
||||
.getSchemaDefinitionService()
|
||||
.attributesDefinitionFor({ type: primaryModelClass.modelName });
|
||||
const attrDefs = store.schema.fields({ type: primaryModelClass.modelName });
|
||||
if (attrDefs) {
|
||||
Object.keys(attrDefs).forEach((key) => {
|
||||
if (!payload[key] && attrDefs[key]?.options?.emptyArrayIfMissing) {
|
||||
attrDefs.keys().forEach((key) => {
|
||||
if (!payload[key] && attrDefs.get(key)?.options?.emptyArrayIfMissing) {
|
||||
payload[key] = [];
|
||||
}
|
||||
});
|
||||
@@ -268,12 +266,10 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
* @return {object}
|
||||
*/
|
||||
normalizeMissingObjects(store, primaryModelClass, payload) {
|
||||
const attrDefs = store
|
||||
.getSchemaDefinitionService()
|
||||
.attributesDefinitionFor({ type: primaryModelClass.modelName });
|
||||
const attrDefs = store.schema.fields({ type: primaryModelClass.modelName });
|
||||
if (attrDefs) {
|
||||
Object.keys(attrDefs).forEach((key) => {
|
||||
if (!payload[key] && attrDefs[key]?.options?.emptyObjectIfMissing) {
|
||||
attrDefs.keys().forEach((key) => {
|
||||
if (!payload[key] && attrDefs.get(key)?.options?.emptyObjectIfMissing) {
|
||||
payload[key] = {};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Store, { CacheHandler } from '@ember-data/store';
|
||||
// Importing 'Store' from 'ember-data/store' to get default configuration automatically.
|
||||
// TODO: Remove eslint-disable after upgrading to eslint-plugin-ember >= v12.2.1
|
||||
// eslint-disable-next-line ember/use-ember-data-rfc-395-imports
|
||||
import Store from 'ember-data/store';
|
||||
import { CacheHandler } from '@ember-data/store';
|
||||
import RequestManager from '@ember-data/request';
|
||||
import { LegacyNetworkHandler } from '@ember-data/legacy-compat';
|
||||
import IndexedDbHandler from 'api/handlers/indexed-db-handler';
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Transform from '@ember-data/serializer/transform';
|
||||
|
||||
export default class AccountValueMapArrayTransform extends Transform {
|
||||
export default class AccountValueMapArrayTransform {
|
||||
deserialize(serialized) {
|
||||
const accountValues = serialized || [];
|
||||
return accountValues.map((accountValueString) => ({
|
||||
@@ -18,4 +16,8 @@ export default class AccountValueMapArrayTransform extends Transform {
|
||||
const accountValues = deserialized || [];
|
||||
return accountValues.map(({ key, value }) => `${key}=${value}`);
|
||||
}
|
||||
|
||||
static create() {
|
||||
return new this();
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,9 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Transform from '@ember-data/serializer/transform';
|
||||
import { TrackedArray } from 'tracked-built-ins';
|
||||
|
||||
export default class ArrayTransform extends Transform {
|
||||
export default class ArrayTransform {
|
||||
deserialize(serialized) {
|
||||
const arr = new TrackedArray(serialized || []);
|
||||
return arr;
|
||||
@@ -16,4 +15,8 @@ export default class ArrayTransform extends Transform {
|
||||
const arr = deserialized || [];
|
||||
return arr;
|
||||
}
|
||||
|
||||
static create() {
|
||||
return new this();
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,7 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Transform from '@ember-data/serializer/transform';
|
||||
|
||||
export default class DurationTransform extends Transform {
|
||||
export default class DurationTransform {
|
||||
/**
|
||||
* Normalize a duration string in the format "3.0001s" to milliseconds.
|
||||
* The backend returns a precision of nanoseconds but we round to whole
|
||||
@@ -37,4 +35,8 @@ export default class DurationTransform extends Transform {
|
||||
maximumFractionDigits: 9,
|
||||
})}s`;
|
||||
}
|
||||
|
||||
static create() {
|
||||
return new this();
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,7 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Transform from '@ember-data/serializer/transform';
|
||||
|
||||
export default class HostSourceIdArrayTransform extends Transform {
|
||||
export default class HostSourceIdArrayTransform {
|
||||
deserialize(serialized) {
|
||||
const stringValues = serialized || [];
|
||||
return stringValues.map(({ id: host_source_id, ...obj }) => ({
|
||||
@@ -18,4 +16,8 @@ export default class HostSourceIdArrayTransform extends Transform {
|
||||
const strings = deserialized || [];
|
||||
return strings.map(({ host_source_id: id, ...obj }) => ({ id, ...obj }));
|
||||
}
|
||||
|
||||
static create() {
|
||||
return new this();
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,12 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Transform from '@ember-data/serializer/transform';
|
||||
|
||||
export default class ObjectAsArrayTransform extends Transform {
|
||||
export default class ObjectAsArrayTransform {
|
||||
deserialize(serialized) {
|
||||
const obj = serialized || {};
|
||||
return Object.entries(obj).map(([key, value]) => ({ key, value }));
|
||||
}
|
||||
|
||||
serialize(deserialized) {
|
||||
const array = deserialized || [];
|
||||
|
||||
@@ -24,4 +23,8 @@ export default class ObjectAsArrayTransform extends Transform {
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
static create() {
|
||||
return new this();
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,9 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Transform from '@ember-data/serializer/transform';
|
||||
import { TrackedObject } from 'tracked-built-ins';
|
||||
|
||||
export default class ObjectTransform extends Transform {
|
||||
export default class ObjectTransform {
|
||||
/**
|
||||
* @param serialized
|
||||
* @returns {object}
|
||||
@@ -26,4 +25,8 @@ export default class ObjectTransform extends Transform {
|
||||
}
|
||||
return deserialized;
|
||||
}
|
||||
|
||||
static create() {
|
||||
return new this();
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,7 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Transform from '@ember-data/serializer/transform';
|
||||
|
||||
export default class StringArrayTransform extends Transform {
|
||||
export default class StringArrayTransform {
|
||||
deserialize(serialized) {
|
||||
const stringValues = serialized || [];
|
||||
return stringValues.map((value) => ({ value }));
|
||||
@@ -15,4 +13,8 @@ export default class StringArrayTransform extends Transform {
|
||||
const strings = deserialized || [];
|
||||
return strings.map(({ value }) => value);
|
||||
}
|
||||
|
||||
static create() {
|
||||
return new this();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
// Ember-data no longer automatically installs BooleanTransform for apps.
|
||||
export { BooleanTransform as default } from '@ember-data/serializer/transform';
|
||||
@@ -3,4 +3,4 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
export { default, initialize } from 'core/initializers/deprecations';
|
||||
export { DateTransform as default } from '@ember-data/serializer/transform';
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
export { NumberTransform as default } from '@ember-data/serializer/transform';
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
// Ember-data no longer automatically installs StringTransform for apps.
|
||||
export { StringTransform as default } from '@ember-data/serializer/transform';
|
||||
@@ -24,22 +24,23 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"dexie": "^3.2.4",
|
||||
"ember-auto-import": "^2.8.1",
|
||||
"ember-auto-import": "^2.10.0",
|
||||
"ember-can": "^4.2.0",
|
||||
"ember-cli-babel": "^8.2.0",
|
||||
"ember-cli-htmlbars": "^6.2.0",
|
||||
"ember-cli-mirage": "^3.0.3",
|
||||
"ember-data": "~4.12.0",
|
||||
"ember-data": "~5.3.12",
|
||||
"miragejs": "^0.1.48",
|
||||
"tracked-built-ins": "^3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/core": "^7.26.10",
|
||||
"@babel/eslint-parser": "^7.21.3",
|
||||
"@babel/plugin-proposal-decorators": "^7.21.0",
|
||||
"@ember/optional-features": "^2.0.0",
|
||||
"@ember/string": "^3.0.1",
|
||||
"@ember/test-helpers": "^4.0.4",
|
||||
"@ember/test-helpers": "^4.0.5",
|
||||
"@ember/test-waiters": "^4.1.0",
|
||||
"@embroider/test-setup": "^2.1.1",
|
||||
"@faker-js/faker": "^8.0.2",
|
||||
"@glimmer/component": "^1.1.2",
|
||||
|
||||
@@ -21,19 +21,19 @@
|
||||
"doc:toc": "doctoc README.md"
|
||||
},
|
||||
"dependencies": {
|
||||
"ember-auto-import": "2.8.1",
|
||||
"@ember/test-waiters": "^4.1.0",
|
||||
"ember-auto-import": "^2.10.0",
|
||||
"ember-cli-babel": "^8.2.0",
|
||||
"ember-cli-htmlbars": "^6.2.0",
|
||||
"ember-simple-auth": "^6.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/core": "^7.26.10",
|
||||
"@babel/eslint-parser": "^7.21.3",
|
||||
"@babel/plugin-proposal-decorators": "^7.21.0",
|
||||
"@ember/optional-features": "^2.0.0",
|
||||
"@ember/string": "^3.0.1",
|
||||
"@ember/test-helpers": "^4.0.4",
|
||||
"@ember/test-waiters": "^3.1.0",
|
||||
"@ember/test-helpers": "^4.0.5",
|
||||
"@embroider/test-setup": "^2.1.1",
|
||||
"@glimmer/component": "^1.1.2",
|
||||
"@glimmer/tracking": "^1.1.2",
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import { registerDeprecationHandler } from '@ember/debug';
|
||||
|
||||
const deprecationList = [
|
||||
'ember-data:deprecate-early-static',
|
||||
'ember-data:deprecate-array-like',
|
||||
];
|
||||
|
||||
export function initialize() {
|
||||
registerDeprecationHandler((message, options, next) => {
|
||||
// TODO: fix `deprecate-early-static` and `deprecate-array-prototype-extension` warning before ember 5 upgrade
|
||||
//silence deprecate-early-static warnings till we find a way to
|
||||
//fix ember-cli-mirage discoverEmberDataModels
|
||||
if (options?.id && deprecationList.includes(options.id)) {
|
||||
return;
|
||||
}
|
||||
if (options?.url) {
|
||||
message += options.url;
|
||||
}
|
||||
next(message, options);
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
initialize,
|
||||
};
|
||||
@@ -34,7 +34,7 @@
|
||||
"@formatjs/intl-durationformat": "^0.2.4",
|
||||
"api": "*",
|
||||
"auth": "*",
|
||||
"ember-auto-import": "^2.8.1",
|
||||
"ember-auto-import": "^2.10.0",
|
||||
"ember-browser-services": "^4.0.3",
|
||||
"ember-cli-babel": "^8.2.0",
|
||||
"ember-cli-htmlbars": "^6.2.0",
|
||||
@@ -49,12 +49,12 @@
|
||||
"sass": "^1.69.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/core": "^7.26.10",
|
||||
"@babel/eslint-parser": "^7.21.3",
|
||||
"@babel/plugin-proposal-decorators": "^7.21.0",
|
||||
"@ember/optional-features": "^2.0.0",
|
||||
"@ember/string": "^3.0.1",
|
||||
"@ember/test-helpers": "^4.0.4",
|
||||
"@ember/test-helpers": "^4.0.5",
|
||||
"@embroider/test-setup": "^2.1.1",
|
||||
"@faker-js/faker": "^8.0.2",
|
||||
"@glimmer/component": "^1.1.2",
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Application from '@ember/application';
|
||||
|
||||
import config from 'dummy/config/environment';
|
||||
import { initialize } from 'dummy/initializers/deprecations';
|
||||
import { module, test } from 'qunit';
|
||||
import Resolver from 'ember-resolver';
|
||||
import { run } from '@ember/runloop';
|
||||
|
||||
module('Unit | Initializer | deprecations', function (hooks) {
|
||||
hooks.beforeEach(function () {
|
||||
this.TestApplication = class TestApplication extends Application {
|
||||
modulePrefix = config.modulePrefix;
|
||||
podModulePrefix = config.podModulePrefix;
|
||||
Resolver = Resolver;
|
||||
};
|
||||
this.TestApplication.initializer({
|
||||
name: 'initializer under test',
|
||||
initialize,
|
||||
});
|
||||
|
||||
this.application = this.TestApplication.create({ autoboot: false });
|
||||
});
|
||||
|
||||
hooks.afterEach(function () {
|
||||
run(this.application, 'destroy');
|
||||
});
|
||||
|
||||
test('it works', async function (assert) {
|
||||
await this.application.boot();
|
||||
|
||||
assert.ok(true);
|
||||
});
|
||||
});
|
||||
@@ -32,7 +32,7 @@
|
||||
"@embroider/test-setup": "^2.1.1",
|
||||
"@hashicorp/design-system-components": "^4.13.0",
|
||||
"codemirror": "5.65.7",
|
||||
"ember-auto-import": "^2.8.1",
|
||||
"ember-auto-import": "^2.10.0",
|
||||
"ember-cli-babel": "^8.2.0",
|
||||
"ember-cli-clipboard": "^1.2.1",
|
||||
"ember-cli-htmlbars": "^6.2.0",
|
||||
@@ -45,12 +45,12 @@
|
||||
"uuid": "^11.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/core": "^7.26.10",
|
||||
"@babel/eslint-parser": "^7.21.3",
|
||||
"@babel/plugin-proposal-decorators": "^7.21.0",
|
||||
"@ember/optional-features": "^2.0.0",
|
||||
"@ember/string": "^3.0.1",
|
||||
"@ember/test-helpers": "^4.0.4",
|
||||
"@ember/test-helpers": "^4.0.5",
|
||||
"@glimmer/component": "^1.1.2",
|
||||
"@glimmer/tracking": "^1.1.2",
|
||||
"babel-loader": "^9.2.1",
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"desktop:dev": "yarn playwright test --config desktop/playwright.config.js --reporter=html"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/core": "^7.26.10",
|
||||
"@babel/eslint-parser": "^7.21.3",
|
||||
"@playwright/test": "^1.49.0",
|
||||
"concurrently": "^9.1.0",
|
||||
|
||||
@@ -29,12 +29,12 @@ export default class ScopesScopeRoute extends Route {
|
||||
async model({ scope_id: id }) {
|
||||
// Since only global and org scopes are authenticatable, we can infer type
|
||||
// from ID because global has a fixed ID.
|
||||
const type = id === 'global' ? TYPE_SCOPE_GLOBAL : TYPE_SCOPE_ORG;
|
||||
return this.store.findRecord('scope', id).catch(() => {
|
||||
const type = id === 'global' ? TYPE_SCOPE_GLOBAL : TYPE_SCOPE_ORG;
|
||||
const maybeExistingScope = this.store.peekRecord('scope', id);
|
||||
const scopeOptions = { id, type };
|
||||
return (
|
||||
maybeExistingScope || this.store.createRecord('scope', scopeOptions)
|
||||
maybeExistingScope ||
|
||||
this.store.push({ data: { id, type: 'scope', attributes: { type } } })
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
|
||||
|
||||
module.exports = function (defaults) {
|
||||
module.exports = async function (defaults) {
|
||||
const { setConfig } = await import('@warp-drive/build-config');
|
||||
|
||||
const app = new EmberApp(defaults, {
|
||||
hinting: false,
|
||||
'ember-cli-babel': {
|
||||
@@ -36,10 +38,15 @@ module.exports = function (defaults) {
|
||||
},
|
||||
},
|
||||
},
|
||||
// TODO: Update to 4.12 when deprecations are resolved
|
||||
// as multiple things break when forcing compatibility on > 4.6
|
||||
emberData: {
|
||||
compatWith: '4.6',
|
||||
});
|
||||
|
||||
// TODO: This config can be removed in ember-data 6.0.
|
||||
// This silences ember-data deprecate warnings by setting to false to
|
||||
// strip the deprecated code (thereby opting into the new behavior).
|
||||
setConfig(app, __dirname, {
|
||||
deprecations: {
|
||||
DEPRECATE_STORE_EXTENDS_EMBER_OBJECT: false,
|
||||
DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE: false,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -41,25 +41,26 @@
|
||||
"uuid": "^11.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/core": "^7.26.10",
|
||||
"@babel/eslint-parser": "^7.21.3",
|
||||
"@babel/plugin-proposal-decorators": "^7.21.0",
|
||||
"@ember/optional-features": "^2.0.0",
|
||||
"@ember/render-modifiers": "^2.0.4",
|
||||
"@ember/string": "^3.0.1",
|
||||
"@ember/test-helpers": "^4.0.4",
|
||||
"@ember/test-helpers": "^4.0.5",
|
||||
"@embroider/macros": "^1.16.9",
|
||||
"@faker-js/faker": "^8.0.2",
|
||||
"@glimmer/component": "^1.1.2",
|
||||
"@glimmer/tracking": "^1.1.2",
|
||||
"@hashicorp/ember-asciinema-player": "https://github.com/hashicorp/ember-asciinema-player.git#e047a096039cff70234c232efe75dcad74c6358a",
|
||||
"@warp-drive/build-config": "^0.0.2",
|
||||
"babel-loader": "^9.2.1",
|
||||
"broccoli-asset-rev": "^3.0.0",
|
||||
"concurrently": "^9.1.0",
|
||||
"core": "*",
|
||||
"doctoc": "^2.2.0",
|
||||
"ember-a11y-testing": "^7.0.0",
|
||||
"ember-auto-import": "^2.8.1",
|
||||
"ember-auto-import": "^2.10.0",
|
||||
"ember-cli": "^5.12.0",
|
||||
"ember-cli-babel": "^8.2.0",
|
||||
"ember-cli-code-coverage": "^1.0.3",
|
||||
|
||||
@@ -21,7 +21,7 @@ module('Acceptance | onboarding', function (hooks) {
|
||||
orgs: '/scopes/global/scopes',
|
||||
};
|
||||
|
||||
hooks.beforeEach(async () => {
|
||||
hooks.beforeEach(async function () {
|
||||
await authenticateSession({});
|
||||
});
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { service } from '@ember/service';
|
||||
import { A } from '@ember/array';
|
||||
import { TYPE_SCOPE_GLOBAL, TYPE_SCOPE_ORG } from 'api/models/scope';
|
||||
|
||||
export default class ScopesScopeRoute extends Route {
|
||||
// =services
|
||||
@@ -27,19 +28,20 @@ export default class ScopesScopeRoute extends Route {
|
||||
* @param {string} params.scope_id
|
||||
* @return {Promise{ScopeModel}}
|
||||
*/
|
||||
model({ scope_id: id }) {
|
||||
async model({ scope_id: id }) {
|
||||
// Since only global and org scopes are authenticatable, we can infer type
|
||||
// from ID because global has a fixed ID.
|
||||
const type = id === 'global' ? 'global' : 'org';
|
||||
const type = id === 'global' ? TYPE_SCOPE_GLOBAL : TYPE_SCOPE_ORG;
|
||||
return this.store.findRecord('scope', id).catch(() => {
|
||||
const maybeExistingScope = this.store.peekRecord('scope', id);
|
||||
const scopeOptions = { id, type };
|
||||
const attributes = { type };
|
||||
/* istanbul ignore else */
|
||||
if (type === 'global') {
|
||||
scopeOptions.name = this.intl.t('titles.global');
|
||||
attributes.name = this.intl.t('titles.global');
|
||||
}
|
||||
return (
|
||||
maybeExistingScope || this.store.createRecord('scope', scopeOptions)
|
||||
maybeExistingScope ||
|
||||
this.store.push({ data: { id, type: 'scope', attributes } })
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Store, { CacheHandler } from '@ember-data/store';
|
||||
// Importing 'Store' from 'ember-data/store' to get default configuration automatically.
|
||||
// TODO: Remove eslint-disable after upgrading to eslint-plugin-ember >= v12.2.1
|
||||
// eslint-disable-next-line ember/use-ember-data-rfc-395-imports
|
||||
import Store from 'ember-data/store';
|
||||
import { CacheHandler } from '@ember-data/store';
|
||||
import RequestManager from '@ember-data/request';
|
||||
import { LegacyNetworkHandler } from '@ember-data/legacy-compat';
|
||||
import CacheDaemonHandler from 'api/handlers/cache-daemon-handler';
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
|
||||
|
||||
module.exports = function (defaults) {
|
||||
module.exports = async function (defaults) {
|
||||
const { setConfig } = await import('@warp-drive/build-config');
|
||||
|
||||
const app = new EmberApp(defaults, {
|
||||
hinting: false,
|
||||
'ember-cli-babel': {
|
||||
@@ -38,6 +40,16 @@ module.exports = function (defaults) {
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: This config can be removed in ember-data 6.0.
|
||||
// This silences ember-data deprecate warnings by setting to false to
|
||||
// strip the deprecated code (thereby opting into the new behavior).
|
||||
setConfig(app, __dirname, {
|
||||
deprecations: {
|
||||
DEPRECATE_STORE_EXTENDS_EMBER_OBJECT: false,
|
||||
DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE: false,
|
||||
},
|
||||
});
|
||||
|
||||
// Use `app.import` to add additional libraries to the generated
|
||||
// output files.
|
||||
//
|
||||
|
||||
@@ -47,17 +47,18 @@
|
||||
"uuid": "^11.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/core": "^7.26.10",
|
||||
"@babel/eslint-parser": "^7.21.3",
|
||||
"@babel/plugin-proposal-decorators": "^7.21.0",
|
||||
"@ember/optional-features": "^2.0.0",
|
||||
"@ember/render-modifiers": "^2.0.4",
|
||||
"@ember/string": "^3.0.1",
|
||||
"@ember/test-helpers": "^4.0.4",
|
||||
"@ember/test-helpers": "^4.0.5",
|
||||
"@embroider/macros": "^1.16.9",
|
||||
"@faker-js/faker": "^8.0.2",
|
||||
"@glimmer/component": "^1.1.2",
|
||||
"@glimmer/tracking": "^1.1.2",
|
||||
"@warp-drive/build-config": "^0.0.2",
|
||||
"babel-loader": "^9.2.1",
|
||||
"broccoli-asset-rev": "^3.0.0",
|
||||
"concurrently": "^9.1.0",
|
||||
@@ -65,7 +66,7 @@
|
||||
"cross-env": "^7.0.3",
|
||||
"doctoc": "^2.2.0",
|
||||
"ember-a11y-testing": "^7.0.0",
|
||||
"ember-auto-import": "^2.8.1",
|
||||
"ember-auto-import": "^2.10.0",
|
||||
"ember-cli": "^5.12.0",
|
||||
"ember-cli-babel": "^8.2.0",
|
||||
"ember-cli-code-coverage": "^1.0.3",
|
||||
|
||||
Reference in new issue
Block a user