ui: Don't show duplicate services in the intentions form dropdown (#8133)

* Add uniq-by helper
* Pass unique services through to intentions form
* Add acceptance test
pull/8136/head
John Cowen 5 years ago committed by GitHub
parent d31691dc87
commit 61433fabb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,13 @@
import { helper } from '@ember/component/helper';
import { isEmpty } from '@ember/utils';
import { A as emberArray } from '@ember/array';
export function uniqBy([byPath, array]) {
if (isEmpty(byPath)) {
return [];
}
return emberArray(array).uniqBy(byPath);
}
export default helper(uniqBy);

@ -39,7 +39,7 @@
<BlockSlot @name="content"> <BlockSlot @name="content">
<ConsulIntentionForm <ConsulIntentionForm
@item={{item}} @item={{item}}
@services={{services}} @services={{uniq-by 'Name' services}}
@nspaces={{nspaces}} @nspaces={{nspaces}}
@ondelete={{action "route" "delete"}} @ondelete={{action "route" "delete"}}
@onsubmit={{action "route" (if item.isNew "create" "update")}} @onsubmit={{action "route" (if item.isNew "create" "update")}}

@ -8,9 +8,9 @@ Feature: dc / intentions / filtered-select: Intention Service Select Dropdowns
And 4 service models from yaml And 4 service models from yaml
--- ---
- Name: service-0 - Name: service-0
Kind: consul Kind: ~
- Name: service-1 - Name: service-1
Kind: consul Kind: ~
- Name: service-2 - Name: service-2
Kind: connect-proxy Kind: connect-proxy
- Name: service-3 - Name: service-3
@ -32,3 +32,28 @@ Feature: dc / intentions / filtered-select: Intention Service Select Dropdowns
| source | | source |
| destination | | destination |
--------------- ---------------
Scenario: Opening the [Name] dropdown with 2 services with the same name from different nspaces
Given 1 datacenter model with the value "datacenter"
And 2 service models from yaml
---
- Name: service-0
Kind: ~
- Name: service-0
Namespace: nspace
Kind: ~
---
When I visit the intention page for yaml
---
dc: datacenter
intention: intention
---
Then the url should be /datacenter/intentions/intention
And I click "[data-test-[Name]-element] .ember-power-select-trigger"
Then I see the text "* (All Services)" in ".ember-power-select-option:nth-last-child(2)"
Then I see the text "service-0" in ".ember-power-select-option:last-child"
Where:
---------------
| Name |
| source |
| destination |
---------------

Loading…
Cancel
Save