Viewable apps query modiifcation

This commit is contained in:
kriks7iitk 2024-07-12 11:52:12 +05:30
parent befa600644
commit b8316730fe
3 changed files with 9 additions and 11 deletions

View file

@ -41,7 +41,7 @@ function AppPermissionsActions({
/>
<div>
<span className="form-check-label text-muted">View</span>
<span className="text-muted tj-text-xsm">Only view deployed version of app</span>
<span className="text-muted tj-text-xsm">Only access released version of apps</span>
</div>
</label>
<label className="form-check form-check-inline">

View file

@ -102,7 +102,7 @@ function AppResourcePermissions({
<span className="form-check-label" data-cy="app-delete-label">
{'View'}
</span>
<span class={`tj-text-xxsm`}>Only view released version of app</span>
<span class={`tj-text-xxsm`}>Only access released version of apps</span>
</label>
<label className="form-check form-check-inline">
<input

View file

@ -31,19 +31,17 @@ export function viewableAppsQueryUsingPermissions(
searchKey?: string,
select?: Array<string>
): SelectQueryBuilder<AppBase> {
let viewableApps = userAppPermissions.hideAll
? [null]
const viewableApps = userAppPermissions.hideAll
? [...userAppPermissions.editableAppsId]
: [
null,
...Array.from(
new Set(
[...userAppPermissions.editableAppsId, ...userAppPermissions.viewableAppsId].filter(
(id) => !userAppPermissions.hiddenAppsId.includes(id)
)
)
new Set([
...userAppPermissions.editableAppsId,
...userAppPermissions.viewableAppsId.filter((id) => !userAppPermissions.hiddenAppsId.includes(id)),
])
),
];
viewableApps = viewableApps.filter((id) => !userAppPermissions.hiddenAppsId.includes(id));
const viewableAppsQb = manager
.createQueryBuilder(AppBase, 'viewable_apps')
.innerJoin('viewable_apps.user', 'user')
@ -59,7 +57,7 @@ export function viewableAppsQueryUsingPermissions(
viewableApps,
});
}
const hiddenApps = userAppPermissions.hiddenAppsId;
const hiddenApps = userAppPermissions.hiddenAppsId.filter((id) => !userAppPermissions.editableAppsId.includes(id));
if (!userAppPermissions.hideAll && viewAll && hiddenApps.length > 0) {
viewableAppsQb.where('viewable_apps.id NOT IN (:...hiddenApps)', {
hiddenApps,