mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:06:06 +00:00
refactor: collectionNotAllowViewPlaceholder (#5208)
This commit is contained in:
parent
9d0602ea23
commit
325c4341ba
@ -20,6 +20,7 @@ import { useResourceActionContext } from '../collection-manager/ResourceActionPr
|
|||||||
import { useDataSourceKey } from '../data-source/data-source/DataSourceProvider';
|
import { useDataSourceKey } from '../data-source/data-source/DataSourceProvider';
|
||||||
import { useRecord } from '../record-provider';
|
import { useRecord } from '../record-provider';
|
||||||
import { SchemaComponentOptions, useDesignable } from '../schema-component';
|
import { SchemaComponentOptions, useDesignable } from '../schema-component';
|
||||||
|
import { CollectionNotAllowViewPlaceholder } from '../data-source';
|
||||||
|
|
||||||
import { useApp } from '../application';
|
import { useApp } from '../application';
|
||||||
|
|
||||||
@ -233,7 +234,7 @@ export const ACLCollectionProvider = (props) => {
|
|||||||
}
|
}
|
||||||
const params = parseAction(actionPath, { schema });
|
const params = parseAction(actionPath, { schema });
|
||||||
if (!params) {
|
if (!params) {
|
||||||
return null;
|
return <CollectionNotAllowViewPlaceholder />;
|
||||||
}
|
}
|
||||||
const [_, actionName] = actionPath.split(':');
|
const [_, actionName] = actionPath.split(':');
|
||||||
params.actionName = actionName;
|
params.actionName = actionName;
|
||||||
|
@ -16,6 +16,7 @@ import { useDataSourceManager } from '../data-source';
|
|||||||
import { DEFAULT_DATA_SOURCE_KEY } from '../../data-source/data-source/DataSourceManager';
|
import { DEFAULT_DATA_SOURCE_KEY } from '../../data-source/data-source/DataSourceManager';
|
||||||
import { useCollection } from '../collection';
|
import { useCollection } from '../collection';
|
||||||
import { BlockItemCard } from '../../schema-component/antd/block-item/BlockItemCard';
|
import { BlockItemCard } from '../../schema-component/antd/block-item/BlockItemCard';
|
||||||
|
import { AnyKindOfDictionary } from 'lodash';
|
||||||
|
|
||||||
export interface CollectionDeletedPlaceholderProps {
|
export interface CollectionDeletedPlaceholderProps {
|
||||||
type: 'Collection' | 'Field' | 'Data Source' | 'Block template';
|
type: 'Collection' | 'Field' | 'Data Source' | 'Block template';
|
||||||
@ -112,3 +113,47 @@ export const CollectionDeletedPlaceholder: FC<CollectionDeletedPlaceholderProps>
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const CollectionNotAllowViewPlaceholder: FC<any> = () => {
|
||||||
|
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 (
|
||||||
|
<BlockItemCard>
|
||||||
|
<Result status="404" subTitle={messageValue} />
|
||||||
|
</BlockItemCard>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
@ -971,5 +971,6 @@
|
|||||||
"Use simple pagination mode": "使用简单分页模式",
|
"Use simple pagination mode": "使用简单分页模式",
|
||||||
"Sorry, the page you visited does not exist.": "抱歉,你访问的页面不存在。",
|
"Sorry, the page you visited does not exist.": "抱歉,你访问的页面不存在。",
|
||||||
"Set Template Engine": "设置模板引擎",
|
"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}}\" 查看权限。"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user