diff --git a/packages/frontend/src/components/projects/Dialog/ChangeStateToProductionDialog.tsx b/packages/frontend/src/components/projects/Dialog/ChangeStateToProductionDialog.tsx new file mode 100644 index 0000000..cf7f1ef --- /dev/null +++ b/packages/frontend/src/components/projects/Dialog/ChangeStateToProductionDialog.tsx @@ -0,0 +1,90 @@ +import ConfirmDialog, { + ConfirmDialogProps, +} from 'components/shared/ConfirmDialog'; +import { Deployment, Domain } from 'gql-client'; +import React from 'react'; +import DeploymentDialogBodyCard from 'components/projects/project/deployments/DeploymentDialogBodyCard'; +import { Button } from 'components/shared/Button'; +import { + ChevronDoubleDownIcon, + LinkChainIcon, +} from 'components/shared/CustomIcon'; +import { TagProps } from 'components/shared/Tag'; + +interface ChangeStateToProductionDialogProps extends ConfirmDialogProps { + deployment: Deployment; + newDeployment?: Deployment; + domains: Domain[]; +} + +export const ChangeStateToProductionDialog = ({ + deployment, + newDeployment, + domains, + open, + handleCancel, + handleConfirm, + ...props +}: ChangeStateToProductionDialogProps) => { + const currentChip = { + value: 'Live Deployment', + type: 'positive' as TagProps['type'], + }; + const newChip = { + value: 'New Deployment', + type: 'attention' as TagProps['type'], + }; + + return ( + +
+
+

+ Upon confirmation, this deployment will be changed to production. +

+ + {newDeployment && ( + <> +
+ {Array.from({ length: 7 }).map((_, index) => ( + + ))} +
+ + + )} +
+
+

+ The new deployment will be associated with these domains: +

+ {domains.length > 0 && + domains.map((value) => { + return ( + + ); + })} +
+
+
+ ); +}; diff --git a/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx b/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx index f4eb980..516b468 100644 --- a/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx +++ b/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx @@ -17,12 +17,10 @@ import { MenuList, } from '@material-tailwind/react'; import { ComponentPropsWithRef } from 'react'; -import ConfirmDialog from '../../../shared/ConfirmDialog'; import AssignDomainDialog from './AssignDomainDialog'; -import DeploymentDialogBodyCard from './DeploymentDialogBodyCard'; -import { Typography } from '@material-tailwind/react'; -import { useGQLClient } from '../../../../context/GQLClientContext'; +import { useGQLClient } from 'context/GQLClientContext'; import { cn } from 'utils/classnames'; +import { ChangeStateToProductionDialog } from 'components/projects/Dialog/ChangeStateToProductionDialog'; interface DeploymentMenuProps extends ComponentPropsWithRef<'div'> { deployment: Deployment; @@ -158,106 +156,44 @@ export const DeploymentMenu = ({ {/* Dialogs */} - setChangeToProduction((preVal) => !preVal)} - open={changeToProduction} confirmButtonTitle="Change" - color="blue" + handleCancel={() => setChangeToProduction((preVal) => !preVal)} + open={changeToProduction} handleConfirm={async () => { await updateDeployment(); setChangeToProduction((preVal) => !preVal); }} - > -
- - Upon confirmation, this deployment will be changed to production. - - - - The new deployment will be associated with these domains: - - {prodBranchDomains.length > 0 && - prodBranchDomains.map((value) => { - return ( - - ^ {value.name} - - ); - })} -
-
- + setRedeployToProduction((preVal) => !preVal)} + handleCancel={() => setRedeployToProduction((preVal) => !preVal)} open={redeployToProduction} confirmButtonTitle="Redeploy" - color="blue" handleConfirm={async () => { await redeployToProd(); setRedeployToProduction((preVal) => !preVal); }} - > -
- - Upon confirmation, new deployment will be created with the same - source code as current deployment. - - - - These domains will point to your new deployment: - - {deployment.domain?.name && ( - - {deployment.domain?.name} - - )} -
-
+ deployment={deployment} + domains={deployment.domain ? [deployment.domain] : []} + /> {Boolean(currentDeployment) && ( - setRollbackDeployment((preVal) => !preVal)} + handleCancel={() => setRollbackDeployment((preVal) => !preVal)} open={rollbackDeployment} confirmButtonTitle="Rollback" - color="blue" handleConfirm={async () => { await rollbackDeploymentHandler(); setRollbackDeployment((preVal) => !preVal); }} - > -
- - Upon confirmation, this deployment will replace your current - deployment - - - - - These domains will point to your new deployment: - - - ^ {currentDeployment.domain?.name} - -
-
+ deployment={currentDeployment} + newDeployment={deployment} + domains={currentDeployment.domain ? [currentDeployment.domain] : []} + /> )}