Disabled editor buttons while uploading changes
This commit is contained in:
parent
f2fe1f5530
commit
c7a4faf5b2
|
@ -1,6 +1,6 @@
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
import { observer } from '@ember/object';
|
import { computed, observer } from '@ember/object';
|
||||||
import { alias } from '@ember/object/computed';
|
import { alias } from '@ember/object/computed';
|
||||||
import { scheduleOnce } from '@ember/runloop';
|
import { scheduleOnce } from '@ember/runloop';
|
||||||
import JSONTreeView from 'npm:json-tree-view';
|
import JSONTreeView from 'npm:json-tree-view';
|
||||||
|
@ -12,6 +12,11 @@ export default Component.extend({
|
||||||
classNames: ['file-preview'],
|
classNames: ['file-preview'],
|
||||||
|
|
||||||
fileLoaded: false,
|
fileLoaded: false,
|
||||||
|
uploadingChanges: false,
|
||||||
|
|
||||||
|
showEditor: null,
|
||||||
|
hideEditor: computed.not('showEditor'),
|
||||||
|
|
||||||
fileContent: null,
|
fileContent: null,
|
||||||
objectURL: null,
|
objectURL: null,
|
||||||
metaData: null,
|
metaData: null,
|
||||||
|
@ -123,6 +128,7 @@ export default Component.extend({
|
||||||
|
|
||||||
if (this.get('isJSON') && this.get('jsonShowTree')) {
|
if (this.get('isJSON') && this.get('jsonShowTree')) {
|
||||||
const content = JSON.stringify(this.get('jsonTreeView.value'));
|
const content = JSON.stringify(this.get('jsonTreeView.value'));
|
||||||
|
this.set('uploadingChanges', true);
|
||||||
|
|
||||||
this.get('storage.client')
|
this.get('storage.client')
|
||||||
.storeFile('application/json', path, content)
|
.storeFile('application/json', path, content)
|
||||||
|
@ -135,6 +141,8 @@ export default Component.extend({
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
alert('Failed to update the file. Check the console for more info.');
|
alert('Failed to update the file. Check the console for more info.');
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
}).finally(() => {
|
||||||
|
this.set('uploadingChanges', false);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.warn('not implemented');
|
console.warn('not implemented');
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
|
|
||||||
{{#if showEditor}}
|
{{#if showEditor}}
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button {{action "saveChanges"}}>Save changes</button>
|
<button {{action "saveChanges"}} disabled={{uploadingChanges}}>Save changes</button>
|
||||||
<button {{action "cancelEditor"}}>Cancel editing</button>
|
<button {{action "cancelEditor"}} disabled={{uploadingChanges}}>Cancel editing</button>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
|
@ -60,7 +60,6 @@
|
||||||
isJSON=documentIsJSON
|
isJSON=documentIsJSON
|
||||||
isEditable=documentIsEditableHide
|
isEditable=documentIsEditableHide
|
||||||
showEditor=documentShowEditor
|
showEditor=documentShowEditor
|
||||||
hideEditor=documentHideEditor
|
|
||||||
jsonShowTree=jsonShowTree
|
jsonShowTree=jsonShowTree
|
||||||
jsonShowSource=jsonShowSource}}
|
jsonShowSource=jsonShowSource}}
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in New Issue