Merge branch 'main' into chore-enhanced-user-info

This commit is contained in:
Randall Morey authored and GitHub committed 2021-10-06 16:19:06 -04:00
commit ca150daf25
41 files changed
+731 -166

No files matched your search

@@ -1,39 +1,43 @@
<Rose::Form
@onSubmit={{fn this.createGrant @addGrant}}
@cancel={{@cancel}}
@disabled={{@model.isSaving}}
as |form|
>
<Rose::List::KeyValue as |list|>
{{! Add grant field (only one per form) }}
<list.item as |item|>
<form.input
@contextual={{true}}
@name='grant'
@type='text'
@value={{this.newGrantString}}
as |input|
>
<item.key>
<input.label>{{t 'resources.role.grant.actions.create'}}</input.label>
</item.key>
<item.cell>
<input.field title={{t 'form.grant.help'}} />
</item.cell>
<item.cell>
<Rose::Button
@submit={{true}}
@disabled={{this.cannotSave}}
@style='secondary'
title={{t 'actions.add'}}
>
{{t 'actions.add'}}
</Rose::Button>
</item.cell>
</form.input>
</list.item>
</Rose::List::KeyValue>
</Rose::Form>
{{#if (can 'setGrants role' @model)}}
<Rose::Form
@onSubmit={{fn this.createGrant @addGrant}}
@cancel={{@cancel}}
@disabled={{@model.isSaving}}
as |form|
>
<Rose::List::KeyValue as |list|>
{{! Add grant field (only one per form) }}
<list.item as |item|>
<form.input
@contextual={{true}}
@name='grant'
@type='text'
@value={{this.newGrantString}}
as |input|
>
<item.key>
<input.label>{{t
'resources.role.grant.actions.create'
}}</input.label>
</item.key>
<item.cell>
<input.field title={{t 'form.grant.help'}} />
</item.cell>
<item.cell>
<Rose::Button
@submit={{true}}
@disabled={{this.cannotSave}}
@style='secondary'
title={{t 'actions.add'}}
>
{{t 'actions.add'}}
</Rose::Button>
</item.cell>
</form.input>
</list.item>
</Rose::List::KeyValue>
</Rose::Form>
{{/if}}
<Rose::Form
@onSubmit={{fn @submit this.grantStrings}}
@@ -61,6 +65,7 @@
@name='grant'
@type='text'
@value={{grant.value}}
@disabled={{if (can 'setGrants role' @model) false true}}
@error={{@model.errors.grant_strings}}
as |input|
>
@@ -72,23 +77,27 @@
</item.cell>
</form.input>
<item.cell>
<Rose::Button
@style='secondary'
@iconOnly='flight-icons/svg/trash-16'
title={{t 'actions.remove'}}
{{on 'click' (fn @removeGrant grant.value)}}
>
{{t 'actions.remove'}}
</Rose::Button>
{{#if (can 'setGrants role' @model)}}
<Rose::Button
@style='secondary'
@iconOnly='flight-icons/svg/trash-16'
title={{t 'actions.remove'}}
{{on 'click' (fn @removeGrant grant.value)}}
>
{{t 'actions.remove'}}
</Rose::Button>
{{/if}}
</item.cell>
</list.item>
{{/each}}
</Rose::List::KeyValue>
<form.actions
@disabled={{if @model.cannotSave @model.cannotSave}}
@submitText={{t 'actions.save'}}
@cancelText={{t 'actions.cancel'}}
/>
{{#if (can 'setGrants role' @model)}}
<form.actions
@disabled={{if @model.cannotSave @model.cannotSave}}
@submitText={{t 'actions.save'}}
@cancelText={{t 'actions.cancel'}}
/>
{{/if}}
</Rose::Form>
@@ -5,10 +5,12 @@
{{t 'titles.details'}}
</nav.link>
{{#if @model.isPassword}}
<nav.link
@route='scopes.scope.auth-methods.auth-method.accounts.account.set-password'
>
{{t 'actions.set-password'}}
</nav.link>
{{#if (can 'setPassword account' @model)}}
<nav.link
@route='scopes.scope.auth-methods.auth-method.accounts.account.set-password'
>
{{t 'actions.set-password'}}
</nav.link>
{{/if}}
{{/if}}
</Rose::Nav::Tabs>
@@ -3,9 +3,11 @@
@dropdownRight={{true}}
as |dropdown|
>
<dropdown.link @route='scopes.scope.groups.group.add-members'>
{{t 'resources.group.actions.add-members'}}
</dropdown.link>
{{#if (can 'addMembers group' @model)}}
<dropdown.link @route='scopes.scope.groups.group.add-members'>
{{t 'resources.group.actions.add-members'}}
</dropdown.link>
{{/if}}
{{#if (can 'delete model' @model)}}
<dropdown.separator />
<dropdown.button
@@ -29,21 +29,26 @@
</Copyable>
</row.cell>
<row.cell>
<Rose::Dropdown
@icon='flight-icons/svg/more-horizontal-16'
@iconOnly={{true}}
@showCaret={{false}}
@dropdownRight={{true}}
@text='{{t 'actions.manage'}}'
as |dropdown|
>
<dropdown.button
@style='danger'
{{on 'click' (route-action 'removeMember' @model.group member)}}
{{#if (can 'removeMembers group' @model.group)}}
<Rose::Dropdown
@icon='flight-icons/svg/more-horizontal-16'
@iconOnly={{true}}
@showCaret={{false}}
@dropdownRight={{true}}
@text='{{t 'actions.manage'}}'
as |dropdown|
>
{{t 'actions.remove'}}
</dropdown.button>
</Rose::Dropdown>
<dropdown.button
@style='danger'
{{on
'click'
(route-action 'removeMember' @model.group member)
}}
>
{{t 'actions.remove'}}
</dropdown.button>
</Rose::Dropdown>
{{/if}}
</row.cell>
</body.row>
{{/each}}
@@ -3,16 +3,18 @@
@dropdownRight={{true}}
as |dropdown|
>
<dropdown.link
@route='scopes.scope.host-catalogs.host-catalog.host-sets.host-set.create-and-add-host'
>
{{t 'resources.host-set.actions.create-and-add-host'}}
</dropdown.link>
<dropdown.link
@route='scopes.scope.host-catalogs.host-catalog.host-sets.host-set.add-hosts'
>
{{t 'resources.host-set.actions.add-hosts'}}
</dropdown.link>
{{#if (can 'addHosts hostSet' @model)}}
<dropdown.link
@route='scopes.scope.host-catalogs.host-catalog.host-sets.host-set.create-and-add-host'
>
{{t 'resources.host-set.actions.create-and-add-host'}}
</dropdown.link>
<dropdown.link
@route='scopes.scope.host-catalogs.host-catalog.host-sets.host-set.add-hosts'
>
{{t 'resources.host-set.actions.add-hosts'}}
</dropdown.link>
{{/if}}
{{#if (can 'delete model' @model)}}
<dropdown.separator />
<dropdown.button
@@ -36,21 +36,23 @@
</Copyable>
</row.cell>
<row.cell>
<Rose::Dropdown
@icon='flight-icons/svg/more-horizontal-16'
@iconOnly={{true}}
@showCaret={{false}}
@dropdownRight={{true}}
@text='{{t 'actions.manage'}}'
as |dropdown|
>
<dropdown.button
@style='danger'
{{on 'click' (route-action 'removeHost' @model.hostSet host)}}
{{#if (can 'removeHosts hostSet' @model.hostSet)}}
<Rose::Dropdown
@icon='flight-icons/svg/more-horizontal-16'
@iconOnly={{true}}
@showCaret={{false}}
@dropdownRight={{true}}
@text='{{t 'actions.manage'}}'
as |dropdown|
>
{{t 'actions.remove'}}
</dropdown.button>
</Rose::Dropdown>
<dropdown.button
@style='danger'
{{on 'click' (route-action 'removeHost' @model.hostSet host)}}
>
{{t 'actions.remove'}}
</dropdown.button>
</Rose::Dropdown>
{{/if}}
</row.cell>
</body.row>
{{/each}}
@@ -3,9 +3,11 @@
@dropdownRight={{true}}
as |dropdown|
>
<dropdown.link @route='scopes.scope.roles.role.add-principals'>
{{t 'resources.role.principal.actions.add-principals'}}
</dropdown.link>
{{#if (can 'addPrincipals role' @model)}}
<dropdown.link @route='scopes.scope.roles.role.add-principals'>
{{t 'resources.role.principal.actions.add-principals'}}
</dropdown.link>
{{/if}}
{{#if (can 'delete model' @model)}}
<dropdown.separator />
<dropdown.button
@@ -33,21 +33,26 @@
</Copyable>
</row.cell>
<row.cell>
<Rose::Dropdown
@icon='flight-icons/svg/more-horizontal-16'
@iconOnly={{true}}
@showCaret={{false}}
@dropdownRight={{true}}
@text='{{t 'actions.manage'}}'
as |dropdown|
>
<dropdown.button
@style='danger'
{{on 'click' (route-action 'removePrincipal' principal.model)}}
{{#if (can 'removePrincipals role' @model.role)}}
<Rose::Dropdown
@icon='flight-icons/svg/more-horizontal-16'
@iconOnly={{true}}
@showCaret={{false}}
@dropdownRight={{true}}
@text='{{t 'actions.manage'}}'
as |dropdown|
>
{{t 'actions.remove'}}
</dropdown.button>
</Rose::Dropdown>
<dropdown.button
@style='danger'
{{on
'click'
(route-action 'removePrincipal' principal.model)
}}
>
{{t 'actions.remove'}}
</dropdown.button>
</Rose::Dropdown>
{{/if}}
</row.cell>
</body.row>
{{/each}}
@@ -3,9 +3,11 @@
@dropdownRight={{true}}
as |dropdown|
>
<dropdown.link @route='scopes.scope.users.user.add-accounts'>
{{t 'resources.user.actions.add-accounts'}}
</dropdown.link>
{{#if (can 'addAccounts user' @model)}}
<dropdown.link @route='scopes.scope.users.user.add-accounts'>
{{t 'resources.user.actions.add-accounts'}}
</dropdown.link>
{{/if}}
{{#if (can 'delete model' @model)}}
<dropdown.separator />
<dropdown.button
@@ -33,24 +33,26 @@
</Copyable>
</row.cell>
<row.cell>
<Rose::Dropdown
@icon='flight-icons/svg/more-horizontal-16'
@iconOnly={{true}}
@showCaret={{false}}
@dropdownRight={{true}}
@text='{{t 'actions.manage'}}'
as |dropdown|
>
<dropdown.button
@style='danger'
{{on
'click'
(route-action 'removeAccount' @model.user account)
}}
{{#if (can 'removeAccounts user' @model.user)}}
<Rose::Dropdown
@icon='flight-icons/svg/more-horizontal-16'
@iconOnly={{true}}
@showCaret={{false}}
@dropdownRight={{true}}
@text='{{t 'actions.manage'}}'
as |dropdown|
>
{{t 'actions.remove'}}
</dropdown.button>
</Rose::Dropdown>
<dropdown.button
@style='danger'
{{on
'click'
(route-action 'removeAccount' @model.user account)
}}
>
{{t 'actions.remove'}}
</dropdown.button>
</Rose::Dropdown>
{{/if}}
</row.cell>
</body.row>
{{/each}}
@@ -49,7 +49,8 @@ module('Acceptance | accounts | set password', function (hooks) {
urls.authMethods = `${urls.orgScope}/auth-methods`;
urls.authMethod = `${urls.authMethods}/${instances.authMethod.id}`;
urls.accounts = `${urls.authMethod}/accounts`;
urls.setPassword = `${urls.accounts}/${instances.account.id}/set-password`;
urls.account = `${urls.accounts}/${instances.account.id}`;
urls.setPassword = `${urls.account}/set-password`;
});
test('visiting account set password', async function (assert) {
@@ -59,6 +60,26 @@ module('Acceptance | accounts | set password', function (hooks) {
assert.equal(currentURL(), urls.setPassword);
});
test('can navigate to route with proper authorization', async function (assert) {
assert.expect(1);
await visit(urls.account);
assert.ok(
find(`.rose-layout-page-navigation [href="${urls.setPassword}"]`)
);
});
test('cannot navigate to route without proper authorization', async function (assert) {
assert.expect(1);
const authorized_actions = instances.account.authorized_actions.filter(
(item) => item !== 'set-password'
);
instances.account.update({ authorized_actions });
await visit(urls.account);
assert.notOk(
find(`.rose-layout-page-navigation [href="${urls.setPassword}"]`)
);
});
test('can set a new password for account', async function (assert) {
assert.expect(1);
this.server.post(
@@ -68,6 +68,16 @@ module('Acceptance | groups | members', function (hooks) {
assert.equal(findAll('tbody tr').length, membersCount - 1);
});
test('cannot remove a member without proper authorization', async function (assert) {
assert.expect(1);
const authorized_actions = instances.group.authorized_actions.filter(
(item) => item !== 'remove-members'
);
instances.group.update({ authorized_actions });
await visit(urls.members);
assert.notOk(find('tbody tr .rose-dropdown-button-danger'));
});
test('shows error message on member remove', async function (assert) {
assert.expect(2);
this.server.post('/groups/:idMethod', () => {
@@ -95,6 +105,22 @@ module('Acceptance | groups | members', function (hooks) {
assert.equal(currentURL(), urls.addMembers);
});
test('can navigate to add members with proper authorization', async function (assert) {
assert.expect(1);
await visit(urls.group);
assert.ok(find(`[href="${urls.addMembers}"]`));
});
test('cannot navigate to add members without proper authorization', async function (assert) {
assert.expect(1);
const authorized_actions = instances.group.authorized_actions.filter(
(item) => item !== 'add-members'
);
instances.group.update({ authorized_actions });
await visit(urls.group);
assert.notOk(find(`[href="${urls.addMembers}"]`));
});
test('select and save members to add', async function (assert) {
assert.expect(3);
instances.group.update({ memberIds: [] });
@@ -99,6 +99,16 @@ module('Acceptance | host-catalogs | host-sets | hosts', function (hooks) {
assert.equal(findAll('tbody tr').length, count - 1);
});
test('cannot remove a host without proper authorization', async function (assert) {
assert.expect(1);
const authorized_actions = instances.hostSet.authorized_actions.filter(
(item) => item !== 'remove-hosts'
);
instances.hostSet.update({ authorized_actions });
await visit(urls.hostSetHosts);
assert.notOk(find('tbody tr .rose-dropdown-button-danger'));
});
test('shows error message on host remove error', async function (assert) {
assert.expect(2);
this.server.post('/host-sets/:idMethod', () => {
@@ -126,6 +136,22 @@ module('Acceptance | host-catalogs | host-sets | hosts', function (hooks) {
assert.equal(currentURL(), urls.addHosts);
});
test('can navigate to add hosts with proper authorization', async function (assert) {
assert.expect(1);
await visit(urls.hostSet);
assert.ok(find(`[href="${urls.addHosts}"]`));
});
test('cannot navigate to add hosts without proper authorization', async function (assert) {
assert.expect(1);
const authorized_actions = instances.hostSet.authorized_actions.filter(
(item) => item !== 'add-hosts'
);
instances.hostSet.update({ authorized_actions });
await visit(urls.hostSet);
assert.notOk(find(`[href="${urls.addHosts}"]`));
});
test('select and save hosts to add', async function (assert) {
assert.expect(3);
instances.hostSet.update({ hostIds: [] });
@@ -63,6 +63,26 @@ module('Acceptance | roles | grants', function (hooks) {
assert.equal(findAll(`${grantsForm} [name="grant"]`).length, grantsCount);
});
test('cannot set grants without proper authorization', async function (assert) {
assert.expect(4);
const authorized_actions = instances.role.authorized_actions.filter(
(item) => item !== 'set-grants'
);
instances.role.update({ authorized_actions });
await visit(urls.grants);
assert.equal(
findAll('main form').length,
1,
'New grant form is not displayed.'
);
assert.notOk(
find('main form button:not([type="submit"])'),
'Grant delete button is not displayed.'
);
assert.notOk(find('.rose-form-actions'), 'Form actions are not displayed.');
assert.ok(find('main form input[disabled]'), 'Grant fields are disabled.');
});
test('update a grant', async function (assert) {
assert.expect(1);
this.server.post(
@@ -69,6 +69,16 @@ module('Acceptance | roles | principals', function (hooks) {
assert.equal(findAll('tbody tr').length, principalsCount - 1);
});
test('principal cannot be removed from a role without proper authorization', async function (assert) {
assert.expect(1);
const authorized_actions = instances.role.authorized_actions.filter(
(item) => item !== 'remove-principals'
);
instances.role.update({ authorized_actions });
await visit(urls.rolePrincipals);
assert.notOk(find('tbody tr .rose-dropdown-button-danger'));
});
test('shows error message on principal remove', async function (assert) {
assert.expect(2);
this.server.post('/roles/:idMethod', () => {
@@ -89,6 +99,16 @@ module('Acceptance | roles | principals', function (hooks) {
assert.ok(find('[role="alert"]'));
});
test('cannot navigate to add principals without proper authorization', async function (assert) {
assert.expect(1);
const authorized_actions = instances.role.authorized_actions.filter(
(item) => item !== 'add-principals'
);
instances.role.update({ authorized_actions });
await visit(urls.rolePrincipals);
assert.notOk(find('.rose-layout-page-actions a'));
});
test('select and save principals to add', async function (assert) {
assert.expect(3);
instances.role.update({ userIds: [], groupIds: [] });
@@ -61,7 +61,7 @@ module('Acceptance | users | accounts', function (hooks) {
assert.equal(findAll('tbody tr').length, accountsCount);
});
test('can remove a account', async function (assert) {
test('can remove an account', async function (assert) {
assert.expect(2);
await visit(urls.accounts);
assert.equal(findAll('tbody tr').length, accountsCount);
@@ -69,6 +69,16 @@ module('Acceptance | users | accounts', function (hooks) {
assert.equal(findAll('tbody tr').length, accountsCount - 1);
});
test('cannot remove an account without proper authorization', async function (assert) {
assert.expect(1);
const authorized_actions = instances.user.authorized_actions.filter(
(item) => item !== 'remove-accounts'
);
instances.user.update({ authorized_actions });
await visit(urls.accounts);
assert.notOk(find('tbody tr .rose-dropdown-button-danger'));
});
test('shows error message on account remove', async function (assert) {
assert.expect(2);
this.server.post('/users/:idMethod', () => {
@@ -92,10 +102,27 @@ module('Acceptance | users | accounts', function (hooks) {
test('visiting account add accounts', async function (assert) {
assert.expect(1);
await visit(urls.addAccounts);
await visit(urls.addAccounts);
await a11yAudit();
assert.equal(currentURL(), urls.addAccounts);
});
test('can navigate to add accounts with proper authorization', async function (assert) {
assert.expect(1);
await visit(urls.accounts);
assert.ok(find(`[href="${urls.addAccounts}"]`));
});
test('cannot navigate to add accounts without proper authorization', async function (assert) {
assert.expect(1);
const authorized_actions = instances.user.authorized_actions.filter(
(item) => item !== 'add-accounts'
);
instances.user.update({ authorized_actions });
await visit(urls.accounts);
assert.notOk(find(`[href="${urls.addAccounts}"]`));
});
test('select and save accounts to add', async function (assert) {
assert.expect(3);
instances.user.update({ accountIds: [] });