diff --git a/ui-v2/app/components/confirmation-dialog/index.hbs b/ui-v2/app/components/confirmation-dialog/index.hbs index 1ffade5cf3..c1fd3180cd 100644 --- a/ui-v2/app/components/confirmation-dialog/index.hbs +++ b/ui-v2/app/components/confirmation-dialog/index.hbs @@ -1,11 +1,13 @@ +
+ Are you sure you want to delete this key? +
++ {{message}} +
+ + +Success! - Your {{type}} has been deleted. + Your {{or label type}} has been deleted.
Success! - Your {{type}} has been saved. + Your {{or label type}} has been saved.
{{/yield-slot}} @@ -64,7 +64,7 @@
Error!
- There was an error saving your {{type}}.
+ There was an error saving your {{or label type}}.
{{#if (and api.error.status api.error.detail)}}
{{api.error.status}}: {{api.error.detail}}
{{/if}}
diff --git a/ui-v2/app/components/notification/index.js b/ui-v2/app/components/notification/index.js
index 32cfa6d37b..cdebe70105 100644
--- a/ui-v2/app/components/notification/index.js
+++ b/ui-v2/app/components/notification/index.js
@@ -24,9 +24,15 @@ export default Component.extend({
$el.remove();
this.notify.clearMessages();
if (typeof this.after === 'function') {
- Promise.resolve(this.after()).then(res => {
- this.notify.add(options);
- });
+ Promise.resolve(this.after())
+ .catch(e => {
+ if (e.name !== 'TransitionAborted') {
+ throw e;
+ }
+ })
+ .then(res => {
+ this.notify.add(options);
+ });
} else {
this.notify.add(options);
}
diff --git a/ui-v2/app/controllers/dc/kv/create.js b/ui-v2/app/controllers/dc/kv/create.js
deleted file mode 100644
index 4723e0ce43..0000000000
--- a/ui-v2/app/controllers/dc/kv/create.js
+++ /dev/null
@@ -1,2 +0,0 @@
-import Controller from './edit';
-export default Controller.extend();
diff --git a/ui-v2/app/controllers/dc/kv/folder.js b/ui-v2/app/controllers/dc/kv/folder.js
deleted file mode 100644
index 5f88002bfd..0000000000
--- a/ui-v2/app/controllers/dc/kv/folder.js
+++ /dev/null
@@ -1,2 +0,0 @@
-import Controller from './index';
-export default Controller.extend();
diff --git a/ui-v2/app/controllers/dc/kv/root-create.js b/ui-v2/app/controllers/dc/kv/root-create.js
deleted file mode 100644
index fd50dd32f7..0000000000
--- a/ui-v2/app/controllers/dc/kv/root-create.js
+++ /dev/null
@@ -1,2 +0,0 @@
-import Controller from './create';
-export default Controller.extend();
diff --git a/ui-v2/app/mixins/kv/with-actions.js b/ui-v2/app/mixins/kv/with-actions.js
deleted file mode 100644
index bb95b9b035..0000000000
--- a/ui-v2/app/mixins/kv/with-actions.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import Mixin from '@ember/object/mixin';
-import { get, set } from '@ember/object';
-import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
-
-export default Mixin.create(WithBlockingActions, {
- // afterCreate just calls afterUpdate
- afterUpdate: function(item, parent) {
- const key = get(parent, 'Key');
- if (key === '/') {
- return this.transitionTo('dc.kv.index');
- } else {
- return this.transitionTo('dc.kv.folder', key);
- }
- },
- afterDelete: function(item, parent) {
- if (this.routeName === 'dc.kv.folder') {
- return this.refresh();
- }
- return this._super(...arguments);
- },
- actions: {
- invalidateSession: function(item) {
- const controller = this.controller;
- const repo = this.sessionRepo;
- return this.feedback.execute(() => {
- return repo.remove(item).then(() => {
- const item = get(controller, 'item');
- set(item, 'Session', null);
- delete item.Session;
- set(controller, 'session', null);
- });
- }, 'deletesession');
- },
- },
-});
diff --git a/ui-v2/app/routes/dc/kv/create.js b/ui-v2/app/routes/dc/kv/create.js
index f1b41cf34c..4b9968fd03 100644
--- a/ui-v2/app/routes/dc/kv/create.js
+++ b/ui-v2/app/routes/dc/kv/create.js
@@ -1,36 +1,5 @@
-import Route from '@ember/routing/route';
-import { inject as service } from '@ember/service';
-import { hash } from 'rsvp';
-import { get } from '@ember/object';
-import WithKvActions from 'consul-ui/mixins/kv/with-actions';
+import Route from './edit';
-export default Route.extend(WithKvActions, {
+export default Route.extend({
templateName: 'dc/kv/edit',
- repo: service('repository/kv'),
- beforeModel: function() {
- this.repo.invalidate();
- },
- model: function(params) {
- const key = params.key || '/';
- const dc = this.modelFor('dc').dc.Name;
- const nspace = this.modelFor('nspace').nspace.substr(1);
- this.item = this.repo.create({
- Datacenter: dc,
- Namespace: nspace,
- });
- return hash({
- create: true,
- isLoading: false,
- item: this.item,
- parent: this.repo.findBySlug(key, dc, nspace),
- });
- },
- setupController: function(controller, model) {
- controller.setProperties(model);
- },
- deactivate: function() {
- if (get(this.item, 'isNew')) {
- this.item.destroyRecord();
- }
- },
});
diff --git a/ui-v2/app/routes/dc/kv/edit.js b/ui-v2/app/routes/dc/kv/edit.js
index 5e9652810e..74f05ed4a8 100644
--- a/ui-v2/app/routes/dc/kv/edit.js
+++ b/ui-v2/app/routes/dc/kv/edit.js
@@ -2,11 +2,10 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { hash } from 'rsvp';
import { get } from '@ember/object';
-import WithKvActions from 'consul-ui/mixins/kv/with-actions';
import ascend from 'consul-ui/utils/ascend';
-export default Route.extend(WithKvActions, {
+export default Route.extend({
repo: service('repository/kv'),
sessionRepo: service('repository/session'),
model: function(params) {
@@ -14,20 +13,26 @@ export default Route.extend(WithKvActions, {
const dc = this.modelFor('dc').dc.Name;
const nspace = this.modelFor('nspace').nspace.substr(1);
return hash({
- isLoading: false,
- parent: this.repo.findBySlug(ascend(key, 1) || '/', dc, nspace),
- item: this.repo.findBySlug(key, dc, nspace),
+ dc: dc,
+ nspace: nspace || 'default',
+ parent:
+ 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,
session: null,
}).then(model => {
// TODO: Consider loading this after initial page load
- const session = get(model.item, 'Session');
- if (session) {
- return hash({
- ...model,
- ...{
- session: this.sessionRepo.findByKey(session, dc, nspace),
- },
- });
+ if (typeof model.item !== 'undefined') {
+ const session = get(model.item, 'Session');
+ if (session) {
+ return hash({
+ ...model,
+ ...{
+ session: this.sessionRepo.findByKey(session, dc, nspace),
+ },
+ });
+ }
}
return model;
});
diff --git a/ui-v2/app/routes/dc/kv/index.js b/ui-v2/app/routes/dc/kv/index.js
index 75ce527258..01da2ac6d8 100644
--- a/ui-v2/app/routes/dc/kv/index.js
+++ b/ui-v2/app/routes/dc/kv/index.js
@@ -3,9 +3,8 @@ import { inject as service } from '@ember/service';
import { hash } from 'rsvp';
import { get } from '@ember/object';
import isFolder from 'consul-ui/utils/isFolder';
-import WithKvActions from 'consul-ui/mixins/kv/with-actions';
-export default Route.extend(WithKvActions, {
+export default Route.extend({
queryParams: {
search: {
as: 'filter',
diff --git a/ui-v2/app/services/data-sink/protocols/http.js b/ui-v2/app/services/data-sink/protocols/http.js
index b6e39965fb..3383bd6b71 100644
--- a/ui-v2/app/services/data-sink/protocols/http.js
+++ b/ui-v2/app/services/data-sink/protocols/http.js
@@ -4,6 +4,7 @@ import { setProperties } from '@ember/object';
export default Service.extend({
settings: service('settings'),
intention: service('repository/intention'),
+ kv: service('repository/kv'),
session: service('repository/session'),
prepare: function(sink, data, instance) {
return setProperties(instance, data);
diff --git a/ui-v2/app/services/data-source/protocols/http.js b/ui-v2/app/services/data-source/protocols/http.js
index a4e231943a..5a51a08f8f 100644
--- a/ui-v2/app/services/data-source/protocols/http.js
+++ b/ui-v2/app/services/data-source/protocols/http.js
@@ -113,6 +113,7 @@ export default Service.extend({
repo.findInstanceBySlug(rest[0], rest[1], rest[2], dc, nspace, configuration);
break;
case 'policy':
+ case 'kv':
case 'intention':
slug = rest[0];
if (slug) {
diff --git a/ui-v2/app/templates/dc/kv/-form.hbs b/ui-v2/app/templates/dc/kv/-form.hbs
deleted file mode 100644
index e92f88cb45..0000000000
--- a/ui-v2/app/templates/dc/kv/-form.hbs
+++ /dev/null
@@ -1,46 +0,0 @@
-