Skip to content

Commit 0c52c30

Browse files
authored
feat: format IPv6 and adjust style (#1562)
1 parent 1492ed4 commit 0c52c30

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/helpers/global.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
export const transformEndpointURL = (url: string) =>
22
/^https?:\/\//.test(url) ? url : `${window.location.protocol}//${url}`
33

4+
export const formatIPv6 = (ip: string) => {
5+
const regexr = /:{1,2}/
6+
7+
if (regexr.test(ip)) {
8+
return `[${ip}]`
9+
} else {
10+
return ip
11+
}
12+
}
13+
414
export const useStringBooleanMap = () => {
515
const [map, setMap] = createSignal<Record<string, boolean>>({})
616
const set = (name: string, value: boolean) => {

src/pages/Connections.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { writeClipboard } from '@solid-primitives/clipboard'
22
import { makePersisted } from '@solid-primitives/storage'
33
import {
4+
IconChevronRight,
45
IconInfoSmall,
56
IconPlayerPause,
67
IconPlayerPlay,
@@ -37,7 +38,7 @@ import {
3738
DocumentTitle,
3839
} from '~/components'
3940
import { CONNECTIONS_TABLE_ACCESSOR_KEY } from '~/constants'
40-
import { formatTimeFromNow } from '~/helpers'
41+
import { formatIPv6, formatTimeFromNow } from '~/helpers'
4142
import { useI18n } from '~/i18n'
4243
import {
4344
allConnections,
@@ -167,7 +168,7 @@ export default () => {
167168
`${
168169
original.metadata.host
169170
? original.metadata.host
170-
: original.metadata.destinationIP
171+
: formatIPv6(original.metadata.destinationIP)
171172
}:${original.metadata.destinationPort}`,
172173
},
173174
{
@@ -181,12 +182,23 @@ export default () => {
181182
accessorFn: (original) =>
182183
!original.rulePayload
183184
? original.rule
184-
: `${original.rule} :: ${original.rulePayload}`,
185+
: `${original.rule} : ${original.rulePayload}`,
185186
},
186187
{
187188
header: () => t('chains'),
188189
accessorKey: CONNECTIONS_TABLE_ACCESSOR_KEY.Chains,
189-
accessorFn: (original) => original.chains.slice().reverse().join(' :: '),
190+
cell: ({ row }) => (
191+
<For each={row.original.chains.slice().reverse()}>
192+
{(name, index) => (
193+
<>
194+
<Show when={index()}>
195+
<IconChevronRight class="inline-block" size={18} />
196+
</Show>
197+
<span class="align-middle">{name}</span>
198+
</>
199+
)}
200+
</For>
201+
),
190202
},
191203
{
192204
header: () => t('connectTime'),

0 commit comments

Comments
 (0)