Skip to content

Commit 840a163

Browse files
refactor: simplify Link components by removing legacyBehavior prop (#1518)
This commit updates multiple components to streamline the usage of Link elements by removing the legacyBehavior and passHref props. No functionality changes introduced. Fixes HDX-3071
1 parent 15b61c7 commit 840a163

File tree

7 files changed

+47
-91
lines changed

7 files changed

+47
-91
lines changed

packages/app/src/AppNav.components.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,8 @@ export const AppNavCloudBanner = () => {
4747
<div className="my-3 bg-muted rounded p-2 text-center">
4848
<span className="fs-8">Ready to deploy on ClickHouse Cloud?</span>
4949
<div className="mt-2 mb-2">
50-
<Link
51-
href="https://clickhouse.com/docs/use-cases/observability/clickstack/getting-started#deploy-with-clickhouse-cloud"
52-
passHref
53-
legacyBehavior
54-
>
55-
<Button
56-
variant="light"
57-
size="xs"
58-
component="a"
59-
className="hover-color-white"
60-
>
50+
<Link href="https://clickhouse.com/docs/use-cases/observability/clickstack/getting-started#deploy-with-clickhouse-cloud">
51+
<Button variant="light" size="xs" className="hover-color-white">
6152
Get Started for Free
6253
</Button>
6354
</Link>

packages/app/src/HDXMultiSeriesTableChart.tsx

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,25 @@ export const Table = ({
111111
const link = getRowSearchLink(row.original);
112112

113113
if (!link) {
114-
return formattedValue;
114+
return (
115+
<div
116+
className={cx('align-top overflow-hidden py-1 pe-3', {
117+
'text-break': wrapLinesEnabled,
118+
'text-truncate': !wrapLinesEnabled,
119+
})}
120+
>
121+
{formattedValue}
122+
</div>
123+
);
115124
}
116125

117126
return (
118127
<Link
119128
href={link}
120-
passHref
121-
className={'align-top overflow-hidden py-1 pe-3'}
129+
className={cx('align-top overflow-hidden py-1 pe-3', {
130+
'text-break': wrapLinesEnabled,
131+
'text-truncate': !wrapLinesEnabled,
132+
})}
122133
style={{
123134
display: 'block',
124135
color: 'inherit',
@@ -256,7 +267,6 @@ export const Table = ({
256267
)}
257268
{items.map(virtualRow => {
258269
const row = rows[virtualRow.index] as TableRow<any>;
259-
const link = getRowSearchLink?.(row.original);
260270
return (
261271
<tr
262272
key={virtualRow.key}
@@ -267,34 +277,9 @@ export const Table = ({
267277
{row.getVisibleCells().map(cell => {
268278
return (
269279
<td key={cell.id} title={`${cell.getValue()}`}>
270-
{!link ? (
271-
<div
272-
className={cx('align-top overflow-hidden py-1 pe-3', {
273-
'text-break': wrapLinesEnabled,
274-
'text-truncate': !wrapLinesEnabled,
275-
})}
276-
>
277-
{flexRender(
278-
cell.column.columnDef.cell,
279-
cell.getContext(),
280-
)}
281-
</div>
282-
) : (
283-
<Link
284-
href={link}
285-
passHref
286-
className="align-top overflow-hidden py-1 pe-3"
287-
style={{
288-
display: 'block',
289-
color: 'inherit',
290-
textDecoration: 'none',
291-
}}
292-
>
293-
{flexRender(
294-
cell.column.columnDef.cell,
295-
cell.getContext(),
296-
)}
297-
</Link>
280+
{flexRender(
281+
cell.column.columnDef.cell,
282+
cell.getContext(),
298283
)}
299284
</td>
300285
);

packages/app/src/KubernetesDashboardPage.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,11 @@ export const InfraPodsStatusTable = ({
421421
{virtualItems.map(virtualRow => {
422422
const pod = podsList[virtualRow.index];
423423
return (
424-
<Link key={pod.id} href={getLink(pod.name)} legacyBehavior>
424+
<Link
425+
key={pod.id}
426+
href={getLink(pod.name)}
427+
style={{ display: 'contents' }}
428+
>
425429
<Table.Tr
426430
className="cursor-pointer"
427431
ref={rowVirtualizer.measureElement}
@@ -657,9 +661,9 @@ const NodesTable = ({
657661
const node = nodesList[virtualRow.index];
658662
return (
659663
<Link
660-
key={node.name}
661664
href={getLink(node.name)}
662-
legacyBehavior
665+
key={node.name}
666+
style={{ display: 'contents' }}
663667
>
664668
<Table.Tr
665669
className="cursor-pointer"
@@ -857,7 +861,7 @@ const NamespacesTable = ({
857861
<Link
858862
key={namespace.name}
859863
href={getLink(namespace.name)}
860-
legacyBehavior
864+
style={{ display: 'contents' }}
861865
>
862866
<Table.Tr
863867
className="cursor-pointer"

packages/app/src/LandingHeader.tsx

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,15 @@ export default function LandingHeader({
8080
{!isLoggedIn &&
8181
activeKey !== '/register' &&
8282
installation?.isTeamExisting === false && (
83-
<Link href="/register" passHref legacyBehavior>
84-
<Button
85-
component="a"
86-
variant="outline"
87-
color="green"
88-
size="sm"
89-
>
83+
<Link href="/register">
84+
<Button variant="outline" color="green" size="sm">
9085
Setup Account
9186
</Button>
9287
</Link>
9388
)}
9489
{isLoggedIn && (
95-
<Link href="/search" passHref legacyBehavior>
96-
<Button
97-
component="a"
98-
variant="outline"
99-
color="green"
100-
size="sm"
101-
>
90+
<Link href="/search">
91+
<Button variant="outline" color="green" size="sm">
10292
Go to Search
10393
</Button>
10494
</Link>
@@ -135,27 +125,15 @@ export default function LandingHeader({
135125
{!isLoggedIn &&
136126
activeKey !== '/register' &&
137127
installation?.isTeamExisting === false && (
138-
<Link href="/register" passHref legacyBehavior>
139-
<Button
140-
component="a"
141-
variant="outline"
142-
color="green"
143-
size="sm"
144-
fullWidth
145-
>
128+
<Link href="/register">
129+
<Button variant="outline" color="green" size="sm" fullWidth>
146130
Setup Account
147131
</Button>
148132
</Link>
149133
)}
150134
{isLoggedIn && (
151-
<Link href="/search" passHref legacyBehavior>
152-
<Button
153-
component="a"
154-
variant="outline"
155-
color="green"
156-
size="sm"
157-
fullWidth
158-
>
135+
<Link href="/search">
136+
<Button variant="outline" color="green" size="sm" fullWidth>
159137
Go to Search
160138
</Button>
161139
</Link>

packages/app/src/components/DBListBarChart.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,7 @@ function ListBar({
132132
) : null;
133133

134134
return getRowSearchLink ? (
135-
<Link
136-
href={getRowSearchLink(row)}
137-
passHref
138-
legacyBehavior
139-
key={group}
140-
>
135+
<Link href={getRowSearchLink(row)} key={group}>
141136
<Box
142137
mb="sm"
143138
td="none"

packages/app/src/components/EventTag.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ export default function EventTag({
113113
</Button>
114114
)}
115115
{generateSearchUrl && (
116-
<Link
117-
href={generateSearchUrl(searchCondition, nameLanguage)}
118-
passHref
119-
legacyBehavior
120-
>
116+
<Link href={generateSearchUrl(searchCondition, nameLanguage)}>
121117
<Button
122118
justify="space-between"
123119
color="gray"

packages/app/src/components/KubeComponents.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,17 @@ const renderKubeEvent = (source: TSource) => (event: KubeEvent) => {
130130

131131
return (
132132
<Timeline.Item key={event.id}>
133-
<Link href={href} passHref legacyBehavior>
134-
<Anchor size="xs" fz={11} title={event.timestamp}>
133+
<Link href={href}>
134+
<Text
135+
size="xs"
136+
fz={11}
137+
title={event.timestamp}
138+
c="green"
139+
td="underline"
140+
fw="bold"
141+
>
135142
<FormatTime value={event.timestamp} />
136-
</Anchor>
143+
</Text>
137144
</Link>
138145
<Group gap="xs" my={4}>
139146
<Text size="sm" fz={12} c="white" fw="bold">

0 commit comments

Comments
 (0)