Skip to content

Commit

Permalink
perf: app list permission (#3023)
Browse files Browse the repository at this point in the history
* perf: app list permission

* perf: create dataset tip
  • Loading branch information
c121914yu authored Oct 30, 2024
1 parent 9f4aa31 commit 97216ee
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/web/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/web/i18n/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "放大",
Expand Down
10 changes: 6 additions & 4 deletions projects/app/src/pages/api/core/app/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,29 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
}).lean()
]);

// Filter apps by permission
const filterApps = myApps
.map((app) => {
const { Per, privateApp } = (() => {
const myPerList = perList.filter(
(item) =>
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({
Expand Down
8 changes: 4 additions & 4 deletions projects/app/src/pages/api/core/dataset/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
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({
Expand Down
6 changes: 3 additions & 3 deletions projects/app/src/pages/dataset/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
]
},
Expand Down

0 comments on commit 97216ee

Please sign in to comment.