Skip to content

Commit

Permalink
fix multi stage approvals (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Wilson authored Aug 10, 2023
1 parent 4616df6 commit 7a768d5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/pages/build/build.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,27 @@ export default function Build({ user, userIsAdminOrHasWritePerm }) {
}, [name, namespace, build, history, showError]);

const handleApproveClick = 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}/approve/${number}`, {
method: 'POST',
}),
);
}

try {
await axiosWrapper(`/api/repos/${namespace}/${name}/builds/${build}/approve/${stage}`, {
method: 'POST',
});
await Promise.all(apiRequests);
await mutate();
} catch (e) {
showError(`Unable to approve build: ${e.message}`);
// eslint-disable-next-line
console.warn(e.message);
}
}, [namespace, name, build, stage, mutate, showError]);
}, [data, namespace, name, build, mutate, showError]);

const handleDeclineClick = useCallback(async () => {
try {
Expand Down

0 comments on commit 7a768d5

Please sign in to comment.