|
39 | 39 | let showDelete = false;
|
40 | 40 | let selectedRecord: Models.DnsRecord = null;
|
41 | 41 |
|
42 |
| - function formatRecordName(name: string) { |
43 |
| - const limit = 30; |
| 42 | + function formatName(name: string, limit: number = 30) { |
44 | 43 | return {
|
45 |
| - value: name.length > limit ? `${name.slice(0, limit)}...` : name, |
46 |
| - truncated: name.length > limit, |
47 |
| - whole: name |
| 44 | + value: name ? (name.length > limit ? `${name.slice(0, limit)}...` : name) : '-', |
| 45 | + truncated: name ? name.length > limit : undefined, |
| 46 | + whole: name ?? '-' |
48 | 47 | };
|
49 | 48 | }
|
50 | 49 | </script>
|
|
65 | 64 | {#each $columns as column}
|
66 | 65 | <Table.Cell column={column.id} {root}>
|
67 | 66 | {#if column.id === 'name'}
|
68 |
| - {@const formatted = formatRecordName(record.name)} |
| 67 | + {@const formatted = formatName(record.name)} |
69 | 68 | <Tooltip placement="bottom" disabled={!formatted.truncated}>
|
70 | 69 | <Typography.Text truncate>{formatted.value}</Typography.Text>
|
71 | 70 | <span
|
|
99 | 98 | </Typography.Text>
|
100 | 99 | {:else if column.id === 'comment'}
|
101 | 100 | <Typography.Text truncate>
|
102 |
| - {record?.comment ?? '-'} |
| 101 | + {@const formatted = formatName(record?.comment)} |
| 102 | + <Tooltip |
| 103 | + placement="bottom" |
| 104 | + maxWidth="fit-content" |
| 105 | + disabled={!formatted.truncated}> |
| 106 | + <Typography.Text truncate>{formatted.value}</Typography.Text> |
| 107 | + <span |
| 108 | + slot="tooltip" |
| 109 | + let:showing |
| 110 | + style:white-space="pre-wrap" |
| 111 | + style:word-break="break-all"> |
| 112 | + {#if showing} |
| 113 | + {formatted.whole} |
| 114 | + {/if} |
| 115 | + </span> |
| 116 | + </Tooltip> |
103 | 117 | </Typography.Text>
|
104 | 118 | {:else if column.id === '$createdAt'}
|
105 | 119 | <DualTimeView time={record.$createdAt} />
|
|
0 commit comments