diff --git a/packages/mindplot/src/components/export/freemind/Map.ts b/packages/mindplot/src/components/export/freemind/Map.ts index f336212f..a64a0be0 100644 --- a/packages/mindplot/src/components/export/freemind/Map.ts +++ b/packages/mindplot/src/components/export/freemind/Map.ts @@ -60,7 +60,14 @@ export default class Freemap { // Is a freemap? $assert( rootElem.tagName === 'map', - `This seem not to be a map document. Found tag: ${rootElem.tagName}`, + `This seem not to be a map document. Found first tag: ${rootElem.tagName}`, + ); + + // Verify that the version attribute exists + console.log(rootElem.getAttribute('version')); + $assert( + rootElem.getAttribute('version') !== null, + 'Freemind version not found', ); // Start the loading process... diff --git a/packages/mindplot/test/unit/import/input/SQLServerTip-version-0.8.0.mm b/packages/mindplot/test/unit/import/input/SQLServerTip-version-0.8.0.mm new file mode 100644 index 00000000..4ca29e7a --- /dev/null +++ b/packages/mindplot/test/unit/import/input/SQLServerTip-version-0.8.0.mm @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/mindplot/test/unit/import/input/anonymity_on_the_edge-invalid.mm b/packages/mindplot/test/unit/import/input/anonymity_on_the_edge-invalid.mm new file mode 100644 index 00000000..0efb25b0 --- /dev/null +++ b/packages/mindplot/test/unit/import/input/anonymity_on_the_edge-invalid.mm @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/mindplot/test/unit/import/input/bug2-invalid.mm b/packages/mindplot/test/unit/import/input/bug2-invalid.mm new file mode 100644 index 00000000..13f03161 --- /dev/null +++ b/packages/mindplot/test/unit/import/input/bug2-invalid.mm @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Todos los contenidos de los talleres están relacionados con el currículo de la enseñanza básica.

+

A diferencia de la práctica tradicional, pretendemos ahondar en el conocimiento partiendo de lo que realmente interesa al niño o niña,

+

ayudándole a que encuentre respuesta a las preguntas que él o ella se plantea.

+

+

Por ese motivo, SaberMás proyecta estar al lado de los niños que necesitan una motivación extra para entender la escuela y fluir en ella,

+

y también al lado de aquellos a quienes la curiosidad y las ganas de saber les lleva más allá.

+ + +
+ + + + + + + \ No newline at end of file diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx index bbebc9d3..1efad759 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx @@ -23,12 +23,17 @@ export type CreateProps = { onClose: () => void; }; +type ErrorFile = { + error: boolean; + message: string; +} + const defaultModel: ImportModel = { title: '' }; const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => { const client: Client = useSelector(activeInstance); const [model, setModel] = React.useState(defaultModel); const [error, setError] = React.useState(); - const [errorFile, setErrorFile] = React.useState(false); + const [errorFile, setErrorFile] = React.useState({error: false, message: ''}); const intl = useIntl(); const mutation = useMutation( @@ -85,7 +90,13 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => { const extensionAccept = ['wxml', 'mm']; if (!extensionAccept.includes(extensionFile)) { - setErrorFile(true); + setErrorFile({ + error: true, + message: intl.formatMessage({ + id: 'import.error-file', + defaultMessage: 'You can import WiseMapping and Freemind maps to your list of maps. Select the file you want to import.' + }) + }); } model.contentType = 'application/xml' @@ -101,13 +112,12 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => { model.content = res; setModel({ ...model }); }) - .catch(e => { - console.log(e); - setErrorFile(true) - }); } catch (e) { if (e instanceof Error) { - setErrorFile(true); + setErrorFile({ + error: true, + message: e.message + }); } } }; @@ -134,12 +144,9 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => { })} submitButton={intl.formatMessage({ id: 'import.button', defaultMessage: 'Create' })} > - {errorFile && + {errorFile.error && - +

{errorFile.message}

}