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
This commit is contained in:
Matthew Irish 2018-05-29 14:48:55 -05:00 committed by GitHub
parent f5c18d58ef
commit e35ec4b6d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 29 deletions

View File

@ -8,6 +8,7 @@ export default Ember.Component.extend({
displayErrors: Ember.computed( displayErrors: Ember.computed(
'errorMessage', 'errorMessage',
'model.isError', 'model.isError',
'model.adapterError.message',
'model.adapterError.errors.@each', 'model.adapterError.errors.@each',
'errors', 'errors',
'errors.@each', 'errors.@each',
@ -24,8 +25,11 @@ export default Ember.Component.extend({
} }
if (modelIsError) { if (modelIsError) {
if (this.get('model.adapterError.errors.length') > 0) {
return this.get('model.adapterError.errors'); return this.get('model.adapterError.errors');
} }
return [this.get('model.adapterError.message')];
}
} }
), ),
}); });

View File

@ -47,8 +47,8 @@ export default Ember.Component.extend(FocusOnInsertMixin, {
persist(method, successCallback) { persist(method, successCallback) {
const model = get(this, 'model'); const model = get(this, 'model');
return model[method]().then(result => { return model[method]().then(() => {
if (!Ember.get(result, 'didError')) { if (!Ember.get(model, 'isError')) {
successCallback(model); successCallback(model);
} }
}); });

View File

@ -78,7 +78,7 @@ export default Ember.Component.extend(FocusOnInsertMixin, {
buttonDisabled: computed.or( buttonDisabled: computed.or(
'requestInFlight', 'requestInFlight',
'key.isFolder', 'key.isFolder',
'key.didError', 'key.isError',
'key.flagsIsInvalid', 'key.flagsIsInvalid',
'hasLintError' 'hasLintError'
), ),
@ -137,7 +137,12 @@ export default Ember.Component.extend(FocusOnInsertMixin, {
// successCallback is called in the context of the component // successCallback is called in the context of the component
persistKey(method, successCallback, isCreate) { persistKey(method, successCallback, isCreate) {
let model = this.get('key'); let model = this.get('key');
const key = model.get('id'); let key = model.get('id');
if (key.startsWith('/')) {
key = key.replace(/^\/+/g, '');
model.set('id', key);
}
if (isCreate && typeof model.createRecord === 'function') { if (isCreate && typeof model.createRecord === 'function') {
// create an ember data model from the proxy // create an ember data model from the proxy
@ -145,8 +150,8 @@ export default Ember.Component.extend(FocusOnInsertMixin, {
this.set('key', model); this.set('key', model);
} }
return model[method]().then(result => { return model[method]().then(() => {
if (!Ember.get(result, 'didError')) { if (!Ember.get(model, 'isError')) {
successCallback(key); successCallback(key);
} }
}); });

View File

@ -46,8 +46,8 @@ export default Ember.Component.extend(FocusOnInsertMixin, {
persistKey(method, successCallback) { persistKey(method, successCallback) {
const key = get(this, 'key'); const key = get(this, 'key');
return key[method]().then(result => { return key[method]().then(() => {
if (!Ember.get(result, 'didError')) { if (!Ember.get(key, 'isError')) {
successCallback(key); successCallback(key);
} }
}); });

View File

@ -1,23 +1,5 @@
{{#if key.isError}} {{message-error model=key}}
{{#each key.adapterError.errors as |error|}} <form onsubmit={{action "createOrUpdateKey" "update"}} onchange={{action "handleChange"}}>
<div class="connected vault-error">
{{error}}
</div>
{{/each}}
{{/if}}
<form class="" onsubmit={{action "createOrUpdateKey" "update"}} onchange={{action "handleChange"}}>
{{#if key.didError}}
<div class="kv-save-error">
<p>
We were unable to save your changes because the key has changed since the page loaded. Reload the page or click the button below to try again.
</p>
<button type="button" onclick={{action "refresh"}}>
Reload {{key.id}}
</button>
</div>
{{/if}}
{{#unless showAdvancedMode}} {{#unless showAdvancedMode}}
<div class="table info-table-row-header"> <div class="table info-table-row-header">
<div class="info-table-row thead"> <div class="info-table-row thead">