From a95b422f1047a7b1b92a0bc3900691d20287753e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Johanson?= Date: Thu, 19 Dec 2024 06:36:30 +0100 Subject: [PATCH] Wrong UUID when undo/redo (#619) --- .../src/map/utils/clientServerMapping.ts | 16 ++++++++-------- .../src/app/core/services/mmp/mmp.service.ts | 13 ++++++++++++- teammapper-frontend/src/assets/i18n/de.json | 3 ++- teammapper-frontend/src/assets/i18n/en.json | 3 ++- teammapper-frontend/src/assets/i18n/es.json | 3 ++- teammapper-frontend/src/assets/i18n/fr.json | 3 ++- teammapper-frontend/src/assets/i18n/it.json | 3 ++- teammapper-frontend/src/assets/i18n/pt-br.json | 3 ++- teammapper-frontend/src/assets/i18n/zh-cn.json | 3 ++- teammapper-frontend/src/assets/i18n/zh-tw.json | 3 ++- 10 files changed, 36 insertions(+), 17 deletions(-) diff --git a/teammapper-backend/src/map/utils/clientServerMapping.ts b/teammapper-backend/src/map/utils/clientServerMapping.ts index 9473923a..0287a5d5 100644 --- a/teammapper-backend/src/map/utils/clientServerMapping.ts +++ b/teammapper-backend/src/map/utils/clientServerMapping.ts @@ -85,14 +85,14 @@ const mapClientNodeToMmpNode = ( mapId: string ): Partial => ({ id: clientNode.id, - colorsBackground: clientNode.colors.background, - colorsBranch: clientNode.colors.branch, - colorsName: clientNode.colors.name, - coordinatesX: clientNode.coordinates.x, - coordinatesY: clientNode.coordinates.y, - fontSize: clientNode.font.size, - fontStyle: clientNode.font.style, - fontWeight: clientNode.font.weight, + colorsBackground: clientNode.colors?.background, + colorsBranch: clientNode.colors?.branch, + colorsName: clientNode.colors?.name, + coordinatesX: clientNode.coordinates?.x, + coordinatesY: clientNode.coordinates?.y, + fontSize: clientNode.font?.size, + fontStyle: clientNode.font?.style, + fontWeight: clientNode.font?.weight, imageSrc: clientNode.image?.src, imageSize: clientNode.image?.size, k: clientNode.k, diff --git a/teammapper-frontend/src/app/core/services/mmp/mmp.service.ts b/teammapper-frontend/src/app/core/services/mmp/mmp.service.ts index ba82923e..db9c0936 100644 --- a/teammapper-frontend/src/app/core/services/mmp/mmp.service.ts +++ b/teammapper-frontend/src/app/core/services/mmp/mmp.service.ts @@ -17,6 +17,7 @@ import { } from '@mmp/map/types'; import { COLORS, EMPTY_IMAGE_DATA } from './mmp-utils'; import { CachedMapOptions } from 'src/app/shared/models/cached-map.model'; +import { validate as uuidValidate } from 'uuid'; /** * Mmp wrapper service with mmp and other functions. @@ -86,7 +87,17 @@ export class MmpService implements OnDestroy { /** * Clear or load an existing mind mmp. */ - public new(map?: MapSnapshot, notifyWithEvent = true) { + public async new(map?: MapSnapshot, notifyWithEvent = true) { + const hasInvalidUUID = map.some(node => !uuidValidate(node.id)); + + if (hasInvalidUUID) { + const importErrorMessage = await this.utilsService.translate( + 'TOASTS.ERRORS.IMPORT_ERROR' + ); + this.toastrService.error(importErrorMessage); + return; + } + const mapWithCoordinates = this.currentMap.instance.applyCoordinatesToMapSnapshot(map); this.currentMap.instance.new(mapWithCoordinates, notifyWithEvent); diff --git a/teammapper-frontend/src/assets/i18n/de.json b/teammapper-frontend/src/assets/i18n/de.json index ae4a559b..bab72c41 100644 --- a/teammapper-frontend/src/assets/i18n/de.json +++ b/teammapper-frontend/src/assets/i18n/de.json @@ -186,7 +186,8 @@ "NODE_COPY_GENERIC": "Beim Kopieren des Knotens ist ein Fehler aufgetreten.", "NODE_CUT_GENERIC": "Beim Ausschneiden des Knotens ist ein Fehler aufgetreten.", "EXPORT_IMAGE_ERROR": "Beim Bild-Export ist ein Fehler aufgetreten. Womöglich ist die Mindmap zu groß.", - "MAP_COULD_NOT_BE_FOUND": "Mindmap konnte nicht gefunden werden!" + "MAP_COULD_NOT_BE_FOUND": "Mindmap konnte nicht gefunden werden!", + "IMPORT_ERROR": "Mindmap konnte nicht importiert werden!" }, "DELETE_MAP_SUCCESS": "Mindmap erfolgreich gelöscht!" }, diff --git a/teammapper-frontend/src/assets/i18n/en.json b/teammapper-frontend/src/assets/i18n/en.json index 030ea98c..9fab9284 100644 --- a/teammapper-frontend/src/assets/i18n/en.json +++ b/teammapper-frontend/src/assets/i18n/en.json @@ -185,7 +185,8 @@ "NODE_COPY_GENERIC": "An error occurred whilst trying to copy the node.", "NODE_CUT_GENERIC": "An error occurred whilst trying to cut the node.", "EXPORT_IMAGE_ERROR": "An error has occurred during image export. The mind map may be too large.", - "MAP_COULD_NOT_BE_FOUND": "Mindmap could not be found!" + "MAP_COULD_NOT_BE_FOUND": "Mindmap could not be found!", + "IMPORT_ERROR": "Mindmap could not be imported!" }, "DELETE_MAP_SUCCESS": "Mindmap successfully deleted!" }, diff --git a/teammapper-frontend/src/assets/i18n/es.json b/teammapper-frontend/src/assets/i18n/es.json index a05776c3..ed186139 100644 --- a/teammapper-frontend/src/assets/i18n/es.json +++ b/teammapper-frontend/src/assets/i18n/es.json @@ -185,7 +185,8 @@ "NODE_COPY_GENERIC": "Se ha producido un error al intentar copiar el nodo.", "NODE_CUT_GENERIC": "Se ha producido un error al intentar cortar el nodo.", "EXPORT_IMAGE_ERROR": "Se ha producido un error durante la exportación de la imagen. El mapa mental puede ser demasiado grande.", - "MAP_COULD_NOT_BE_FOUND": "No se ha encontrado el mapa mental." + "MAP_COULD_NOT_BE_FOUND": "No se ha encontrado el mapa mental.", + "IMPORT_ERROR": "No se ha podido importar el mapa mental." }, "DELETE_MAP_SUCCESS": "¡Mapa mental borrado con éxito!" }, diff --git a/teammapper-frontend/src/assets/i18n/fr.json b/teammapper-frontend/src/assets/i18n/fr.json index 68bbcd4f..9575c05f 100644 --- a/teammapper-frontend/src/assets/i18n/fr.json +++ b/teammapper-frontend/src/assets/i18n/fr.json @@ -185,7 +185,8 @@ "NODE_COPY_GENERIC": "Une erreur s'est produite lors de la copie du nœud.", "NODE_CUT_GENERIC": "Une erreur s'est produite lors de la découpe du nœud.", "EXPORT_IMAGE_ERROR": "Une erreur s'est produite lors de l'exportation de l'image. Il se peut que la mind map soit trop grande.", - "MAP_COULD_NOT_BE_FOUND": "La carte heuristique est introuvable !" + "MAP_COULD_NOT_BE_FOUND": "La carte heuristique est introuvable !", + "IMPORT_ERROR": "La Mindmap n'a pas pu être importée !" }, "DELETE_MAP_SUCCESS": "Mindmap supprimée avec succès !" }, diff --git a/teammapper-frontend/src/assets/i18n/it.json b/teammapper-frontend/src/assets/i18n/it.json index df5ad33b..d24d0b71 100644 --- a/teammapper-frontend/src/assets/i18n/it.json +++ b/teammapper-frontend/src/assets/i18n/it.json @@ -185,7 +185,8 @@ "NODE_COPY_GENERIC": "Si è verificato un errore durante il tentativo di copiare il nodo.", "NODE_CUT_GENERIC": "Si è verificato un errore durante il tentativo di tagliare il nodo.", "EXPORT_IMAGE_ERROR": "Si è verificato un errore durante l'esportazione dell'immagine. La mappa mentale potrebbe essere troppo grande.", - "MAP_COULD_NOT_BE_FOUND": "Impossibile trovare la mappa mentale!" + "MAP_COULD_NOT_BE_FOUND": "Impossibile trovare la mappa mentale!", + "IMPORT_ERROR": "Non è stato possibile importare la mappa mentale!" }, "DELETE_MAP_SUCCESS": "Mappa mentale cancellata con successo!" }, diff --git a/teammapper-frontend/src/assets/i18n/pt-br.json b/teammapper-frontend/src/assets/i18n/pt-br.json index 71103894..d0679d77 100644 --- a/teammapper-frontend/src/assets/i18n/pt-br.json +++ b/teammapper-frontend/src/assets/i18n/pt-br.json @@ -185,7 +185,8 @@ "NODE_COPY_GENERIC": "Ocorreu um erro ao tentar copiar o nó.", "NODE_CUT_GENERIC": "Ocorreu um erro ao tentar cortar o nó.", "EXPORT_IMAGE_ERROR": "Ocorreu um erro durante a exportação da imagem. O mapa mental pode ser muito grande.", - "MAP_COULD_NOT_BE_FOUND": "Não foi possível encontrar o mapa mental!" + "MAP_COULD_NOT_BE_FOUND": "Não foi possível encontrar o mapa mental!", + "IMPORT_ERROR": "O mapa mental não pôde ser importado!" }, "DELETE_MAP_SUCCESS": "Mapa mental excluído com sucesso!" }, diff --git a/teammapper-frontend/src/assets/i18n/zh-cn.json b/teammapper-frontend/src/assets/i18n/zh-cn.json index fbda6429..9ddb8fdb 100644 --- a/teammapper-frontend/src/assets/i18n/zh-cn.json +++ b/teammapper-frontend/src/assets/i18n/zh-cn.json @@ -185,7 +185,8 @@ "NODE_COPY_GENERIC": "尝试复制节点时发生错误。", "NODE_CUT_GENERIC": "在尝试切割节点时发生错误。", "EXPORT_IMAGE_ERROR": "导出图像时发生错误。思维导图可能过大。", - "MAP_COULD_NOT_BE_FOUND": "找不到思维导图!" + "MAP_COULD_NOT_BE_FOUND": "找不到思维导图!", + "IMPORT_ERROR": "无法导入思维导图!" }, "DELETE_MAP_SUCCESS": "思维导图已成功删除!" }, diff --git a/teammapper-frontend/src/assets/i18n/zh-tw.json b/teammapper-frontend/src/assets/i18n/zh-tw.json index 10c0746d..6158752c 100644 --- a/teammapper-frontend/src/assets/i18n/zh-tw.json +++ b/teammapper-frontend/src/assets/i18n/zh-tw.json @@ -185,7 +185,8 @@ "NODE_COPY_GENERIC": "An error occurred whilst trying to copy the node.", "NODE_CUT_GENERIC": "An error occurred whilst trying to cut the node.", "EXPORT_IMAGE_ERROR": "An error has occurred during image export. The mind map may be too large.", - "MAP_COULD_NOT_BE_FOUND": "Mindmap could not be found!" + "MAP_COULD_NOT_BE_FOUND": "Mindmap could not be found!", + "IMPORT_ERROR": "Mindmap could not be imported!" }, "DELETE_MAP_SUCCESS": "Mindmap successfully deleted!" },