From abc1827280319f93d78562f5a439a7b8b87c9dd3 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Fri, 26 Mar 2021 09:41:07 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20"no=20primary=20au?= =?UTF-8?q?th=20method"=20warning=20to=20index?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/core/translations/resources/en-us.yaml | 3 +++ .../controllers/scopes/scope/auth-methods/index.js | 7 +++++++ .../templates/scopes/scope/auth-methods/index.hbs | 11 +++++++++++ ui/admin/config/environment.js | 2 +- .../scopes/scope/auth-methods/index-test.js | 14 ++++++++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 ui/admin/app/controllers/scopes/scope/auth-methods/index.js create mode 100644 ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index e670a70d7..86d80732c 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -24,6 +24,9 @@ auth-method: none: title: No Auth Methods description: No auth methods were found for this scope. + no-primary-auth-method: + title: No Primary Auth Method Found + description: A primary auth method auto-vivifies users when they authenticate for the first time. The primary auth method is also presented first to unauthenticated users. Each scope may have one primary auth method. Please choose a primary auth method for this scope. types: password: Password actions: diff --git a/ui/admin/app/controllers/scopes/scope/auth-methods/index.js b/ui/admin/app/controllers/scopes/scope/auth-methods/index.js new file mode 100644 index 000000000..c51e1d044 --- /dev/null +++ b/ui/admin/app/controllers/scopes/scope/auth-methods/index.js @@ -0,0 +1,7 @@ +import Controller from '@ember/controller'; + +export default class ScopesScopeAuthMethodsIndexController extends Controller { + get hasPrimaryAuthMethod() { + return this.model.filterBy('isPrimary'); + } +} diff --git a/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs b/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs index 7578f9e50..a75dcdece 100644 --- a/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs +++ b/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs @@ -30,6 +30,17 @@ {{#if @model}} + {{#if (feature-flag 'primary-auth-method')}} + {{#unless this.hasPrimaryAuthMethod}} + + {{t "resources.auth-method.messages.no-primary-auth-method.description"}} + + {{/unless}} + {{/if}} + diff --git a/ui/admin/config/environment.js b/ui/admin/config/environment.js index b59054b8d..90be4e447 100644 --- a/ui/admin/config/environment.js +++ b/ui/admin/config/environment.js @@ -85,7 +85,7 @@ module.exports = function (environment) { }, featureFlags: { - 'primary-auth-method': false, + 'primary-auth-method': true, }, }; diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js new file mode 100644 index 000000000..33ee7da2e --- /dev/null +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js @@ -0,0 +1,14 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { + setupTest(hooks); + + // TODO: Replace this with your real tests. + test('it exists', function (assert) { + let controller = this.owner.lookup( + 'controller:scopes/scope/auth-methods/index' + ); + assert.ok(controller); + }); +});