ui: Use a custom request for nspace deletion (#8878)

* Turn repo.remove into a custom action to bypass ember-data deletion

* Don't show actions on a deleting nspace
This commit is contained in:
John Cowen 2020-10-08 16:00:52 +01:00 committed by GitHub
parent 0b3f438703
commit 09fbe303b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -21,6 +21,7 @@
{{/if}}
</BlockSlot>
<BlockSlot @name="actions" as |Actions|>
{{#if (not item.DeletedAt)}}
<Actions as |Action|>
<Action data-test-edit-action @href={{href-to 'dc.nspaces.edit' item.Name}}>
<BlockSlot @name="label">
@ -50,6 +51,7 @@
</Action>
{{/if}}
</Actions>
{{/if}}
</BlockSlot>
</ListCollection>
{{/if}}

View File

@ -12,6 +12,27 @@ export default RepositoryService.extend({
getModelName: function() {
return modelName;
},
remove: function(item) {
// Namespace deletion is more of a soft delete.
// Therefore the namespace still exists once we've requested a delete/removal.
// This makes 'removing' more of a custom action rather than a standard
// ember-data delete.
// Here we use the same request for a delete but we bypass ember-data's
// destroyRecord/unloadRecord and serialization so we don't get
// ember data error messages when the UI tries to update a 'DeletedAt' property
// on an object that ember-data is trying to delete
const res = this.store.adapterFor('nspace').rpc(
(adapter, request, serialized, unserialized) => {
return adapter.requestForDeleteRecord(request, serialized, unserialized);
},
(serializer, respond, serialized, unserialized) => {
return item;
},
item,
'nspace'
);
return res;
},
findAll: function(configuration = {}) {
const query = {};
if (typeof configuration.cursor !== 'undefined') {