From 97216eec597e9f7f55ffc136ffcc52ab0cc84c00 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Wed, 30 Oct 2024 12:38:16 +0800 Subject: [PATCH] perf: app list permission (#3023) * perf: app list permission * perf: create dataset tip --- packages/web/i18n/en/common.json | 2 +- packages/web/i18n/zh/common.json | 2 +- projects/app/src/pages/api/core/app/list.ts | 10 ++++++---- projects/app/src/pages/api/core/dataset/list.ts | 8 ++++---- projects/app/src/pages/dataset/list/index.tsx | 6 +++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/web/i18n/en/common.json b/packages/web/i18n/en/common.json index 9adb2e1e6..6b387c3ce 100644 --- a/packages/web/i18n/en/common.json +++ b/packages/web/i18n/en/common.json @@ -227,7 +227,7 @@ "common.submit_success": "Submitted Successfully", "common.submitted": "Submitted", "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.Use Helper": "Use Helper", "common.ui.textarea.Magnifying": "Magnifying", diff --git a/packages/web/i18n/zh/common.json b/packages/web/i18n/zh/common.json index 539a45429..970979880 100644 --- a/packages/web/i18n/zh/common.json +++ b/packages/web/i18n/zh/common.json @@ -234,7 +234,7 @@ "common.submit_success": "提交成功", "common.submitted": "已提交", "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.Use Helper": "使用帮助", "common.ui.textarea.Magnifying": "放大", diff --git a/projects/app/src/pages/api/core/app/list.ts b/projects/app/src/pages/api/core/app/list.ts index 20c1328ce..0a6e820b3 100644 --- a/projects/app/src/pages/api/core/app/list.ts +++ b/projects/app/src/pages/api/core/app/list.ts @@ -117,6 +117,7 @@ async function handler(req: ApiRequestProps): Promise { const { Per, privateApp } = (() => { @@ -124,20 +125,21 @@ async function handler(req: ApiRequestProps): Promise String(item.tmbId) === String(tmbId) || myGroupIds.includes(String(item.groupId)) ); - const getPer = (id: string) => { + const getPer = (appId: string) => { const tmbPer = myPerList.find( - (item) => String(item.resourceId) === id && !!item.tmbId + (item) => String(item.resourceId) === appId && !!item.tmbId )?.permission; const groupPer = getGroupPer( myPerList .filter( (item) => - String(item.resourceId) === id && myGroupIds.includes(String(item.groupId)) + String(item.resourceId) === appId && myGroupIds.includes(String(item.groupId)) ) .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 { Per: new AppPermission({ diff --git a/projects/app/src/pages/api/core/dataset/list.ts b/projects/app/src/pages/api/core/dataset/list.ts index 40aaba81b..cf26169bc 100644 --- a/projects/app/src/pages/api/core/dataset/list.ts +++ b/projects/app/src/pages/api/core/dataset/list.ts @@ -108,20 +108,20 @@ async function handler(req: ApiRequestProps) { String(item.tmbId) === String(tmbId) || myGroupIds.includes(String(item.groupId)) ); - const getPer = (id: string) => { + const getPer = (datasetId: string) => { const tmbPer = myPerList.find( - (item) => String(item.resourceId) === id && !!item.tmbId + (item) => String(item.resourceId) === datasetId && !!item.tmbId )?.permission; const groupPer = getGroupPer( myPerList .filter( (item) => - String(item.resourceId) === id && myGroupIds.includes(String(item.groupId)) + String(item.resourceId) === datasetId && myGroupIds.includes(String(item.groupId)) ) .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 { Per: new DatasetPermission({ diff --git a/projects/app/src/pages/dataset/list/index.tsx b/projects/app/src/pages/dataset/list/index.tsx index 1658dda82..21efbf034 100644 --- a/projects/app/src/pages/dataset/list/index.tsx +++ b/projects/app/src/pages/dataset/list/index.tsx @@ -157,19 +157,19 @@ const Dataset = () => { icon: 'core/dataset/commonDatasetColor', label: t('dataset:common_dataset'), description: t('dataset:common_dataset_desc'), - onClick: () => setCreateDatasetType(DatasetTypeEnum.dataset) + onClick: () => onSelectDatasetType(DatasetTypeEnum.dataset) }, { icon: 'core/dataset/websiteDatasetColor', label: t('dataset:website_dataset'), description: t('dataset:website_dataset_desc'), - onClick: () => setCreateDatasetType(DatasetTypeEnum.websiteDataset) + onClick: () => onSelectDatasetType(DatasetTypeEnum.websiteDataset) }, { icon: 'core/dataset/externalDatasetColor', label: t('dataset:external_file'), description: t('dataset:external_file_dataset_desc'), - onClick: () => setCreateDatasetType(DatasetTypeEnum.externalFile) + onClick: () => onSelectDatasetType(DatasetTypeEnum.externalFile) } ] },