open-vault/ui/app/components/message-error.js
Matthew Irish e35ec4b6d6
UI - strip secret slash (#4649)
* remove unused didError

* error should fall back to message if the errors array is empty

* strip leading slash when saving a secret
2018-05-29 14:48:55 -05:00

36 lines
841 B
JavaScript

import Ember from 'ember';
export default Ember.Component.extend({
model: null,
errors: [],
errorMessage: null,
displayErrors: Ember.computed(
'errorMessage',
'model.isError',
'model.adapterError.message',
'model.adapterError.errors.@each',
'errors',
'errors.@each',
function() {
const errorMessage = this.get('errorMessage');
const errors = this.get('errors');
const modelIsError = this.get('model.isError');
if (errorMessage) {
return [errorMessage];
}
if (errors && errors.length > 0) {
return errors;
}
if (modelIsError) {
if (this.get('model.adapterError.errors.length') > 0) {
return this.get('model.adapterError.errors');
}
return [this.get('model.adapterError.message')];
}
}
),
});