diff --git a/web/src/gui/deployments/DeploymentPreview.tsx b/web/src/gui/deployments/DeploymentPreview.tsx index 9045885c..6f1ae898 100644 --- a/web/src/gui/deployments/DeploymentPreview.tsx +++ b/web/src/gui/deployments/DeploymentPreview.tsx @@ -1,4 +1,4 @@ -import { Link } from '@tanstack/react-router'; +import { Link, useNavigate } from '@tanstack/react-router'; import { FC } from 'react'; import { FiClock, FiFileText, FiGitCommit } from 'react-icons/fi'; import TimeAgo from 'react-timeago-i18n'; @@ -31,6 +31,7 @@ export const DeploymentPreview: FC<{ siteIdQuery ?? '', deployment_id ?? '' ); + const navigate = useNavigate(); const { data: previews } = deployment_id ? useDeploymentPreviews(siteIdQuery ?? '', deployment_id ?? '') @@ -49,9 +50,27 @@ export const DeploymentPreview: FC<{ githubContext?.data.workflow ?? '' ); + const handleCardClick = (event: any) => { + event.preventDefault(); + + navigate({ + to: '/site/$siteId/deployment/$deploymentId', + params: { + siteId: deployment?.site_id ?? '', + deploymentId: deployment?.deployment_id ?? '', + }, + }); + }; + if (githubContext) { return ( -
+
event.stopPropagation()} > -
+
{previews && previews.length > 0 && ( Deployment Preview -
-
- - {githubContext.data.commit.message} - - +
+
+
+ event.stopPropagation()} + > + {githubContext.data.commit.message} + + +
+
+ event.stopPropagation()} + > + + {githubContext.data.commit.id.slice(0, 7)} + + event.stopPropagation()} + > + {!workflowStartsWithEmoji && } + {githubContext.data.workflow} + + {githubContext.duration && + match(githubContext.duration) + .with({ type: 'completed' }, (duration) => ( +
+ + {secondsToDuration( + duration.duration + )} +
+ )) + .with({ type: 'pending' }, (duration) => ( +
+ + +
+ )) + .otherwise(() => <>)} +
-
+
event.stopPropagation()} > - - {githubContext.data.commit.id.slice(0, 7)} + {githubContext.data.event} #{' '} + {githubContext.data.runNumber} event.stopPropagation()} > - {!workflowStartsWithEmoji && } - {githubContext.data.workflow} - - {githubContext.duration && - match(githubContext.duration) - .with({ type: 'completed' }, (duration) => ( -
- - {secondsToDuration(duration.duration)} -
- )) - .with({ type: 'pending' }, (duration) => ( -
- - -
- )) - .otherwise(() => <>)} -
-
-
- - {githubContext.data.event} #{' '} - {githubContext.data.runNumber} - - - {githubContext.data.commit.author.name} - {githubContext.data.commit.author.name} - - {githubContext.data.commit.timestamp && ( -
- {githubContext.data.commit.author.name} + {githubContext.data.commit.author.name} -
- )} + + {githubContext.data.commit.timestamp && ( +
+ +
+ )} - {/*
{githubContext.data.commit.timestamp}
*/} + {/*
{githubContext.data.commit.timestamp}
*/} +
); @@ -176,8 +214,9 @@ export const DeploymentPreview: FC<{ siteId: deployment?.site_id ?? '', }} className="block h-fit w-full cursor-pointer md:h-screen md:max-h-32 md:w-fit" + title="View deployment details" > -
+
{previews && previews.length > 0 && ( Deployment Preview -
+
{previews && previews.length > 0 && ( +
-
+
{context.data.commit.message} @@ -113,8 +113,9 @@ export const GithubDeploymentContext: FC<{ {decoratedContext.workflowUrl && ( @@ -122,8 +123,9 @@ export const GithubDeploymentContext: FC<{ {decoratedContext.data.commit.url && ( @@ -132,8 +134,9 @@ export const GithubDeploymentContext: FC<{
{decoratedContext.data.commit.id.slice(0, 7)} @@ -141,7 +144,7 @@ export const GithubDeploymentContext: FC<{
-
+
{context.data.event}
@@ -151,15 +154,16 @@ export const GithubDeploymentContext: FC<{
-
+
Created by
Duration
{match(decoratedContext.duration) .with({ type: 'completed' }, (duration) => ( -
+
{secondsToDuration(duration.duration)}
@@ -208,6 +212,7 @@ export const GithubDeploymentContext: FC<{ to={decoratedContext.workflowUrl} className="flex items-center gap-1.5 hover:underline" target="_blank" + title="View workflow details" > {!workflowStartsWithEmoji && } {decoratedContext.data.workflow} diff --git a/web/src/gui/deployments/files/FileExplorer.tsx b/web/src/gui/deployments/files/FileExplorer.tsx index 8c7374dd..63ba7787 100644 --- a/web/src/gui/deployments/files/FileExplorer.tsx +++ b/web/src/gui/deployments/files/FileExplorer.tsx @@ -1,8 +1,9 @@ import * as Collapsible from '@radix-ui/react-collapsible'; import byteSize from 'byte-size'; import clsx from 'clsx'; -import { FC, useState } from 'react'; +import { FC, useEffect, useState } from 'react'; import { LuChevronRight, LuFolderClosed, LuFolderOpen } from 'react-icons/lu'; +import { VscCollapseAll, VscExpandAll } from 'react-icons/vsc'; import { useDeploymentFiles } from '@/api'; import { components } from '@/api/schema.gen'; @@ -75,22 +76,47 @@ export const FileExplorer: FC<{ siteId: string; deploymentId: string }> = ({ }) => { const { data: deploymentFiles } = useDeploymentFiles(siteId, deploymentId); const tree = reorgFilesIntoTree(deploymentFiles); + const [allCollapsed, setAllCollapsed] = useState(false); if (!deploymentFiles) { return; } + const collapseAllLabel = allCollapsed + ? 'Expand all folders' + : 'Collapse all folders'; + return (
File Explorer
- +
+ + +
-
- +
+
); @@ -101,7 +127,14 @@ export const TreeEntry: FC<{ name: string; isRoot?: boolean; hideRoot?: boolean; -}> = ({ node, name, isRoot = false, hideRoot = false }) => { + allCollapsed?: boolean; +}> = ({ + node, + name, + isRoot = false, + hideRoot = false, + allCollapsed = false, +}) => { if (node.type === 'file') { return ; } @@ -112,6 +145,7 @@ export const TreeEntry: FC<{ name={name} isRoot={isRoot} hideRoot={hideRoot} + allCollapsed={allCollapsed} /> ); }; @@ -121,15 +155,26 @@ export const FolderEntry: FC<{ name: string; isRoot?: boolean; hideRoot?: boolean; -}> = ({ node, name, isRoot = false, hideRoot = false }) => { + allCollapsed?: boolean; +}> = ({ + node, + name, + isRoot = false, + hideRoot = false, + allCollapsed = false, +}) => { const [isOpen, setIsOpen] = useState(true); + useEffect(() => { + setIsOpen(!allCollapsed); + }, [allCollapsed]); + const { fileCount, directoryCount } = countFilesAndDirectories(node); if (isRoot && hideRoot) { return (
    - +
); } @@ -144,7 +189,7 @@ export const FolderEntry: FC<{ >
@@ -162,7 +207,7 @@ export const FolderEntry: FC<{ )} {name}
-
+
{[ fileCount && `${fileCount} file${ @@ -177,7 +222,7 @@ export const FolderEntry: FC<{ .map((count) => (
{count}
@@ -188,7 +233,7 @@ export const FolderEntry: FC<{
    - +
@@ -196,7 +241,10 @@ export const FolderEntry: FC<{ ); }; -export const SubTree: FC<{ node: FolderNode }> = ({ node }) => { +export const SubTree: FC<{ node: FolderNode; allCollapsed?: boolean }> = ({ + node, + allCollapsed = false, +}) => { return ( <> {Object.entries(node.files) @@ -213,7 +261,11 @@ export const SubTree: FC<{ node: FolderNode }> = ({ node }) => { }) .map(([key, value]) => (
  • - +
  • ))} @@ -228,7 +280,7 @@ export const FileEntry: FC<{ file: DeploymentFile; name: string }> = ({ return (
    = ({ {name}
    -
    +
    {file.deployment_file_mime_type} {file_size && {file_size.toString()}}
    @@ -258,7 +310,7 @@ export const FrameworkDetection: FC<{ const framework = useFramework(siteId, deploymentId); return ( -
    +
    {getFrameworkIcon(framework)} {framework}
    diff --git a/web/src/routes/_authed/site/$siteId._site/deployment/$deploymentId/index.tsx b/web/src/routes/_authed/site/$siteId._site/deployment/$deploymentId/index.tsx index aef642ce..2070f4a6 100644 --- a/web/src/routes/_authed/site/$siteId._site/deployment/$deploymentId/index.tsx +++ b/web/src/routes/_authed/site/$siteId._site/deployment/$deploymentId/index.tsx @@ -105,6 +105,7 @@ function RouteComponent() { 'Preview regeneration queued' ); }} + className="cursor-pointer" > Refresh Preview