From 6b17dce2ae48b84185b3f161a09432a27637da7c Mon Sep 17 00:00:00 2001 From: Nabarun Gogoi Date: Thu, 22 Feb 2024 11:25:17 +0530 Subject: [PATCH] UI fixes in Snowball frontend app (#93) * Fix alignment of deployment status chip * Use template name from env * Use env for git template link * Add loading spinner for create project * Display user name * Format the displayed user name --------- Co-authored-by: neeraj --- packages/backend/test/fixtures/users.json | 6 +-- .../projects/create/ProjectRepoCard.tsx | 23 +++++++++--- .../deployments/DeploymentDetailsCard.tsx | 20 +++++----- .../project/deployments/FilterForm.tsx | 8 ++-- packages/frontend/src/constants.ts | 3 +- .../frontend/src/layouts/ProjectSearch.tsx | 37 +++++++++++++++++-- .../org-slug/projects/create/Template.tsx | 2 +- .../projects/create/template/index.tsx | 25 ++++++++++--- 8 files changed, 90 insertions(+), 34 deletions(-) diff --git a/packages/backend/test/fixtures/users.json b/packages/backend/test/fixtures/users.json index 118beba5..37d26909 100644 --- a/packages/backend/test/fixtures/users.json +++ b/packages/backend/test/fixtures/users.json @@ -1,19 +1,19 @@ [ { "id": "59f4355d-9549-4aac-9b54-eeefceeabef0", - "name": "Snowball", + "name": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "email": "snowball@snowballtools.xyz", "isVerified": true }, { "id": "e505b212-8da6-48b2-9614-098225dab34b", - "name": "Alice Anderson", + "name": "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8", "email": "alice@snowballtools.xyz", "isVerified": true }, { "id": "cd892fad-9138-4aa2-a62c-414a32776ea7", - "name": "Bob Banner", + "name": "0x8315177ab297ba92a06054ce80a67ed4dbd7ed3a", "email": "bob@snowballtools.xyz", "isVerified": true } diff --git a/packages/frontend/src/components/projects/create/ProjectRepoCard.tsx b/packages/frontend/src/components/projects/create/ProjectRepoCard.tsx index 77099d0a..59a9d57d 100644 --- a/packages/frontend/src/components/projects/create/ProjectRepoCard.tsx +++ b/packages/frontend/src/components/projects/create/ProjectRepoCard.tsx @@ -1,7 +1,8 @@ import React, { useCallback } from 'react'; +import toast from 'react-hot-toast'; import { useNavigate, useParams } from 'react-router-dom'; -import { Chip, IconButton } from '@material-tailwind/react'; +import { Chip, IconButton, Spinner } from '@material-tailwind/react'; import { relativeTimeISO } from '../../../utils/time'; import { GitRepositoryDetails } from '../../../types'; @@ -14,6 +15,7 @@ interface ProjectRepoCardProps { const ProjectRepoCard: React.FC = ({ repository }) => { const client = useGQLClient(); const navigate = useNavigate(); + const [isLoading, setIsLoading] = React.useState(false); const { orgSlug } = useParams(); @@ -22,6 +24,7 @@ const ProjectRepoCard: React.FC = ({ repository }) => { return; } + setIsLoading(true); const { addProject } = await client.addProject(orgSlug!, { name: `${repository.owner!.login}-${repository.name}`, prodBranch: repository.default_branch!, @@ -30,7 +33,13 @@ const ProjectRepoCard: React.FC = ({ repository }) => { template: 'webapp', }); - navigate(`import?projectId=${addProject.id}`); + if (Boolean(addProject)) { + setIsLoading(false); + navigate(`import?projectId=${addProject.id}`); + } else { + setIsLoading(false); + toast.error('Failed to create project'); + } }, [client, repository]); return ( @@ -53,9 +62,13 @@ const ProjectRepoCard: React.FC = ({ repository }) => {

{repository.updated_at && relativeTimeISO(repository.updated_at)}

-
- {'>'} -
+ {isLoading ? ( + + ) : ( +
+ {'>'} +
+ )} ); }; diff --git a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx index 60bc1237..e57a5302 100644 --- a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx +++ b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx @@ -87,18 +87,12 @@ const DeploymentDetailsCard = ({ }; return ( -
-
+
+
{deployment.url && ( {deployment.url} )} - ^} - />
{deployment.environment === Environment.Production @@ -107,13 +101,21 @@ const DeploymentDetailsCard = ({
+ ^} + /> +
+
^ {deployment.branch} ^ {deployment.commitHash.substring(0, SHORT_COMMIT_HASH_LENGTH)}{' '} {deployment.commitMessage}
-
+
^ {relativeTimeMs(deployment.createdAt)} ^ {deployment.createdBy.name} diff --git a/packages/frontend/src/components/projects/project/deployments/FilterForm.tsx b/packages/frontend/src/components/projects/project/deployments/FilterForm.tsx index 39d18fa9..8846b47c 100644 --- a/packages/frontend/src/components/projects/project/deployments/FilterForm.tsx +++ b/packages/frontend/src/components/projects/project/deployments/FilterForm.tsx @@ -44,18 +44,18 @@ const FilterForm = ({ value, onChange }: FilterFormProps) => { }, [value]); return ( -
-
+
+
setSearchedBranch(event.target.value)} />
-
+
-
+