mirror of
https://github.com/snowball-tools/snowballtools-base.git
synced 2024-11-17 08:09:20 +00:00
Refactor: DeploymentMenu
uses toast
component (#203)
### TL;DR This PR includes updates to the project settings. ### What changed? The project settings have been refactored for better usability and consistency with other components. ### How to test? To test this change, navigate to the project settings and ensure all options are working as expected. ### Why make this change? This change was made to improve the user experience and maintain consistency across the application. ---
This commit is contained in:
parent
82a1c151a8
commit
003b83ba21
@ -1,5 +1,4 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import toast from 'react-hot-toast';
|
|
||||||
import { Deployment, Domain, Environment, Project } from 'gql-client';
|
import { Deployment, Domain, Environment, Project } from 'gql-client';
|
||||||
import { Button } from 'components/shared/Button';
|
import { Button } from 'components/shared/Button';
|
||||||
import {
|
import {
|
||||||
@ -22,6 +21,7 @@ import AssignDomainDialog from './AssignDomainDialog';
|
|||||||
import { useGQLClient } from 'context/GQLClientContext';
|
import { useGQLClient } from 'context/GQLClientContext';
|
||||||
import { cn } from 'utils/classnames';
|
import { cn } from 'utils/classnames';
|
||||||
import { ChangeStateToProductionDialog } from 'components/projects/Dialog/ChangeStateToProductionDialog';
|
import { ChangeStateToProductionDialog } from 'components/projects/Dialog/ChangeStateToProductionDialog';
|
||||||
|
import { useToast } from 'components/shared/Toast';
|
||||||
|
|
||||||
interface DeploymentMenuProps extends ComponentPropsWithRef<'div'> {
|
interface DeploymentMenuProps extends ComponentPropsWithRef<'div'> {
|
||||||
deployment: Deployment;
|
deployment: Deployment;
|
||||||
@ -41,6 +41,7 @@ export const DeploymentMenu = ({
|
|||||||
...props
|
...props
|
||||||
}: DeploymentMenuProps) => {
|
}: DeploymentMenuProps) => {
|
||||||
const client = useGQLClient();
|
const client = useGQLClient();
|
||||||
|
const { toast, dismiss } = useToast();
|
||||||
|
|
||||||
const [changeToProduction, setChangeToProduction] = useState(false);
|
const [changeToProduction, setChangeToProduction] = useState(false);
|
||||||
const [redeployToProduction, setRedeployToProduction] = useState(false);
|
const [redeployToProduction, setRedeployToProduction] = useState(false);
|
||||||
@ -51,9 +52,19 @@ export const DeploymentMenu = ({
|
|||||||
const isUpdated = await client.updateDeploymentToProd(deployment.id);
|
const isUpdated = await client.updateDeploymentToProd(deployment.id);
|
||||||
if (isUpdated) {
|
if (isUpdated) {
|
||||||
await onUpdate();
|
await onUpdate();
|
||||||
toast.success('Deployment changed to production');
|
toast({
|
||||||
|
id: 'deployment_changed_to_production',
|
||||||
|
title: 'Deployment changed to production',
|
||||||
|
variant: 'success',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error('Unable to change deployment to production');
|
toast({
|
||||||
|
id: 'deployment_not_changed_to_production',
|
||||||
|
title: 'Error changing deployment to production',
|
||||||
|
variant: 'error',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,9 +72,19 @@ export const DeploymentMenu = ({
|
|||||||
const isRedeployed = await client.redeployToProd(deployment.id);
|
const isRedeployed = await client.redeployToProd(deployment.id);
|
||||||
if (isRedeployed) {
|
if (isRedeployed) {
|
||||||
await onUpdate();
|
await onUpdate();
|
||||||
toast.success('Redeployed to production');
|
toast({
|
||||||
|
id: 'redeployed_to_production',
|
||||||
|
title: 'Redeployed to production',
|
||||||
|
variant: 'success',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error('Unable to redeploy to production');
|
toast({
|
||||||
|
id: 'redeployed_to_production_failed',
|
||||||
|
title: 'Error redeploying to production',
|
||||||
|
variant: 'error',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,10 +94,20 @@ export const DeploymentMenu = ({
|
|||||||
deployment.id,
|
deployment.id,
|
||||||
);
|
);
|
||||||
if (isRollbacked) {
|
if (isRollbacked) {
|
||||||
await onUpdate();
|
await onUpdate();
|
||||||
toast.success('Deployment rolled back');
|
toast({
|
||||||
|
id: 'deployment_rolled_back',
|
||||||
|
title: 'Deployment rolled back',
|
||||||
|
variant: 'success',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error('Unable to rollback deployment');
|
toast({
|
||||||
|
id: 'deployment_rollback_failed',
|
||||||
|
title: 'Error rolling back deployment',
|
||||||
|
variant: 'error',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,9 +115,19 @@ export const DeploymentMenu = ({
|
|||||||
const isDeleted = await client.deleteDeployment(deployment.id);
|
const isDeleted = await client.deleteDeployment(deployment.id);
|
||||||
if (isDeleted) {
|
if (isDeleted) {
|
||||||
await onUpdate();
|
await onUpdate();
|
||||||
toast.success('Deleted deployment');
|
toast({
|
||||||
|
id: 'deployment_deleted',
|
||||||
|
title: 'Deployment deleted',
|
||||||
|
variant: 'success',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error('Unable to delete deployment');
|
toast({
|
||||||
|
id: 'deployment_not_deleted',
|
||||||
|
title: 'Error deleting deployment',
|
||||||
|
variant: 'error',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user