Skip to content

Commit 047c111

Browse files
committed
add: tooltip for comment.
1 parent 2de6a1e commit 047c111

File tree

1 file changed

+21
-7
lines changed
  • src/routes/(console)/organization-[organization]/domains/domain-[domain]

1 file changed

+21
-7
lines changed

src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@
3939
let showDelete = false;
4040
let selectedRecord: Models.DnsRecord = null;
4141
42-
function formatRecordName(name: string) {
43-
const limit = 30;
42+
function formatName(name: string, limit: number = 30) {
4443
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 ?? '-'
4847
};
4948
}
5049
</script>
@@ -65,7 +64,7 @@
6564
{#each $columns as column}
6665
<Table.Cell column={column.id} {root}>
6766
{#if column.id === 'name'}
68-
{@const formatted = formatRecordName(record.name)}
67+
{@const formatted = formatName(record.name)}
6968
<Tooltip placement="bottom" disabled={!formatted.truncated}>
7069
<Typography.Text truncate>{formatted.value}</Typography.Text>
7170
<span
@@ -99,7 +98,22 @@
9998
</Typography.Text>
10099
{:else if column.id === 'comment'}
101100
<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>
103117
</Typography.Text>
104118
{:else if column.id === '$createdAt'}
105119
<DualTimeView time={record.$createdAt} />

0 commit comments

Comments
 (0)