2023-03-15 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2019-02-14 15:39:19 +00:00
|
|
|
import Base from './_popup-base';
|
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import { alias } from '@ember/object/computed';
|
|
|
|
|
|
|
|
export default Base.extend({
|
|
|
|
model: alias('params.firstObject'),
|
2021-12-17 03:44:29 +00:00
|
|
|
key: computed('params', function () {
|
2019-02-14 15:39:19 +00:00
|
|
|
return this.params.objectAt(1);
|
|
|
|
}),
|
|
|
|
|
|
|
|
messageArgs(model, key) {
|
|
|
|
return [model, key];
|
|
|
|
},
|
|
|
|
|
|
|
|
successMessage(model, key) {
|
|
|
|
return `Successfully removed '${key}' from metadata`;
|
|
|
|
},
|
|
|
|
errorMessage(e, model, key) {
|
2022-11-09 23:15:31 +00:00
|
|
|
const error = e.errors ? e.errors.join(' ') : e.message;
|
2019-02-14 15:39:19 +00:00
|
|
|
return `There was a problem removing '${key}' from the metadata - ${error}`;
|
|
|
|
},
|
|
|
|
|
|
|
|
transaction(model, key) {
|
2022-11-09 23:15:31 +00:00
|
|
|
const metadata = model.metadata;
|
2019-02-14 15:39:19 +00:00
|
|
|
delete metadata[key];
|
|
|
|
model.set('metadata', { ...metadata });
|
|
|
|
return model.save();
|
|
|
|
},
|
|
|
|
});
|