mirror of
https://github.com/status-im/consul.git
synced 2025-03-02 22:30:43 +00:00
ui: Add sorting to Roles (#8369)
* Add sorting to ACLs roles with comparator * Add acls/roles sorting test * Add navigation feature test to roles * Update onchange value target for sorting roles
This commit is contained in:
parent
25cc7e5cbc
commit
3b244d8f56
@ -1,5 +1,6 @@
|
|||||||
export default (collection, clickable, attribute, text, actions) => () => {
|
export default (collection, clickable, attribute, text, actions) => () => {
|
||||||
return collection('.consul-role-list li:not(:first-child)', {
|
return collection('.consul-role-list [data-test-list-row]', {
|
||||||
|
role: clickable('a'),
|
||||||
name: attribute('data-test-role', '[data-test-role]'),
|
name: attribute('data-test-role', '[data-test-role]'),
|
||||||
description: text('[data-test-description]'),
|
description: text('[data-test-description]'),
|
||||||
policy: text('[data-test-policy].policy', { multiple: true }),
|
policy: text('[data-test-policy].policy', { multiple: true }),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import Controller from '@ember/controller';
|
import Controller from '@ember/controller';
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
queryParams: {
|
queryParams: {
|
||||||
|
sortBy: 'sort',
|
||||||
search: {
|
search: {
|
||||||
as: 'filter',
|
as: 'filter',
|
||||||
replace: true,
|
replace: true,
|
||||||
|
@ -2,6 +2,7 @@ import service from 'consul-ui/sort/comparators/service';
|
|||||||
import check from 'consul-ui/sort/comparators/check';
|
import check from 'consul-ui/sort/comparators/check';
|
||||||
import intention from 'consul-ui/sort/comparators/intention';
|
import intention from 'consul-ui/sort/comparators/intention';
|
||||||
import token from 'consul-ui/sort/comparators/token';
|
import token from 'consul-ui/sort/comparators/token';
|
||||||
|
import role from 'consul-ui/sort/comparators/role';
|
||||||
|
|
||||||
export function initialize(container) {
|
export function initialize(container) {
|
||||||
// Service-less injection using private properties at a per-project level
|
// Service-less injection using private properties at a per-project level
|
||||||
@ -11,6 +12,7 @@ export function initialize(container) {
|
|||||||
check: check(),
|
check: check(),
|
||||||
intention: intention(),
|
intention: intention(),
|
||||||
token: token(),
|
token: token(),
|
||||||
|
role: role(),
|
||||||
};
|
};
|
||||||
Sort.reopen({
|
Sort.reopen({
|
||||||
comparator: function(type) {
|
comparator: function(type) {
|
||||||
|
@ -7,6 +7,7 @@ import WithRoleActions from 'consul-ui/mixins/role/with-actions';
|
|||||||
export default Route.extend(WithRoleActions, {
|
export default Route.extend(WithRoleActions, {
|
||||||
repo: service('repository/role'),
|
repo: service('repository/role'),
|
||||||
queryParams: {
|
queryParams: {
|
||||||
|
sortBy: 'sort',
|
||||||
search: {
|
search: {
|
||||||
as: 'filter',
|
as: 'filter',
|
||||||
replace: true,
|
replace: true,
|
||||||
|
3
ui-v2/app/sort/comparators/role.js
Normal file
3
ui-v2/app/sort/comparators/role.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default () => key => {
|
||||||
|
return key;
|
||||||
|
};
|
@ -3,6 +3,17 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
{{title 'Access Controls'}}
|
{{title 'Access Controls'}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#let (selectable-key-values
|
||||||
|
(array "Name:asc" "A to Z")
|
||||||
|
(array "Name:desc" "Z to A")
|
||||||
|
(array "CreateIndex:asc" "Newest to oldest")
|
||||||
|
(array "CreateIndex:desc" "Oldest to newest")
|
||||||
|
selected=sortBy
|
||||||
|
)
|
||||||
|
as |sort|
|
||||||
|
}}
|
||||||
|
|
||||||
<AppView
|
<AppView
|
||||||
@class="role list"
|
@class="role list"
|
||||||
@loading={{isLoading}}
|
@loading={{isLoading}}
|
||||||
@ -31,17 +42,24 @@
|
|||||||
<BlockSlot @name="actions">
|
<BlockSlot @name="actions">
|
||||||
<a data-test-create href="{{href-to 'dc.acls.roles.create'}}" class="type-create">Create</a>
|
<a data-test-create href="{{href-to 'dc.acls.roles.create'}}" class="type-create">Create</a>
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
<BlockSlot @name="content">
|
<BlockSlot @name="toolbar">
|
||||||
{{#if (gt items.length 0) }}
|
{{#if (gt items.length 0) }}
|
||||||
<SearchBar
|
<SearchBar
|
||||||
@value={{search}}
|
@value={{search}}
|
||||||
@onsearch={{action (mut search) value="target.value"}}
|
@onsearch={{action (mut search) value="target.value"}}
|
||||||
|
@secondary="sort"
|
||||||
|
@selected={{sort.selected}}
|
||||||
|
@options={{sort.items}}
|
||||||
|
@onchange={{action (mut sortBy) value='target.selected.key'}}
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<ChangeableSet @dispatcher={{searchable 'role' items}} @terms={{search}}>
|
</BlockSlot>
|
||||||
|
<BlockSlot @name="content">
|
||||||
|
{{#let (sort-by (comparator 'role' sort.selected.key) items) as |sorted|}}
|
||||||
|
<ChangeableSet @dispatcher={{searchable 'role' sorted}} @terms={{search}}>
|
||||||
<BlockSlot @name="set" as |filtered|>
|
<BlockSlot @name="set" as |filtered|>
|
||||||
<ConsulRoleList
|
<ConsulRoleList
|
||||||
@items={{sort-by "CreateTime:desc" "Name:asc" filtered}}
|
@items={{filtered}}
|
||||||
@ondelete={{action send 'delete'}}
|
@ondelete={{action send 'delete'}}
|
||||||
/>
|
/>
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
@ -76,5 +94,7 @@
|
|||||||
</EmptyState>
|
</EmptyState>
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
</ChangeableSet>
|
</ChangeableSet>
|
||||||
|
{{/let}}
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
</AppView>
|
</AppView>
|
||||||
|
{{/let}}
|
16
ui-v2/tests/acceptance/dc/acls/roles/navigation.feature
Normal file
16
ui-v2/tests/acceptance/dc/acls/roles/navigation.feature
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
@setupApplicationTest
|
||||||
|
Feature: dc / roles / navigation
|
||||||
|
Scenario: Clicking a role in the listing and back again
|
||||||
|
Given 1 datacenter model with the value "dc-1"
|
||||||
|
And 3 role models
|
||||||
|
When I visit the roles page for yaml
|
||||||
|
---
|
||||||
|
dc: dc-1
|
||||||
|
---
|
||||||
|
Then the url should be /dc-1/acls/roles
|
||||||
|
And the title should be "Roles - Consul"
|
||||||
|
Then I see 3 role models
|
||||||
|
When I click role on the roles
|
||||||
|
And I click "[data-test-back]"
|
||||||
|
Then the url should be /dc-1/acls/roles
|
||||||
|
|
57
ui-v2/tests/acceptance/dc/acls/roles/sorting.feature
Normal file
57
ui-v2/tests/acceptance/dc/acls/roles/sorting.feature
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
@setupApplicationTest
|
||||||
|
Feature: dc / acls / roles / sorting
|
||||||
|
Scenario: Sorting Roles
|
||||||
|
Given 1 datacenter model with the value "dc-1"
|
||||||
|
And 4 role models from yaml
|
||||||
|
---
|
||||||
|
- Name: "system-A"
|
||||||
|
CreateIndex: 3
|
||||||
|
- Name: "system-D"
|
||||||
|
CreateIndex: 2
|
||||||
|
- Name: "system-C"
|
||||||
|
CreateIndex: 1
|
||||||
|
- Name: "system-B"
|
||||||
|
CreateIndex: 4
|
||||||
|
---
|
||||||
|
When I visit the roles page for yaml
|
||||||
|
---
|
||||||
|
dc: dc-1
|
||||||
|
---
|
||||||
|
Then the url should be /dc-1/acls/roles
|
||||||
|
Then I see 4 role models
|
||||||
|
When I click selected on the sort
|
||||||
|
When I click options.1.button on the sort
|
||||||
|
Then I see name on the roles vertically like yaml
|
||||||
|
---
|
||||||
|
- "system-D"
|
||||||
|
- "system-C"
|
||||||
|
- "system-B"
|
||||||
|
- "system-A"
|
||||||
|
---
|
||||||
|
When I click selected on the sort
|
||||||
|
When I click options.0.button on the sort
|
||||||
|
Then I see name on the roles vertically like yaml
|
||||||
|
---
|
||||||
|
- "system-A"
|
||||||
|
- "system-B"
|
||||||
|
- "system-C"
|
||||||
|
- "system-D"
|
||||||
|
---
|
||||||
|
When I click selected on the sort
|
||||||
|
When I click options.2.button on the sort
|
||||||
|
Then I see name on the roles vertically like yaml
|
||||||
|
---
|
||||||
|
- "system-C"
|
||||||
|
- "system-D"
|
||||||
|
- "system-A"
|
||||||
|
- "system-B"
|
||||||
|
---
|
||||||
|
When I click selected on the sort
|
||||||
|
When I click options.3.button on the sort
|
||||||
|
Then I see name on the roles vertically like yaml
|
||||||
|
---
|
||||||
|
- "system-B"
|
||||||
|
- "system-A"
|
||||||
|
- "system-D"
|
||||||
|
- "system-C"
|
||||||
|
---
|
@ -0,0 +1,10 @@
|
|||||||
|
import steps from '../../../steps';
|
||||||
|
|
||||||
|
// step definitions that are shared between features should be moved to the
|
||||||
|
// tests/acceptance/steps/steps.js file
|
||||||
|
|
||||||
|
export default function(assert) {
|
||||||
|
return steps(assert).then('I should find a file', function() {
|
||||||
|
assert.ok(true, this.step);
|
||||||
|
});
|
||||||
|
}
|
10
ui-v2/tests/acceptance/steps/dc/acls/roles/sorting-steps.js
Normal file
10
ui-v2/tests/acceptance/steps/dc/acls/roles/sorting-steps.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import steps from '../../../steps';
|
||||||
|
|
||||||
|
// step definitions that are shared between features should be moved to the
|
||||||
|
// tests/acceptance/steps/steps.js file
|
||||||
|
|
||||||
|
export default function(assert) {
|
||||||
|
return steps(assert).then('I should find a file', function() {
|
||||||
|
assert.ok(true, this.step);
|
||||||
|
});
|
||||||
|
}
|
@ -170,7 +170,7 @@ export default {
|
|||||||
acl: create(acl(visitable, submitable, deletable, cancelable, clickable)),
|
acl: create(acl(visitable, submitable, deletable, cancelable, clickable)),
|
||||||
policies: create(policies(visitable, creatable, consulPolicyList, freetextFilter)),
|
policies: create(policies(visitable, creatable, consulPolicyList, freetextFilter)),
|
||||||
policy: create(policy(visitable, submitable, deletable, cancelable, clickable, tokenList)),
|
policy: create(policy(visitable, submitable, deletable, cancelable, clickable, tokenList)),
|
||||||
roles: create(roles(visitable, creatable, consulRoleList, freetextFilter)),
|
roles: create(roles(visitable, creatable, consulRoleList, popoverSelect)),
|
||||||
// TODO: This needs a policyList
|
// TODO: This needs a policyList
|
||||||
role: create(role(visitable, submitable, deletable, cancelable, policySelector, tokenList)),
|
role: create(role(visitable, submitable, deletable, cancelable, policySelector, tokenList)),
|
||||||
tokens: create(tokens(visitable, creatable, text, consulTokenList, popoverSelect)),
|
tokens: create(tokens(visitable, creatable, text, consulTokenList, popoverSelect)),
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
export default function(visitable, creatable, roles, filter) {
|
export default function(visitable, creatable, roles, popoverSelect) {
|
||||||
return {
|
return {
|
||||||
visit: visitable('/:dc/acls/roles'),
|
visit: visitable('/:dc/acls/roles'),
|
||||||
roles: roles(),
|
roles: roles(),
|
||||||
filter: filter(),
|
sort: popoverSelect(),
|
||||||
...creatable(),
|
...creatable(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user