diff --git a/packages/nc-gui/components/import/QuickImport.vue b/packages/nc-gui/components/import/QuickImport.vue index 3ac14f1a68..25925e841f 100644 --- a/packages/nc-gui/components/import/QuickImport.vue +++ b/packages/nc-gui/components/import/QuickImport.vue @@ -60,11 +60,17 @@ v-model="url" hide-details="auto" type="url" - :label="quickImportType == 'excel' ? $t('msg.info.excelURL') : $t('msg.info.csvURL') " + :label="quickImportType === 'excel' ? $t('msg.info.excelURL') : $t('msg.info.csvURL') " class="caption" outlined dense - :rules="[v => !!v || $t('general.required') ]" + :rules=" + [ + v => !!v || $t('general.required'), + v => quickImportType === 'excel' ? + (/.*\.(xls|xlsx|xlsm|ods|ots)/.test(v) || errorMessages.importExcel) : + (/.*\.(csv)/.test(v) || errorMessages.importCSV), + ]" /> @@ -213,7 +219,11 @@ export default { parserConfig: { maxRowsToParse: 500 }, - filename: '' + filename: '', + errorMessages: { + importExcel: "Target file is not an accepted file type. The accepted file types are .xls, .xlsx, .xlsm, .ods, .ots!", + importCSV: "Target file is not an accepted file type. The accepted file type is .csv!" + } } }, computed: { @@ -322,11 +332,11 @@ export default { if (this.quickImportType === 'excel') { if (!/.*\.(xls|xlsx|xlsm|ods|ots)/.test(file.name)) { - return this.$toast.error('Dropped file is not an accepted file type. The accepted file types are .xls, .xlsx, .xlsm, .ods, .ots!').goAway(3000) + return this.$toast.error(this.errorMessages.importExcel).goAway(3000) } } else if (this.quickImportType === 'csv') { if (!/.*\.(csv)/.test(file.name)) { - return this.$toast.error('Dropped file is not an accepted file type. The accepted file type is .csv!').goAway(3000) + return this.$toast.error(this.errorMessages.importCSV).goAway(3000) } } this._file(file)