From a9e67042675456e23adf9694dada02bc21c4b750 Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:59:01 -0500 Subject: [PATCH] UI: Handle some deprecations (#28276) * don't update the passed object directly fixes deprecation https://deprecations.emberjs.com/id/setting-on-hash * replace hasRecordForId with peekRecord -- ember-data:deprecate-has-record-for-id * fix deprecation ember-data:deprecate-has-record-for-id * update deprecation workflow --- ui/app/adapters/named-path.js | 2 +- ui/app/app.js | 1 + ui/app/controllers/vault/cluster/init.js | 3 ++- ui/app/initializers/deprecation-filter.js | 3 ++- ui/app/models/auth-config.js | 7 ++++++- ui/config/deprecation-workflow.js | 21 ++++++++++----------- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/ui/app/adapters/named-path.js b/ui/app/adapters/named-path.js index 535cf33e3d..6b8fb72974 100644 --- a/ui/app/adapters/named-path.js +++ b/ui/app/adapters/named-path.js @@ -30,7 +30,7 @@ export default class NamedPathAdapter extends ApplicationAdapter { const [store, { modelName }, snapshot] = arguments; const name = snapshot.attr('name'); // throw error if user attempts to create a record with same name, otherwise POST request silently overrides (updates) the existing model - if (store.hasRecordForId(modelName, name)) { + if (store.peekRecord({ type: modelName, id: name }) !== null) { throw new Error(`A record already exists with the name: ${name}`); } else { return this._saveRecord(...arguments); diff --git a/ui/app/app.js b/ui/app/app.js index 9409b0cd91..5de9c28a3a 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -8,6 +8,7 @@ import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; import config from 'vault/config/environment'; +// TODO: DEPRECATION https://ember-engines.com/docs/deprecations#-use-alias-for-inject-router-service-from-host-application export default class App extends Application { modulePrefix = config.modulePrefix; podModulePrefix = config.podModulePrefix; diff --git a/ui/app/controllers/vault/cluster/init.js b/ui/app/controllers/vault/cluster/init.js index 9083f2ddde..ddcd72e5e3 100644 --- a/ui/app/controllers/vault/cluster/init.js +++ b/ui/app/controllers/vault/cluster/init.js @@ -40,7 +40,8 @@ export default Controller.extend(DEFAULTS, { }), actions: { - initCluster(data) { + initCluster(payload) { + const data = { ...payload }; const isCloudSeal = !!this.model.sealType && this.model.sealType !== 'shamir'; if (data.secret_shares) { const shares = parseInt(data.secret_shares, 10); diff --git a/ui/app/initializers/deprecation-filter.js b/ui/app/initializers/deprecation-filter.js index 3063b37615..5e163149da 100644 --- a/ui/app/initializers/deprecation-filter.js +++ b/ui/app/initializers/deprecation-filter.js @@ -10,7 +10,8 @@ export function initialize() { registerDeprecationHandler((message, options, next) => { // filter deprecations that are scheduled to be removed in a specific version // when upgrading or addressing deprecation warnings be sure to update this or remove if not needed - if (options?.until.includes('5.0') && options?.id.startsWith('ember-data')) { + if (options?.until.includes('6.0')) { + // ignore all deprecations for 6+ return; } next(message, options); diff --git a/ui/app/models/auth-config.js b/ui/app/models/auth-config.js index 46ab4f9700..46f7318569 100644 --- a/ui/app/models/auth-config.js +++ b/ui/app/models/auth-config.js @@ -6,5 +6,10 @@ import Model, { belongsTo } from '@ember-data/model'; export default Model.extend({ - backend: belongsTo('auth-method', { inverse: 'authConfigs', readOnly: true, async: false }), + backend: belongsTo('auth-method', { + inverse: 'authConfigs', + readOnly: true, + async: false, + as: 'auth-config', + }), }); diff --git a/ui/config/deprecation-workflow.js b/ui/config/deprecation-workflow.js index cf343738e6..7ddd86cbb1 100644 --- a/ui/config/deprecation-workflow.js +++ b/ui/config/deprecation-workflow.js @@ -5,20 +5,19 @@ /* global self */ self.deprecationWorkflow = self.deprecationWorkflow || {}; -//self.deprecationWorkflow.config = { -//throwOnUnhandled: true -//} +self.deprecationWorkflow.config = { + throwOnUnhandled: false, +}; + self.deprecationWorkflow.config = { // current output from deprecationWorkflow.flushDeprecations(); - // deprecations that will not be removed until 5.0.0 are filtered by deprecation-filter initializer rather than silencing below workflow: [ - { handler: 'silence', matchId: 'ember-data:model-save-promise' }, - { handler: 'silence', matchId: 'ember-engines.deprecation-camelized-engine-names' }, { handler: 'silence', matchId: 'ember-engines.deprecation-router-service-from-host' }, - { handler: 'silence', matchId: 'ember-modifier.use-modify' }, - { handler: 'silence', matchId: 'ember-modifier.no-element-property' }, - { handler: 'silence', matchId: 'ember-modifier.no-args-property' }, - { handler: 'silence', matchId: 'ember-cli-mirage-config-routes-only-export' }, - { handler: 'silence', matchId: 'setting-on-hash' }, + // ember-data + { handler: 'silence', matchId: 'ember-data:deprecate-early-static' }, + { handler: 'silence', matchId: 'ember-data:deprecate-model-reopen' }, + { handler: 'silence', matchId: 'ember-data:deprecate-promise-proxies' }, + { handler: 'silence', matchId: 'ember-data:no-a-with-array-like' }, + { handler: 'silence', matchId: 'ember-data:deprecate-promise-many-array-behaviors' }, ], };