open-vault/ui/app/controllers/vault/cluster/policies/create.js

21 lines
658 B
JavaScript
Raw Normal View History

import Controller from '@ember/controller';
import trimRight from 'vault/utils/trim-right';
2018-04-03 14:16:57 +00:00
import PolicyEditController from 'vault/mixins/policy-edit-controller';
export default Controller.extend(PolicyEditController, {
2018-04-03 14:16:57 +00:00
showFileUpload: false,
file: null,
actions: {
setPolicyFromFile(index, fileInfo) {
let { value, fileName } = fileInfo;
let model = this.get('model');
model.set('policy', value);
if (!model.get('name')) {
let trimmedFileName = trimRight(fileName, ['.json', '.txt', '.hcl', '.policy']);
model.set('name', trimmedFileName);
2018-04-03 14:16:57 +00:00
}
this.set('showFileUpload', false);
},
},
});