From c2960a44b80f606d44b998ab8f9d259bfc005784 Mon Sep 17 00:00:00 2001 From: "Bryson G." Date: Sat, 14 Dec 2024 15:29:51 -0800 Subject: [PATCH] refactor(dashboard): SelectionLink for listed item page redirects --- .../wfSpec/[...props]/components/WfRuns.tsx | 15 ++++----- .../[tenantId]/components/LinkWithTenant.tsx | 9 ++++-- .../[tenantId]/components/SelectionLink.tsx | 32 +++++++++++++++++++ .../components/tables/WfSpecTable.tsx | 11 +++---- 4 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 dashboard/src/app/[tenantId]/components/SelectionLink.tsx diff --git a/dashboard/src/app/[tenantId]/(diagram)/wfSpec/[...props]/components/WfRuns.tsx b/dashboard/src/app/[tenantId]/(diagram)/wfSpec/[...props]/components/WfRuns.tsx index 2099bd7b0..78dd5cb83 100644 --- a/dashboard/src/app/[tenantId]/(diagram)/wfSpec/[...props]/components/WfRuns.tsx +++ b/dashboard/src/app/[tenantId]/(diagram)/wfSpec/[...props]/components/WfRuns.tsx @@ -10,6 +10,8 @@ import { useParams, useSearchParams } from 'next/navigation' import { FC, Fragment, useMemo, useState } from 'react' import { PaginatedWfRunIdList, searchWfRun } from '../actions/searchWfRun' import { WfRunsHeader } from './WfRunsHeader' +import { SelectionLink } from '@/app/[tenantId]/components/SelectionLink' +import { parseExpression } from 'cron-parser' export const WfRuns: FC = spec => { const searchParams = useSearchParams() @@ -57,18 +59,13 @@ export const WfRuns: FC = spec => { ) : ( -
+
{data?.pages.map((page, i) => ( {page.results.map(wfRunId => ( -
- - {wfRunId.id} - -
+ +

{wfRunId.id}

+
))}
))} diff --git a/dashboard/src/app/[tenantId]/components/LinkWithTenant.tsx b/dashboard/src/app/[tenantId]/components/LinkWithTenant.tsx index f0b0ca947..3411b2d34 100644 --- a/dashboard/src/app/[tenantId]/components/LinkWithTenant.tsx +++ b/dashboard/src/app/[tenantId]/components/LinkWithTenant.tsx @@ -4,13 +4,16 @@ import NextLink from 'next/link' import { useParams } from 'next/navigation' import { ComponentProps } from 'react' -const LinkWithTenant = ({ linkStyle, ...props }: ComponentProps & { linkStyle?: boolean }) => { +const LinkWithTenant = ({ linkStyle, href, ...props }: ComponentProps & { linkStyle?: boolean }) => { const { tenantId } = useParams() + return ( *:first-child]:text-blue-500 [&>*:first-child]:hover:underline': linkStyle, + })} /> ) } diff --git a/dashboard/src/app/[tenantId]/components/SelectionLink.tsx b/dashboard/src/app/[tenantId]/components/SelectionLink.tsx new file mode 100644 index 000000000..811c761a6 --- /dev/null +++ b/dashboard/src/app/[tenantId]/components/SelectionLink.tsx @@ -0,0 +1,32 @@ +import { WfSpecData } from '@/types' +import LinkWithTenant from './LinkWithTenant' + +import { Fragment } from 'react' +import { TagIcon } from 'lucide-react' +import { Separator } from '@/components/ui/separator' + +export const SelectionLink = ({ + href, + key, + children, + ...props +}: { href: string | undefined } & Omit, 'href'>) => { + return href !== undefined ? ( + + + {children} + + + + ) : ( + +
{children}
+ +
+ ) +} diff --git a/dashboard/src/app/[tenantId]/components/tables/WfSpecTable.tsx b/dashboard/src/app/[tenantId]/components/tables/WfSpecTable.tsx index 10201e16c..f417546dc 100644 --- a/dashboard/src/app/[tenantId]/components/tables/WfSpecTable.tsx +++ b/dashboard/src/app/[tenantId]/components/tables/WfSpecTable.tsx @@ -5,7 +5,7 @@ import { TagIcon } from 'lucide-react' import { useParams, useRouter } from 'next/navigation' import { FC, Fragment, useEffect, useState } from 'react' import { SearchResultProps } from '.' -import LinkWithTenant from '../LinkWithTenant' +import { SelectionLink } from '../SelectionLink' export const WfSpecTable: FC = ({ pages = [] }) => { const router = useRouter() @@ -26,16 +26,13 @@ export const WfSpecTable: FC = ({ pages = [] }) => {
{wfSpecs.map(wfSpec => ( - -

{wfSpec.name}

+ +

{wfSpec.name}

Latest: v{wfSpec.latestVersion}
-
+
))}