Merge pull request #244 from hashicorp/feature-user-accounts-ui
Feature user accounts ui
This commit is contained in:
30 files changed
+680
-59
No files matched your search
@@ -55,7 +55,6 @@
|
||||
@value={{@model.attributes.login_name}}
|
||||
@label={{t "form.login_name.label"}}
|
||||
@error={{@model.errors.login_name}}
|
||||
@helperText={{t "form.login_name.help"}}
|
||||
readonly={{false}}
|
||||
as |field|>
|
||||
{{#if @model.errors.login_name}}
|
||||
@@ -74,7 +73,6 @@
|
||||
@value={{this.password}}
|
||||
@label={{t "form.password.label"}}
|
||||
@error={{@model.errors.password}}
|
||||
@helperText={{t "form.password.help"}}
|
||||
readonly={{false}}
|
||||
autocomplete="new-password"
|
||||
as |field|>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<row.headerCell>{{t 'form.id.label'}}</row.headerCell>
|
||||
<row.headerCell>{{t 'form.name.label'}}</row.headerCell>
|
||||
<row.headerCell>{{t 'form.type.label'}}</row.headerCell>
|
||||
<row.headerCell>{{t 'resources.host-catalog.title_plural'}}</row.headerCell>
|
||||
<row.headerCell>{{t 'resources.host-catalog.title'}}</row.headerCell>
|
||||
</header.row>
|
||||
</table.header>
|
||||
<table.body as |body|>
|
||||
@@ -57,4 +57,4 @@
|
||||
</message.link>
|
||||
</Rose::Message>
|
||||
</Rose::Layout::Centered>
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
@@ -0,0 +1,56 @@
|
||||
{{#if this.hasAvailableAccounts}}
|
||||
<Rose::Form
|
||||
class="full-width"
|
||||
@onSubmit={{fn this.submit @submit}}
|
||||
@cancel={{@cancel}}
|
||||
@disabled={{@model.isSaving}}
|
||||
@error={{@model.errors.base}}
|
||||
as |form|
|
||||
>
|
||||
|
||||
<form.actions
|
||||
@submitText={{t "resources.user.actions.add-accounts"}}
|
||||
@cancelText={{t "actions.cancel"}} />
|
||||
|
||||
<Rose::Table as |table|>
|
||||
<table.header as |header|>
|
||||
<header.row as |row|>
|
||||
<row.headerCell>{{t 'form.id.label'}}</row.headerCell>
|
||||
<row.headerCell>{{t 'form.username.label'}}</row.headerCell>
|
||||
<row.headerCell>{{t 'resources.auth-method.title'}}</row.headerCell>
|
||||
</header.row>
|
||||
</table.header>
|
||||
<table.body as |body|>
|
||||
{{#each this.filteredAccounts as |account|}}
|
||||
<body.row as |row|>
|
||||
<row.cell>
|
||||
<form.checkbox
|
||||
@label={{account.id}}
|
||||
@description={{account.description}}
|
||||
onChange={{fn this.toggleAccount account}} />
|
||||
</row.cell>
|
||||
<row.cell>{{account.username}}</row.cell>
|
||||
<row.cell>
|
||||
<code>{{account.auth_method_id}}</code>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
</table.body>
|
||||
</Rose::Table>
|
||||
|
||||
</Rose::Form>
|
||||
{{/if}}
|
||||
|
||||
{{#unless this.hasAvailableAccounts}}
|
||||
<Rose::Layout::Centered>
|
||||
<Rose::Message @title={{t "resources.user.messages.no-accounts.title"}} as |message|>
|
||||
<message.description>
|
||||
{{t "resources.user.messages.no-accounts.description"}}
|
||||
</message.description>
|
||||
<message.link @route="scopes.scope.users.user.accounts">
|
||||
<Rose::Icon @name="chevron-left" />
|
||||
{{t "actions.back"}}
|
||||
</message.link>
|
||||
</Rose::Message>
|
||||
</Rose::Layout::Centered>
|
||||
{{/unless}}
|
||||
@@ -0,0 +1,53 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { computed, action } from '@ember/object';
|
||||
import { A } from '@ember/array';
|
||||
|
||||
export default class FormUserAddAccountsComponent extends Component {
|
||||
// =properties
|
||||
|
||||
/**
|
||||
* Array of selected account IDs.
|
||||
* @type {EmberArray}
|
||||
*/
|
||||
selectedAccountIDs = A();
|
||||
|
||||
/**
|
||||
* Checks for unassigned accounts.
|
||||
* @param {[AccountModel]} filteredAccounts
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('filteredAccounts')
|
||||
get hasAvailableAccounts() {
|
||||
return this.filteredAccounts.length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accounts not already added to the user.
|
||||
* @type {[AccountModel]}
|
||||
*/
|
||||
@computed('args.{accounts.[],model.account_ids.[]}')
|
||||
get filteredAccounts() {
|
||||
// Get IDs for accounts already added to the current user
|
||||
const alreadyAddedAccountIDs = this.args.model.account_ids;
|
||||
const notAddedAccounts = this.args.accounts.filter(
|
||||
({ id }) => !alreadyAddedAccountIDs.includes(id)
|
||||
);
|
||||
return notAddedAccounts;
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
@action
|
||||
toggleAccount(account) {
|
||||
if (!this.selectedAccountIDs.includes(account.id)) {
|
||||
this.selectedAccountIDs.addObject(account.id);
|
||||
} else {
|
||||
this.selectedAccountIDs.removeObject(account.id);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
submit(fn) {
|
||||
fn(this.selectedAccountIDs);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user