mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-10 17:33:24 +01:00
Added i18n importer and alert error
This commit is contained in:
parent
18ffa839c7
commit
3e94563a31
@ -2,10 +2,8 @@ import WisemappingImporter from './WisemappingImporter';
|
||||
import FreemindImporter from './FreemindImporter';
|
||||
import Importer from './Importer';
|
||||
|
||||
type textType = 'wxml' | 'mm';
|
||||
|
||||
export default class TextImporterFactory {
|
||||
static create(type: textType, map: string): Importer {
|
||||
static create(type: string, map: string): Importer {
|
||||
let result: Importer;
|
||||
switch (type) {
|
||||
case 'wxml':
|
||||
|
@ -204,11 +204,14 @@
|
||||
"defaultMessage": "Erstellen"
|
||||
},
|
||||
"import.description": {
|
||||
"defaultMessage": "Sie können WiseMapping-Karten in Ihre Kartenliste importieren. Wählen Sie die Datei aus, die Sie importieren möchten."
|
||||
"defaultMessage": "Sie können Karten von WiseMapping oder Freemind in Ihre Kartenliste importieren. Wählen Sie die Datei aus, die Sie importieren möchten."
|
||||
},
|
||||
"import.title": {
|
||||
"defaultMessage": "Importieren Sie vorhandene Mindmaps"
|
||||
},
|
||||
"import.error-file": {
|
||||
"defaultMessage": "Die Dateierweiterung ist ungültig"
|
||||
},
|
||||
"info.basic-info": {
|
||||
"defaultMessage": "Basisinformation"
|
||||
},
|
||||
|
@ -224,6 +224,9 @@
|
||||
"import.title": {
|
||||
"defaultMessage": "Import existing mindmap"
|
||||
},
|
||||
"import.error-file": {
|
||||
"defaultMessage": "The file extension is invalid"
|
||||
},
|
||||
"info.basic-info": {
|
||||
"defaultMessage": "Basic Info"
|
||||
},
|
||||
|
@ -218,6 +218,9 @@
|
||||
"import.title": {
|
||||
"defaultMessage": "Importar mapa mental existente"
|
||||
},
|
||||
"import.error-file": {
|
||||
"defaultMessage": "La extension del archivo es invalida"
|
||||
},
|
||||
"info.basic-info": {
|
||||
"defaultMessage": "Información básica"
|
||||
},
|
||||
|
@ -204,11 +204,14 @@
|
||||
"defaultMessage": "Créer"
|
||||
},
|
||||
"import.description": {
|
||||
"defaultMessage": "Vous pouvez importer des cartes WiseMapping dans votre liste de cartes. Sélectionnez le fichier que vous souhaitez importer."
|
||||
"defaultMessage": "Sie können WiseMapping- oder Freemind-Karten in Ihre Kartenliste importieren. Selectionnez le fichier que vous souhaitez Importeur."
|
||||
},
|
||||
"import.title": {
|
||||
"defaultMessage": "Importer une carte mentale existante"
|
||||
},
|
||||
"import.error-file": {
|
||||
"defaultMessage": "L'extension de fichier n'est pas valide"
|
||||
},
|
||||
"info.basic-info": {
|
||||
"defaultMessage": "Informations de base"
|
||||
},
|
||||
|
@ -209,6 +209,9 @@
|
||||
"import.title": {
|
||||
"defaultMessage": "Загрузить майнд-карту с компьютера"
|
||||
},
|
||||
"import.error-file": {
|
||||
"defaultMessage": "Недопустимое расширение файла"
|
||||
},
|
||||
"info.basic-info": {
|
||||
"defaultMessage": "Основная информация"
|
||||
},
|
||||
|
@ -210,11 +210,14 @@
|
||||
"defaultMessage": "创建"
|
||||
},
|
||||
"import.description": {
|
||||
"defaultMessage": "您可以将WiseMapping脑图导入到您的脑图列表中。选择要导入的文件。"
|
||||
"defaultMessage": "您可以将脑图从 WiseMapping 和 Freemind 导入到您的脑图列表中。选择要导入的文件。"
|
||||
},
|
||||
"import.title": {
|
||||
"defaultMessage": "导入现有的思维导图"
|
||||
},
|
||||
"import.error-file": {
|
||||
"defaultMessage": "文件扩展名无效"
|
||||
},
|
||||
"info.basic-info": {
|
||||
"defaultMessage": "基本信息"
|
||||
},
|
||||
|
@ -446,7 +446,13 @@
|
||||
"import.description": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Sie können WiseMapping-Karten in Ihre Kartenliste importieren. Wählen Sie die Datei aus, die Sie importieren möchten."
|
||||
"value": "Sie können Karten von WiseMapping oder Freemind in Ihre Kartenliste importieren. Wählen Sie die Datei aus, die Sie importieren möchten."
|
||||
}
|
||||
],
|
||||
"import.error-file": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Die Dateierweiterung ist ungültig"
|
||||
}
|
||||
],
|
||||
"import.title": [
|
||||
|
@ -443,6 +443,12 @@
|
||||
"value": "You can import WiseMapping and Freemind maps to your list of maps. Select the file you want to import."
|
||||
}
|
||||
],
|
||||
"import.error-file": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "The file extension is invalid"
|
||||
}
|
||||
],
|
||||
"import.title": [
|
||||
{
|
||||
"type": 0,
|
||||
|
@ -443,6 +443,12 @@
|
||||
"value": "Puede importar mapas de WiseMapping y Freemind a su lista de mapas. Seleccione el archivo que desea importar."
|
||||
}
|
||||
],
|
||||
"import.error-file": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "La extension del archivo es invalida"
|
||||
}
|
||||
],
|
||||
"import.title": [
|
||||
{
|
||||
"type": 0,
|
||||
|
@ -438,7 +438,13 @@
|
||||
"import.description": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Vous pouvez importer des cartes WiseMapping dans votre liste de cartes. Sélectionnez le fichier que vous souhaitez importer."
|
||||
"value": "Sie können WiseMapping- oder Freemind-Karten in Ihre Kartenliste importieren. Selectionnez le fichier que vous souhaitez Importeur."
|
||||
}
|
||||
],
|
||||
"import.error-file": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "L'extension de fichier n'est pas valide"
|
||||
}
|
||||
],
|
||||
"import.title": [
|
||||
|
@ -443,6 +443,12 @@
|
||||
"value": "Можно импортировать FreeMind 1.0.1 и WiseMapping файлы. Выберите файл, который хотите импортировать."
|
||||
}
|
||||
],
|
||||
"import.error-file": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Недопустимое расширение файла"
|
||||
}
|
||||
],
|
||||
"import.title": [
|
||||
{
|
||||
"type": 0,
|
||||
|
@ -440,7 +440,13 @@
|
||||
"import.description": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "您可以将WiseMapping脑图导入到您的脑图列表中。选择要导入的文件。"
|
||||
"value": "您可以将脑图从 WiseMapping 和 Freemind 导入到您的脑图列表中。选择要导入的文件。"
|
||||
}
|
||||
],
|
||||
"import.error-file": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "文件扩展名无效"
|
||||
}
|
||||
],
|
||||
"import.title": [
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { Alert } from '@mui/material';
|
||||
import Button from '@mui/material/Button';
|
||||
import FormControl from '@mui/material/FormControl';
|
||||
import { Importer, TextImporterFactory } from '@wisemapping/mindplot';
|
||||
@ -27,6 +28,7 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => {
|
||||
const client: Client = useSelector(activeInstance);
|
||||
const [model, setModel] = React.useState<ImportModel>(defaultModel);
|
||||
const [error, setError] = React.useState<ErrorInfo>();
|
||||
const [errorFile, setErrorFile] = React.useState<boolean>(false);
|
||||
const intl = useIntl();
|
||||
|
||||
const mutation = useMutation<number, ErrorInfo, ImportModel>(
|
||||
@ -82,8 +84,8 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => {
|
||||
const extensionFile = file.name.split('.').pop();
|
||||
const extensionAccept = ['wxml', 'mm'];
|
||||
|
||||
if ( extensionAccept.find(ext => ext === extensionFile) ) {
|
||||
new Error('The file extension is invalid');
|
||||
if (!extensionAccept.includes(extensionFile)) {
|
||||
setErrorFile(true);
|
||||
}
|
||||
|
||||
model.contentType = 'application/xml'
|
||||
@ -91,18 +93,7 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => {
|
||||
const fileContent = event?.target?.result;
|
||||
const mapConent: string = typeof fileContent === 'string' ? fileContent : fileContent.toString();
|
||||
|
||||
let importer: Importer
|
||||
switch(extensionFile) {
|
||||
case 'wxml': {
|
||||
importer = TextImporterFactory.create('wxml', mapConent);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'mm': {
|
||||
importer = TextImporterFactory.create('mm', mapConent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const importer: Importer = TextImporterFactory.create(extensionFile, mapConent)
|
||||
|
||||
importer.import(model.title, model.description)
|
||||
.then(res => {
|
||||
@ -134,6 +125,14 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => {
|
||||
})}
|
||||
submitButton={intl.formatMessage({ id: 'import.button', defaultMessage: 'Create' })}
|
||||
>
|
||||
{errorFile &&
|
||||
<Alert severity='error'>
|
||||
<FormattedMessage
|
||||
id="import.error-file"
|
||||
defaultMessage="The file extension is invalid"
|
||||
/>
|
||||
</Alert>
|
||||
}
|
||||
<FormControl fullWidth={true}>
|
||||
<input
|
||||
accept=".wxml,.mm"
|
||||
|
Loading…
Reference in New Issue
Block a user