diff --git a/ui/app/components/console/ui-panel.js b/ui/app/components/console/ui-panel.js index 525dfb2270..ed3524d977 100644 --- a/ui/app/components/console/ui-panel.js +++ b/ui/app/components/console/ui-panel.js @@ -108,7 +108,7 @@ export default Component.extend({ const currentRoute = owner.lookup(`router:main`).currentRouteName; try { - this.store.clearAllDatasets(); + this.store.clearDataset(); yield this.router.transitionTo(currentRoute); this.logAndOutput(null, { type: 'success', content: 'The current screen has been refreshed!' }); } catch (error) { diff --git a/ui/app/components/generated-item-list.js b/ui/app/components/generated-item-list.js index 3a971e0e41..09aa959681 100644 --- a/ui/app/components/generated-item-list.js +++ b/ui/app/components/generated-item-list.js @@ -32,7 +32,7 @@ export default class GeneratedItemList extends Component { @action refreshItemList() { const route = getOwner(this).lookup(`route:${this.router.currentRouteName}`); - this.store.clearAllDatasets(); + this.store.clearDataset(); route.refresh(); } } diff --git a/ui/app/routes/vault/cluster/access/identity/aliases/index.js b/ui/app/routes/vault/cluster/access/identity/aliases/index.js index 31a15e8e88..9bdd92d28a 100644 --- a/ui/app/routes/vault/cluster/access/identity/aliases/index.js +++ b/ui/app/routes/vault/cluster/access/identity/aliases/index.js @@ -38,12 +38,12 @@ export default Route.extend(ListRoute, { willTransition(transition) { window.scrollTo(0, 0); if (!transition || transition.targetName !== this.routeName) { - this.store.clearAllDatasets(); + this.store.clearDataset(); } return true; }, reload() { - this.store.clearAllDatasets(); + this.store.clearDataset(); this.refresh(); }, }, diff --git a/ui/app/routes/vault/cluster/access/identity/index.js b/ui/app/routes/vault/cluster/access/identity/index.js index 1dbbd4a48f..76a6332522 100644 --- a/ui/app/routes/vault/cluster/access/identity/index.js +++ b/ui/app/routes/vault/cluster/access/identity/index.js @@ -38,12 +38,12 @@ export default Route.extend(ListRoute, { willTransition(transition) { window.scrollTo(0, 0); if (transition.targetName !== this.routeName) { - this.store.clearAllDatasets(); + this.store.clearDataset(); } return true; }, reload() { - this.store.clearAllDatasets(); + this.store.clearDataset(); this.refresh(); }, }, diff --git a/ui/app/routes/vault/cluster/access/leases/list.js b/ui/app/routes/vault/cluster/access/leases/list.js index a754048265..1a58a9ec4c 100644 --- a/ui/app/routes/vault/cluster/access/leases/list.js +++ b/ui/app/routes/vault/cluster/access/leases/list.js @@ -104,7 +104,7 @@ export default Route.extend({ willTransition(transition) { window.scrollTo(0, 0); if (transition.targetName !== this.routeName) { - this.store.clearAllDatasets(); + this.store.clearDataset(); } return true; }, diff --git a/ui/app/routes/vault/cluster/access/method/item/list.js b/ui/app/routes/vault/cluster/access/method/item/list.js index d2920cb39a..1c41c1b859 100644 --- a/ui/app/routes/vault/cluster/access/method/item/list.js +++ b/ui/app/routes/vault/cluster/access/method/item/list.js @@ -46,12 +46,12 @@ export default Route.extend(ListRoute, { willTransition(transition) { window.scrollTo(0, 0); if (transition.targetName !== this.routeName) { - this.store.clearAllDatasets(); + this.store.clearDataset(); } return true; }, reload() { - this.store.clearAllDatasets(); + this.store.clearDataset(); this.refresh(); }, }, diff --git a/ui/app/routes/vault/cluster/access/namespaces/index.js b/ui/app/routes/vault/cluster/access/namespaces/index.js index d274e78516..55265487cf 100644 --- a/ui/app/routes/vault/cluster/access/namespaces/index.js +++ b/ui/app/routes/vault/cluster/access/namespaces/index.js @@ -74,12 +74,12 @@ export default Route.extend(UnloadModel, { willTransition(transition) { window.scrollTo(0, 0); if (!transition || transition.targetName !== this.routeName) { - this.store.clearAllDatasets(); + this.store.clearDataset(); } return true; }, reload() { - this.store.clearAllDatasets(); + this.store.clearDataset(); this.refresh(); }, }, diff --git a/ui/app/routes/vault/cluster/policies/index.js b/ui/app/routes/vault/cluster/policies/index.js index 2c26ad9cc1..34c9abf77e 100644 --- a/ui/app/routes/vault/cluster/policies/index.js +++ b/ui/app/routes/vault/cluster/policies/index.js @@ -65,12 +65,12 @@ export default Route.extend(ClusterRoute, ListRoute, { willTransition(transition) { window.scrollTo(0, 0); if (!transition || transition.targetName !== this.routeName) { - this.store.clearAllDatasets(); + this.store.clearDataset(); } return true; }, reload() { - this.store.clearAllDatasets(); + this.store.clearDataset(); this.refresh(); }, }, diff --git a/ui/app/routes/vault/cluster/secrets/backend/list.js b/ui/app/routes/vault/cluster/secrets/backend/list.js index f2ee9eb71b..254119da4e 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/list.js +++ b/ui/app/routes/vault/cluster/secrets/backend/list.js @@ -163,7 +163,7 @@ export default Route.extend({ const has404 = this.has404; // only clear store cache if this is a new model if (secret !== controller?.baseKey?.id) { - this.store.clearAllDatasets(); + this.store.clearDataset(); } controller.set('hasModel', true); controller.setProperties({ @@ -220,12 +220,12 @@ export default Route.extend({ willTransition(transition) { window.scrollTo(0, 0); if (transition.targetName !== this.routeName) { - this.store.clearAllDatasets(); + this.store.clearDataset(); } return true; }, reload() { - this.store.clearAllDatasets(); + this.store.clearDataset(); this.refresh(); }, }, diff --git a/ui/app/services/store.js b/ui/app/services/store.js index d0b3e39dce..41ba746913 100644 --- a/ui/app/services/store.js +++ b/ui/app/services/store.js @@ -6,7 +6,7 @@ import Store, { CacheHandler } from '@ember-data/store'; import RequestManager from '@ember-data/request'; import { LegacyNetworkHandler } from '@ember-data/legacy-compat'; -import { run, schedule } from '@ember/runloop'; +import { schedule } from '@ember/runloop'; import { resolve, Promise } from 'rsvp'; import { dasherize } from '@ember/string'; import { assert } from '@ember/debug'; @@ -159,20 +159,10 @@ export default class StoreService extends Store { return resp; } - forceUnload(modelName) { - // Hack to get unloadAll to work correctly until we update to ember-data@4.12 - // so that all the records are properly unloaded and we don't get ghost records - this.peekAll(modelName).length; - // force destroy queue to flush https://github.com/emberjs/data/issues/5447 - run(() => this.unloadAll(modelName)); - } - // pushes records into the store and returns the result fetchPage(modelName, query) { const response = this.constructResponse(modelName, query); - this.forceUnload(modelName); - // Hack to ensure the pushed records below all get in the store. remove with update to ember-data@4.12 - this.peekAll(modelName).length; + this.unloadAll(modelName); return new Promise((resolve) => { // push subset of records into the store schedule('destroy', () => { @@ -185,8 +175,6 @@ export default class StoreService extends Store { 'query' ) ); - // Hack to make sure all records get in model correctly. remove with update to ember-data@4.12 - this.peekAll(modelName).length; const model = this.peekAll(modelName).slice(); model.set('meta', response.meta); resolve(model); @@ -218,34 +206,4 @@ export default class StoreService extends Store { } this.lazyCaches.clear(); } - - clearAllDatasets() { - this.clearDataset(); - } - - /** - * this is designed to be a temporary workaround to an issue in the test environment after upgrading to Ember 4.12 - * when performing an unloadAll or unloadRecord for auth-method or secret-engine models within the app code an error breaks the tests - * after the test run is finished during teardown an unloadAll happens and the error "Expected a stable identifier" is thrown - * it seems that when the unload happens in the app, for some reason the mount-config relationship models are not unloaded - * then when the unloadAll happens a second time during test teardown there seems to be an issue since those records should already have been unloaded - * when logging in the teardownRecord hook, it appears that other embedded inverse: null relationships such as replication-attributes are torn down when the parent model is unloaded - * the following fixes the issue by explicitly unloading the mount-config models associated to the parent - * this should be looked into further to find the root cause, at which time these overrides may be removed - */ - unloadAll(modelName) { - const hasMountConfig = ['auth-method', 'secret-engine']; - if (hasMountConfig.includes(modelName)) { - this.peekAll(modelName).forEach((record) => this.unloadRecord(record)); - } else { - super.unloadAll(modelName); - } - } - unloadRecord(record) { - const hasMountConfig = ['auth-method', 'secret-engine']; - if (record && hasMountConfig.includes(record.constructor.modelName) && record.config) { - super.unloadRecord(record.config); - } - super.unloadRecord(record); - } } diff --git a/ui/lib/core/addon/mixins/list-route.js b/ui/lib/core/addon/mixins/list-route.js index 781e76fb58..1a78345b78 100644 --- a/ui/lib/core/addon/mixins/list-route.js +++ b/ui/lib/core/addon/mixins/list-route.js @@ -35,12 +35,12 @@ export default Mixin.create({ willTransition(transition) { window.scrollTo(0, 0); if (transition.targetName !== this.routeName) { - this.store.clearAllDatasets(); + this.store.clearDataset(); } return true; }, reload() { - this.store.clearAllDatasets(); + this.store.clearDataset(); this.refresh(); }, }, diff --git a/ui/lib/kmip/addon/routes/scopes/index.js b/ui/lib/kmip/addon/routes/scopes/index.js index 569c520dcb..3816f4cd9a 100644 --- a/ui/lib/kmip/addon/routes/scopes/index.js +++ b/ui/lib/kmip/addon/routes/scopes/index.js @@ -31,12 +31,12 @@ export default Route.extend(ListRoute, { willTransition(transition) { window.scrollTo(0, 0); if (transition.targetName !== this.routeName) { - this.store.clearAllDatasets(); + this.store.clearDataset(); } return true; }, reload() { - this.store.clearAllDatasets(); + this.store.clearDataset(); this.refresh(); }, }, diff --git a/ui/tests/unit/services/store-test.js b/ui/tests/unit/services/store-test.js index 9510fac734..ba349ffe3b 100644 --- a/ui/tests/unit/services/store-test.js +++ b/ui/tests/unit/services/store-test.js @@ -68,14 +68,14 @@ module('Unit | Service | store', function (hooks) { assert.notOk(this.store.get('lazyCaches').has('transit-key'), 'cache is no longer stored'); }); - test('store.clearAllDatasets', function (assert) { + test('store.clearDataset with no args clears entire cache', function (assert) { const arr = ['one', 'two']; const arr2 = ['one', 'two', 'three', 'four']; this.store.storeDataset('data', { id: 1 }, {}, arr); this.store.storeDataset('transit-key', { id: 2 }, {}, arr2); assert.strictEqual(this.store.get('lazyCaches').size, 2, 'it stores both keys'); - this.store.clearAllDatasets(); + this.store.clearDataset(); assert.strictEqual(this.store.get('lazyCaches').size, 0, 'deletes all of the keys'); assert.notOk(this.store.get('lazyCaches').has('transit-key'), 'first cache key is no longer stored'); assert.notOk(this.store.get('lazyCaches').has('data'), 'second cache key is no longer stored');