Skip to content

Commit 7eced3b

Browse files
committed
Fixed: if a nested folder has edit rights for processes all processes in the parent folders appear to be editable even though the changes are not commited
Processes are now only shown in the editor list if the user has edit rights in the specific folder.
1 parent 607b7f8 commit 7eced3b

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

  • src/management-system-v2/app/(dashboard)/[environmentId]/processes/[mode]

src/management-system-v2/app/(dashboard)/[environmentId]/processes/[mode]/[processId]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const ProcessComponent = async (props: ProcessComponentProps) => {
7070
// return acc;
7171
// }, {} as UserType);
7272

73-
if (!ability.can('view', toCaslResource('Process', process))) {
73+
if (!ability.can(props.isListView ? 'view' : 'manage', toCaslResource('Process', process))) {
7474
throw new UnauthorizedError();
7575
}
7676

src/management-system-v2/app/(dashboard)/[environmentId]/processes/[mode]/folder/[folderId]/page.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import EllipsisBreadcrumb from '@/components/ellipsis-breadcrumb';
1616
import { ComponentProps } from 'react';
1717
import { spaceURL } from '@/lib/utils';
1818
import { getFolderById, getRootFolder, getFolderContents } from '@/lib/data/db/folders';
19+
import { toCaslResource } from '@/lib/ability/caslAbility';
1920
export type ListItem = ProcessMetadata | (Folder & { type: 'folder' });
2021

2122
const ProcessesPage = async (props: {
@@ -39,9 +40,12 @@ const ProcessesPage = async (props: {
3940

4041
const folderContentsFiltered = isListView
4142
? folderContents.filter(
42-
(folderContent) => folderContent.type === 'folder' || folderContent.versions.length > 0,
43-
)
44-
: folderContents;
43+
(folderContent) => folderContent.type === 'folder' || folderContent.versions.length > 0,
44+
)
45+
: folderContents.filter(
46+
(entry) =>
47+
entry.type === 'folder' || ability.can('update', toCaslResource('Process', entry)),
48+
);
4549

4650
const hasNoReleasedProcesses = isListView
4751
? folderContentsFiltered.every((item) => item.type === 'folder')

0 commit comments

Comments
 (0)