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(
|
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,7 +25,10 @@ export default Ember.Component.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelIsError) {
|
if (modelIsError) {
|
||||||
return this.get('model.adapterError.errors');
|
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) {
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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">
|
||||||
|
|
Loading…
Reference in a new issue