Skip to content
Permalink
Browse files
fix: promote mechanic
  • Loading branch information
bolotskydev committed Mar 25, 2021
1 parent b809bd3 commit 7192bbcaa22a07260ed6477444eb85224f56517e
Showing 1 changed file with 9 additions and 2 deletions.
@@ -61,14 +61,21 @@ export default function Build({ userIsAdminOrHasWritePerm }) {
const handleViewModeClick = (mode) => () => setIsGraphView(mode === 'graph');

const handleDeploySubmit = useCallback(async ({ action, target, parameters }) => {
const queryParams = { target: target || 'production', ...parameters };
const queryParams = parameters
.map(({ key, value }) => ({ key, value }))
.reduce((acc, { key, value }) => ({ ...acc, [key]: value }), {});
queryParams.target = target || 'production';
const encode = encodeURIComponent;
const queryString = Object.entries(queryParams).map(([key, value]) => `${encode(key)}=${encode(value)}`).join('&');
try {
const res = await axiosWrapper(`${instance}/api/repos/${namespace}/${name}/builds/${build}/${action}?${queryString}`, {
method: 'POST',
});
history.push(`/${namespace}/${name}/${res.build.number}`);
if (res) {
history.push(`/${namespace}/${name}/${res.number}`);
} else {
showError('Unable to create new deploy in this repo');
}
} catch (e) {
showError(`Unable to create new deploy: ${e.message}`);
// eslint-disable-next-line

0 comments on commit 7192bbc

Please sign in to comment.