chore: add export & import warnings (#4027)

* chore: add export & import warnings

* chore: update
This commit is contained in:
YANG QIA 2024-04-12 16:22:18 +08:00 committed by GitHub
parent bfbec4c004
commit a18dab363a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 48 additions and 6 deletions

View File

@ -30,6 +30,8 @@ export const CSSVariableProvider = ({ children }) => {
document.body.style.setProperty('--marginSM', `${token.marginSM}px`);
document.body.style.setProperty('--colorInfoBg', token.colorInfoBg);
document.body.style.setProperty('--colorInfoBorder', token.colorInfoBorder);
document.body.style.setProperty('--colorWarningBg', token.colorWarningBg);
document.body.style.setProperty('--colorWarningBorder', token.colorWarningBorder);
document.body.style.setProperty('--colorText', token.colorText);
document.body.style.setProperty('--colorPrimaryText', token.colorPrimaryText);
document.body.style.setProperty('--colorPrimaryTextActive', token.colorPrimaryTextActive);

View File

@ -10,13 +10,13 @@ import {
useDesignable,
} from '@nocobase/client';
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useShared } from './useShared';
import { useExportTranslation } from './locale';
export const ExportDesigner = () => {
const field = useField();
const fieldSchema = useFieldSchema();
const { t } = useTranslation();
const { t } = useExportTranslation();
const { dn } = useDesignable();
const [schema, setSchema] = useState<ISchema>();
const { schema: pageSchema } = useShared();
@ -94,6 +94,7 @@ export const ExportDesigner = () => {
title={t('Exportable fields')}
schema={schema}
initialValues={{ exportSettings: fieldSchema?.['x-action-settings']?.exportSettings }}
scope={{ t }}
components={{ ArrayItems }}
onSubmit={({ exportSettings }) => {
fieldSchema['x-action-settings']['exportSettings'] = exportSettings

View File

@ -0,0 +1,7 @@
import { useTranslation } from 'react-i18next';
export const NAMESPACE = 'export';
export function useExportTranslation() {
return useTranslation([NAMESPACE, 'client'], { nsMode: 'fallback' });
}

View File

@ -8,7 +8,8 @@ import {
} from '@nocobase/client';
import lodash from 'lodash';
import { saveAs } from 'file-saver';
import { useTranslation } from 'react-i18next';
import { App } from 'antd';
import { useExportTranslation } from './locale';
export const useExportAction = () => {
const { service, resource } = useBlockRequestContext();
@ -17,9 +18,17 @@ export const useExportAction = () => {
const compile = useCompile();
const { getCollectionJoinField } = useCollectionManager_deprecated();
const { name, title, getField } = useCollection_deprecated();
const { t } = useTranslation();
const { t } = useExportTranslation();
const { modal } = App.useApp();
return {
async onClick() {
const confirmed = await modal.confirm({
title: t('Export'),
content: t('Export warning'),
});
if (!confirmed) {
return;
}
const { exportSettings } = lodash.cloneDeep(actionSchema?.['x-action-settings'] ?? {});
exportSettings.forEach((es) => {
const { uiSchema, interface: fieldInterface } =

View File

@ -0,0 +1,3 @@
{
"Export warning": "Only a small amount of data can be exported (preferably within 1000 rows), and a large amount of data will cause the system to freeze. Please use the Action: Export records pro plugin for large data exports."
}

View File

@ -0,0 +1,3 @@
{
"Export warning": "仅支持少量数据导出最好1000行以内大量数据会导致系统卡住。请通过 Action: Export records pro 插件实现大量数据导出。"
}

View File

@ -85,6 +85,21 @@ export const ImportActionInitializer = () => {
type: 'void',
'x-component': 'FormLayout',
properties: {
warning: {
type: 'void',
'x-component': 'Markdown.Void',
'x-editable': false,
'x-component-props': {
style: {
padding: `var(--paddingContentVerticalSM)`,
backgroundColor: `var(--colorWarningBg)`,
border: `1px solid var(--colorWarningBorder)`,
color: `var(--colorText)`,
marginBottom: `var(--marginSM)`,
},
content: `{{ t("Import warning", {ns: "${NAMESPACE}" }) }}`,
},
},
download: {
type: 'void',
title: `{{ t("Step 1: Download template", {ns: "${NAMESPACE}" }) }}`,

View File

@ -8,7 +8,8 @@
"Download template": "Download template",
"Step 1: Download template": "Step 1: Download template",
"Step 2: Upload Excel": "Step 2: Upload Excel",
"Download tip": "- Download the template and fill in the data according to the format \r\n - Import only the first worksheet \r\n - Support single import of up to 10,000 rows of data \r\n - Do not change the header of the template to prevent import failure",
"Download tip": "- Download the template and fill in the data according to the format \r\n - Import only the first worksheet \r\n - Support single import of up to 1,000 rows of data \r\n - Do not change the header of the template to prevent import failure",
"Import warning": "Only a small amount of data can be imported (preferably within 1000 rows), and a large amount of data will cause the system to freeze. Please use the Action: Import records pro plugin for large data imports.",
"Upload placeholder": "Drag and drop the file here or click to upload, file size should not exceed 30M",
"Excel data importing": "Excel data importing",
"Import done, total success have {{successCount}} , total failure have {{failureCount}}": "Import is complete, with a total of {{successCount}} successful and {{failureCount}} failed",

View File

@ -8,7 +8,8 @@
"Download template": "下载模板",
"Step 1: Download template": "1.下载模板",
"Step 2: Upload Excel": "2.上传完善后的表格",
"Download tip": "- 下载模板后,按格式填写数据\r\n - 只导入第一张工作表\r\n - 支持单次导入不超过10000行数据\r\n - 请勿改模板表头,防止导入失败",
"Download tip": "- 下载模板后,按格式填写数据\r\n - 只导入第一张工作表\r\n - 支持单次导入不超过1000行数据\r\n - 请勿改模板表头,防止导入失败",
"Import warning": "仅支持少量数据导入最好1000行以内大量数据会导致系统卡住。请通过 Action: Import records pro 插件实现大量数据导入。",
"Upload placeholder": "将文件拖曳到此处或点击上传文件大小不超过10M",
"Excel data importing": "数据导入中,请勿关闭窗口",
"Import done, total success have {{successCount}} , total failure have {{failureCount}}": "导入完成,共导入成功{{successCount}}条数据,共导入失败{{failureCount}}条数据",