From bf343c0b8c2714bd06545959cc033ab6aba02163 Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Tue, 15 Aug 2023 13:20:08 -0700 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20fix=20deprecation=20war?= =?UTF-8?q?ning=20for=20firstobject=20usage=20(#1844)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/tests/unit/models/scope-test.js | 5 +---- ui/admin/app/routes/application.js | 2 +- ui/admin/app/routes/scopes/index.js | 2 +- ui/admin/app/routes/scopes/scope/authenticate/index.js | 2 +- .../scopes/scope/auth-methods/auth-method/accounts/index.hbs | 4 ++-- .../scope/auth-methods/auth-method/managed-groups/index.hbs | 2 +- .../auth-method/managed-groups/managed-group/members.hbs | 2 +- ui/desktop/app/routes/application.js | 2 +- ui/desktop/app/routes/scopes/index.js | 2 +- ui/desktop/app/routes/scopes/scope/authenticate/index.js | 2 +- 10 files changed, 11 insertions(+), 14 deletions(-) diff --git a/addons/api/tests/unit/models/scope-test.js b/addons/api/tests/unit/models/scope-test.js index 58ba67b8a..a6891ea19 100644 --- a/addons/api/tests/unit/models/scope-test.js +++ b/addons/api/tests/unit/models/scope-test.js @@ -26,10 +26,7 @@ module('Unit | Model | scope', function (hooks) { })); const scopes = await store.findAll('scope'); // check integrity of scope relationships - assert.notOk( - await scopes.firstObject.get('scope'), - 'Global scope has no parent' - ); + assert.notOk(await scopes[0].get('scope'), 'Global scope has no parent'); assert.strictEqual( await scopes.objectAt(1).get('scope.scope_id'), 'global', diff --git a/ui/admin/app/routes/application.js b/ui/admin/app/routes/application.js index 137527b1a..d17504028 100644 --- a/ui/admin/app/routes/application.js +++ b/ui/admin/app/routes/application.js @@ -83,7 +83,7 @@ export default class ApplicationRoute extends Route { */ @action error(e) { - const isUnauthenticated = A(e?.errors)?.firstObject?.isUnauthenticated; + const isUnauthenticated = A(e?.errors)?.[0]?.isUnauthenticated; if (isUnauthenticated) { this.session.invalidate(); return false; diff --git a/ui/admin/app/routes/scopes/index.js b/ui/admin/app/routes/scopes/index.js index 84aa5040a..fb617e4f3 100644 --- a/ui/admin/app/routes/scopes/index.js +++ b/ui/admin/app/routes/scopes/index.js @@ -19,7 +19,7 @@ export default class ScopesIndexRoute extends Route { * If authenticated, redirects to the scope route of the authenticted scope. * If unauthenticated, redirects to the first scope that was loaded (if any). * @param {[ScopeModel]} model - * @param {?ScopeModel} model.firstObject + * @param {?ScopeModel} model[0] */ redirect() { const authenticatedScopeID = get( diff --git a/ui/admin/app/routes/scopes/scope/authenticate/index.js b/ui/admin/app/routes/scopes/scope/authenticate/index.js index eaf5b2d74..107c8a910 100644 --- a/ui/admin/app/routes/scopes/scope/authenticate/index.js +++ b/ui/admin/app/routes/scopes/scope/authenticate/index.js @@ -20,7 +20,7 @@ export default class ScopesScopeAuthenticateIndexRoute extends Route { * @param {[AuthMethodModel]} model.authMethods */ redirect({ authMethods }) { - const firstAuthMethod = authMethods.firstObject; + const firstAuthMethod = authMethods[0]; if (firstAuthMethod) { this.router.transitionTo( 'scopes.scope.authenticate.method', diff --git a/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs b/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs index 735d4cdad..ed85af7f2 100644 --- a/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs +++ b/ui/admin/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs @@ -24,7 +24,7 @@ {{#if @model.accounts}} {{! OIDC accounts display more fields }} - {{#if @model.accounts.firstObject.isOIDC}} + {{#if (get @model.accounts '0.isOIDC')}} - {{else if @model.accounts.firstObject.isLDAP}} + {{else if (get @model.accounts '0.isLDAP')}} {{#if @model.managedGroups}} - {{#if @model.managedGroups.firstObject.isOIDC}} + {{#if (get @model.managedGroups '0.isOIDC')}} {{#if @model.members}} - {{#if @model.members.firstObject.isOIDC}} + {{#if (get @model.members '0.isOIDC')}}