1
- import { PinFilledIcon , PinIcon } from '@sanity/icons'
1
+ import { ErrorOutlineIcon , PinFilledIcon , PinIcon } from '@sanity/icons'
2
2
import {
3
3
Box ,
4
4
// Custom button with full radius used here
5
5
// eslint-disable-next-line no-restricted-imports
6
6
Button ,
7
+ Card ,
7
8
Container ,
8
9
Flex ,
9
10
Stack ,
11
+ Text ,
10
12
} from '@sanity/ui'
11
13
import { useCallback } from 'react'
12
14
15
+ import { ToneIcon } from '../../../../ui-components/toneIcon/ToneIcon'
16
+ import { TextWithTone } from '../../../components/textWithTone/TextWithTone'
17
+ import { Details } from '../../../form/components/Details'
13
18
import { useTranslation } from '../../../i18n'
14
19
import { usePerspective } from '../../../perspective/usePerspective'
15
20
import { useSetPerspective } from '../../../perspective/useSetPerspective'
@@ -28,6 +33,7 @@ export function ReleaseDashboardDetails({release}: {release: ReleaseDocument}) {
28
33
const { selectedReleaseId} = usePerspective ( )
29
34
const setPerspective = useSetPerspective ( )
30
35
const isSelected = releaseId === selectedReleaseId
36
+ const shouldDisplayError = release . state === 'active' && typeof release . error !== 'undefined'
31
37
32
38
const handlePinRelease = useCallback ( ( ) => {
33
39
if ( isSelected ) {
@@ -40,7 +46,7 @@ export function ReleaseDashboardDetails({release}: {release: ReleaseDocument}) {
40
46
return (
41
47
< Container width = { 3 } >
42
48
< Stack padding = { 3 } paddingY = { [ 4 , 4 , 5 , 6 ] } space = { [ 3 , 3 , 4 , 5 ] } >
43
- < Flex gap = { 1 } >
49
+ < Flex gap = { 1 } align = "center" >
44
50
< Button
45
51
disabled = { state === 'archived' || state === 'published' }
46
52
icon = { isSelected ? PinFilledIcon : PinIcon }
@@ -54,11 +60,37 @@ export function ReleaseDashboardDetails({release}: {release: ReleaseDocument}) {
54
60
tone = { getReleaseTone ( release ) }
55
61
/>
56
62
< ReleaseTypePicker release = { release } />
63
+ { shouldDisplayError && (
64
+ < Flex gap = { 2 } padding = { 2 } data-testid = "release-error-details" >
65
+ < Text size = { 1 } >
66
+ < ToneIcon icon = { ErrorOutlineIcon } tone = "critical" />
67
+ </ Text >
68
+ < TextWithTone size = { 1 } tone = "critical" >
69
+ { tRelease ( 'failed-publish-title' ) }
70
+ </ TextWithTone >
71
+ </ Flex >
72
+ ) }
57
73
</ Flex >
58
-
59
74
< Box padding = { 2 } >
60
75
< ReleaseDetailsEditor release = { release } />
61
76
</ Box >
77
+ { shouldDisplayError && (
78
+ < Card padding = { 4 } radius = { 4 } tone = "critical" >
79
+ < Flex gap = { 3 } >
80
+ < Text size = { 1 } >
81
+ < ErrorOutlineIcon />
82
+ </ Text >
83
+ < Stack space = { 4 } >
84
+ < Text > { tRelease ( 'failed-publish-title' ) } </ Text >
85
+ < Details title = { tRelease ( 'error-details-title' ) } >
86
+ < Text >
87
+ < code > { release . error ?. message } </ code >
88
+ </ Text >
89
+ </ Details >
90
+ </ Stack >
91
+ </ Flex >
92
+ </ Card >
93
+ ) }
62
94
</ Stack >
63
95
</ Container >
64
96
)
0 commit comments