diff --git a/ui-v2/app/controllers/dc/intentions/index.js b/ui-v2/app/controllers/dc/intentions/index.js
index 3407bfeef8..f99cde37f3 100644
--- a/ui-v2/app/controllers/dc/intentions/index.js
+++ b/ui-v2/app/controllers/dc/intentions/index.js
@@ -1,9 +1,7 @@
import Controller from '@ember/controller';
export default Controller.extend({
queryParams: {
- filterBy: {
- as: 'action',
- },
+ sortBy: 'sort',
search: {
as: 'filter',
replace: true,
diff --git a/ui-v2/app/initializers/sort.js b/ui-v2/app/initializers/sort.js
index 6ddcc3ef86..464abe4d18 100644
--- a/ui-v2/app/initializers/sort.js
+++ b/ui-v2/app/initializers/sort.js
@@ -1,5 +1,6 @@
import service from 'consul-ui/sort/comparators/service';
import check from 'consul-ui/sort/comparators/check';
+import intention from 'consul-ui/sort/comparators/intention';
export function initialize(container) {
// Service-less injection using private properties at a per-project level
@@ -7,6 +8,7 @@ export function initialize(container) {
const comparators = {
service: service(),
check: check(),
+ intention: intention(),
};
Sort.reopen({
comparator: function(type) {
diff --git a/ui-v2/app/routes/dc/intentions/index.js b/ui-v2/app/routes/dc/intentions/index.js
index d62d3c00aa..16284be807 100644
--- a/ui-v2/app/routes/dc/intentions/index.js
+++ b/ui-v2/app/routes/dc/intentions/index.js
@@ -2,9 +2,7 @@ import Route from '@ember/routing/route';
export default Route.extend({
queryParams: {
- filterBy: {
- as: 'action',
- },
+ sortBy: 'sort',
search: {
as: 'filter',
replace: true,
diff --git a/ui-v2/app/sort/comparators/intention.js b/ui-v2/app/sort/comparators/intention.js
new file mode 100644
index 0000000000..62e718f7a1
--- /dev/null
+++ b/ui-v2/app/sort/comparators/intention.js
@@ -0,0 +1,3 @@
+export default () => key => {
+ return key;
+};
diff --git a/ui-v2/app/templates/dc/intentions/index.hbs b/ui-v2/app/templates/dc/intentions/index.hbs
index dff4f8949a..1d076c7b88 100644
--- a/ui-v2/app/templates/dc/intentions/index.hbs
+++ b/ui-v2/app/templates/dc/intentions/index.hbs
@@ -7,14 +7,18 @@
- {{#let (filter-by "Action" "deny" api.data) as |denied|}}
{{#let (selectable-key-values
- (array "" (concat "All (" api.data.length ")"))
- (array "allow" (concat "Allow (" (sub api.data.length denied.length) ")"))
- (array "deny" (concat "Deny (" denied.length ")"))
- selected=filterBy
+ (array "Action:asc" "Allow to Deny")
+ (array "Action:desc" "Deny to Allow")
+ (array "SourceName:asc" "Source: A to Z")
+ (array "SourceName:desc" "Source: Z to A")
+ (array "DestinationName:asc" "Destination: A to Z")
+ (array "DestinationName:desc" "Destination: Z to A")
+ (array "Precedence:asc" "Precedence: Asc")
+ (array "Precedence:desc" "Precedence: Desc")
+ selected=sortBy
)
- as |filter|
+ as |sort|
}}
@@ -33,15 +37,16 @@
data-test-intention-filter="true"
@value={{search}}
@onsearch={{action (mut search) value="target.value"}}
- @selected={{filter.selected}}
- @options={{filter.items}}
- @onchange={{action (mut filterBy) value='target.value'}}
+ @secondary="sort"
+ @selected={{sort.selected}}
+ @options={{sort.items}}
+ @onchange={{action (mut sortBy) value='target.value'}}
/>
{{/if}}
-
-
+ {{#let (sort-by (comparator 'intention' sort.selected.key) api.data) as |sorted|}}
+
-
+ {{/let}}
-
{{/let}}
- {{/let}}
-
\ No newline at end of file
diff --git a/ui-v2/tests/acceptance/components/intention-filter.feature b/ui-v2/tests/acceptance/components/intention-filter.feature
deleted file mode 100644
index d8acd9aff3..0000000000
--- a/ui-v2/tests/acceptance/components/intention-filter.feature
+++ /dev/null
@@ -1,55 +0,0 @@
-@setupApplicationTest
-Feature: components / intention-filter: Intention Filter
- In order to find the intention I'm looking for easier
- As a user
- I should be able to filter by 'policy' (allow/deny) and freetext search tokens by source and destination
- Scenario: Filtering [Model]
- Given 1 datacenter model with the value "dc-1"
- And 2 [Model] models
- When I visit the [Page] page for yaml
- ---
- dc: dc-1
- ---
- Then the url should be [Url]
-
- Then I see 2 [Model] models
- And I see allIsSelected on the filter
-
- When I click allow on the filter
- Then I see allowIsSelected on the filter
- And I see 1 [Model] model
- And I see 1 [Model] model with the action "allow"
-
- When I click deny on the filter
- Then I see denyIsSelected on the filter
- And I see 1 [Model] model
- And I see 1 [Model] model with the action "deny"
-
- When I click all on the filter
- Then I see 2 [Model] models
- Then I see allIsSelected on the filter
- Then I fill in with yaml
- ---
- s: alarm
- ---
- And I see 1 [Model] model
- And I see 1 [Model] model with the source "alarm"
- Then I fill in with yaml
- ---
- s: feed
- ---
- And I see 1 [Model] model
- And I see 1 [Model] model with the destination "feed"
- Then I fill in with yaml
- ---
- s: transmitter
- ---
- And I see 2 [Model] models
- And I see 1 [Model] model with the source "transmitter"
- And I see 1 [Model] model with the destination "transmitter"
-
- Where:
- ---------------------------------------------
- | Model | Page | Url |
- | intention | intentions | /dc-1/intentions |
- ---------------------------------------------
diff --git a/ui-v2/tests/acceptance/dc/intentions/navigation.feature b/ui-v2/tests/acceptance/dc/intentions/navigation.feature
new file mode 100644
index 0000000000..76e24d0341
--- /dev/null
+++ b/ui-v2/tests/acceptance/dc/intentions/navigation.feature
@@ -0,0 +1,30 @@
+@setupApplicationTest
+Feature: dc / intentions / navigation
+ Scenario: Clicking a intention in the listing and back again
+ Given 1 datacenter model with the value "dc-1"
+ And 3 intention models
+ When I visit the intentions page for yaml
+ ---
+ dc: dc-1
+ ---
+ Then the url should be /dc-1/intentions
+ And the title should be "Intentions - Consul"
+ Then I see 3 intention models
+ When I click intention on the intentions
+ Then a GET request was made to "/v1/internal/ui/services?dc=dc-1&ns=*"
+ And I click "[data-test-back]"
+ Then the url should be /dc-1/intentions
+ Scenario: Clicking the create button and back again
+ Given 1 datacenter model with the value "dc-1"
+ And 3 intention models
+ When I visit the intentions page for yaml
+ ---
+ dc: dc-1
+ ---
+ Then the url should be /dc-1/intentions
+ And the title should be "Intentions - Consul"
+ Then I see 3 intention models
+ When I click create
+ Then the url should be /dc-1/intentions/create
+ And I click "[data-test-back]"
+ Then the url should be /dc-1/intentions
diff --git a/ui-v2/tests/acceptance/dc/intentions/sorting.feature b/ui-v2/tests/acceptance/dc/intentions/sorting.feature
new file mode 100644
index 0000000000..8575c60443
--- /dev/null
+++ b/ui-v2/tests/acceptance/dc/intentions/sorting.feature
@@ -0,0 +1,42 @@
+@setupApplicationTest
+@notNamespaceable
+Feature: dc / intentions / sorting
+ Scenario: Sorting Intentions
+ Given 1 datacenter model with the value "dc-1"
+ And 6 intention models from yaml
+ ---
+ - Action: "allow"
+ - Action: "allow"
+ - Action: "deny"
+ - Action: "deny"
+ - Action: "allow"
+ - Action: "deny"
+ ---
+ When I visit the intentions page for yaml
+ ---
+ dc: dc-1
+ ---
+ Then I see 6 intention models
+ When I click selected on the sort
+ When I click options.1.button on the sort
+ Then I see action on the intentions vertically like yaml
+ ---
+ - "deny"
+ - "deny"
+ - "deny"
+ - "allow"
+ - "allow"
+ - "allow"
+ ---
+ When I click selected on the sort
+ When I click options.0.button on the sort
+ Then I see action on the intentions vertically like yaml
+ ---
+ - "allow"
+ - "allow"
+ - "allow"
+ - "deny"
+ - "deny"
+ - "deny"
+ ---
+
diff --git a/ui-v2/tests/acceptance/page-navigation.feature b/ui-v2/tests/acceptance/page-navigation.feature
index f4e0e15b5f..c2648c77b3 100644
--- a/ui-v2/tests/acceptance/page-navigation.feature
+++ b/ui-v2/tests/acceptance/page-navigation.feature
@@ -46,7 +46,6 @@ Feature: page-navigation
| node | nodes | /dc-1/nodes/node-0/health-checks | /v1/session/node/node-0?dc=dc-1&ns=@namespace | /dc-1/nodes |
| kv | kvs | /dc-1/kv/0-key-value/edit | /v1/session/info/ee52203d-989f-4f7a-ab5a-2bef004164ca?dc=dc-1&ns=@namespace | /dc-1/kv |
# | acl | acls | /dc-1/acls/anonymous | /v1/acl/info/anonymous?dc=dc-1 | /dc-1/acls |
- | intention | intentions | /dc-1/intentions/ee52203d-989f-4f7a-ab5a-2bef004164ca | /v1/internal/ui/services?dc=dc-1&ns=* | /dc-1/intentions |
# These Endpoints will be datacenters due to the datacenters checkbox selectors
| token | tokens | /dc-1/acls/tokens/ee52203d-989f-4f7a-ab5a-2bef004164ca | /v1/catalog/datacenters | /dc-1/acls/tokens |
| policy | policies | /dc-1/acls/policies/ee52203d-989f-4f7a-ab5a-2bef004164ca | /v1/catalog/datacenters | /dc-1/acls/policies |
@@ -123,7 +122,7 @@ Feature: page-navigation
| Item | Model | URL | Back |
| kv | kvs | /dc-1/kv/0-key-value/edit | /dc-1/kv |
# | acl | acls | /dc-1/acls/anonymous | /dc-1/acls |
- | intention | intentions | /dc-1/intentions/ee52203d-989f-4f7a-ab5a-2bef004164ca | /dc-1/intentions |
+ # | intention | intentions | /dc-1/intentions/ee52203d-989f-4f7a-ab5a-2bef004164ca | /dc-1/intentions |
--------------------------------------------------------------------------------------------------------
@ignore
Scenario: Clicking items in the listings, without depending on the salt ^
diff --git a/ui-v2/tests/acceptance/steps/components/intention-filter-steps.js b/ui-v2/tests/acceptance/steps/dc/intentions/navigation-steps.js
similarity index 88%
rename from ui-v2/tests/acceptance/steps/components/intention-filter-steps.js
rename to ui-v2/tests/acceptance/steps/dc/intentions/navigation-steps.js
index 3c9a76f69f..ba1093295f 100644
--- a/ui-v2/tests/acceptance/steps/components/intention-filter-steps.js
+++ b/ui-v2/tests/acceptance/steps/dc/intentions/navigation-steps.js
@@ -1,4 +1,4 @@
-import steps from '../steps';
+import steps from '../../steps';
// step definitions that are shared between features should be moved to the
// tests/acceptance/steps/steps.js file
diff --git a/ui-v2/tests/acceptance/steps/dc/intentions/sorting-steps.js b/ui-v2/tests/acceptance/steps/dc/intentions/sorting-steps.js
new file mode 100644
index 0000000000..ba1093295f
--- /dev/null
+++ b/ui-v2/tests/acceptance/steps/dc/intentions/sorting-steps.js
@@ -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);
+ });
+}
diff --git a/ui-v2/tests/pages.js b/ui-v2/tests/pages.js
index d22010e94d..3060bc11bf 100644
--- a/ui-v2/tests/pages.js
+++ b/ui-v2/tests/pages.js
@@ -85,10 +85,6 @@ const catalogFilter = searchBarFactory(freetextFilter, () =>
const aclFilter = searchBarFactory(freetextFilter, () =>
radiogroup('type', ['', 'management', 'client'])
);
-const intentionFilter = searchBarFactory(freetextFilter, () =>
- radiogroup('currentFilter', ['', 'allow', 'deny'])
-);
-
const policyForm = policyFormFactory(submitable, cancelable, radiogroup, text);
const policySelector = policySelectorFactory(clickable, deletable, collection, alias, policyForm);
const roleForm = roleFormFactory(submitable, cancelable, policySelector);
@@ -172,7 +168,9 @@ export default {
token: create(
token(visitable, submitable, deletable, cancelable, clickable, policySelector, roleSelector)
),
- intentions: create(intentions(visitable, creatable, consulIntentionList, intentionFilter)),
+ intentions: create(
+ intentions(visitable, creatable, clickable, consulIntentionList, popoverSelect)
+ ),
intention: create(intention(visitable, submitable, deletable, cancelable)),
nspaces: create(nspaces(visitable, creatable, consulNspaceList, freetextFilter)),
nspace: create(
diff --git a/ui-v2/tests/pages/dc/intentions/index.js b/ui-v2/tests/pages/dc/intentions/index.js
index e925ad1fc9..2c292bab1c 100644
--- a/ui-v2/tests/pages/dc/intentions/index.js
+++ b/ui-v2/tests/pages/dc/intentions/index.js
@@ -1,7 +1,8 @@
-export default function(visitable, creatable, intentions, filter) {
+export default function(visitable, creatable, clickable, intentions, popoverSelect) {
return creatable({
visit: visitable('/:dc/intentions'),
intentions: intentions(),
- filter: filter('[data-test-intention-filter]'),
+ sort: popoverSelect(),
+ create: clickable('[data-test-create]'),
});
}