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}}\" 查看权限。" }