Skip to content

Commit 1f8b25d

Browse files
authored
Get rid of pointless Cell type (#2119)
get rid of pointless Cell type
1 parent 95f2e49 commit 1f8b25d

12 files changed

+23
-65
lines changed

app/pages/project/vpcs/VpcPage/tabs/VpcFirewallRulesTab.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { DateCell } from '~/table/cells/DateCell'
2323
import { EnabledCell } from '~/table/cells/EnabledCell'
2424
import { FirewallFilterCell } from '~/table/cells/FirewallFilterCell'
2525
import { ButtonCell } from '~/table/cells/LinkCell'
26-
import { TypeValueListCell } from '~/table/cells/TypeValueListCell'
26+
import { TypeValueCell } from '~/table/cells/TypeValueCell'
2727
import { getActionsCol } from '~/table/columns/action-col'
2828
import { Table } from '~/table/Table'
2929
import { Button } from '~/ui/lib/Button'
@@ -50,11 +50,17 @@ const staticColumns = [
5050
}),
5151
colHelper.accessor('targets', {
5252
header: 'Targets',
53-
cell: (info) => <TypeValueListCell value={info.getValue()} />,
53+
cell: (info) => (
54+
<div>
55+
{info.getValue().map(({ type, value }) => (
56+
<TypeValueCell key={type + '|' + value} type={type} value={value} />
57+
))}
58+
</div>
59+
),
5460
}),
5561
colHelper.accessor('filters', {
5662
header: 'Filters',
57-
cell: (info) => <FirewallFilterCell value={info.getValue()} />,
63+
cell: (info) => <FirewallFilterCell {...info.getValue()} />,
5864
}),
5965
colHelper.accessor('status', {
6066
header: 'Status',

app/table/cells/Cell.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

app/table/cells/DateCell.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
*/
88
import { format } from 'date-fns'
99

10-
import type { Cell } from './Cell'
1110
import { TwoLineCell } from './TwoLineCell'
1211

13-
export const DateCell = ({ value }: Cell<Date>) => (
12+
export const DateCell = ({ value }: { value: Date }) => (
1413
<TwoLineCell value={[format(value, 'MMM d, yyyy'), format(value, 'p')]} />
1514
)

app/table/cells/EnabledCell.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import { Success12Icon } from '@oxide/design-system/icons/react'
1010

1111
import { Badge } from '~/ui/lib/Badge'
1212

13-
import type { Cell } from './Cell'
14-
15-
export const EnabledCell = ({ value }: Cell<VpcFirewallRuleStatus>) =>
13+
export const EnabledCell = ({ value }: { value: VpcFirewallRuleStatus }) =>
1614
value === 'enabled' ? (
1715
<>
1816
<Success12Icon className="mr-1 text-accent" />

app/table/cells/FirewallFilterCell.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ import type { VpcFirewallRuleFilter } from '@oxide/api'
99

1010
import { Badge } from '~/ui/lib/Badge'
1111

12-
import { type Cell } from './Cell'
1312
import { TypeValueCell } from './TypeValueCell'
1413

15-
export const FirewallFilterCell = ({
16-
value: { hosts, ports, protocols },
17-
}: Cell<VpcFirewallRuleFilter>) => (
14+
export const FirewallFilterCell = ({ hosts, ports, protocols }: VpcFirewallRuleFilter) => (
1815
<div className="flex flex-col gap-1">
1916
<div className="flex flex-wrap gap-1">
20-
{hosts?.map((tv, i) => <TypeValueCell key={`${tv}-${i}`} value={tv} />)}
17+
{hosts?.map((tv, i) => <TypeValueCell key={`${tv}-${i}`} {...tv} />)}
2118
</div>
2219
<div className="flex gap-1">
2320
{protocols?.map((p, i) => <Badge key={`${p}-${i}`}>{p}</Badge>)}

app/table/cells/InstanceResourceCell.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import { filesize } from 'filesize'
99

1010
import type { Instance } from '@oxide/api'
1111

12-
import type { Cell } from './Cell'
12+
type Props = { value: Pick<Instance, 'ncpus' | 'memory'> }
1313

14-
export const InstanceResourceCell = ({
15-
value,
16-
}: Cell<Pick<Instance, 'ncpus' | 'memory'>>) => {
14+
export const InstanceResourceCell = ({ value }: Props) => {
1715
const memory = filesize(value.memory, { output: 'object', base: 2 })
1816
return (
1917
<div className="space-y-0.5">

app/table/cells/InstanceStatusCell.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ import type { Instance } from '@oxide/api'
1010
import { InstanceStatusBadge } from '~/components/StatusBadge'
1111
import { TimeAgo } from '~/components/TimeAgo'
1212

13-
import type { Cell } from './Cell'
13+
type Props = { value: Pick<Instance, 'runState' | 'timeRunStateUpdated'> }
1414

15-
export const InstanceStatusCell = ({
16-
value,
17-
}: Cell<Pick<Instance, 'runState' | 'timeRunStateUpdated'>>) => {
15+
export const InstanceStatusCell = ({ value }: Props) => {
1816
return (
1917
<div className="flex flex-col">
2018
<InstanceStatusBadge key="run-state" status={value.runState} />

app/table/cells/SizeCell.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
*/
88
import { filesize } from 'filesize'
99

10-
import type { Cell } from './Cell'
11-
1210
/** Human-readable format for size in bytes */
13-
export const SizeCell = ({ value: bytes }: Cell<number>) => {
11+
export const SizeCell = ({ value: bytes }: { value: number }) => {
1412
const size = filesize(bytes, { base: 2, output: 'object' })
1513
return (
1614
<span className="text-secondary">

app/table/cells/TruncateCell.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@
77
*/
88
import { Truncate } from '~/ui/lib/Truncate'
99

10-
import type { Cell } from './Cell'
10+
type Props = { value: string; maxLength?: number }
1111

12-
export const TruncateCell = ({
13-
value,
14-
maxLength = 32,
15-
}: Cell<string> & {
16-
maxLength?: number
17-
}) => (
12+
export const TruncateCell = ({ value, maxLength = 32 }: Props) => (
1813
<span className="text-secondary">
1914
<Truncate text={value} maxLength={maxLength} />
2015
</span>

app/table/cells/TwoLineCell.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
*/
88
import cn from 'classnames'
99

10-
import type { Cell } from './Cell'
11-
12-
interface TwoLineCellProps extends Cell<[string | JSX.Element, string | JSX.Element]> {
10+
interface TwoLineCellProps {
11+
value: [React.ReactNode, React.ReactNode]
1312
detailsClass?: string
1413
}
1514

app/table/cells/TypeValueCell.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88

99
import { Badge } from '~/ui/lib/Badge'
1010

11-
import type { Cell } from './Cell'
12-
1311
export type TypeValue = {
1412
type: string
1513
value: string
1614
}
1715

18-
export const TypeValueCell = ({ value: { type, value } }: Cell<TypeValue>) => (
16+
export const TypeValueCell = ({ type, value }: TypeValue) => (
1917
<div className="space-x-1">
2018
<Badge>{type}</Badge>
2119
<Badge variant="solid" className="!normal-case">

app/table/cells/TypeValueListCell.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)