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:
parent
f5c18d58ef
commit
e35ec4b6d6
|
@ -8,6 +8,7 @@ export default Ember.Component.extend({
|
|||
displayErrors: Ember.computed(
|
||||
'errorMessage',
|
||||
'model.isError',
|
||||
'model.adapterError.message',
|
||||
'model.adapterError.errors.@each',
|
||||
'errors',
|
||||
'errors.@each',
|
||||
|
@ -24,8 +25,11 @@ export default Ember.Component.extend({
|
|||
}
|
||||
|
||||
if (modelIsError) {
|
||||
if (this.get('model.adapterError.errors.length') > 0) {
|
||||
return this.get('model.adapterError.errors');
|
||||
}
|
||||
return [this.get('model.adapterError.message')];
|
||||
}
|
||||
}
|
||||
),
|
||||
});
|
||||
|
|
|
@ -47,8 +47,8 @@ export default Ember.Component.extend(FocusOnInsertMixin, {
|
|||
|
||||
persist(method, successCallback) {
|
||||
const model = get(this, 'model');
|
||||
return model[method]().then(result => {
|
||||
if (!Ember.get(result, 'didError')) {
|
||||
return model[method]().then(() => {
|
||||
if (!Ember.get(model, 'isError')) {
|
||||
successCallback(model);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -78,7 +78,7 @@ export default Ember.Component.extend(FocusOnInsertMixin, {
|
|||
buttonDisabled: computed.or(
|
||||
'requestInFlight',
|
||||
'key.isFolder',
|
||||
'key.didError',
|
||||
'key.isError',
|
||||
'key.flagsIsInvalid',
|
||||
'hasLintError'
|
||||
),
|
||||
|
@ -137,7 +137,12 @@ export default Ember.Component.extend(FocusOnInsertMixin, {
|
|||
// successCallback is called in the context of the component
|
||||
persistKey(method, successCallback, isCreate) {
|
||||
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') {
|
||||
// create an ember data model from the proxy
|
||||
|
@ -145,8 +150,8 @@ export default Ember.Component.extend(FocusOnInsertMixin, {
|
|||
this.set('key', model);
|
||||
}
|
||||
|
||||
return model[method]().then(result => {
|
||||
if (!Ember.get(result, 'didError')) {
|
||||
return model[method]().then(() => {
|
||||
if (!Ember.get(model, 'isError')) {
|
||||
successCallback(key);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -46,8 +46,8 @@ export default Ember.Component.extend(FocusOnInsertMixin, {
|
|||
|
||||
persistKey(method, successCallback) {
|
||||
const key = get(this, 'key');
|
||||
return key[method]().then(result => {
|
||||
if (!Ember.get(result, 'didError')) {
|
||||
return key[method]().then(() => {
|
||||
if (!Ember.get(key, 'isError')) {
|
||||
successCallback(key);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,23 +1,5 @@
|
|||
{{#if key.isError}}
|
||||
{{#each key.adapterError.errors as |error|}}
|
||||
<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}}
|
||||
|
||||
{{message-error model=key}}
|
||||
<form onsubmit={{action "createOrUpdateKey" "update"}} onchange={{action "handleChange"}}>
|
||||
{{#unless showAdvancedMode}}
|
||||
<div class="table info-table-row-header">
|
||||
<div class="info-table-row thead">
|
||||
|
|
Loading…
Reference in New Issue