-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Topology intention saving improvements (#9513)
* ui: Keep track of existing intentions and use those to save changes Previously we risked overwriting existing data in an intention if we tried to save an intention without having loaded it first, for example Description and Metadata would have been overwritten. This change loads in all the intentions for an origin service so we can pick off the one we need to save and change to ensure that we don't overwrite any existing data.
- Loading branch information
Showing
10 changed files
with
200 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
ui: Fixes an issue where intention description or metadata could be overwritten if saved from the topology view. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
ui/packages/consul-ui/app/components/topology-metrics/notifications/index.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{#if (eq @type 'create')}} | ||
{{#if (eq @status 'success') }} | ||
Your intention has been added. | ||
{{else}} | ||
There was an error adding your intention. | ||
{{/if}} | ||
{{else if (eq @type 'update') }} | ||
{{#if (eq @status 'success') }} | ||
Your intention has been saved. | ||
{{else}} | ||
There was an error saving your intention. | ||
{{/if}} | ||
{{/if}} | ||
{{#let @error.errors.firstObject as |error|}} | ||
{{#if error.detail }} | ||
<br />{{concat '(' (if error.status (concat error.status ': ')) error.detail ')'}} | ||
{{/if}} | ||
{{/let}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 46 additions & 10 deletions
56
ui/packages/consul-ui/app/routes/dc/services/show/topology.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
ui/packages/consul-ui/tests/acceptance/dc/services/show/topology.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@setupApplicationTest | ||
Feature: dc / services / show / topology: Intention Create | ||
Background: | ||
Given 1 datacenter model with the value "datacenter" | ||
And 1 intention model from yaml | ||
--- | ||
SourceNS: default | ||
SourceName: web | ||
DestinationNS: default | ||
DestinationName: db | ||
ID: intention-id | ||
--- | ||
And 1 node model | ||
And 1 service model from yaml | ||
--- | ||
- Service: | ||
Name: web | ||
Kind: ~ | ||
--- | ||
And 1 topology model from yaml | ||
--- | ||
Downstreams: [] | ||
Upstreams: | ||
- Name: db | ||
Namespace: default | ||
Datacenter: datacenter | ||
Intention: {} | ||
--- | ||
When I visit the service page for yaml | ||
--- | ||
dc: datacenter | ||
service: web | ||
--- | ||
Scenario: Allow a connection between service and upstream by saving an intention | ||
When I click ".consul-topology-metrics [data-test-action]" | ||
And I click ".consul-topology-metrics [data-test-confirm]" | ||
And "[data-notification]" has the "success" class | ||
Scenario: There was an error saving the intention | ||
Given the url "/v1/connect/intentions/exact?source=default%2Fweb&destination=default%2Fdb&dc=datacenter" responds with a 500 status | ||
When I click ".consul-topology-metrics [data-test-action]" | ||
And I click ".consul-topology-metrics [data-test-confirm]" | ||
And "[data-notification]" has the "error" class | ||
|
10 changes: 10 additions & 0 deletions
10
ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/topology-steps.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters