2018-09-25 16:28:26 +00:00
|
|
|
import Controller from '@ember/controller';
|
2018-06-05 15:30:32 +00:00
|
|
|
import trimRight from 'vault/utils/trim-right';
|
2018-04-03 14:16:57 +00:00
|
|
|
import PolicyEditController from 'vault/mixins/policy-edit-controller';
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
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')) {
|
2018-06-14 04:06:19 +00:00
|
|
|
let trimmedFileName = trimRight(fileName, ['.json', '.txt', '.hcl', '.policy']);
|
2018-06-05 15:30:32 +00:00
|
|
|
model.set('name', trimmedFileName);
|
2018-04-03 14:16:57 +00:00
|
|
|
}
|
|
|
|
this.set('showFileUpload', false);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|