From c6ea3a8f53a44988f6786e228dce1046a7dc65e6 Mon Sep 17 00:00:00 2001 From: Wahyu Kurniawan Date: Fri, 8 Mar 2024 09:58:26 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20style:=20adjust=20responsive=20f?= =?UTF-8?q?or=20deployment=20details=20card?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../deployments/DeploymentDetailsCard.tsx | 175 ++++++++++-------- 1 file changed, 102 insertions(+), 73 deletions(-) diff --git a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx index c4940bac..3c964344 100644 --- a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx +++ b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useCallback } from 'react'; import { Deployment, DeploymentStatus, @@ -60,85 +60,114 @@ const DeploymentDetailsCard = ({ } }; - return ( -
-
- {/* DEPLOYMENT URL */} - {deployment.url && ( - - - {deployment.url} - - - )} - - {deployment.environment === Environment.Production - ? `Production ${deployment.isCurrent ? '(Current)' : ''}` - : 'Preview'} - -
- - {/* DEPLOYMENT STATUS */} -
- - {deployment.status} - -
- - {/* DEPLOYMENT COMMIT DETAILS */} -
- - - {deployment.branch} - - - - - {deployment.commitHash.substring(0, SHORT_COMMIT_HASH_LENGTH)}{' '} - {deployment.commitMessage} - - -
- - {/* DEPLOYMENT INFOs */} -
-
- - - {relativeTimeMs(deployment.createdAt)} - -
- -
- - - {formatAddress(deployment.createdBy.name ?? '')} - -
+ const renderDeploymentMenu = useCallback( + (className?: string) => { + return ( + ); + }, + [deployment, currentDeployment, onUpdate, project, prodBranchDomains], + ); + + const renderDeploymentStatus = useCallback( + (className?: string) => { + return ( +
+ + {deployment.status} + +
+ ); + }, + [deployment.status, deployment.commitHash], + ); + + return ( +
+
+
+ {/* DEPLOYMENT URL */} + {deployment.url && ( + + + {deployment.url} + + + )} + + {deployment.environment === Environment.Production + ? `Production ${deployment.isCurrent ? '(Current)' : ''}` + : 'Preview'} + +
+ {/* MENU ON MOBILE */} + {renderDeploymentMenu('flex md:hidden ml-auto')} +
+ + {/* DEPLOYMENT STATUS */} + {renderDeploymentStatus('w-[10%] max-w-[110px] hidden md:flex h-fit')} + + {/* DEPLOYMENT COMMIT DETAILS */} +
+
+ + + + {deployment.branch} + + + + + + {deployment.commitHash.substring(0, SHORT_COMMIT_HASH_LENGTH)}{' '} + {deployment.commitMessage} + + +
+ {renderDeploymentStatus('flex md:hidden h-fit')} +
+ + {/* DEPLOYMENT INFOs */} +
+
+
+ + + {relativeTimeMs(deployment.createdAt)} + +
+
+
+ +
+ + {formatAddress(deployment.createdBy.name ?? '')} + +
+
+ {renderDeploymentMenu('ml-auto hidden md:flex')}
);