Skip to content

Commit 548c570

Browse files
committed
fix(delete-project): ensure user is creator of project
1 parent 879f55f commit 548c570

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

features/ProjectStats/ProjectActions/ProjectActions.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ import { DeleteProjectButton } from "./DeleteProjectButton";
1010

1111
export interface ProjectActionsProps {
1212
projectId: NonNullable<ProjectId>;
13+
isCreator: boolean;
1314
isAdministrator: boolean;
1415
isEditor: boolean;
1516
}
1617

1718
/**
1819
* Table cell with edit and delete actions for provided project product.
1920
*/
20-
export const ProjectActions = ({ projectId, isAdministrator, isEditor }: ProjectActionsProps) => {
21+
export const ProjectActions = ({
22+
projectId,
23+
isCreator,
24+
isAdministrator,
25+
isEditor,
26+
}: ProjectActionsProps) => {
2127
const { data: project, isLoading } = useGetProject(projectId);
2228

2329
if (isLoading) {
@@ -28,7 +34,7 @@ export const ProjectActions = ({ projectId, isAdministrator, isEditor }: Project
2834
<Box display="flex">
2935
<OpenProjectButton projectId={projectId} />
3036
{(isEditor || isAdministrator) && <EditProjectButton project={project} />}
31-
{(isEditor || isAdministrator) && <DeleteProjectButton project={project} />}
37+
{isCreator && <DeleteProjectButton project={project} />}
3238
{(isEditor || isAdministrator) && <ChargesLinkIconButton productId={project.product_id} />}
3339
</Box>
3440
) : null;

features/ProjectStats/ProjectStatsSection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export const ProjectStatsSection = ({ userFilter }: ProjectStatsSectionProps) =>
113113
cell: ({ row }) => (
114114
<ProjectActions
115115
isAdministrator={!!user.username && row.original.administrators.includes(user.username)}
116+
isCreator={!!user.username && row.original.creator === user.username}
116117
isEditor={!!user.username && row.original.editors.includes(user.username)}
117118
projectId={row.original.project_id}
118119
/>

0 commit comments

Comments
 (0)