chore: Use HDS components in auth methods list view (#1686)
* chore: 🤖 use hds table and dropdown
This commit is contained in:
1 parent
3b3d6ab50f
commit
7d909551ac
5 files changed
+124
-109
No files matched your search
@@ -24,6 +24,10 @@
|
|||||||
[class^='hds-form-group'] {
|
[class^='hds-form-group'] {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hds-table__td p {
|
||||||
|
color: var(--token-form-indicator-optional-color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.hds-dropdown {
|
.hds-dropdown {
|
||||||
|
|||||||
@@ -679,3 +679,11 @@
|
|||||||
}
|
}
|
||||||
/* stylelint-enable selector-class-pattern */
|
/* stylelint-enable selector-class-pattern */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.auth-methods-list-alert {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.auth-methods-list-table {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
@@ -41,6 +41,25 @@
|
|||||||
|
|
||||||
<page.body>
|
<page.body>
|
||||||
|
|
||||||
|
{{#if @model}}
|
||||||
|
{{#unless this.hasPrimaryAuthMethod}}
|
||||||
|
<Hds::Alert
|
||||||
|
class='auth-methods-list-alert'
|
||||||
|
@type='inline'
|
||||||
|
@color='warning'
|
||||||
|
as |A|
|
||||||
|
>
|
||||||
|
<A.Title>
|
||||||
|
{{t 'resources.auth-method.messages.no-primary-auth-method.title'}}
|
||||||
|
</A.Title>
|
||||||
|
<A.Description>
|
||||||
|
{{t
|
||||||
|
'resources.auth-method.messages.no-primary-auth-method.description'
|
||||||
|
}}
|
||||||
|
</A.Description>
|
||||||
|
</Hds::Alert>
|
||||||
|
{{/unless}}
|
||||||
|
{{/if}}
|
||||||
{{#if
|
{{#if
|
||||||
(or
|
(or
|
||||||
@model
|
@model
|
||||||
@@ -92,101 +111,80 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if @model}}
|
{{#if @model}}
|
||||||
{{#unless this.hasPrimaryAuthMethod}}
|
<Hds::Table
|
||||||
<Rose::Notification
|
class='auth-methods-list-table'
|
||||||
@style='warning'
|
@model={{@model}}
|
||||||
@heading={{t
|
@columns={{array
|
||||||
'resources.auth-method.messages.no-primary-auth-method.title'
|
(hash label=(t 'form.name.label'))
|
||||||
}}
|
(hash label=(t 'form.type.label'))
|
||||||
>
|
(hash label=(t 'form.id.label'))
|
||||||
{{t
|
(hash label='')
|
||||||
'resources.auth-method.messages.no-primary-auth-method.description'
|
(hash label=(t 'titles.actions'))
|
||||||
}}
|
}}
|
||||||
</Rose::Notification>
|
@valign='middle'
|
||||||
{{/unless}}
|
>
|
||||||
|
<:body as |B|>
|
||||||
<Rose::Table as |table|>
|
<B.Tr>
|
||||||
<table.header as |header|>
|
<B.Td>
|
||||||
<header.row as |row|>
|
{{#if (can 'read auth-method' B.data)}}
|
||||||
<row.headerCell>{{t 'form.name.label'}}</row.headerCell>
|
<LinkTo
|
||||||
<row.headerCell>{{t 'form.type.label'}}</row.headerCell>
|
@route='scopes.scope.auth-methods.auth-method'
|
||||||
<row.headerCell>{{t 'form.id.label'}}</row.headerCell>
|
@model={{B.data.id}}
|
||||||
<row.cell />
|
|
||||||
<row.headerCell>{{t 'titles.actions'}}</row.headerCell>
|
|
||||||
</header.row>
|
|
||||||
</table.header>
|
|
||||||
|
|
||||||
<table.body as |body|>
|
|
||||||
{{#each @model as |authMethod|}}
|
|
||||||
<body.row as |row|>
|
|
||||||
<row.headerCell>
|
|
||||||
{{#if (can 'read auth-method' authMethod)}}
|
|
||||||
<LinkTo
|
|
||||||
@route='scopes.scope.auth-methods.auth-method'
|
|
||||||
@model={{authMethod.id}}
|
|
||||||
>
|
|
||||||
{{authMethod.displayName}}
|
|
||||||
</LinkTo>
|
|
||||||
{{else}}
|
|
||||||
{{authMethod.displayName}}
|
|
||||||
{{/if}}
|
|
||||||
<p>{{authMethod.description}}</p>
|
|
||||||
</row.headerCell>
|
|
||||||
<row.cell>
|
|
||||||
<Hds::Badge
|
|
||||||
@text={{t
|
|
||||||
(concat 'resources.auth-method.types.' authMethod.type)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</row.cell>
|
|
||||||
<row.cell>
|
|
||||||
<Copyable
|
|
||||||
@text={{authMethod.id}}
|
|
||||||
@buttonText={{t 'actions.copy-to-clipboard'}}
|
|
||||||
@acknowledgeText={{t 'states.copied'}}
|
|
||||||
>
|
>
|
||||||
<code>{{authMethod.id}}</code>
|
{{B.data.displayName}}
|
||||||
</Copyable>
|
</LinkTo>
|
||||||
</row.cell>
|
{{else}}
|
||||||
<row.cell>
|
{{B.data.displayName}}
|
||||||
{{#if authMethod.isPrimary}}
|
{{/if}}
|
||||||
<Hds::Badge @text={{t 'states.primary'}} @color='success' />
|
<p>{{B.data.description}}</p>
|
||||||
{{/if}}
|
</B.Td>
|
||||||
</row.cell>
|
<B.Td>
|
||||||
<row.cell>
|
<Hds::Badge
|
||||||
{{#if (can 'makePrimary auth-method' authMethod)}}
|
@text={{t (concat 'resources.auth-method.types.' B.data.type)}}
|
||||||
<Rose::Dropdown
|
/>
|
||||||
|
</B.Td>
|
||||||
|
<B.Td>
|
||||||
|
<Copyable
|
||||||
|
@text={{B.data.id}}
|
||||||
|
@buttonText={{t 'actions.copy-to-clipboard'}}
|
||||||
|
@acknowledgeText={{t 'states.copied'}}
|
||||||
|
>
|
||||||
|
<code>{{B.data.id}}</code>
|
||||||
|
</Copyable>
|
||||||
|
</B.Td>
|
||||||
|
<B.Td>
|
||||||
|
{{#if B.data.isPrimary}}
|
||||||
|
<Hds::Badge @text={{t 'states.primary'}} @color='success' />
|
||||||
|
{{/if}}
|
||||||
|
</B.Td>
|
||||||
|
<B.Td>
|
||||||
|
{{#if (can 'makePrimary auth-method' B.data)}}
|
||||||
|
<Hds::Dropdown as |dd|>
|
||||||
|
<dd.ToggleIcon
|
||||||
|
@icon='more-horizontal'
|
||||||
@text={{t 'actions.manage'}}
|
@text={{t 'actions.manage'}}
|
||||||
@dropdownRight={{true}}
|
@hasChevron={{false}}
|
||||||
@iconOnly={{true}}
|
/>
|
||||||
@showCaret={{false}}
|
{{#unless B.data.isPrimary}}
|
||||||
@icon='flight-icons/svg/more-horizontal-16'
|
<dd.Interactive
|
||||||
as |dropdown|
|
@text={{t 'resources.auth-method.actions.make-primary'}}
|
||||||
>
|
{{on 'click' (route-action 'makePrimary' B.data)}}
|
||||||
{{#unless authMethod.isPrimary}}
|
/>
|
||||||
<dropdown.button
|
{{/unless}}
|
||||||
{{on 'click' (route-action 'makePrimary' authMethod)}}
|
{{#if B.data.isPrimary}}
|
||||||
>
|
<dd.Interactive
|
||||||
{{t 'resources.auth-method.actions.make-primary'}}
|
@text={{t
|
||||||
</dropdown.button>
|
'resources.auth-method.actions.remove-as-primary'
|
||||||
{{/unless}}
|
}}
|
||||||
{{#if authMethod.isPrimary}}
|
{{on 'click' (route-action 'removeAsPrimary' B.data)}}
|
||||||
<dropdown.button
|
/>
|
||||||
{{on
|
{{/if}}
|
||||||
'click'
|
</Hds::Dropdown>
|
||||||
(route-action 'removeAsPrimary' authMethod)
|
{{/if}}
|
||||||
}}
|
</B.Td>
|
||||||
>
|
</B.Tr>
|
||||||
{{t 'resources.auth-method.actions.remove-as-primary'}}
|
</:body>
|
||||||
</dropdown.button>
|
</Hds::Table>
|
||||||
{{/if}}
|
|
||||||
</Rose::Dropdown>
|
|
||||||
{{/if}}
|
|
||||||
</row.cell>
|
|
||||||
</body.row>
|
|
||||||
{{/each}}
|
|
||||||
</table.body>
|
|
||||||
</Rose::Table>
|
|
||||||
|
|
||||||
{{else if (has-resource-filter-selections
|
{{else if (has-resource-filter-selections
|
||||||
'scopes.scope.auth-methods' 'type'
|
'scopes.scope.auth-methods' 'type'
|
||||||
|
|||||||
@@ -22,10 +22,13 @@ import {
|
|||||||
// //invalidateSession,
|
// //invalidateSession,
|
||||||
} from 'ember-simple-auth/test-support';
|
} from 'ember-simple-auth/test-support';
|
||||||
|
|
||||||
module('Acceptance | auth-methods | create ', function (hooks) {
|
module('Acceptance | auth-methods | create', function (hooks) {
|
||||||
setupApplicationTest(hooks);
|
setupApplicationTest(hooks);
|
||||||
setupMirage(hooks);
|
setupMirage(hooks);
|
||||||
|
const DROPDOWN_SELECTOR_ICON =
|
||||||
|
'tbody .hds-table__tr:nth-child(1) .hds-table__td:last-child .hds-dropdown-toggle-icon';
|
||||||
|
const DROPDOWN_SELECTOR_OPTION =
|
||||||
|
'.hds-dropdown__content .hds-dropdown-list-item [type=button]';
|
||||||
let getAuthMethodsCount;
|
let getAuthMethodsCount;
|
||||||
const instances = {
|
const instances = {
|
||||||
scopes: {
|
scopes: {
|
||||||
@@ -255,24 +258,27 @@ module('Acceptance | auth-methods | create ', function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('user can make and remove primary auth methods from index', async function (assert) {
|
test('user can make and remove primary auth methods from index', async function (assert) {
|
||||||
assert.expect(3);
|
assert.expect(4);
|
||||||
assert.notOk(
|
assert.notOk(
|
||||||
instances.orgScope.primaryAuthMethodId,
|
instances.orgScope.primaryAuthMethodId,
|
||||||
'Primary auth method is not yet set.'
|
'Primary auth method is not yet set.'
|
||||||
);
|
);
|
||||||
await visit(urls.authMethods);
|
await visit(urls.authMethods);
|
||||||
await click(
|
|
||||||
'.rose-table-body .rose-table-row:first-child .rose-dropdown-content [type="button"]:first-child'
|
await click(DROPDOWN_SELECTOR_ICON);
|
||||||
);
|
assert.dom(DROPDOWN_SELECTOR_OPTION).exists();
|
||||||
|
await click(DROPDOWN_SELECTOR_OPTION);
|
||||||
|
|
||||||
let scope = this.server.schema.scopes.find(instances.orgScope.id);
|
let scope = this.server.schema.scopes.find(instances.orgScope.id);
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
scope.primaryAuthMethodId,
|
scope.primaryAuthMethodId,
|
||||||
instances.authMethod.id,
|
instances.authMethod.id,
|
||||||
'Primary auth method is set.'
|
'Primary auth method is set.'
|
||||||
);
|
);
|
||||||
await click(
|
await click(DROPDOWN_SELECTOR_ICON);
|
||||||
'.rose-table-body .rose-table-row:first-child .rose-dropdown-content [type="button"]:first-child'
|
await click(DROPDOWN_SELECTOR_OPTION);
|
||||||
);
|
|
||||||
scope = this.server.schema.scopes.find(instances.orgScope.id);
|
scope = this.server.schema.scopes.find(instances.orgScope.id);
|
||||||
assert.notOk(scope.primaryAuthMethodId, 'Primary auth method is unset.');
|
assert.notOk(scope.primaryAuthMethodId, 'Primary auth method is unset.');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,17 +23,16 @@ import {
|
|||||||
module('Acceptance | auth methods | read', function (hooks) {
|
module('Acceptance | auth methods | read', function (hooks) {
|
||||||
setupApplicationTest(hooks);
|
setupApplicationTest(hooks);
|
||||||
setupMirage(hooks);
|
setupMirage(hooks);
|
||||||
const AUTH_LINK_SELECTOR =
|
const AUTH_LINK_SELECTOR = 'main tbody .hds-table__td:nth-child(1) a';
|
||||||
'main tbody .rose-table-header-cell:nth-child(1) a';
|
|
||||||
const AUTH_TYPE_SELECTOR =
|
const AUTH_TYPE_SELECTOR =
|
||||||
'tbody .rose-table-row:nth-child(1) .rose-table-cell';
|
'tbody .hds-table__tr:nth-child(1) .hds-table__td:nth-child(2)';
|
||||||
const AUTH_ACTIONS_SELECTOR =
|
const AUTH_ACTIONS_SELECTOR =
|
||||||
'tbody .rose-table-row:nth-child(1) .rose-table-cell:last-child .rose-dropdown';
|
'tbody .hds-table__tr:nth-child(1) .hds-table__td:last-child .hds-dropdown';
|
||||||
const LDAP_AUTH_LINK_SELECTOR = 'tbody .rose-table-row:nth-child(2) a';
|
const LDAP_AUTH_LINK_SELECTOR = 'tbody .hds-table__tr:nth-child(2) a';
|
||||||
const LDAP_AUTH_TYPE_SELECTOR =
|
const LDAP_AUTH_TYPE_SELECTOR =
|
||||||
'tbody .rose-table-row:nth-child(2) .rose-table-cell';
|
'tbody .hds-table__tr:nth-child(2) .hds-table__td:nth-child(2)';
|
||||||
const LDAP_AUTH_ACTIONS_SELECTOR =
|
const LDAP_AUTH_ACTIONS_SELECTOR =
|
||||||
'tbody .rose-table-row:nth-child(2) .rose-table-cell:last-child .rose-dropdown';
|
'tbody .hds-table__tr:nth-child(2) .hds-table__td:last-child .hds-dropdown';
|
||||||
|
|
||||||
const instances = {
|
const instances = {
|
||||||
scopes: {
|
scopes: {
|
||||||
|
|||||||
Reference in new issue
Block a user