From 9d0602ea2340665e3fb23a03ac837d7227f99dd3 Mon Sep 17 00:00:00 2001 From: Katherine Date: Thu, 5 Sep 2024 20:46:26 +0800 Subject: [PATCH 1/2] refactor: batch updated and batch edit, change 'All' to 'Entire collection" (#5200) * refactor: batch updated and batch edit, change 'All' to 'Entire collection' * fix: test --- .../src/client/BulkEditAction.Settings.tsx | 2 +- .../src/client/__e2e__/schemaSettings.test.ts | 2 +- .../@nocobase/plugin-action-bulk-edit/src/locale/zh-CN.json | 3 ++- .../src/client/BulkUpdateAction.Settings.tsx | 2 +- .../src/client/__e2e__/schemaSettings.test.ts | 2 +- .../@nocobase/plugin-action-bulk-update/src/locale/zh-CN.ts | 1 + 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/BulkEditAction.Settings.tsx b/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/BulkEditAction.Settings.tsx index bdc89e6785..7b2ae0069e 100644 --- a/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/BulkEditAction.Settings.tsx +++ b/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/BulkEditAction.Settings.tsx @@ -33,7 +33,7 @@ function UpdateMode() { title={t('Data will be updated')} options={[ { label: t('Selected'), value: 'selected' }, - { label: t('All'), value: 'all' }, + { label: t('Entire collection', { ns: 'action-bulk-edit' }), value: 'all' }, ]} value={fieldSchema?.['x-action-settings']?.['updateMode']} onChange={(value) => { diff --git a/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/__e2e__/schemaSettings.test.ts b/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/__e2e__/schemaSettings.test.ts index 2b39281840..7b1816f287 100644 --- a/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/__e2e__/schemaSettings.test.ts +++ b/packages/plugins/@nocobase/plugin-action-bulk-edit/src/client/__e2e__/schemaSettings.test.ts @@ -21,7 +21,7 @@ test.describe('bulk edit action setting', () => { await expect(page.getByTitle('Data will be updated').getByText('Selected')).toBeVisible(); await page.getByRole('menuitem', { name: 'Data will be updated' }).click(); //切换为全部数据 - await page.getByRole('option', { name: 'All' }).click(); + await page.getByRole('option', { name: 'Entire collection' }).click(); //配置更新规则 await page.getByLabel('Bulk edit').click(); await page.getByLabel('schema-initializer-Grid-popup:bulkEdit:addBlock-general').hover(); diff --git a/packages/plugins/@nocobase/plugin-action-bulk-edit/src/locale/zh-CN.json b/packages/plugins/@nocobase/plugin-action-bulk-edit/src/locale/zh-CN.json index f9e8775f39..05ba2d2124 100644 --- a/packages/plugins/@nocobase/plugin-action-bulk-edit/src/locale/zh-CN.json +++ b/packages/plugins/@nocobase/plugin-action-bulk-edit/src/locale/zh-CN.json @@ -1,4 +1,5 @@ { "Bulk edit": "批量编辑", - "Data will be updated": "更新的数据" + "Data will be updated": "更新的数据", + "Entire collection":"全表" } diff --git a/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdateAction.Settings.tsx b/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdateAction.Settings.tsx index 5be24f6b66..6521d54bf9 100644 --- a/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdateAction.Settings.tsx +++ b/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdateAction.Settings.tsx @@ -33,7 +33,7 @@ function UpdateMode() { title={t('Data will be updated')} options={[ { label: t('Selected'), value: 'selected' }, - { label: t('All'), value: 'all' }, + { label: t('Entire collection', { ns: 'action-bulk-edit' }), value: 'all' }, ]} value={fieldSchema?.['x-action-settings']?.['updateMode']} onChange={(value) => { diff --git a/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/__e2e__/schemaSettings.test.ts b/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/__e2e__/schemaSettings.test.ts index fb37fbaed5..73bd22caac 100644 --- a/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/__e2e__/schemaSettings.test.ts +++ b/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/__e2e__/schemaSettings.test.ts @@ -24,7 +24,7 @@ test.describe('data will be updated && Assign field values && after successful s await expect(page.getByTitle('Data will be updated').getByText('Selected')).toBeVisible(); await page.getByRole('menuitem', { name: 'Data will be updated' }).click(); //切换为全部数据 - await page.getByRole('option', { name: 'All' }).click(); + await page.getByRole('option', { name: 'Entire collection' }).click(); //字段赋值 await page.getByRole('menuitem', { name: 'Assign field values' }).click(); await page.getByLabel('schema-initializer-Grid-assignFieldValuesForm:configureFields-general').click(); diff --git a/packages/plugins/@nocobase/plugin-action-bulk-update/src/locale/zh-CN.ts b/packages/plugins/@nocobase/plugin-action-bulk-update/src/locale/zh-CN.ts index f1ca06e0ea..71fdb1988c 100644 --- a/packages/plugins/@nocobase/plugin-action-bulk-update/src/locale/zh-CN.ts +++ b/packages/plugins/@nocobase/plugin-action-bulk-update/src/locale/zh-CN.ts @@ -11,4 +11,5 @@ export default { 'Bulk update': '批量更新', 'After successful bulk update': '批量成功更新后', 'Please select the records to be updated': '请选择要更新的记录', + "Entire collection":"全表" }; From 325c4341ba9a2e24f0589d9871af8869a8012964 Mon Sep 17 00:00:00 2001 From: Katherine Date: Thu, 5 Sep 2024 21:02:08 +0800 Subject: [PATCH 2/2] refactor: collectionNotAllowViewPlaceholder (#5208) --- packages/core/client/src/acl/ACLProvider.tsx | 3 +- .../CollectionDeletedPlaceholder.tsx | 45 +++++++++++++++++++ packages/core/client/src/locale/zh-CN.json | 3 +- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/acl/ACLProvider.tsx b/packages/core/client/src/acl/ACLProvider.tsx index 44a4c9d385..0a8f685ca9 100644 --- a/packages/core/client/src/acl/ACLProvider.tsx +++ b/packages/core/client/src/acl/ACLProvider.tsx @@ -20,6 +20,7 @@ import { useResourceActionContext } from '../collection-manager/ResourceActionPr import { useDataSourceKey } from '../data-source/data-source/DataSourceProvider'; import { useRecord } from '../record-provider'; import { SchemaComponentOptions, useDesignable } from '../schema-component'; +import { CollectionNotAllowViewPlaceholder } from '../data-source'; import { useApp } from '../application'; @@ -233,7 +234,7 @@ export const ACLCollectionProvider = (props) => { } const params = parseAction(actionPath, { schema }); if (!params) { - return null; + return ; } const [_, actionName] = actionPath.split(':'); params.actionName = actionName; diff --git a/packages/core/client/src/data-source/components/CollectionDeletedPlaceholder.tsx b/packages/core/client/src/data-source/components/CollectionDeletedPlaceholder.tsx index fdf2aff562..8a7bf0366b 100644 --- a/packages/core/client/src/data-source/components/CollectionDeletedPlaceholder.tsx +++ b/packages/core/client/src/data-source/components/CollectionDeletedPlaceholder.tsx @@ -16,6 +16,7 @@ import { useDataSourceManager } from '../data-source'; import { DEFAULT_DATA_SOURCE_KEY } from '../../data-source/data-source/DataSourceManager'; import { useCollection } from '../collection'; import { BlockItemCard } from '../../schema-component/antd/block-item/BlockItemCard'; +import { AnyKindOfDictionary } from 'lodash'; export interface CollectionDeletedPlaceholderProps { type: 'Collection' | 'Field' | 'Data Source' | 'Block template'; @@ -112,3 +113,47 @@ export const CollectionDeletedPlaceholder: FC return null; }; + +/** + * @internal + */ +export const CollectionNotAllowViewPlaceholder: FC = () => { + const { designable } = useDesignable(); + const { t } = useTranslation(); + const dataSource = useDataSource(); + const compile = useCompile(); + const collection = useCollection(); + const dataSourceManager = useDataSourceManager(); + const nameValue = useMemo(() => { + const dataSourcePrefix = + dataSourceManager?.getDataSources().length >= 1 && dataSource && dataSource.key !== DEFAULT_DATA_SOURCE_KEY + ? `${compile(dataSource.displayName || dataSource.key)} > ` + : ''; + if (collection) { + return `${dataSourcePrefix}${collection.name}`; + } + const collectionPrefix = collection + ? `${compile(collection.title) || collection.name || collection.tableName} > ` + : ''; + return `${dataSourcePrefix}${collectionPrefix}${collection.name}`; + }, []); + + const messageValue = useMemo(() => { + return t( + `The current user only has the UI configuration permission, but don't have view permission for collection "{{name}}"`, + { + name: nameValue, + }, + ).replaceAll('>', '>'); + }, [nameValue, t]); + + if (designable) { + return ( + + + + ); + } + + return null; +}; diff --git a/packages/core/client/src/locale/zh-CN.json b/packages/core/client/src/locale/zh-CN.json index c3645dfdd8..64271b1928 100644 --- a/packages/core/client/src/locale/zh-CN.json +++ b/packages/core/client/src/locale/zh-CN.json @@ -971,5 +971,6 @@ "Use simple pagination mode": "使用简单分页模式", "Sorry, the page you visited does not exist.": "抱歉,你访问的页面不存在。", "Set Template Engine": "设置模板引擎", - "Skip getting the total number of table records during paging to speed up loading. It is recommended to enable this option for data tables with a large amount of data": "在分页时跳过获取表记录总数,以加快加载速度,建议对有大量数据的数据表开启此选项" + "Skip getting the total number of table records during paging to speed up loading. It is recommended to enable this option for data tables with a large amount of data": "在分页时跳过获取表记录总数,以加快加载速度,建议对有大量数据的数据表开启此选项", + "The current user only has the UI configuration permission, but don't have view permission for collection \"{{name}}\"": "当前用户只有 UI 配置权限,但没有数据表 \"{{name}}\" 查看权限。" }