Skip to content

Commit

Permalink
fix multi stage rejections (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Wilson authored Aug 11, 2023
1 parent 87c52f9 commit 8919487
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/pages/build/build.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,26 @@ export default function Build({ user, userIsAdminOrHasWritePerm }) {
}, [data, namespace, name, build, mutate, showError]);

const handleDeclineClick = useCallback(async () => {
const stageCount = data?.stages?.length || 1;
const apiRequests = [];

for (let i = 0; i < stageCount; i++) {
const { number } = data.stages[i];
apiRequests.push(
axiosWrapper(`/api/repos/${namespace}/${name}/builds/${build}/decline/${number}`, {
method: 'POST',
}),
);
}
try {
await axiosWrapper(`/api/repos/${namespace}/${name}/builds/${build}/decline/${stage}`, {
method: 'POST',
});
await Promise.all(apiRequests);
await mutate();
} catch (e) {
showError(`Unable to decline build: ${e.message}`);
// eslint-disable-next-line
console.warn(e.message);
}
}, [namespace, name, build, stage, mutate, showError]);
}, [data, namespace, name, build, mutate, showError]);

const handleMenuItemSelect = useCallback((value) => {
switch (value) {
Expand Down

0 comments on commit 8919487

Please sign in to comment.