Skip to content

Commit

Permalink
Accept ember-data as the source of truth instead of Consul for ns CRUD
Browse files Browse the repository at this point in the history
The data properties sent to be saved in the backend
or the same ones that we receive back if its successful
therefore we can just ignore the result and avoid ember-data
syncing problems
  • Loading branch information
John Cowen committed Dec 17, 2019
1 parent b038b5e commit cf24ecb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
11 changes: 0 additions & 11 deletions ui-v2/app/routes/dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,4 @@ export default Route.extend({
setupController: function(controller, model) {
controller.setProperties(model);
},
actions: {
// TODO: This will eventually be deprecated please see
// https://deprecations.emberjs.com/v3.x/#toc_deprecate-router-events
willTransition: function(transition) {
// This will refresh both dcs and nspaces on any route transition
// under here
if (typeof transition !== 'undefined' && transition.from.name.endsWith('nspaces.create')) {
this.refresh();
}
},
},
});
17 changes: 5 additions & 12 deletions ui-v2/app/serializers/nspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,11 @@ export default Serializer.extend({
},
respondForCreateRecord: function(respond, serialized, data) {
return respond((headers, body) => {
// potentially this could be default functionality
// we are basically making the assumption here that if a create
// comes back with a record then we should prefer that over the local
// one seeing as it has come from the backend, could we potenitally lose
// data that is stored in the frontend here?
// if we were to do this as a default thing we'd have to use uid here
// which we don't know until its gone through the serializer after this
const item = this.store.peekRecord('nspace', body.Name);
if (item) {
this.store.unloadRecord(item);
}
return body;
// The data properties sent to be saved in the backend
// or the same ones that we receive back if its successfull
// therefore we can just ignore the result and avoid ember-data
// syncing problems
return {};
});
},
respondForUpdateRecord: function(respond, serialized, data) {
Expand Down
2 changes: 1 addition & 1 deletion ui-v2/app/templates/dc/nspaces/-notifications.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{/if}}
{{ else if (eq type 'delete')}}
{{#if (eq status 'success') }}
Your namespace was deleted.
Your namespace has been marked for deletion.
{{else}}
There was an error deleting your namespace.
{{/if}}
Expand Down

0 comments on commit cf24ecb

Please sign in to comment.