refactor: API: Add AuthMethodOIDC class to hold static states
This commit is contained in:
8 files changed
+52
-7
No files matched your search
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Empty auth method definition
|
||||
*/
|
||||
export class AuthMethod {}
|
||||
|
||||
/**
|
||||
* Simple OIDC auth method definition to contain possible oidc states.
|
||||
* @property states {[string]} states
|
||||
*/
|
||||
export class AuthMethodOIDC extends AuthMethod {
|
||||
/**
|
||||
* Possible auth-method statuses
|
||||
*/
|
||||
static states = ['inactive', 'active-private', 'active-public'];
|
||||
}
|
||||
@@ -28,8 +28,6 @@ export const options = {
|
||||
};
|
||||
|
||||
export default class AuthMethodModel extends GeneratedAuthMethodModel {
|
||||
STATES_ENUM = options.oidc.state;
|
||||
|
||||
// =error attributes
|
||||
// These attributes exist solely to capture errors on nested fields.
|
||||
// See the application adapter's error normalization method for
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'api/classes/auth-method';
|
||||
@@ -0,0 +1,22 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { AuthMethod, AuthMethodOIDC } from 'api/classes/auth-method';
|
||||
|
||||
module('Unit | Class | auth method', function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
assert.ok(AuthMethod);
|
||||
assert.ok(AuthMethodOIDC);
|
||||
});
|
||||
|
||||
test('oidc auth method lists states', function (assert) {
|
||||
assert.deepEqual(AuthMethodOIDC.states, [
|
||||
'inactive',
|
||||
'active-private',
|
||||
'active-public',
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -45,7 +45,7 @@ auth-method:
|
||||
delete: Delete Auth Method
|
||||
make-primary: Make Primary
|
||||
remove-as-primary: Remove as Primary
|
||||
change-state: State
|
||||
status: Status
|
||||
notifications:
|
||||
make-primary-success: Auth method successfully elected to primary.
|
||||
remove-as-primary-success: Auth method successfully removed as primary.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Controller from '@ember/controller';
|
||||
import { AuthMethodOIDC } from 'api/classes/auth-method';
|
||||
|
||||
export default class ScopesScopeAuthMethodsAuthMethodController extends Controller {
|
||||
// =attributes
|
||||
@@ -10,4 +11,12 @@ export default class ScopesScopeAuthMethodsAuthMethodController extends Controll
|
||||
get breadCrumb() {
|
||||
return this.model.displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* OIDC auth-method states
|
||||
* @type {[string]}
|
||||
*/
|
||||
get oidcStates() {
|
||||
return AuthMethodOIDC.states;
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ export default class ScopesScopeAuthMethodsAuthMethodRoute extends Route {
|
||||
|
||||
/**
|
||||
* Update state of OIDC auth method
|
||||
* @param {string} state - "inactive", "active-private", "active-public"
|
||||
* @param {string} state
|
||||
*/
|
||||
@action
|
||||
@notifyError(({ message }) => message)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{{#if @model.isOIDC}}
|
||||
<Rose::Dropdown
|
||||
@text='{{concat
|
||||
(t 'resources.auth-method.actions.change-state')
|
||||
(t 'resources.auth-method.actions.status')
|
||||
' : '
|
||||
(t (concat 'states.auth-method.oidc.states.' @model.attributes.state))
|
||||
}}'
|
||||
@dropdownRight={{true}}
|
||||
as |dropdown|
|
||||
>
|
||||
<dropdown.section @title={{t 'resources.auth-method.actions.change-state'}}>
|
||||
<dropdown.section @title={{t 'resources.auth-method.actions.status'}}>
|
||||
<Rose::Form as |form|>
|
||||
<form.radioGroup
|
||||
@name='theme'
|
||||
@@ -16,7 +16,7 @@
|
||||
@changed={{route-action 'changeState'}}
|
||||
as |radioGroup|
|
||||
>
|
||||
{{#each @model.STATES_ENUM as |state|}}
|
||||
{{#each this.oidcStates as |state|}}
|
||||
<dropdown.item>
|
||||
<radioGroup.radio
|
||||
@label={{t (concat 'states.auth-method.oidc.states.' state)}}
|
||||
|
||||
Reference in new issue
Block a user