mirror of https://github.com/status-im/consul.git
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
This commit is contained in:
parent
d31691dc87
commit
61433fabb4
|
@ -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">
|
||||
<ConsulIntentionForm
|
||||
@item={{item}}
|
||||
@services={{services}}
|
||||
@services={{uniq-by 'Name' services}}
|
||||
@nspaces={{nspaces}}
|
||||
@ondelete={{action "route" "delete"}}
|
||||
@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
|
||||
---
|
||||
- Name: service-0
|
||||
Kind: consul
|
||||
Kind: ~
|
||||
- Name: service-1
|
||||
Kind: consul
|
||||
Kind: ~
|
||||
- Name: service-2
|
||||
Kind: connect-proxy
|
||||
- Name: service-3
|
||||
|
@ -32,3 +32,28 @@ Feature: dc / intentions / filtered-select: Intention Service Select Dropdowns
|
|||
| source |
|
||||
| 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…
Reference in New Issue