Commit c44a1a73 by Finley Ge Committed by GitHub

fix: update private list permission count (#7143)

parent f1f59cc3
......@@ -184,21 +184,23 @@ async function handler(req: ApiRequestProps<ListAppBodyType>): Promise<ListAppRe
});
};
const getClbCount = (appId: string) => {
return roleList.filter((item) => String(item.resourceId) === String(appId)).length;
};
// Inherit app, check parent folder clb and it's own clb
if (!AppFolderTypeList.includes(app.type) && app.parentId && app.inheritPermission) {
return {
Per: getPer(String(app.parentId)).addRole(getPer(String(app._id)).role),
privateApp: getClbCount(String(app.parentId)) <= 1
privateApp:
roleList.filter(
(item) =>
String(item.resourceId) === String(app._id) ||
String(item.resourceId) === String(app.parentId)
).length <= 1
};
}
return {
Per: getPer(String(app._id)),
privateApp: getClbCount(String(app._id)) <= 1
privateApp:
roleList.filter((item) => String(item.resourceId) === String(app._id)).length <= 1
};
})();
......
......@@ -147,10 +147,6 @@ async function handler(req: ApiRequestProps): Promise<GetDatasetListResponse> {
isOwner: String(dataset.tmbId) === String(tmbId) || teamPer.isOwner
});
};
const getClbCount = (datasetId: string) => {
return roleList.filter((item) => String(item.resourceId) === String(datasetId)).length;
};
// inherit
if (
dataset.inheritPermission &&
......@@ -159,12 +155,18 @@ async function handler(req: ApiRequestProps): Promise<GetDatasetListResponse> {
) {
return {
Per: getPer(String(dataset.parentId)).addRole(getPer(String(dataset._id)).role),
privateDataset: getClbCount(String(dataset.parentId)) <= 1
privateDataset:
roleList.filter(
(item) =>
String(item.resourceId) === String(dataset._id) ||
String(item.resourceId) === String(dataset.parentId)
).length <= 1
};
}
return {
Per: getPer(String(dataset._id)),
privateDataset: getClbCount(String(dataset._id)) <= 1
privateDataset:
roleList.filter((item) => String(item.resourceId) === String(dataset._id)).length <= 1
};
})();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment