Skip to content

Commit

Permalink
show antd notification on deployment errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveDarsa committed Oct 13, 2023
1 parent 69aba9d commit 60c718b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/CancelDeployment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const CANCEL_DEPLOYMENT_MUTATION = gql`
`;

export const CancelDeploymentButton = ({ action, success, loading, error, beforeText, afterText }) => {
const [api, contextHolder] = notification.useNotification();
const [api, contextHolder] = notification.useNotification({ maxCount: 1 });

const openNotificationWithIcon = errorMessage => {
api['error']({
Expand Down
28 changes: 18 additions & 10 deletions src/components/DeployLatest/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useState} from 'react';
import React from 'react';
import { Mutation } from 'react-apollo';

import { notification } from 'antd';
import Button from 'components/Button';
import gql from 'graphql-tag';

Expand Down Expand Up @@ -30,6 +31,18 @@ const DeployLatest = ({ pageEnvironment: environment, onDeploy, ...rest }) => {
deploymentsEnabled = false;
}

const [api, contextHolder] = notification.useNotification({ maxCount: 1 });

const openNotificationWithIcon = errorMessage => {
api['error']({
message: 'There was a problem deploying.',
description: errorMessage,
placement: 'top',
duration: 0,
style: { width: '500px' },
});
};

return (
<NewDeployment>
{!deploymentsEnabled && (
Expand Down Expand Up @@ -60,17 +73,12 @@ const DeployLatest = ({ pageEnvironment: environment, onDeploy, ...rest }) => {
}
return (
<React.Fragment>
<Button action={deploy} disabled={loading}>
{loading ? <span className="loader"></span> : "Deploy"}
{contextHolder}
<Button action={deploy} disabled={loading} loading={loading}>
Deploy
</Button>
{success && <div className="deploy_result">Deployment queued.</div>}

{error && (
<div className="deploy_result">
<p>There was a problem deploying.</p>
<p>{error.message}</p>
</div>
)}
{error && openNotificationWithIcon(error.message)}
</React.Fragment>
);
}}
Expand Down

0 comments on commit 60c718b

Please sign in to comment.