Skip to content

Commit

Permalink
Remove inline links from tables
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Feb 7, 2023
1 parent cc51ff7 commit 5f2de5b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { Card, Table, Tooltip } from '@pluralsh/design-system'
import { createColumnHelper } from '@tanstack/react-table'
import { Row, createColumnHelper } from '@tanstack/react-table'
import { TableText } from 'components/cluster/TableElements'
import PropWide from 'components/utils/PropWide'
import {
A,
Div,
Flex,
H2,
} from 'honorable'
import { Link, useOutletContext, useParams } from 'react-router-dom'
import { Div, Flex, H2 } from 'honorable'
import { useNavigate, useOutletContext, useParams } from 'react-router-dom'

import { DeleteJob } from './Job'

Expand All @@ -18,21 +13,12 @@ const columns = (namespace, refetch) => [
columnHelper.accessor(row => row?.metadata?.name, {
id: 'name',
cell: (props => (
<TableText>
<Tooltip
label={props.getValue()}
placement="top-start"
>
<A
inline
display="inline"
as={Link}
to={`/apps/${namespace}/components/job/${props.getValue()}`}
>
{props.getValue()}
</A>
</Tooltip>
</TableText>
<Tooltip
label={props.getValue()}
placement="top-start"
>
<TableText>{props.getValue()}</TableText>
</Tooltip>
)),
header: 'Name',
}),
Expand Down Expand Up @@ -84,10 +70,13 @@ const columns = (namespace, refetch) => [
]

function CronJobJobs({ jobs, namespace, refetch }) {
const navigate = useNavigate()

return (
<Table
data={jobs}
columns={columns(namespace, refetch)}
onRowClick={(_e, { original }: Row<any>) => navigate(`/apps/${namespace}/components/job/${original?.metadata?.name}`)}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ColDelete,
ColImages,
ColMemoryReservation,
ColNameLink,
ColName,
ColRestarts,
PodsList,
} from 'components/cluster/pods/PodsList'
Expand All @@ -17,7 +17,7 @@ export default function Pods({ pods }) {
const { refetch } = useOutletContext<any>()

const columns = useMemo(() => [
ColNameLink,
ColName,
{
...ColMemoryReservation,
meta: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export function ContainersList({
data={tableData}
columns={columns}
enableColumnResizing
onRowClick={(e, { original }: Row<ContainerTableRow>) => original?.readiness === Readiness.Ready && navigate(`/pods/${namespace}/${podName}/shell/${original?.name}`)}
onRowClick={(_e, { original }: Row<ContainerTableRow>) => original?.readiness === Readiness.Ready && navigate(`/pods/${namespace}/${podName}/shell/${original?.name}`)}
{...TABLE_HEIGHT}
/>
)
Expand Down
4 changes: 2 additions & 2 deletions assets/src/components/cluster/nodes/NodeInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
ColContainers,
ColCpuReservation,
ColMemoryReservation,
ColNameLink,
ColName,
ColRestarts,
PodsList,
} from '../pods/PodsList'
Expand Down Expand Up @@ -49,7 +49,7 @@ export default function NodeInfo() {
})

const columns = useMemo(() => [
ColNameLink,
ColName,
ColMemoryReservation,
ColCpuReservation,
ColRestarts,
Expand Down
19 changes: 5 additions & 14 deletions assets/src/components/cluster/nodes/NodesList.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useMemo, useState } from 'react'
import { filesize } from 'filesize'
import { A, Div, Flex } from 'honorable'
import { Div, Flex } from 'honorable'
import {
IconFrame,
Table,
Tooltip,
TrashCanIcon,
} from '@pluralsh/design-system'
import { Link, useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router-dom'
import { ColumnDef, Row, createColumnHelper } from '@tanstack/react-table'
import { Node, NodeMetric } from 'generated/graphql'
import { ReadinessT, nodeStatusToReadiness, readinessToLabel } from 'utils/status'
Expand Down Expand Up @@ -91,21 +91,12 @@ function DeleteNode({ name, refetch }) {
const ColName = columnHelper.accessor(row => row.name, {
id: 'name',
enableSorting: true,
cell: ({ row: { original }, ...props }) => (
cell: props => (
<Tooltip
label={props.getValue()}
placement="top"
>
<TableText>
<A
inline
display="inline"
as={Link}
to={`/nodes/${original.name}`}
>
{props.getValue()}
</A>
</TableText>
<TableText> {props.getValue()} </TableText>
</Tooltip>
),
header: 'Name',
Expand Down Expand Up @@ -289,7 +280,7 @@ export function NodesList({
loose
data={tableData}
columns={columns}
onRowClick={(e, { original }: Row<TableData>) => navigate(`/nodes/${original?.name}`)}
onRowClick={(_e, { original }: Row<TableData>) => navigate(`/nodes/${original?.name}`)}
/>
)
}
4 changes: 2 additions & 2 deletions assets/src/components/cluster/pods/Pods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
ColCpuReservation,
ColImages,
ColMemoryReservation,
ColNameLink,
ColName,
ColNamespace,
ColRestarts,
PodWithId,
Expand Down Expand Up @@ -117,7 +117,7 @@ export default function AllPods() {

const columns = useMemo(() => [
ColNamespace,
ColNameLink,
ColName,
ColMemoryReservation,
ColCpuReservation,
ColRestarts,
Expand Down
43 changes: 7 additions & 36 deletions assets/src/components/cluster/pods/PodsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,46 +105,17 @@ type PodTableRow = {
}
const columnHelper = createColumnHelper<PodTableRow>()

export const ColNameLink = columnHelper.accessor(row => row.name, {
id: 'name-link',
enableGlobalFilter: true,
enableSorting: true,
cell: ({ row: { original }, ...props }) => (
<TableText>
<Tooltip
label={props.getValue()}
placement="top-start"
>
<A
inline
display="inline"
as={Link}
to={`/pods/${original.namespace}/${original.name}`}
>
{props.getValue()}
</A>
</Tooltip>
</TableText>
),
header: 'Name',
meta: {
truncate: true,
},
})

export const ColName = columnHelper.accessor(row => row.name, {
id: 'name',
enableGlobalFilter: true,
enableSorting: true,
cell: props => (
<TableText>
<Tooltip
label={props.getValue()}
placement="top-start"
>
<span>{props.getValue()}</span>
</Tooltip>
</TableText>
<Tooltip
label={props.getValue()}
placement="top-start"
>
<TableText>{props.getValue()}</TableText>
</Tooltip>
),
header: 'Name',
})
Expand Down Expand Up @@ -372,7 +343,7 @@ export const PodsList = memo(({
columns={columns}
virtualizeRows
{...props}
onRowClick={(e, { original }: Row<PodTableRow>) => navigate(`/pods/${original.namespace}/${original.name}`)}
onRowClick={(_e, { original }: Row<PodTableRow>) => navigate(`/pods/${original.namespace}/${original.name}`)}
/>
)
})

0 comments on commit 5f2de5b

Please sign in to comment.