Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show antd notification on deployment errors #178

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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