Skip to content

Commit e51fcfa

Browse files
committed
Handle longer tags in dialog title
1 parent 9e8153d commit e51fcfa

5 files changed

Lines changed: 74 additions & 15 deletions

File tree

src/features/dashboard/templates/tags/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export { TagDialogBuildRow } from './tag-dialog-build-row'
22
export { TagDialogFooter, type TagDialogStage } from './tag-dialog-footer'
33
export { TagDialogStageTransition } from './tag-dialog-stage-transition'
44
export { TagDialogSuccess } from './tag-dialog-success'
5+
export { TagDialogTitle } from './tag-dialog-title'

src/features/dashboard/templates/tags/components/tag-dialog-success.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { cn } from '@/lib/utils/ui'
44
import { CheckIcon } from '@/ui/primitives/icons'
5+
import { MiddleTruncate } from '@/ui/primitives/middle-truncate'
56

67
interface TagDialogSuccessProps {
78
tag: string
@@ -22,9 +23,15 @@ export function TagDialogSuccess({
2223
)}
2324
>
2425
<CheckIcon className="size-12 text-accent-positive-highlight" />
25-
<p className="prose-headline-small uppercase text-fg">
26-
<span className="font-mono">{tag}</span>
27-
<br />
26+
<p className="prose-headline-small text-fg max-w-full uppercase">
27+
<span
28+
className="flex max-w-full items-baseline justify-center font-mono"
29+
title={`‘${tag}’`}
30+
>
31+
<span className="shrink-0"></span>
32+
<MiddleTruncate tail={10} text={tag} className="min-w-0" />
33+
<span className="shrink-0"></span>
34+
</span>
2835
{message}
2936
</p>
3037
</div>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use client'
2+
3+
import { cn } from '@/lib/utils/ui'
4+
import { DialogTitle } from '@/ui/primitives/dialog'
5+
import { MiddleTruncate } from '@/ui/primitives/middle-truncate'
6+
7+
interface TagDialogTitleProps {
8+
prefix?: string
9+
tag: string
10+
suffix?: string
11+
className?: string
12+
srOnly?: boolean
13+
}
14+
15+
export function TagDialogTitle({
16+
prefix,
17+
tag,
18+
suffix,
19+
className,
20+
srOnly,
21+
}: TagDialogTitleProps) {
22+
if (srOnly) {
23+
return (
24+
<DialogTitle className="sr-only">
25+
{prefix}{tag}{suffix}
26+
</DialogTitle>
27+
)
28+
}
29+
30+
return (
31+
<DialogTitle
32+
className={cn('flex min-w-0 items-baseline pr-6', className)}
33+
title={`${prefix ?? ''}${tag}${suffix ?? ''}`}
34+
>
35+
{prefix ? (
36+
<span className="shrink-0 whitespace-pre">{prefix}</span>
37+
) : null}
38+
<span className="shrink-0"></span>
39+
<MiddleTruncate text={tag} className="min-w-0 font-mono" />
40+
<span className="shrink-0"></span>
41+
{suffix ? (
42+
<span className="shrink-0 whitespace-pre">{suffix}</span>
43+
) : null}
44+
</DialogTitle>
45+
)
46+
}

src/features/dashboard/templates/tags/reassign-dialog.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
DialogContent,
77
DialogDescription,
88
DialogHeader,
9-
DialogTitle,
109
} from '@/ui/primitives/dialog'
1110
import { ArrowDivider } from './arrow-divider'
1211
import BuildPicker, { type BuildSelectionSource } from './build-picker'
@@ -15,6 +14,7 @@ import {
1514
TagDialogFooter,
1615
TagDialogStageTransition,
1716
TagDialogSuccess,
17+
TagDialogTitle,
1818
} from './components'
1919
import { trackTagTableInteraction } from './table-config'
2020
import { useTagAssignmentMutation } from './use-tag-assignment-mutation'
@@ -138,11 +138,11 @@ function ReassignTagDialogBody({
138138
return (
139139
<TagDialogStageTransition phase={stage === 'success' ? 'success' : 'form'}>
140140
<DialogHeader>
141-
<DialogTitle className={stage === 'success' ? 'sr-only' : undefined}>
142-
{stage === 'success'
143-
? `‘${tag}’ reassigned successfully`
144-
: `reassign ${tag}’`}
145-
</DialogTitle>
141+
{stage === 'success' ? (
142+
<TagDialogTitle srOnly tag={tag} suffix=" reassigned successfully" />
143+
) : (
144+
<TagDialogTitle prefix="reassign " tag={tag} />
145+
)}
146146
<DialogDescription className="sr-only">
147147
{stage === 'success'
148148
? `Tag ${tag} reassigned.`

src/features/dashboard/templates/tags/rollback-dialog.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import {
66
DialogContent,
77
DialogDescription,
88
DialogHeader,
9-
DialogTitle,
109
} from '@/ui/primitives/dialog'
1110
import { ArrowDivider } from './arrow-divider'
1211
import {
1312
TagDialogBuildRow,
1413
TagDialogFooter,
1514
TagDialogStageTransition,
1615
TagDialogSuccess,
16+
TagDialogTitle,
1717
} from './components'
1818
import { trackTagTableInteraction } from './table-config'
1919
import { useTagAssignmentMutation } from './use-tag-assignment-mutation'
@@ -115,11 +115,16 @@ function RollbackTagDialogBody({
115115
return (
116116
<TagDialogStageTransition phase={stage === 'success' ? 'success' : 'form'}>
117117
<DialogHeader>
118-
<DialogTitle className={stage === 'success' ? 'sr-only' : undefined}>
119-
{stage === 'success'
120-
? `Rollback ‘${tag}’ succeeded`
121-
: `Rollback ‘${tag}’`}
122-
</DialogTitle>
118+
{stage === 'success' ? (
119+
<TagDialogTitle
120+
srOnly
121+
prefix="Rollback "
122+
tag={tag}
123+
suffix=" succeeded"
124+
/>
125+
) : (
126+
<TagDialogTitle prefix="Rollback " tag={tag} />
127+
)}
123128
<DialogDescription className="sr-only">
124129
{stage === 'success'
125130
? `Tag ${tag} rolled back to build ${targetBuildId}.`

0 commit comments

Comments
 (0)