perf: app list permission (#3023)

* perf: app list permission

* perf: create dataset tip
This commit is contained in:
Archer
2024-10-30 12:38:16 +08:00
committed by GitHub
parent 9f4aa3160e
commit 97216eec59
5 changed files with 15 additions and 13 deletions

View File

@@ -227,7 +227,7 @@
"common.submit_success": "Submitted Successfully", "common.submit_success": "Submitted Successfully",
"common.submitted": "Submitted", "common.submitted": "Submitted",
"common.support": "Support", "common.support": "Support",
"common.system.Commercial version function": "Please Upgrade to the Commercial Version to Use This Feature: https://tryfastgpt.ai", "common.system.Commercial version function": "Please Upgrade to the Commercial Version to Use This Feature: https://doc.fastgpt.cn/docs/commercial/intro/",
"common.system.Help Chatbot": "Help Chatbot", "common.system.Help Chatbot": "Help Chatbot",
"common.system.Use Helper": "Use Helper", "common.system.Use Helper": "Use Helper",
"common.ui.textarea.Magnifying": "Magnifying", "common.ui.textarea.Magnifying": "Magnifying",

View File

@@ -234,7 +234,7 @@
"common.submit_success": "提交成功", "common.submit_success": "提交成功",
"common.submitted": "已提交", "common.submitted": "已提交",
"common.support": "支持", "common.support": "支持",
"common.system.Commercial version function": "请升级商业版后使用该功能https://fastgpt.in", "common.system.Commercial version function": "请升级商业版后使用该功能https://doc.fastgpt.cn/docs/commercial/intro/",
"common.system.Help Chatbot": "机器人助手", "common.system.Help Chatbot": "机器人助手",
"common.system.Use Helper": "使用帮助", "common.system.Use Helper": "使用帮助",
"common.ui.textarea.Magnifying": "放大", "common.ui.textarea.Magnifying": "放大",

View File

@@ -117,6 +117,7 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
}).lean() }).lean()
]); ]);
// Filter apps by permission
const filterApps = myApps const filterApps = myApps
.map((app) => { .map((app) => {
const { Per, privateApp } = (() => { const { Per, privateApp } = (() => {
@@ -124,20 +125,21 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
(item) => (item) =>
String(item.tmbId) === String(tmbId) || myGroupIds.includes(String(item.groupId)) String(item.tmbId) === String(tmbId) || myGroupIds.includes(String(item.groupId))
); );
const getPer = (id: string) => { const getPer = (appId: string) => {
const tmbPer = myPerList.find( const tmbPer = myPerList.find(
(item) => String(item.resourceId) === id && !!item.tmbId (item) => String(item.resourceId) === appId && !!item.tmbId
)?.permission; )?.permission;
const groupPer = getGroupPer( const groupPer = getGroupPer(
myPerList myPerList
.filter( .filter(
(item) => (item) =>
String(item.resourceId) === id && myGroupIds.includes(String(item.groupId)) String(item.resourceId) === appId && myGroupIds.includes(String(item.groupId))
) )
.map((item) => item.permission) .map((item) => item.permission)
); );
const clbCount = perList.filter((item) => String(item.resourceId) === id).length; // Count app collaborators
const clbCount = perList.filter((item) => String(item.resourceId) === appId).length;
return { return {
Per: new AppPermission({ Per: new AppPermission({

View File

@@ -108,20 +108,20 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
String(item.tmbId) === String(tmbId) || myGroupIds.includes(String(item.groupId)) String(item.tmbId) === String(tmbId) || myGroupIds.includes(String(item.groupId))
); );
const getPer = (id: string) => { const getPer = (datasetId: string) => {
const tmbPer = myPerList.find( const tmbPer = myPerList.find(
(item) => String(item.resourceId) === id && !!item.tmbId (item) => String(item.resourceId) === datasetId && !!item.tmbId
)?.permission; )?.permission;
const groupPer = getGroupPer( const groupPer = getGroupPer(
myPerList myPerList
.filter( .filter(
(item) => (item) =>
String(item.resourceId) === id && myGroupIds.includes(String(item.groupId)) String(item.resourceId) === datasetId && myGroupIds.includes(String(item.groupId))
) )
.map((item) => item.permission) .map((item) => item.permission)
); );
const clbCount = perList.filter((item) => String(item.resourceId) === id).length; const clbCount = perList.filter((item) => String(item.resourceId) === datasetId).length;
return { return {
Per: new DatasetPermission({ Per: new DatasetPermission({

View File

@@ -157,19 +157,19 @@ const Dataset = () => {
icon: 'core/dataset/commonDatasetColor', icon: 'core/dataset/commonDatasetColor',
label: t('dataset:common_dataset'), label: t('dataset:common_dataset'),
description: t('dataset:common_dataset_desc'), description: t('dataset:common_dataset_desc'),
onClick: () => setCreateDatasetType(DatasetTypeEnum.dataset) onClick: () => onSelectDatasetType(DatasetTypeEnum.dataset)
}, },
{ {
icon: 'core/dataset/websiteDatasetColor', icon: 'core/dataset/websiteDatasetColor',
label: t('dataset:website_dataset'), label: t('dataset:website_dataset'),
description: t('dataset:website_dataset_desc'), description: t('dataset:website_dataset_desc'),
onClick: () => setCreateDatasetType(DatasetTypeEnum.websiteDataset) onClick: () => onSelectDatasetType(DatasetTypeEnum.websiteDataset)
}, },
{ {
icon: 'core/dataset/externalDatasetColor', icon: 'core/dataset/externalDatasetColor',
label: t('dataset:external_file'), label: t('dataset:external_file'),
description: t('dataset:external_file_dataset_desc'), description: t('dataset:external_file_dataset_desc'),
onClick: () => setCreateDatasetType(DatasetTypeEnum.externalFile) onClick: () => onSelectDatasetType(DatasetTypeEnum.externalFile)
} }
] ]
}, },