diff --git a/ui/core/app/components/form/account/index.hbs b/ui/core/app/components/form/account/index.hbs new file mode 100644 index 000000000..eb41e9b5d --- /dev/null +++ b/ui/core/app/components/form/account/index.hbs @@ -0,0 +1,53 @@ + + + + + {{#if @model.errors.name}} + + {{#each @model.errors.name as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{#if @model.errors.description}} + + {{#each @model.errors.description as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + \ No newline at end of file diff --git a/ui/core/app/router.js b/ui/core/app/router.js index 21a0a2ff8..fcd91a2f2 100644 --- a/ui/core/app/router.js +++ b/ui/core/app/router.js @@ -73,7 +73,9 @@ Router.map(function () { this.route('auth-methods', function() { this.route('auth-method', { path: ':auth_method_id' }, function() { - this.route('accounts'); + this.route('accounts', function() { + this.route('account', { path: ':account_id' }, function() {}); + }); }); this.route('new'); }); diff --git a/ui/core/app/routes/scopes/scope/auth-methods/auth-method.js b/ui/core/app/routes/scopes/scope/auth-methods/auth-method.js index a0d7dca9d..3c608f660 100644 --- a/ui/core/app/routes/scopes/scope/auth-methods/auth-method.js +++ b/ui/core/app/routes/scopes/scope/auth-methods/auth-method.js @@ -4,7 +4,7 @@ export default class ScopesScopeAuthMethodsAuthMethodRoute extends Route { // =methods /** - * Load a single auth-method in current scope. + * Load an auth method by ID. * @param {object} params * @param {string} params.auth_method_id * @return {authMethodModel} diff --git a/ui/core/app/routes/scopes/scope/auth-methods/auth-method/accounts.js b/ui/core/app/routes/scopes/scope/auth-methods/auth-method/accounts.js index 1f56c6e5e..7bd909128 100644 --- a/ui/core/app/routes/scopes/scope/auth-methods/auth-method/accounts.js +++ b/ui/core/app/routes/scopes/scope/auth-methods/auth-method/accounts.js @@ -1,15 +1,53 @@ import Route from '@ember/routing/route'; +import { action } from '@ember/object'; +import { inject as service } from '@ember/service'; export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route { + // =services + + @service intl; + @service notify; + // =methods /** - * Returns accounts in current auth method. + * Returns accounts for the current auth method. * @return {Promise{[AccountModel]}} */ model() { - const { id: auth_method_id } = this.modelFor('scopes.scope.auth-methods.auth-method'); + const { id: auth_method_id } = + this.modelFor('scopes.scope.auth-methods.auth-method'); return this.store.query('account', { auth_method_id }); } + + // =actions + + /** + * Rollback changes on an account. + * @param {AccountModel} account + */ + @action + cancel(account) { + account.rollbackAttributes(); + } + + /** + * Save an account in current scope. + * @param {AccountModel} account + */ + @action + async save(account) { + try { + await account.save(); + await this.refresh(); + await this.transitionTo('scopes.scope.auth-methods.auth-method.accounts.account', account); + this.notify.success( + this.intl.t('notify.save-success') + ); + } catch (error) { + // TODO: replace with translated strings + this.notify.error(error.message, { closeAfter: null }); + } + } } diff --git a/ui/core/app/routes/scopes/scope/auth-methods/auth-method/accounts/account.js b/ui/core/app/routes/scopes/scope/auth-methods/auth-method/accounts/account.js new file mode 100644 index 000000000..4b290a2c3 --- /dev/null +++ b/ui/core/app/routes/scopes/scope/auth-methods/auth-method/accounts/account.js @@ -0,0 +1,40 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeAuthMethodsAuthMethodAccountsAccountRoute extends Route { + + // =methods + + /** + * Load an account by ID. + * @param {object} params + * @param {string} params.account_id + * @return {AccountModel} + */ + model({ account_id }) { + return this.store.findRecord('account', account_id, { reload: true }); + } + + /** + * Renders the route-set specific page sections + * @override + */ + renderTemplate() { + super.renderTemplate(...arguments); + + this.render('scopes/scope/auth-methods/auth-method/accounts/account/-header', { + into: 'scopes/scope/auth-methods/auth-method', + outlet: 'header' + }); + + this.render('-empty', { + into: 'scopes/scope/auth-methods/auth-method', + outlet: 'actions' + }); + + this.render('scopes/scope/auth-methods/auth-method/accounts/account/-navigation', { + into: 'scopes/scope/auth-methods/auth-method', + outlet: 'navigation' + }); + } + +} diff --git a/ui/core/app/routes/scopes/scope/auth-methods/auth-method/accounts/account/index.js b/ui/core/app/routes/scopes/scope/auth-methods/auth-method/accounts/account/index.js new file mode 100644 index 000000000..4e996c777 --- /dev/null +++ b/ui/core/app/routes/scopes/scope/auth-methods/auth-method/accounts/account/index.js @@ -0,0 +1,4 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeAuthMethodsAuthMethodAccountsAccountIndexRoute extends Route { +} diff --git a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/-header.hbs b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/-header.hbs index 12f2b18eb..b2abc5389 100644 --- a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/-header.hbs +++ b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/-header.hbs @@ -1,4 +1,6 @@

{{t "resources.auth-method"}}

+{{!-- {{t (concat 'auth.method-types.' @model.type)}} - \ No newline at end of file + +--}} diff --git a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts.hbs b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts.hbs index 0436296b8..54c6c65e5 100644 --- a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts.hbs +++ b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts.hbs @@ -1,37 +1,3 @@ {{title (t 'titles.accounts')}} -{{#if @model}} - - - - - {{t 'form.label.name'}} - {{t 'form.label.id'}} - - - - {{#each @model as |account|}} - - - {{account.name}} -

{{account.description}}

-
- - {{account.id}} - -
- {{/each}} -
-
- -{{else}} - - - - - {{t "descriptions.auth-method-accounts-welcome"}} - - - - -{{/if}} +{{outlet}} diff --git a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account.hbs b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account.hbs new file mode 100644 index 000000000..e2147cab0 --- /dev/null +++ b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account.hbs @@ -0,0 +1 @@ +{{outlet}} \ No newline at end of file diff --git a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account/-header.hbs b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account/-header.hbs new file mode 100644 index 000000000..13c6af9c3 --- /dev/null +++ b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account/-header.hbs @@ -0,0 +1,4 @@ +

{{t "resources.account"}}

+ + {{t (concat 'account.types.' @model.type)}} + \ No newline at end of file diff --git a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account/-navigation.hbs b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account/-navigation.hbs new file mode 100644 index 000000000..24e8754b8 --- /dev/null +++ b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account/-navigation.hbs @@ -0,0 +1,5 @@ + + + {{t 'titles.details'}} + + diff --git a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account/index.hbs b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account/index.hbs new file mode 100644 index 000000000..07b4e30bc --- /dev/null +++ b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/account/index.hbs @@ -0,0 +1,5 @@ + diff --git a/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs new file mode 100644 index 000000000..8586ac7c0 --- /dev/null +++ b/ui/core/app/templates/scopes/scope/auth-methods/auth-method/accounts/index.hbs @@ -0,0 +1,40 @@ +{{#if @model}} + + + + + {{t 'form.label.name'}} + {{t 'form.label.id'}} + + + + {{#each @model as |account|}} + + + + {{account.name}} + +

{{account.description}}

+
+ + {{account.id}} + +
+ {{/each}} +
+
+ +{{else}} + + + + + {{t "descriptions.accounts-welcome"}} + + + + +{{/if}} \ No newline at end of file diff --git a/ui/core/tests/integration/components/form/account-test.js b/ui/core/tests/integration/components/form/account-test.js new file mode 100644 index 000000000..dddbd38c8 --- /dev/null +++ b/ui/core/tests/integration/components/form/account-test.js @@ -0,0 +1,24 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, find } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | form/account/index', function(hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + this.submit = () => {}; + this.cancel = () => {}; + this.model = { type: 'password' }; + + await render(hbs` + `); + + assert.ok(find('form')); + }); + +}); diff --git a/ui/core/tests/unit/routes/scopes/scope/auth-methods/auth-method/accounts/account-test.js b/ui/core/tests/unit/routes/scopes/scope/auth-methods/auth-method/accounts/account-test.js new file mode 100644 index 000000000..84dd0848f --- /dev/null +++ b/ui/core/tests/unit/routes/scopes/scope/auth-methods/auth-method/accounts/account-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | scopes/scope/auth-methods/auth-method/accounts/account', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:scopes/scope/auth-methods/auth-method/accounts/account'); + assert.ok(route); + }); +}); diff --git a/ui/core/tests/unit/routes/scopes/scope/auth-methods/auth-method/accounts/account/index-test.js b/ui/core/tests/unit/routes/scopes/scope/auth-methods/auth-method/accounts/account/index-test.js new file mode 100644 index 000000000..66e3ce904 --- /dev/null +++ b/ui/core/tests/unit/routes/scopes/scope/auth-methods/auth-method/accounts/account/index-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | scopes/scope/auth-methods/auth-method/accounts/account/index', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:scopes/scope/auth-methods/auth-method/accounts/account/index'); + assert.ok(route); + }); +}); diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml index 90efd18ae..bc7e08dc6 100644 --- a/ui/core/translations/en-us.yaml +++ b/ui/core/translations/en-us.yaml @@ -47,6 +47,9 @@ target: host: types: static: Static +account: + types: + password: Password resources: user: User users: Users @@ -68,6 +71,8 @@ resources: hosts: Hosts target: Target targets: Targets + accounts: Accounts + account: Account titles: iam: IAM new: New @@ -103,7 +108,8 @@ titles: group-members-welcome: Welcome to Members no-available-users: No Users Available accounts: Accounts - auth-method-accounts-welcome: Welcome to Accounts + account: Account + accounts-welcome: Welcome to Accounts descriptions: host-catalogs: Overview of collections of hosts and host sets. empty-set: There are no items to display yet. You may be able to add items or try back later. @@ -124,7 +130,7 @@ descriptions: no-principals-available: Principals are not available for assignment. group-members-welcome: Users belonging to this group appear here. no-available-users: No users are available to add to this group. - auth-method-accounts-welcome: No accounts are available in this auth method. + accounts-welcome: No accounts are available in this auth method. states: info: Info success: Success