Added message error when the file is invalid

This commit is contained in:
Ezequiel-Vega 2022-03-31 12:08:59 -03:00
parent 6b8f61a67f
commit 76f430161d
14 changed files with 26 additions and 21 deletions

View File

@ -146,7 +146,6 @@ export default class FreemindImporter extends Importer {
private convertNodeProperties(freeNode: FreemindNode, wiseTopic: NodeModel, centralTopic: boolean): void { private convertNodeProperties(freeNode: FreemindNode, wiseTopic: NodeModel, centralTopic: boolean): void {
const text: string = freeNode.getText(); const text: string = freeNode.getText();
<<<<<<< HEAD
if (text) { if (text) {
if (!centralTopic && text.length > 100) { if (!centralTopic && text.length > 100) {
wiseTopic.setText(text.replace(/([^\n]{1,100})\s/g, '$1\n')); wiseTopic.setText(text.replace(/([^\n]{1,100})\s/g, '$1\n'));
@ -154,9 +153,6 @@ export default class FreemindImporter extends Importer {
wiseTopic.setText(text); wiseTopic.setText(text);
} }
} }
=======
if (text) wiseTopic.setText(text);
>>>>>>> 5901b660deddff72765594a2aadd5045e7061043
const bgColor: string = freeNode.getBackgorundColor(); const bgColor: string = freeNode.getBackgorundColor();
if (bgColor) wiseTopic.setBackgroundColor(bgColor); if (bgColor) wiseTopic.setBackgroundColor(bgColor);

View File

@ -210,7 +210,7 @@
"defaultMessage": "Importieren Sie vorhandene Mindmaps" "defaultMessage": "Importieren Sie vorhandene Mindmaps"
}, },
"import.error-file": { "import.error-file": {
"defaultMessage": "Die Dateierweiterung ist ungültig" "defaultMessage": "Sie versuchen, eine Datei mit einer ungültigen Erweiterung zu importieren. Gültige Erweiterungen sind .mm und .wxml"
}, },
"info.basic-info": { "info.basic-info": {
"defaultMessage": "Basisinformation" "defaultMessage": "Basisinformation"

View File

@ -225,7 +225,7 @@
"defaultMessage": "Import existing mindmap" "defaultMessage": "Import existing mindmap"
}, },
"import.error-file": { "import.error-file": {
"defaultMessage": "The file extension is invalid" "defaultMessage": "You are trying to import a file with an invalid extension, valid extensions are .mm and .wxml"
}, },
"info.basic-info": { "info.basic-info": {
"defaultMessage": "Basic Info" "defaultMessage": "Basic Info"

View File

@ -219,7 +219,7 @@
"defaultMessage": "Importar mapa mental existente" "defaultMessage": "Importar mapa mental existente"
}, },
"import.error-file": { "import.error-file": {
"defaultMessage": "La extension del archivo es invalida" "defaultMessage": "Está intentando importar un archivo con una extensión no valida, las extenciones validas son .mm y .wxml"
}, },
"info.basic-info": { "info.basic-info": {
"defaultMessage": "Información básica" "defaultMessage": "Información básica"

View File

@ -210,7 +210,7 @@
"defaultMessage": "Importer une carte mentale existante" "defaultMessage": "Importer une carte mentale existante"
}, },
"import.error-file": { "import.error-file": {
"defaultMessage": "L'extension de fichier n'est pas valide" "defaultMessage": "Vous essayez d'importer un fichier avec une extension invalide, les extensions valides sont .mm et .wxml"
}, },
"info.basic-info": { "info.basic-info": {
"defaultMessage": "Informations de base" "defaultMessage": "Informations de base"

View File

@ -210,7 +210,7 @@
"defaultMessage": "Загрузить майнд-карту с компьютера" "defaultMessage": "Загрузить майнд-карту с компьютера"
}, },
"import.error-file": { "import.error-file": {
"defaultMessage": "Недопустимое расширение файла" "defaultMessage": "Вы пытаетесь импортировать файл с недопустимым расширением, допустимыми расширениями являются .mm и .wxml."
}, },
"info.basic-info": { "info.basic-info": {
"defaultMessage": "Основная информация" "defaultMessage": "Основная информация"

View File

@ -216,7 +216,7 @@
"defaultMessage": "导入现有的思维导图" "defaultMessage": "导入现有的思维导图"
}, },
"import.error-file": { "import.error-file": {
"defaultMessage": "文件扩展名无效" "defaultMessage": "您正在尝试导入具有无效扩展名的文件,有效扩展名是 .mm 和 .wxml"
}, },
"info.basic-info": { "info.basic-info": {
"defaultMessage": "基本信息" "defaultMessage": "基本信息"

View File

@ -452,7 +452,7 @@
"import.error-file": [ "import.error-file": [
{ {
"type": 0, "type": 0,
"value": "Die Dateierweiterung ist ungültig" "value": "Sie versuchen, eine Datei mit einer ungültigen Erweiterung zu importieren. Gültige Erweiterungen sind .mm und .wxml"
} }
], ],
"import.title": [ "import.title": [

View File

@ -446,7 +446,7 @@
"import.error-file": [ "import.error-file": [
{ {
"type": 0, "type": 0,
"value": "The file extension is invalid" "value": "You are trying to import a file with an invalid extension, valid extensions are .mm and .wxml"
} }
], ],
"import.title": [ "import.title": [

View File

@ -446,7 +446,7 @@
"import.error-file": [ "import.error-file": [
{ {
"type": 0, "type": 0,
"value": "La extension del archivo es invalida" "value": "Está intentando importar un archivo con una extensión no valida, las extenciones validas son .mm y .wxml"
} }
], ],
"import.title": [ "import.title": [

View File

@ -444,7 +444,7 @@
"import.error-file": [ "import.error-file": [
{ {
"type": 0, "type": 0,
"value": "L'extension de fichier n'est pas valide" "value": "Vous essayez d'importer un fichier avec une extension invalide, les extensions valides sont .mm et .wxml"
} }
], ],
"import.title": [ "import.title": [

View File

@ -446,7 +446,7 @@
"import.error-file": [ "import.error-file": [
{ {
"type": 0, "type": 0,
"value": "Недопустимое расширение файла" "value": "Вы пытаетесь импортировать файл с недопустимым расширением, допустимыми расширениями являются .mm и .wxml."
} }
], ],
"import.title": [ "import.title": [

View File

@ -446,7 +446,7 @@
"import.error-file": [ "import.error-file": [
{ {
"type": 0, "type": 0,
"value": "文件扩展名无效" "value": "您正在尝试导入具有无效扩展名的文件,有效扩展名是 .mm 和 .wxml"
} }
], ],
"import.title": [ "import.title": [

View File

@ -92,15 +92,24 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => {
const fileContent = event?.target?.result; const fileContent = event?.target?.result;
const mapConent: string = typeof fileContent === 'string' ? fileContent : fileContent.toString(); const mapConent: string = typeof fileContent === 'string' ? fileContent : fileContent.toString();
try {
const importer: Importer = TextImporterFactory.create(extensionFile, mapConent)
const importer: Importer = TextImporterFactory.create(extensionFile, mapConent) importer.import(model.title, model.description)
importer.import(model.title, model.description)
.then(res => { .then(res => {
model.content = res; model.content = res;
setModel({ ...model }); setModel({ ...model });
}) })
.catch(e => console.log(e)); .catch(e => {
console.log(e);
setErrorFile(true)
});
} catch (e) {
if (e instanceof Error) {
setErrorFile(true);
}
}
}; };
// Read in the image file as a data URL. // Read in the image file as a data URL.
@ -128,7 +137,7 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => {
{errorFile && {errorFile &&
<Alert severity='error'> <Alert severity='error'>
<FormattedMessage <FormattedMessage
id="import.error-file" id='import.error-file'
defaultMessage="The file extension is invalid" defaultMessage="The file extension is invalid"
/> />
</Alert> </Alert>