open-vault/ui/app/components/identity/popup-metadata.js
Hamid Ghaf 27bb03bbc0
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

35 lines
855 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Base from './_popup-base';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
export default Base.extend({
model: alias('params.firstObject'),
key: computed('params', function () {
return this.params.objectAt(1);
}),
messageArgs(model, key) {
return [model, key];
},
successMessage(model, key) {
return `Successfully removed '${key}' from metadata`;
},
errorMessage(e, model, key) {
const error = e.errors ? e.errors.join(' ') : e.message;
return `There was a problem removing '${key}' from the metadata - ${error}`;
},
transaction(model, key) {
const metadata = model.metadata;
delete metadata[key];
model.set('metadata', { ...metadata });
return model.save();
},
});