Skip to content

Commit

Permalink
fix: further sanity checks for file saves
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Bassett <[email protected]>
  • Loading branch information
cadriel committed Apr 8, 2021
1 parent 645741e commit 13e8fb4
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/components/widgets/filesystem/FileEditorDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
>
<app-btn
icon
:disabled="!ready"
color=""
@click="emitClose()"
>
Expand All @@ -34,14 +35,14 @@
</app-btn>
<app-btn
v-if="!readonly && !printerPrinting && rootProperties.showSaveRestart"
:disabled="loading || !editorReady"
:disabled="!ready"
@click="emitSave(true)">
<v-icon small :left="!isMobile">$restart</v-icon>
<span class="d-none d-md-inline-block">{{ $t('app.general.btn.save_restart') }}</span>
</app-btn>
<app-btn
v-if="!readonly"
:disabled="loading || !editorReady"
:disabled="!ready"
@click="emitSave(false)">
<v-icon small :left="!isMobile">$save</v-icon>
<span class="d-none d-md-inline-block">{{ $t('app.general.btn.save') }}</span>
Expand Down Expand Up @@ -105,6 +106,18 @@ export default class FileEditorDialog extends Mixins(StateMixin) {
updatedContent = this.contents
editorReady = false
get ready () {
return (
!this.loading &&
this.editorReady &&
!this.isUploading
)
}
get isUploading (): boolean {
return this.$store.state.files.uploads.length > 0
}
get rootProperties () {
return this.$store.getters['files/getRootProperties'](this.root)
}
Expand All @@ -122,8 +135,10 @@ export default class FileEditorDialog extends Mixins(StateMixin) {
}
emitSave (restart: boolean) {
this.$emit('save', this.updatedContent, restart)
if (restart) this.$emit('input', false)
if (this.editorReady) {
this.$emit('save', this.updatedContent, restart)
if (restart) this.$emit('input', false)
}
}
}
</script>

0 comments on commit 13e8fb4

Please sign in to comment.