Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: [Bugfix] KV creation from within a 'folder' #8613

Merged
merged 2 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui-v2/app/components/consul-kv-form/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<label for="" class="type-text{{if api.data.error.Value ' has-error'}}">
<span>Value</span>
{{#if json}}
<CodeEditor @value={{atob api.data.Value}} @onkeyup={{action api.change "value"}} />
<CodeEditor @name="value" @value={{atob api.data.Value}} @onkeyup={{action api.change "value"}} />
{{else}}
<textarea autofocus={{not api.isCreate}} name="value" oninput={{action api.change}}>{{atob api.data.Value}}</textarea>
{{/if}}
Expand Down
12 changes: 11 additions & 1 deletion ui-v2/app/routes/dc/kv/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export default Route.extend({
repo: service('repository/kv'),
sessionRepo: service('repository/session'),
model: function(params) {
const create =
this.routeName
.split('.')
.pop()
.indexOf('create') !== -1;
const key = params.key;
const dc = this.modelFor('dc').dc.Name;
const nspace = this.modelFor('nspace').nspace.substr(1);
Expand All @@ -19,7 +24,12 @@ export default Route.extend({
typeof key !== 'undefined'
? this.repo.findBySlug(ascend(key, 1) || '/', dc, nspace)
: this.repo.findBySlug('/', dc, nspace),
item: typeof key !== 'undefined' ? this.repo.findBySlug(key, dc, nspace) : undefined,
item: create
? this.repo.create({
Datacenter: dc,
Namespace: nspace,
})
: this.repo.findBySlug(key, dc, nspace),
session: null,
}).then(model => {
// TODO: Consider loading this after initial page load
Expand Down
64 changes: 50 additions & 14 deletions ui-v2/tests/acceptance/dc/kvs/create.feature
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
@setupApplicationTest
Feature: dc / kvs / create
Scenario:
Given 1 datacenter model with the value "datacenter"
When I visit the kv page for yaml
---
dc: datacenter
---
Then the url should be /datacenter/kv/create
And the title should be "New Key/Value - Consul"

@ignore
Scenario: Test we can create a KV
Then ok
@setupApplicationTest
Feature: dc / kvs / create
Scenario: Creating a root KV
Given 1 datacenter model with the value "datacenter"
When I visit the kv page for yaml
---
dc: datacenter
---
Then the url should be /datacenter/kv/create
And the title should be "New Key/Value - Consul"
Then I fill in with yaml
---
additional: key-value
value: value
---
And I submit
Then the url should be /datacenter/kv
Then a PUT request was made to "/v1/kv/key-value?dc=datacenter&ns=@namespace"
And "[data-notification]" has the "notification-update" class
And "[data-notification]" has the "success" class
Scenario: Creating a folder
Given 1 datacenter model with the value "datacenter"
When I visit the kv page for yaml
---
dc: datacenter
---
Then the url should be /datacenter/kv/create
And the title should be "New Key/Value - Consul"
Then I fill in with yaml
---
additional: key-value/
---
And I submit
Then the url should be /datacenter/kv
Then a PUT request was made to "/v1/kv/key-value/?dc=datacenter&ns=@namespace"
And "[data-notification]" has the "notification-update" class
And "[data-notification]" has the "success" class
Scenario: Clicking create from within a folder
Given 1 datacenter model with the value "datacenter"
And 1 kv model from yaml
---
- key-value/
---
When I visit the kvs page for yaml
---
dc: datacenter
---
And I click kv on the kvs
And I click create
And I see the text "New Key / Value" in "h1"