mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 14:47:56 +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 FreemindImporter from './FreemindImporter';
|
||||||
import Importer from './Importer';
|
import Importer from './Importer';
|
||||||
|
|
||||||
type textType = 'wxml' | 'mm';
|
|
||||||
|
|
||||||
export default class TextImporterFactory {
|
export default class TextImporterFactory {
|
||||||
static create(type: textType, map: string): Importer {
|
static create(type: string, map: string): Importer {
|
||||||
let result: Importer;
|
let result: Importer;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'wxml':
|
case 'wxml':
|
||||||
|
@ -204,11 +204,14 @@
|
|||||||
"defaultMessage": "Erstellen"
|
"defaultMessage": "Erstellen"
|
||||||
},
|
},
|
||||||
"import.description": {
|
"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": {
|
"import.title": {
|
||||||
"defaultMessage": "Importieren Sie vorhandene Mindmaps"
|
"defaultMessage": "Importieren Sie vorhandene Mindmaps"
|
||||||
},
|
},
|
||||||
|
"import.error-file": {
|
||||||
|
"defaultMessage": "Die Dateierweiterung ist ungültig"
|
||||||
|
},
|
||||||
"info.basic-info": {
|
"info.basic-info": {
|
||||||
"defaultMessage": "Basisinformation"
|
"defaultMessage": "Basisinformation"
|
||||||
},
|
},
|
||||||
|
@ -224,6 +224,9 @@
|
|||||||
"import.title": {
|
"import.title": {
|
||||||
"defaultMessage": "Import existing mindmap"
|
"defaultMessage": "Import existing mindmap"
|
||||||
},
|
},
|
||||||
|
"import.error-file": {
|
||||||
|
"defaultMessage": "The file extension is invalid"
|
||||||
|
},
|
||||||
"info.basic-info": {
|
"info.basic-info": {
|
||||||
"defaultMessage": "Basic Info"
|
"defaultMessage": "Basic Info"
|
||||||
},
|
},
|
||||||
|
@ -218,6 +218,9 @@
|
|||||||
"import.title": {
|
"import.title": {
|
||||||
"defaultMessage": "Importar mapa mental existente"
|
"defaultMessage": "Importar mapa mental existente"
|
||||||
},
|
},
|
||||||
|
"import.error-file": {
|
||||||
|
"defaultMessage": "La extension del archivo es invalida"
|
||||||
|
},
|
||||||
"info.basic-info": {
|
"info.basic-info": {
|
||||||
"defaultMessage": "Información básica"
|
"defaultMessage": "Información básica"
|
||||||
},
|
},
|
||||||
|
@ -204,11 +204,14 @@
|
|||||||
"defaultMessage": "Créer"
|
"defaultMessage": "Créer"
|
||||||
},
|
},
|
||||||
"import.description": {
|
"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": {
|
"import.title": {
|
||||||
"defaultMessage": "Importer une carte mentale existante"
|
"defaultMessage": "Importer une carte mentale existante"
|
||||||
},
|
},
|
||||||
|
"import.error-file": {
|
||||||
|
"defaultMessage": "L'extension de fichier n'est pas valide"
|
||||||
|
},
|
||||||
"info.basic-info": {
|
"info.basic-info": {
|
||||||
"defaultMessage": "Informations de base"
|
"defaultMessage": "Informations de base"
|
||||||
},
|
},
|
||||||
|
@ -209,6 +209,9 @@
|
|||||||
"import.title": {
|
"import.title": {
|
||||||
"defaultMessage": "Загрузить майнд-карту с компьютера"
|
"defaultMessage": "Загрузить майнд-карту с компьютера"
|
||||||
},
|
},
|
||||||
|
"import.error-file": {
|
||||||
|
"defaultMessage": "Недопустимое расширение файла"
|
||||||
|
},
|
||||||
"info.basic-info": {
|
"info.basic-info": {
|
||||||
"defaultMessage": "Основная информация"
|
"defaultMessage": "Основная информация"
|
||||||
},
|
},
|
||||||
|
@ -210,11 +210,14 @@
|
|||||||
"defaultMessage": "创建"
|
"defaultMessage": "创建"
|
||||||
},
|
},
|
||||||
"import.description": {
|
"import.description": {
|
||||||
"defaultMessage": "您可以将WiseMapping脑图导入到您的脑图列表中。选择要导入的文件。"
|
"defaultMessage": "您可以将脑图从 WiseMapping 和 Freemind 导入到您的脑图列表中。选择要导入的文件。"
|
||||||
},
|
},
|
||||||
"import.title": {
|
"import.title": {
|
||||||
"defaultMessage": "导入现有的思维导图"
|
"defaultMessage": "导入现有的思维导图"
|
||||||
},
|
},
|
||||||
|
"import.error-file": {
|
||||||
|
"defaultMessage": "文件扩展名无效"
|
||||||
|
},
|
||||||
"info.basic-info": {
|
"info.basic-info": {
|
||||||
"defaultMessage": "基本信息"
|
"defaultMessage": "基本信息"
|
||||||
},
|
},
|
||||||
|
@ -446,7 +446,13 @@
|
|||||||
"import.description": [
|
"import.description": [
|
||||||
{
|
{
|
||||||
"type": 0,
|
"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": [
|
"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."
|
"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": [
|
"import.title": [
|
||||||
{
|
{
|
||||||
"type": 0,
|
"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."
|
"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": [
|
"import.title": [
|
||||||
{
|
{
|
||||||
"type": 0,
|
"type": 0,
|
||||||
|
@ -438,7 +438,13 @@
|
|||||||
"import.description": [
|
"import.description": [
|
||||||
{
|
{
|
||||||
"type": 0,
|
"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": [
|
"import.title": [
|
||||||
|
@ -443,6 +443,12 @@
|
|||||||
"value": "Можно импортировать FreeMind 1.0.1 и WiseMapping файлы. Выберите файл, который хотите импортировать."
|
"value": "Можно импортировать FreeMind 1.0.1 и WiseMapping файлы. Выберите файл, который хотите импортировать."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"import.error-file": [
|
||||||
|
{
|
||||||
|
"type": 0,
|
||||||
|
"value": "Недопустимое расширение файла"
|
||||||
|
}
|
||||||
|
],
|
||||||
"import.title": [
|
"import.title": [
|
||||||
{
|
{
|
||||||
"type": 0,
|
"type": 0,
|
||||||
|
@ -440,7 +440,13 @@
|
|||||||
"import.description": [
|
"import.description": [
|
||||||
{
|
{
|
||||||
"type": 0,
|
"type": 0,
|
||||||
"value": "您可以将WiseMapping脑图导入到您的脑图列表中。选择要导入的文件。"
|
"value": "您可以将脑图从 WiseMapping 和 Freemind 导入到您的脑图列表中。选择要导入的文件。"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"import.error-file": [
|
||||||
|
{
|
||||||
|
"type": 0,
|
||||||
|
"value": "文件扩展名无效"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"import.title": [
|
"import.title": [
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { Alert } from '@mui/material';
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
import FormControl from '@mui/material/FormControl';
|
import FormControl from '@mui/material/FormControl';
|
||||||
import { Importer, TextImporterFactory } from '@wisemapping/mindplot';
|
import { Importer, TextImporterFactory } from '@wisemapping/mindplot';
|
||||||
@ -27,6 +28,7 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => {
|
|||||||
const client: Client = useSelector(activeInstance);
|
const client: Client = useSelector(activeInstance);
|
||||||
const [model, setModel] = React.useState<ImportModel>(defaultModel);
|
const [model, setModel] = React.useState<ImportModel>(defaultModel);
|
||||||
const [error, setError] = React.useState<ErrorInfo>();
|
const [error, setError] = React.useState<ErrorInfo>();
|
||||||
|
const [errorFile, setErrorFile] = React.useState<boolean>(false);
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const mutation = useMutation<number, ErrorInfo, ImportModel>(
|
const mutation = useMutation<number, ErrorInfo, ImportModel>(
|
||||||
@ -82,8 +84,8 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => {
|
|||||||
const extensionFile = file.name.split('.').pop();
|
const extensionFile = file.name.split('.').pop();
|
||||||
const extensionAccept = ['wxml', 'mm'];
|
const extensionAccept = ['wxml', 'mm'];
|
||||||
|
|
||||||
if ( extensionAccept.find(ext => ext === extensionFile) ) {
|
if (!extensionAccept.includes(extensionFile)) {
|
||||||
new Error('The file extension is invalid');
|
setErrorFile(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
model.contentType = 'application/xml'
|
model.contentType = 'application/xml'
|
||||||
@ -91,18 +93,7 @@ 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();
|
||||||
|
|
||||||
let importer: Importer
|
const importer: Importer = TextImporterFactory.create(extensionFile, mapConent)
|
||||||
switch(extensionFile) {
|
|
||||||
case 'wxml': {
|
|
||||||
importer = TextImporterFactory.create('wxml', mapConent);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'mm': {
|
|
||||||
importer = TextImporterFactory.create('mm', mapConent);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
importer.import(model.title, model.description)
|
importer.import(model.title, model.description)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
@ -134,6 +125,14 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => {
|
|||||||
})}
|
})}
|
||||||
submitButton={intl.formatMessage({ id: 'import.button', defaultMessage: 'Create' })}
|
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}>
|
<FormControl fullWidth={true}>
|
||||||
<input
|
<input
|
||||||
accept=".wxml,.mm"
|
accept=".wxml,.mm"
|
||||||
|
Loading…
Reference in New Issue
Block a user