ui: [Bugfix] KV creation from within a 'folder' (#8613)
* ui: Prefill an newly created KV for the when we are on a create route * ui: Add some KV creation tests
This commit is contained in:
parent
2f9c3b870b
commit
4086385e59
|
@ -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}}
|
||||
|
|
|
@ -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);
|
||||
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue