Skip to content

Commit 05aab68

Browse files
authored
Disable approve/merge/close buttons for merged Proposed Changes (#4633)
1 parent cffafd3 commit 05aab68

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

changelog/3495.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Disable approve/merge/close buttons for merged Proposed Changes

frontend/app/src/screens/proposed-changes/action-button/pc-approve-button.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ import { useAtomValue } from "jotai/index";
1212
import React, { useState } from "react";
1313
import { toast } from "react-toastify";
1414

15-
interface PcMergeButtonProps extends ButtonProps {
15+
interface PcApproveButtonProps extends ButtonProps {
1616
proposedChangeId: string;
1717
approvers: Array<any>;
18+
state: "closed" | "open" | "merged";
1819
}
1920

2021
export const PcApproveButton = ({
2122
approvers = [],
2223
proposedChangeId,
24+
state,
2325
...props
24-
}: PcMergeButtonProps) => {
26+
}: PcApproveButtonProps) => {
2527
const branch = useAtomValue(currentBranchAtom);
2628
const date = useAtomValue(datetimeAtom);
2729
const auth = useAuth();
@@ -81,7 +83,13 @@ export const PcApproveButton = ({
8183
variant="outline"
8284
onClick={handleApprove}
8385
isLoading={isLoadingApprove}
84-
disabled={!auth?.permissions?.write || !approverId || !canApprove}
86+
disabled={
87+
!auth?.permissions?.write ||
88+
!approverId ||
89+
!canApprove ||
90+
state === "closed" ||
91+
state === "merged"
92+
}
8593
{...props}
8694
>
8795
Approve

frontend/app/src/screens/proposed-changes/proposed-change-details.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ export const ProposedChangeDetails = ({ className, ...props }: HTMLAttributes<HT
9494
name: "Actions",
9595
value: (
9696
<div className="flex flex-wrap gap-2">
97-
<PcApproveButton approvers={approvers} proposedChangeId={proposedChangeId!} />
97+
<PcApproveButton
98+
approvers={approvers}
99+
proposedChangeId={proposedChangeId!}
100+
state={state}
101+
/>
98102
<PcMergeButton
99103
proposedChangeId={proposedChangeId!}
100104
state={state}

frontend/app/tests/e2e/proposed-changes/proposed-changes.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ test.describe("/proposed-changes", () => {
135135
});
136136

137137
await test.step("not able to edit proposed change", async () => {
138+
await expect(page.getByRole("button", { name: "Approve" })).toBeDisabled();
138139
await expect(page.getByRole("button", { name: "Merge" })).toBeDisabled();
140+
await expect(page.getByRole("button", { name: "Close" })).toBeDisabled();
139141
await expect(page.getByTestId("edit-button")).toBeDisabled();
140142
});
141143
});

0 commit comments

Comments
 (0)