mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
organization scope in apps
This commit is contained in:
parent
6cdde65b80
commit
aee893fc98
2 changed files with 11 additions and 4 deletions
|
|
@ -50,7 +50,7 @@ export function viewableAppsQueryUsingPermissions(
|
|||
.createQueryBuilder(AppBase, 'viewable_apps')
|
||||
.innerJoin('viewable_apps.user', 'user')
|
||||
.addSelect(['user.firstName', 'user.lastName'])
|
||||
.where('viewable_apps.organization_id = :organizationId', { organizationId: user.organizationId });
|
||||
.where('viewable_apps.organizationId = :organizationId', { organizationId: user.organizationId });
|
||||
|
||||
if (searchKey) {
|
||||
viewableAppsQb.andWhere('LOWER(viewable_apps.name) like :searchKey', {
|
||||
|
|
@ -64,14 +64,14 @@ export function viewableAppsQueryUsingPermissions(
|
|||
const { isAllEditable, isAllViewable, hideAll } = userAppPermissions;
|
||||
if (isAllEditable) return viewableAppsQb;
|
||||
if ((isAllViewable && hideAll) || (!isAllViewable && !hideAll) || (!isAllViewable && hideAll)) {
|
||||
viewableAppsQb.where('viewable_apps.id IN (:...viewableApps)', {
|
||||
viewableAppsQb.andWhere('viewable_apps.id IN (:...viewableApps)', {
|
||||
viewableApps,
|
||||
});
|
||||
return viewableAppsQb;
|
||||
}
|
||||
const hiddenApps = userAppPermissions.hiddenAppsId.filter((id) => !userAppPermissions.editableAppsId.includes(id));
|
||||
if (!userAppPermissions.hideAll && isAllViewable && hiddenApps.length > 0) {
|
||||
viewableAppsQb.where('viewable_apps.id NOT IN (:...hiddenApps)', {
|
||||
viewableAppsQb.andWhere('viewable_apps.id NOT IN (:...hiddenApps)', {
|
||||
hiddenApps,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,13 +191,20 @@ export class AppsService {
|
|||
resources: [{ resource: TOOLJET_RESOURCE.APP }],
|
||||
organizationId: user.organizationId,
|
||||
});
|
||||
console.log(userPermission);
|
||||
|
||||
return await dbTransactionWrap(async (manager: EntityManager) => {
|
||||
return await viewableAppsQueryUsingPermissions(
|
||||
const apps = await viewableAppsQueryUsingPermissions(
|
||||
user,
|
||||
userPermission[TOOLJET_RESOURCE.APP],
|
||||
manager,
|
||||
searchKey
|
||||
).getCount();
|
||||
|
||||
console.log('Apps are to show');
|
||||
console.log(apps);
|
||||
|
||||
return apps;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue