Merge pull request #137 from snowball-tools/sushan/T-4914-project-overview-layout

Project overview layout
This commit is contained in:
Sushan Yadav 2024-02-29 09:57:12 +05:45 committed by GitHub
commit 6a108c1a1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 420 additions and 174 deletions

View File

@ -0,0 +1,28 @@
import React from 'react';
import { GitCommitWithBranch } from 'types';
import { Heading } from 'components/shared/Heading';
import ActivityCard from './ActivityCard';
import { Button } from 'components/shared/Button';
export const Activity = ({
activities,
}: {
activities: GitCommitWithBranch[];
}) => {
return (
<div className="col-span-2 mr-1">
<div className="flex items-center justify-between">
<Heading className="text-lg leading-6 font-medium">Activity</Heading>
<Button variant="tertiary" size="sm">
See all
</Button>
</div>
<div className="mt-5">
{activities.map((activity, index) => {
return <ActivityCard activity={activity} key={`activity-${index}`} />;
})}
</div>
</div>
);
};

View File

@ -1,11 +1,11 @@
import React from 'react'; import React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { GitCommitWithBranch } from '../../../types'; import { GitCommitWithBranch } from '../../../../../types';
import { Avatar } from 'components/shared/Avatar'; import { Avatar } from 'components/shared/Avatar';
import { Button } from 'components/shared/Button'; import { Button } from 'components/shared/Button';
import { import {
ArrowRightCircleFilledIcon, ArrowRightCircleFilledIcon,
BranchIcon, BranchStrokeIcon,
} from 'components/shared/CustomIcon'; } from 'components/shared/CustomIcon';
import { formatDistance } from 'date-fns'; import { formatDistance } from 'date-fns';
import { getInitials } from 'utils/geInitials'; import { getInitials } from 'utils/geInitials';
@ -50,7 +50,7 @@ const ActivityCard = ({ activity }: ActivityCardProps) => {
<span className="w-0.5 h-0.5 rounded-full bg-border-interactive-hovered"></span> <span className="w-0.5 h-0.5 rounded-full bg-border-interactive-hovered"></span>
<span className="flex justify-center items-center gap-1.5"> <span className="flex justify-center items-center gap-1.5">
<div> <div>
<BranchIcon /> <BranchStrokeIcon className="w-3 h-3" />
</div> </div>
<span <span
title={activity.branch.name} title={activity.branch.name}

View File

@ -0,0 +1 @@
export * from './Activity';

View File

@ -0,0 +1,29 @@
import React from 'react';
import { PropsWithChildren } from 'react';
import { cloneElement } from 'utils/cloneElement';
interface OverviewInfoProps {
label: string;
icon: React.ReactNode;
}
export const OverviewInfo = ({
label,
icon,
children,
}: PropsWithChildren<OverviewInfoProps>) => {
const styledIcon = cloneElement({
element: icon,
className: 'w-4 h-4',
});
return (
<div className="flex justify-between gap-2 py-3 text-sm items-center">
<div className="flex gap-2 items-center text-elements-high-em">
{styledIcon}
{label}
</div>
<div>{children}</div>
</div>
);
};

View File

@ -0,0 +1,20 @@
import React from 'react';
import { CustomIcon, CustomIconProps } from './CustomIcon';
export const BranchStrokeIcon = (props: CustomIconProps) => {
return (
<CustomIcon
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
{...props}
>
<path
d="M4.66667 4.99984C5.58714 4.99984 6.33333 4.25365 6.33333 3.33317C6.33333 2.4127 5.58714 1.6665 4.66667 1.6665C3.74619 1.6665 3 2.4127 3 3.33317C3 4.25365 3.74619 4.99984 4.66667 4.99984ZM4.66667 4.99984V10.9998M4.66667 10.9998C3.74619 10.9998 3 11.746 3 12.6665C3 13.587 3.74619 14.3332 4.66667 14.3332C5.58714 14.3332 6.33333 13.587 6.33333 12.6665C6.33333 11.746 5.58714 10.9998 4.66667 10.9998ZM4.66667 10.9998V9.33317C4.66667 8.59679 5.26362 7.99984 6 7.99984H10C10.7364 7.99984 11.3333 7.40288 11.3333 6.6665V4.99984M11.3333 4.99984C12.2538 4.99984 13 4.25365 13 3.33317C13 2.4127 12.2538 1.6665 11.3333 1.6665C10.4129 1.6665 9.66667 2.4127 9.66667 3.33317C9.66667 4.25365 10.4129 4.99984 11.3333 4.99984Z"
stroke="currentColor"
strokeLinejoin="round"
/>
</CustomIcon>
);
};

View File

@ -0,0 +1,41 @@
import React from 'react';
import { CustomIcon, CustomIconProps } from './CustomIcon';
export const CalendarDaysIcon = (props: CustomIconProps) => {
return (
<CustomIcon
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
{...props}
>
<path
d="M2.3335 5.00016H13.6668M4.33349 13.6668H11.6668C12.7714 13.6668 13.6668 12.7714 13.6668 11.6668V4.3335C13.6668 3.22893 12.7714 2.3335 11.6668 2.3335H4.3335C3.22893 2.3335 2.3335 3.22893 2.3335 4.33349V11.6668C2.3335 12.7714 3.22893 13.6668 4.33349 13.6668Z"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M4.6665 7.8335C4.6665 7.55735 4.89036 7.3335 5.1665 7.3335C5.44265 7.3335 5.6665 7.55735 5.6665 7.8335C5.6665 8.10964 5.44265 8.3335 5.1665 8.3335C4.89036 8.3335 4.6665 8.10964 4.6665 7.8335Z"
fill="currentColor"
/>
<path
d="M4.6665 10.8335C4.6665 10.5574 4.89036 10.3335 5.1665 10.3335C5.44265 10.3335 5.6665 10.5574 5.6665 10.8335C5.6665 11.1096 5.44265 11.3335 5.1665 11.3335C4.89036 11.3335 4.6665 11.1096 4.6665 10.8335Z"
fill="currentColor"
/>
<path
d="M7.49984 10.8335C7.49984 10.5574 7.72369 10.3335 7.99984 10.3335C8.27598 10.3335 8.49984 10.5574 8.49984 10.8335C8.49984 11.1096 8.27598 11.3335 7.99984 11.3335C7.72369 11.3335 7.49984 11.1096 7.49984 10.8335Z"
fill="currentColor"
/>
<path
d="M7.49984 7.8335C7.49984 7.55735 7.72369 7.3335 7.99984 7.3335C8.27598 7.3335 8.49984 7.55735 8.49984 7.8335C8.49984 8.10964 8.27598 8.3335 7.99984 8.3335C7.72369 8.3335 7.49984 8.10964 7.49984 7.8335Z"
fill="currentColor"
/>
<path
d="M10.3332 7.8335C10.3332 7.55735 10.557 7.3335 10.8332 7.3335C11.1093 7.3335 11.3332 7.55735 11.3332 7.8335C11.3332 8.10964 11.1093 8.3335 10.8332 8.3335C10.557 8.3335 10.3332 8.10964 10.3332 7.8335Z"
fill="currentColor"
/>
</CustomIcon>
);
};

View File

@ -0,0 +1,22 @@
import React from 'react';
import { CustomIcon, CustomIconProps } from './CustomIcon';
export const CursorBoxIcon = (props: CustomIconProps) => {
return (
<CustomIcon
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
{...props}
>
<path
d="M13.5 7V3.83333C13.5 3.09695 12.903 2.5 12.1667 2.5H3.83333C3.09695 2.5 2.5 3.09695 2.5 3.83333V12.1667C2.5 12.903 3.09695 13.5 3.83333 13.5H7M9.43391 14.0852L7.5218 7.9391C7.44202 7.68269 7.68269 7.44202 7.9391 7.5218L14.0852 9.43391C14.3658 9.52122 14.4043 9.90262 14.1468 10.0443L11.5848 11.4534C11.5294 11.4838 11.4838 11.5294 11.4534 11.5848L10.0443 14.1468C9.90262 14.4043 9.52122 14.3658 9.43391 14.0852Z"
stroke="currentColor"
strokeWidth="1.05263"
strokeLinecap="round"
strokeLinejoin="round"
/>
</CustomIcon>
);
};

View File

@ -0,0 +1,19 @@
import React from 'react';
import { CustomIcon, CustomIconProps } from './CustomIcon';
export const GithubStrokeIcon = (props: CustomIconProps) => {
return (
<CustomIcon
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
{...props}
>
<path
d="M13.0194 4.73001C13.1722 4.23701 13.2212 3.71768 13.1634 3.20479C13.1055 2.6919 12.942 2.19656 12.6831 1.75001C12.6392 1.67398 12.5761 1.61085 12.5001 1.56697C12.424 1.52308 12.3378 1.49999 12.25 1.50001C11.6676 1.49879 11.093 1.6338 10.5721 1.89425C10.0512 2.1547 9.59845 2.53337 9.25 3.00001H7.75C7.40155 2.53337 6.94878 2.1547 6.42788 1.89425C5.90698 1.6338 5.33238 1.49879 4.75 1.50001C4.66221 1.49999 4.57597 1.52308 4.49994 1.56697C4.4239 1.61085 4.36077 1.67398 4.31687 1.75001C4.05803 2.19656 3.89452 2.6919 3.83664 3.20479C3.77877 3.71768 3.8278 4.23701 3.98062 4.73001C3.6717 5.26921 3.50623 5.87862 3.5 6.50001V7.00001C3.50105 7.84601 3.80817 8.66306 4.36464 9.30029C4.92111 9.93752 5.68935 10.3519 6.5275 10.4669C6.18538 10.9047 5.99968 11.4444 6 12V12.5H4.5C4.10218 12.5 3.72064 12.342 3.43934 12.0607C3.15804 11.7794 3 11.3978 3 11C3 10.6717 2.93534 10.3466 2.8097 10.0433C2.68406 9.73999 2.49991 9.46439 2.26777 9.23224C2.03562 9.00009 1.76002 8.81595 1.45671 8.69031C1.15339 8.56467 0.828305 8.50001 0.5 8.50001C0.367392 8.50001 0.240215 8.55269 0.146447 8.64645C0.0526784 8.74022 0 8.8674 0 9.00001C0 9.13262 0.0526784 9.25979 0.146447 9.35356C0.240215 9.44733 0.367392 9.50001 0.5 9.50001C0.897825 9.50001 1.27936 9.65804 1.56066 9.93935C1.84196 10.2207 2 10.6022 2 11C2 11.663 2.26339 12.2989 2.73223 12.7678C3.20107 13.2366 3.83696 13.5 4.5 13.5H6V14.5C6 14.6326 6.05268 14.7598 6.14645 14.8536C6.24021 14.9473 6.36739 15 6.5 15C6.63261 15 6.75979 14.9473 6.85355 14.8536C6.94732 14.7598 7 14.6326 7 14.5V12C7 11.6022 7.15804 11.2207 7.43934 10.9393C7.72064 10.658 8.10218 10.5 8.5 10.5C8.89782 10.5 9.27936 10.658 9.56066 10.9393C9.84196 11.2207 10 11.6022 10 12V14.5C10 14.6326 10.0527 14.7598 10.1464 14.8536C10.2402 14.9473 10.3674 15 10.5 15C10.6326 15 10.7598 14.9473 10.8536 14.8536C10.9473 14.7598 11 14.6326 11 14.5V12C11.0003 11.4444 10.8146 10.9047 10.4725 10.4669C11.3107 10.3519 12.0789 9.93752 12.6354 9.30029C13.1918 8.66306 13.4989 7.84601 13.5 7.00001V6.50001C13.4938 5.87862 13.3283 5.26921 13.0194 4.73001ZM12.5 7.00001C12.5 7.66305 12.2366 8.29893 11.7678 8.76778C11.2989 9.23662 10.663 9.50001 10 9.50001H7C6.33696 9.50001 5.70107 9.23662 5.23223 8.76778C4.76339 8.29893 4.5 7.66305 4.5 7.00001V6.50001C4.50613 6.00002 4.65582 5.51233 4.93125 5.09501C4.98259 5.02733 5.01585 4.94769 5.02788 4.8636C5.03991 4.77951 5.03031 4.69374 5 4.61438C4.86976 4.27851 4.80709 3.92023 4.81556 3.56009C4.82403 3.19995 4.90349 2.84501 5.04938 2.51563C5.45857 2.55965 5.85262 2.6952 6.2023 2.91224C6.55198 3.12928 6.84832 3.42223 7.06938 3.76938C7.11442 3.83982 7.17641 3.89784 7.24968 3.93813C7.32294 3.97842 7.40514 3.9997 7.48875 4.00001H9.51062C9.59455 4.00001 9.67713 3.97889 9.75075 3.93858C9.82437 3.89828 9.88666 3.84009 9.93188 3.76938C10.1529 3.4222 10.4492 3.12922 10.7989 2.91218C11.1486 2.69514 11.5427 2.55961 11.9519 2.51563C12.0976 2.8451 12.1768 3.20007 12.1851 3.56021C12.1933 3.92036 12.1304 4.27859 12 4.61438C11.9698 4.69298 11.9597 4.77788 11.9706 4.86138C11.9815 4.94487 12.0131 5.02432 12.0625 5.09251C12.3407 5.50984 12.4926 5.99853 12.5 6.50001V7.00001Z"
fill="currentColor"
/>
</CustomIcon>
);
};

View File

@ -0,0 +1,21 @@
import React from 'react';
import { CustomIcon, CustomIconProps } from './CustomIcon';
export const LinkIcon = (props: CustomIconProps) => {
return (
<CustomIcon
width="18"
height="18"
viewBox="0 0 18 18"
fill="none"
{...props}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M5.99634 4.3125C5.99634 4.00184 6.24818 3.75 6.55884 3.75H12.1875C13.3266 3.75 14.25 4.67341 14.25 5.8125V12.1844C14.25 12.495 13.9982 12.7469 13.6875 12.7469C13.3769 12.7469 13.125 12.495 13.125 12.1844V5.8125C13.125 5.76745 13.1218 5.72315 13.1157 5.6798L5.27275 13.5227C5.05308 13.7424 4.69692 13.7424 4.47725 13.5227C4.25758 13.3031 4.25758 12.9469 4.47725 12.7273L12.3202 4.88432C12.2768 4.87818 12.2326 4.875 12.1875 4.875H6.55884C6.24818 4.875 5.99634 4.62316 5.99634 4.3125Z"
fill="currentColor"
/>
</CustomIcon>
);
};

View File

@ -0,0 +1,21 @@
import React from 'react';
import { CustomIcon, CustomIconProps } from './CustomIcon';
export const StorageIcon = (props: CustomIconProps) => {
return (
<CustomIcon
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
{...props}
>
<path
d="M13 3.42576C13 4.39738 10.7614 5.18502 8 5.18502C5.23858 5.18502 3 4.39738 3 3.42576M13 3.42576C13 2.45415 10.7614 1.6665 8 1.6665C5.23858 1.6665 3 2.45415 3 3.42576M13 3.42576V12.5739C13 13.5455 10.7614 14.3332 8 14.3332C5.23858 14.3332 3 13.5455 3 12.5739V3.42576M13 7.92562C13 8.89723 10.7614 9.68488 8 9.68488C5.23858 9.68488 3 8.89723 3 7.92562"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
/>
</CustomIcon>
);
};

View File

@ -36,6 +36,11 @@ export * from './WarningDiamondIcon';
export * from './ArrowRightCircleIcon'; export * from './ArrowRightCircleIcon';
export * from './ClockOutlineIcon'; export * from './ClockOutlineIcon';
export * from './ArrowRightCircleFilledIcon'; export * from './ArrowRightCircleFilledIcon';
export * from './GithubStrokeIcon';
export * from './BranchStrokeIcon';
export * from './StorageIcon';
export * from './LinkIcon';
export * from './CursorBoxIcon';
// Templates // Templates
export * from './templates'; export * from './templates';

View File

@ -8,7 +8,6 @@ export const tabsTheme = tv({
triggerWrapper: [ triggerWrapper: [
// Horizontal default // Horizontal default
'px-1', 'px-1',
'pb-5',
'cursor-default', 'cursor-default',
'select-none', 'select-none',
'text-elements-low-em', 'text-elements-low-em',
@ -55,9 +54,13 @@ export const tabsTheme = tv({
'outline-none', 'outline-none',
'leading-none', 'leading-none',
'tracking-[-0.006em]', 'tracking-[-0.006em]',
'text-sm',
'rounded-md', 'rounded-md',
// Horizontal default // Horizontal default
'data-[orientation=horizontal]:focus-ring', 'data-[orientation=horizontal]:focus-ring',
'data-[orientation=horizontal]:h-10',
// select direct child of data-[orientation=horizontal]
'[&[data-orientation=horizontal]_>_*]:h-full',
// Vertical // Vertical
'data-[orientation=vertical]:gap-2', 'data-[orientation=vertical]:gap-2',
'data-[orientation=vertical]:justify-start', 'data-[orientation=vertical]:justify-start',

View File

@ -5,25 +5,25 @@ export const tagTheme = tv(
{ {
slots: { slots: {
wrapper: ['flex', 'gap-1.5', 'rounded-lg', 'border'], wrapper: ['flex', 'gap-1.5', 'rounded-lg', 'border'],
icon: ['h-4', 'w-4'], icon: [],
label: ['font-inter', 'text-xs'], label: ['font-inter', 'text-xs'],
}, },
variants: { variants: {
type: { type: {
attention: { attention: {
icon: ['text-elements-warning'], wrapper: ['text-elements-warning'],
}, },
negative: { negative: {
icon: ['text-elements-danger'], wrapper: ['text-elements-danger'],
}, },
positive: { positive: {
icon: ['text-elements-success'], wrapper: ['text-elements-success'],
}, },
emphasized: { emphasized: {
icon: ['text-elements-on-secondary'], wrapper: ['text-elements-on-secondary'],
}, },
neutral: { neutral: {
icon: ['text-elements-mid-em'], wrapper: ['text-elements-mid-em'],
}, },
}, },
style: { style: {
@ -36,9 +36,11 @@ export const tagTheme = tv(
size: { size: {
sm: { sm: {
wrapper: ['px-2', 'py-2'], wrapper: ['px-2', 'py-2'],
icon: ['h-4', 'w-4'],
}, },
xs: { xs: {
wrapper: ['px-2', 'py-1.5'], wrapper: ['px-2', 'py-1'],
icon: ['h-3', 'w-3'],
}, },
}, },
}, },

View File

@ -27,6 +27,8 @@ export const Tag = ({
type = 'attention', type = 'attention',
style = 'default', style = 'default',
size = 'sm', size = 'sm',
className,
...props
}: TagProps) => { }: TagProps) => {
const { const {
wrapper: wrapperCls, wrapper: wrapperCls,
@ -51,7 +53,7 @@ export const Tag = ({
}, [cloneIcon, iconCls, rightIcon]); }, [cloneIcon, iconCls, rightIcon]);
return ( return (
<div className={wrapperCls()}> <div className={wrapperCls({ className })} {...props}>
{renderLeftIcon} {renderLeftIcon}
<p className={labelCls()}>{children}</p> <p className={labelCls()}>{children}</p>
{renderRightIcon} {renderRightIcon}

View File

@ -8,18 +8,13 @@ import {
} from 'react-router-dom'; } from 'react-router-dom';
import { Project as ProjectType } from 'gql-client'; import { Project as ProjectType } from 'gql-client';
import {
Button,
Tab,
Tabs,
TabsBody,
TabsHeader,
Typography,
} from '@material-tailwind/react';
import HorizontalLine from '../../../components/HorizontalLine';
import { useGQLClient } from '../../../context/GQLClientContext'; import { useGQLClient } from '../../../context/GQLClientContext';
import { useOctokit } from '../../../context/OctokitContext'; import { useOctokit } from '../../../context/OctokitContext';
import { Button } from 'components/shared/Button';
import { ChevronLeft } from 'components/shared/CustomIcon';
import { WavyBorder } from 'components/shared/WavyBorder';
import { Heading } from 'components/shared/Heading';
import { Tabs } from 'components/shared/Tabs';
const Id = () => { const Id = () => {
const { id } = useParams(); const { id } = useParams();
@ -69,96 +64,61 @@ const Id = () => {
<div className="h-full"> <div className="h-full">
{project ? ( {project ? (
<> <>
<div className="flex p-4 gap-4 items-center"> <div className="px-6 py-4 flex justify-between items-center gap-4">
<div className="flex items-center justify-center gap-4">
<Button <Button
variant="outlined" variant="tertiary"
className="rounded-full" className="rounded-full h-11 w-11 p-0"
aria-label="Go back"
leftIcon={<ChevronLeft />}
onClick={() => navigate(-1)} onClick={() => navigate(-1)}
placeholder={''} />
> <Heading className="text-2xl font-medium">
{'<'}
</Button>
<Typography variant="h3" className="grow" placeholder={''}>
{project?.name} {project?.name}
</Typography> </Heading>
<Link to={repoUrl} target="_blank">
<Button
className="rounded-full"
variant="outlined"
placeholder={''}
>
Open Repo
</Button>
</Link>
<Button className="rounded-full" color="blue" placeholder={''}>
Go to app
</Button>
</div> </div>
<HorizontalLine /> <div className="flex items-center justify-center gap-3">
<div className="p-4"> <Link to={repoUrl} target="_blank">
<Tabs value={currentTab}> <Button className="h-11 transition-colors" variant="tertiary">
<TabsHeader Open repo
className="rounded-none border-b border-blue-gray-50 bg-transparent p-0" </Button>
indicatorProps={{
className:
'bg-transparent border-b-2 border-gray-900 shadow-none rounded-none',
}}
placeholder={''}
>
<Link to="">
<Tab
value=""
className={'p-2 cursor-pointer'}
placeholder={''}
>
Overview
</Tab>
</Link> </Link>
<Link to="deployments"> <Button className="h-11 transition-colors">Go to app</Button>
<Tab </div>
value="deployments" </div>
className={'p-2 cursor-pointer'} <WavyBorder />
placeholder={''} <div className="px-6 ">
> <Tabs value={currentTab} className="flex-col pt-6">
Deployments <Tabs.List>
</Tab> <Tabs.Trigger value="">
</Link> <Link to="">Overview</Link>
<Link to="database"> </Tabs.Trigger>
<Tab <Tabs.Trigger value="deployments">
value="database" <Link to="deployments">Deployments</Link>
className={'p-2 cursor-pointer'} </Tabs.Trigger>
placeholder={''} <Tabs.Trigger value="database">
> <Link to="database">Database</Link>
Database </Tabs.Trigger>
</Tab> <Tabs.Trigger value="integrations">
</Link> <Link to="integrations">Integrations</Link>
<Link to="integrations"> </Tabs.Trigger>
<Tab <Tabs.Trigger value="settings">
value="integrations" <Link to="settings">Settings</Link>
className={'p-2 cursor-pointer'} </Tabs.Trigger>
placeholder={''} </Tabs.List>
> {/* Not wrapping in Tab.Content because we are using Outlet */}
Integrations <div className="py-7">
</Tab>
</Link>
<Link to="settings">
<Tab
value="settings"
className={'p-2 cursor-pointer'}
placeholder={''}
>
Settings
</Tab>
</Link>
</TabsHeader>
<TabsBody placeholder={''}>
<Outlet context={{ project, onUpdate }} /> <Outlet context={{ project, onUpdate }} />
</TabsBody> </div>
</Tabs> </Tabs>
</div> </div>
</> </>
) : ( ) : (
<h4>Project not found</h4> <div className="grid place-items-center h-[calc(100vh-174px)]">
<Heading as="h4" className="text-2xl font-medium">
Project not found.
</Heading>
</div>
)} )}
</div> </div>
); );

View File

@ -1,18 +1,30 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Domain, DomainStatus } from 'gql-client'; import { Domain, DomainStatus } from 'gql-client';
import { useNavigate, useOutletContext } from 'react-router-dom'; import { Link, useNavigate, useOutletContext } from 'react-router-dom';
import { RequestError } from 'octokit'; import { RequestError } from 'octokit';
import { Typography, Chip, Avatar, Tooltip } from '@material-tailwind/react';
import ActivityCard from '../../../../components/projects/project/ActivityCard';
import { relativeTimeMs } from '../../../../utils/time';
import { useOctokit } from '../../../../context/OctokitContext'; import { useOctokit } from '../../../../context/OctokitContext';
import { GitCommitWithBranch, OutletContextType } from '../../../../types'; import { GitCommitWithBranch, OutletContextType } from '../../../../types';
import { useGQLClient } from '../../../../context/GQLClientContext'; import { useGQLClient } from '../../../../context/GQLClientContext';
import { formatAddress } from '../../../../utils/format';
import { Button } from 'components/shared/Button'; import { Button } from 'components/shared/Button';
import { Heading } from 'components/shared/Heading'; import { Heading } from 'components/shared/Heading';
import { Avatar } from 'components/shared/Avatar';
import { getInitials } from 'utils/geInitials';
import {
BranchStrokeIcon,
CheckRoundFilledIcon,
ClockIcon,
CursorBoxIcon,
GithubStrokeIcon,
GlobeIcon,
LinkIcon,
StorageIcon,
} from 'components/shared/CustomIcon';
import { Tag } from 'components/shared/Tag';
import { Activity } from 'components/projects/project/overview/Activity';
import { OverviewInfo } from 'components/projects/project/overview/OverviewInfo';
import { CalendarDaysIcon } from 'components/shared/CustomIcon/CalendarDaysIcon';
import { relativeTimeMs } from 'utils/time';
const COMMITS_PER_PAGE = 4; const COMMITS_PER_PAGE = 4;
@ -103,92 +115,109 @@ const OverviewTabPanel = () => {
}, [project]); }, [project]);
return ( return (
<div className="grid grid-cols-5 gap-[72px] mt-7"> <div className="grid grid-cols-5 gap-[72px]">
<div className="col-span-3"> <div className="col-span-3">
<div className="flex items-center gap-2"> <div className="flex items-center gap-4 mb-6">
<Avatar <Avatar
src={project.icon || '/gray.png'} size={48}
variant="rounded" initials={getInitials(project.name)}
placeholder={''} imageSrc={project.icon}
type="blue"
/> />
<div className="grow"> <div className="flex-1 space-y-1">
<Typography placeholder={''}>{project.name}</Typography> <Heading className="text-lg leading-6 font-medium">
<Typography variant="small" color="gray" placeholder={''}> {project.name}
</Heading>
<span className="text-sm text-elements-low-em tracking-tight">
{project.subDomain} {project.subDomain}
</Typography> </span>
</div> </div>
</div> </div>
<div className="flex justify-between p-2 text-sm items-center"> <OverviewInfo label="Domain" icon={<GlobeIcon />}>
<div>^ Domain</div>
{liveDomain ? ( {liveDomain ? (
<Chip <Tag type="positive" size="xs" leftIcon={<CheckRoundFilledIcon />}>
className="normal-case ml-6 inline font-normal" Connected
size="sm" </Tag>
value="Connected"
icon="^"
color="green"
/>
) : ( ) : (
<div className="flex items-center"> <div className="flex items-center gap-2">
<Chip <Tag type="attention" size="xs" leftIcon={<ClockIcon />}>
className="normal-case inline font-normal mx-2" Not connected
size="sm" </Tag>
value="Not connected"
icon="^"
color="orange"
/>
<Button <Button
className="normal-case rounded-full"
variant="primary"
size="sm"
onClick={() => { onClick={() => {
navigate('settings/domains'); navigate('settings/domains');
}} }}
variant="tertiary"
size="sm"
> >
Setup Setup
</Button> </Button>
</div> </div>
)} )}
</div> </OverviewInfo>
{project.deployments.length !== 0 ? ( {project.deployments.length !== 0 ? (
<> <>
<div className="flex justify-between p-2 text-sm"> {/* SOURCE */}
<p>^ Source</p> <OverviewInfo label="Source" icon={<GithubStrokeIcon />}>
<p>^ {project.deployments[0]?.branch}</p> <div className="flex gap-2 items-center">
<BranchStrokeIcon className="text-elements-low-em w-4 h-5" />
<span className="text-elements-high-em text-sm tracking-tighter">
{project.deployments[0]?.branch}
</span>
</div> </div>
<div className="flex justify-between p-2 text-sm"> </OverviewInfo>
<p>^ Deployment</p>
<p className="text-blue-600">{liveDomain?.name}</p> {/* DATABASE */}
<OverviewInfo label="Database" icon={<StorageIcon />}>
<div className="flex gap-2 items-center">
<Link to="#">
<span className="group text-controls-primary hover:border-controls-primary transition-colors border-b border-b-transparent flex gap-2 items-center text-sm tracking-tight">
{/* // TODO: add db name
dbname
*/}
<LinkIcon className="group-hover:rotate-45 transition-transform" />
</span>
</Link>
</div> </div>
<div className="flex justify-between p-2 text-sm"> </OverviewInfo>
<p>^ Created</p>
<p> {/* DEPLOYMENT */}
{relativeTimeMs(project.deployments[0].createdAt)} by ^{' '} <OverviewInfo label="Deployment URL" icon={<CursorBoxIcon />}>
<Tooltip content={project.deployments[0].createdBy.name}> <div className="flex gap-2 items-center">
{formatAddress(project.deployments[0].createdBy.name ?? '')} <Link to="#">
</Tooltip> <span className="text-controls-primary group hover:border-controls-primary transition-colors border-b border-b-transparent flex gap-2 items-center text-sm tracking-tight">
</p> {liveDomain?.name}{' '}
<LinkIcon className="group-hover:rotate-45 transition-transform" />
</span>
</Link>
</div> </div>
</OverviewInfo>
{/* DEPLOYMENT DATE */}
<OverviewInfo label="Deployment date" icon={<CalendarDaysIcon />}>
<div className="flex gap-2 items-center text-elements-high-em text-sm tracking-tighter">
<span>{relativeTimeMs(project.deployments[0].createdAt)}</span>
by
<Avatar
// TODO: add imageSrc
// imageSrc={project.deployments[0]?.createdBy.avatar}
initials={getInitials(
project.deployments[0]?.createdBy?.name ?? '',
)}
className="rounded-full"
size={24}
/>
<span>{project.deployments[0]?.createdBy?.name}</span>
</div>
</OverviewInfo>
</> </>
) : ( ) : (
<div>No current deployment found</div> <p className="text-elements-low-em text-sm py-3">
No current deployment found.
</p>
)} )}
</div> </div>
<div className="col-span-2 mr-1"> <Activity activities={activities} />
<div className="flex items-center justify-between">
<Heading className="text-lg leading-6 font-medium">Activity</Heading>
<Button variant="tertiary" size="sm">
See all
</Button>
</div>
<div className="mt-5">
{activities.map((activity, index) => {
return (
<ActivityCard activity={activity} key={`activity-${index}`} />
);
})}
</div>
</div>
</div> </div>
); );
}; };

View File

@ -0,0 +1,43 @@
import React, {
ReactElement,
isValidElement,
Children,
cloneElement as reactCloneElement,
HTMLProps,
ReactNode,
} from 'react';
import { ClassProp } from 'tailwind-variants';
import { cn } from './classnames';
interface cloneElement extends HTMLProps<ReactNode> {
element: ReactNode;
themeStyle?: (props: ClassProp) => string;
}
export const cloneElement = ({
element,
themeStyle,
className,
...props
}: cloneElement) => {
if (isValidElement(element)) {
return (
<>
{Children.map(element, (child) => {
const originalClassName = (child.props as HTMLProps<ReactNode>)
?.className;
return reactCloneElement(child as ReactElement, {
className: themeStyle
? themeStyle({
className: cn(originalClassName, className), // overriding icon classNames
})
: originalClassName,
...props,
});
})}
</>
);
}
return <></>;
};