From 776c46f12911a6d8a89a1daf47ea4f91b098a176 Mon Sep 17 00:00:00 2001 From: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com> Date: Tue, 21 Nov 2023 10:36:59 -0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20replace=20store.find?= =?UTF-8?q?All=20with=20store.query=20(#2002)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-11825 --- addons/api/addon/adapters/application.js | 10 ---------- addons/api/tests/dummy/app/routes/application.js | 2 +- addons/api/tests/unit/adapters/application-test.js | 7 +------ addons/api/tests/unit/models/scope-test.js | 2 +- ui/admin/app/routes/scopes.js | 2 +- ui/desktop/app/routes/scopes.js | 2 +- 6 files changed, 5 insertions(+), 20 deletions(-) diff --git a/addons/api/addon/adapters/application.js b/addons/api/addon/adapters/application.js index 18e1c3c67..fe9c69977 100644 --- a/addons/api/addon/adapters/application.js +++ b/addons/api/addon/adapters/application.js @@ -106,16 +106,6 @@ export default class ApplicationAdapter extends RESTAdapter.extend( return dasherize(pluralize(type)); } - /** - * Intercepts "empty" responses and adds an empty `items` array. - * @override - * @method findAll - * @return {Promise} promise - */ - findAll() { - return super.findAll(...arguments).then(prenormalizeArrayResponse); - } - /** * Intercepts "empty" responses and adds an empty `items` array. * This query method now supports pagination by checking the responseType and diff --git a/addons/api/tests/dummy/app/routes/application.js b/addons/api/tests/dummy/app/routes/application.js index 19cf9e7fb..06c87fe6a 100644 --- a/addons/api/tests/dummy/app/routes/application.js +++ b/addons/api/tests/dummy/app/routes/application.js @@ -12,6 +12,6 @@ export default class ApplicationRoute extends Route { @service store; model() { - this.store.findAll('scope'); + this.store.query('scope', {}); } } diff --git a/addons/api/tests/unit/adapters/application-test.js b/addons/api/tests/unit/adapters/application-test.js index 2f309f5a1..354084efc 100644 --- a/addons/api/tests/unit/adapters/application-test.js +++ b/addons/api/tests/unit/adapters/application-test.js @@ -144,12 +144,7 @@ module('Unit | Adapter | application', function (hooks) { const adapter = this.owner.lookup('adapter:application'); const store = this.owner.lookup('service:store'); this.server.get('/v1/users', () => new Response({})); - const prenormalized = await adapter.findAll( - store, - { modelName: 'user' }, - null, - [], - ); + const prenormalized = await adapter.query(store, { modelName: 'user' }, {}); assert.deepEqual(prenormalized, { items: [] }); }); diff --git a/addons/api/tests/unit/models/scope-test.js b/addons/api/tests/unit/models/scope-test.js index b264156b6..603a25852 100644 --- a/addons/api/tests/unit/models/scope-test.js +++ b/addons/api/tests/unit/models/scope-test.js @@ -23,7 +23,7 @@ module('Unit | Model | scope', function (hooks) { { id: 'p_3', type: 'project', scope: { scope_id: 'o_2' } }, ], })); - const scopes = await store.findAll('scope'); + const scopes = await store.query('scope', {}); // check integrity of scope relationships assert.notOk(await scopes[0].get('scope'), 'Global scope has no parent'); assert.strictEqual( diff --git a/ui/admin/app/routes/scopes.js b/ui/admin/app/routes/scopes.js index 3368d4aca..589106584 100644 --- a/ui/admin/app/routes/scopes.js +++ b/ui/admin/app/routes/scopes.js @@ -35,7 +35,7 @@ export default class ScopesRoute extends Route { }); // NOTE: In the absence of a `scope_id` query parameter, this endpoint is // expected to default to the global scope, thus returning org scopes. - return this.store.findAll('scope').catch(() => A([])); + return this.store.query('scope', {}).catch(() => A([])); } /** diff --git a/ui/desktop/app/routes/scopes.js b/ui/desktop/app/routes/scopes.js index ce75f17f8..5e41c3579 100644 --- a/ui/desktop/app/routes/scopes.js +++ b/ui/desktop/app/routes/scopes.js @@ -26,6 +26,6 @@ export default class ScopesRoute extends Route { model() { // NOTE: In the absence of a `scope_id` query parameter, this endpoint is // expected to default to the global scope, thus returning org scopes. - return this.store.findAll('scope').catch(() => A([])); + return this.store.query('scope', {}).catch(() => A([])); } }