@@ -6,14 +6,16 @@ import {
66 TableCell ,
77 TableRow ,
88 Text ,
9- TextLink ,
109 Tooltip ,
1110} from '@contentful/f36-components' ;
11+ import { PageAppSDK } from '@contentful/app-sdk' ;
1212import { DisplayStatus } from '../../../../types/runs' ;
1313import type { RunWithStatus } from '../../../../types/runs' ;
14+ import { EntriesCreatedModal } from './EntriesCreatedModal' ;
1415
1516interface RunRowProps {
1617 run : RunWithStatus ;
18+ sdk : PageAppSDK ;
1719 spaceId : string ;
1820 webappHost : string ;
1921 onReview : ( runId : string ) => void ;
@@ -99,8 +101,9 @@ function StatusBadge({
99101 }
100102}
101103
102- export function RunRow ( { run, spaceId, webappHost, onReview, onRetry } : RunRowProps ) {
104+ export function RunRow ( { run, sdk , spaceId, webappHost, onReview, onRetry } : RunRowProps ) {
103105 const [ isRetrying , setIsRetrying ] = useState ( false ) ;
106+ const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
104107
105108 const handleRetry = async ( ) => {
106109 setIsRetrying ( true ) ;
@@ -112,98 +115,89 @@ export function RunRow({ run, spaceId, webappHost, onReview, onRetry }: RunRowPr
112115 } ;
113116
114117 return (
115- < TableRow >
116- { /* Name */ }
117- < TableCell >
118- < Text fontWeight = "fontWeightMedium" > { run . documentTitle } </ Text >
118+ < >
119+ < TableRow >
120+ { /* Name */ }
121+ < TableCell >
122+ < Text fontWeight = "fontWeightMedium" > { run . documentTitle } </ Text >
123+ </ TableCell >
119124
120- { /* Entry links for completed runs */ }
121- { run . displayStatus === DisplayStatus . COMPLETED &&
122- run . createdEntryIds &&
123- run . createdEntryIds . length > 0 && (
124- < Flex gap = "spacingXs" flexWrap = "wrap" marginTop = "spacing2Xs" >
125- { run . createdEntryIds . map ( ( entryId , index ) => (
126- < TextLink
127- key = { entryId }
128- href = { `https://${ webappHost } /spaces/${ spaceId } /entries/${ entryId } ` }
129- target = "_blank"
130- rel = "noopener noreferrer"
131- style = { { fontSize : '12px' } } >
132- { run . createdEntryIds ! . length === 1 ? 'View entry' : `Entry ${ index + 1 } ` }
133- </ TextLink >
125+ { /* Created date */ }
126+ < TableCell >
127+ < Text fontSize = "fontSizeS" fontColor = "gray600" >
128+ { formatDate ( run . startedAt ) }
129+ </ Text >
130+ </ TableCell >
131+
132+ { /* Status badge */ }
133+ < TableCell style = { { verticalAlign : 'middle' } } >
134+ < StatusBadge
135+ status = { run . displayStatus }
136+ errorMessage = { run . errorMessage }
137+ entryCount = { run . createdEntryIds ?. length }
138+ />
139+ </ TableCell >
140+
141+ { /* Action */ }
142+ < TableCell style = { { verticalAlign : 'middle' } } >
143+ { run . displayStatus === DisplayStatus . RUNNING && (
144+ < Flex gap = "spacing2Xs" alignItems = "center" >
145+ { [ 0 , 1 , 2 ] . map ( ( i ) => (
146+ < div
147+ key = { i }
148+ style = { {
149+ width : '5px' ,
150+ height : '5px' ,
151+ borderRadius : '50%' ,
152+ background : '#536171' ,
153+ animation : `driveDotBounce 1.2s ease-in-out ${ i * 0.2 } s infinite` ,
154+ } }
155+ />
134156 ) ) }
157+ < style > { `
158+ @keyframes driveDotBounce {
159+ 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
160+ 40% { transform: translateY(-5px); opacity: 1; }
161+ }
162+ ` } </ style >
135163 </ Flex >
136164 ) }
137- </ TableCell >
138-
139- { /* Created date */ }
140- < TableCell >
141- < Text fontSize = "fontSizeS" fontColor = "gray600" >
142- { formatDate ( run . startedAt ) }
143- </ Text >
144- </ TableCell >
165+ { run . displayStatus === DisplayStatus . NEEDS_REVIEW && (
166+ < Button variant = "secondary" size = "small" onClick = { ( ) => onReview ( run . runId ) } >
167+ Review
168+ </ Button >
169+ ) }
170+ { run . displayStatus === DisplayStatus . COMPLETED &&
171+ run . createdEntryIds &&
172+ run . createdEntryIds . length > 0 && (
173+ < Button variant = "secondary" size = "small" onClick = { ( ) => setIsModalOpen ( true ) } >
174+ View
175+ </ Button >
176+ ) }
177+ { ( run . displayStatus === DisplayStatus . FAILED ||
178+ run . displayStatus === DisplayStatus . EXPIRED ) && (
179+ < Button
180+ variant = "secondary"
181+ size = "small"
182+ onClick = { ( ) => void handleRetry ( ) }
183+ isLoading = { isRetrying }
184+ isDisabled = { isRetrying } >
185+ Retry
186+ </ Button >
187+ ) }
188+ </ TableCell >
189+ </ TableRow >
145190
146- { /* Status badge */ }
147- < TableCell style = { { verticalAlign : 'middle' } } >
148- < StatusBadge
149- status = { run . displayStatus }
150- errorMessage = { run . errorMessage }
151- entryCount = { run . createdEntryIds ?. length }
191+ { run . createdEntryIds && run . createdEntryIds . length > 0 && (
192+ < EntriesCreatedModal
193+ isOpen = { isModalOpen }
194+ onClose = { ( ) => setIsModalOpen ( false ) }
195+ sdk = { sdk }
196+ spaceId = { spaceId }
197+ webappHost = { webappHost }
198+ entryIds = { run . createdEntryIds }
152199 />
153- </ TableCell >
154-
155- { /* Action */ }
156- < TableCell style = { { verticalAlign : 'middle' } } >
157- { run . displayStatus === DisplayStatus . RUNNING && (
158- < Flex gap = "spacing2Xs" alignItems = "center" >
159- { [ 0 , 1 , 2 ] . map ( ( i ) => (
160- < div
161- key = { i }
162- style = { {
163- width : '5px' ,
164- height : '5px' ,
165- borderRadius : '50%' ,
166- background : '#536171' ,
167- animation : `driveDotBounce 1.2s ease-in-out ${ i * 0.2 } s infinite` ,
168- } }
169- />
170- ) ) }
171- < style > { `
172- @keyframes driveDotBounce {
173- 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
174- 40% { transform: translateY(-5px); opacity: 1; }
175- }
176- ` } </ style >
177- </ Flex >
178- ) }
179- { run . displayStatus === DisplayStatus . NEEDS_REVIEW && (
180- < Button variant = "secondary" size = "small" onClick = { ( ) => onReview ( run . runId ) } >
181- Review
182- </ Button >
183- ) }
184- { run . displayStatus === DisplayStatus . COMPLETED && run . createdEntryIds ?. length === 1 && (
185- < Button
186- as = "a"
187- variant = "secondary"
188- size = "small"
189- href = { `https://${ webappHost } /spaces/${ spaceId } /entries/${ run . createdEntryIds [ 0 ] } ` }
190- target = "_blank"
191- rel = "noopener noreferrer" >
192- View
193- </ Button >
194- ) }
195- { ( run . displayStatus === DisplayStatus . FAILED ||
196- run . displayStatus === DisplayStatus . EXPIRED ) && (
197- < Button
198- variant = "secondary"
199- size = "small"
200- onClick = { ( ) => void handleRetry ( ) }
201- isLoading = { isRetrying }
202- isDisabled = { isRetrying } >
203- Retry
204- </ Button >
205- ) }
206- </ TableCell >
207- </ TableRow >
200+ ) }
201+ </ >
208202 ) ;
209203}
0 commit comments