Skip to content

Commit a012c36

Browse files
authored
Handle proposed change action errors (#7035)
* handle errors * remove unwanted file * accessibility
1 parent 4932c25 commit a012c36

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ export const ApproveButton = ({ setOpen }: ProposedChangeActionButtonProps) => {
3333
/>
3434
);
3535
},
36+
onError: () => {
37+
toast(
38+
<Alert
39+
type={ALERT_TYPES.ERROR}
40+
message={
41+
hasApproved
42+
? "An error occurred while canceling the approval"
43+
: "An error occurred while approving"
44+
}
45+
/>
46+
);
47+
},
3648
});
3749

3850
const handleAction = (event: React.MouseEvent<HTMLButtonElement>) => {
@@ -72,6 +84,8 @@ export const ApproveButton = ({ setOpen }: ProposedChangeActionButtonProps) => {
7284
}}
7385
disabled={isPending}
7486
data-testid="proposed-change-action-button-select"
87+
aria-label="More actions"
88+
type="button"
7589
>
7690
<Icon icon="mdi:unfold-more-horizontal" />
7791
</Button>

frontend/app/src/entities/proposed-changes/ui/action-button/pc-close-button.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export const CloseButton = ({ setOpen }: ProposedChangeActionButtonProps) => {
2424
});
2525
toast(<Alert type={ALERT_TYPES.SUCCESS} message={"Proposed change closed!"} />);
2626
},
27+
onError: () => {
28+
toast(
29+
<Alert
30+
type={ALERT_TYPES.ERROR}
31+
message={"An error occurred while closing the propsoed change"}
32+
/>
33+
);
34+
},
2735
});
2836

2937
const handleAction = (event: React.MouseEvent<HTMLButtonElement>) => {
@@ -66,6 +74,8 @@ export const CloseButton = ({ setOpen }: ProposedChangeActionButtonProps) => {
6674
}}
6775
disabled={isPending}
6876
data-testid="proposed-change-action-button-select"
77+
aria-label="More actions"
78+
type="button"
6979
>
7080
<Icon icon="mdi:unfold-more-horizontal" />
7181
</Button>

frontend/app/src/entities/proposed-changes/ui/action-button/pc-draft-button.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ export const DraftButton = ({ setOpen }: ProposedChangeActionButtonProps) => {
3030
/>
3131
);
3232
},
33+
onError: () => {
34+
toast(
35+
<Alert
36+
type={ALERT_TYPES.ERROR}
37+
message={
38+
isDraft
39+
? "An error occurred while removing draft status"
40+
: "An error occurred while moving to draft"
41+
}
42+
/>
43+
);
44+
},
3345
});
3446

3547
const handleAction = (event: React.MouseEvent<HTMLButtonElement>) => {
@@ -74,6 +86,8 @@ export const DraftButton = ({ setOpen }: ProposedChangeActionButtonProps) => {
7486
}}
7587
disabled={isPending}
7688
data-testid="proposed-change-action-button-select"
89+
aria-label="More actions"
90+
type="button"
7791
>
7892
<Icon icon="mdi:unfold-more-horizontal" />
7993
</Button>

frontend/app/src/entities/proposed-changes/ui/action-button/pc-merge-button.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export const MergeButton = ({ setOpen }: ProposedChangeActionButtonProps) => {
2424
});
2525
toast(<Alert type={ALERT_TYPES.SUCCESS} message={"Proposed change merged!"} />);
2626
},
27+
onError: () => {
28+
toast(
29+
<Alert
30+
type={ALERT_TYPES.ERROR}
31+
message={"An error occurred while merging proposed change"}
32+
/>
33+
);
34+
},
2735
});
2836

2937
const handleAction = (event: React.MouseEvent<HTMLButtonElement>) => {
@@ -66,6 +74,8 @@ export const MergeButton = ({ setOpen }: ProposedChangeActionButtonProps) => {
6674
}}
6775
disabled={isPending}
6876
data-testid="proposed-change-action-button-select"
77+
aria-label="More actions"
78+
type="button"
6979
>
7080
<Icon icon="mdi:unfold-more-horizontal" />
7181
</Button>

frontend/app/src/entities/proposed-changes/ui/action-button/pc-reject-button.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ export const RejectButton = ({ setOpen }: ProposedChangeActionButtonProps) => {
3232
/>
3333
);
3434
},
35+
onError: () => {
36+
toast(
37+
<Alert
38+
type={ALERT_TYPES.ERROR}
39+
message={
40+
hasRejected
41+
? "An error occurred while canceling the rejection"
42+
: "An error occurred while rejecting proposed change"
43+
}
44+
/>
45+
);
46+
},
3547
});
3648

3749
const handleAction = (event: React.MouseEvent<HTMLButtonElement>) => {
@@ -71,6 +83,8 @@ export const RejectButton = ({ setOpen }: ProposedChangeActionButtonProps) => {
7183
}}
7284
disabled={isPending}
7385
data-testid="proposed-change-action-button-select"
86+
aria-label="More actions"
87+
type="button"
7488
>
7589
<Icon icon="mdi:unfold-more-horizontal" />
7690
</Button>

0 commit comments

Comments
 (0)