11import type { IFlow } from '@plumber/types'
22
33import { ReactElement } from 'react'
4+ import { BiChevronRight } from 'react-icons/bi'
45import { Link } from 'react-router-dom'
56import {
67 Card ,
@@ -9,6 +10,7 @@ import {
910 Grid ,
1011 GridItem ,
1112 HStack ,
13+ Icon ,
1214 Text ,
1315 VStack ,
1416} from '@chakra-ui/react'
@@ -22,10 +24,18 @@ import FlowContextMenu from './FlowContextMenu'
2224
2325type FlowRowProps = {
2426 flow : IFlow
27+ isExecution ?: boolean
28+ showMenu ?: boolean
29+ showTimestamp ?: boolean
2530}
2631
2732export default function FlowRow ( props : FlowRowProps ) : ReactElement {
28- const { flow } = props
33+ const {
34+ flow,
35+ showMenu = true ,
36+ showTimestamp = true ,
37+ isExecution = false ,
38+ } = props
2939
3040 const createdAt = DateTime . fromMillis ( parseInt ( flow . createdAt , 10 ) )
3141 const updatedAt = DateTime . fromMillis ( parseInt ( flow . updatedAt , 10 ) )
@@ -42,12 +52,18 @@ export default function FlowRow(props: FlowRowProps): ReactElement {
4252 borderRadius = { 0 }
4353 borderBottom = "1px solid"
4454 borderBottomColor = "base.divider.medium"
55+ minH = { 100 }
4556 >
4657 < CardBody
4758 sx = { { cursor : 'pointer' } }
4859 p = { 0 }
4960 as = { Link }
50- to = { URLS . FLOW ( flow . id ) }
61+ to = {
62+ isExecution ? URLS . EXECUTIONS_FOR_FLOW ( flow . id ) : URLS . FLOW ( flow . id )
63+ }
64+ display = "flex"
65+ alignItems = "center"
66+ justifyContent = "stretch"
5167 >
5268 < Grid
5369 templateAreas = { {
@@ -63,6 +79,7 @@ export default function FlowRow(props: FlowRowProps): ReactElement {
6379 md : 'calc(30px * 3 + 8px * 2) minmax(0, auto) min-content' ,
6480 } }
6581 gap = { 6 }
82+ flex = { 1 }
6683 alignItems = "center"
6784 py = { 6 }
6885 px = { { base : 3 , md : 8 } }
@@ -90,16 +107,18 @@ export default function FlowRow(props: FlowRowProps): ReactElement {
90107 >
91108 { flow ?. name }
92109 </ Text >
93- < Text
94- display = "inline-block"
95- w = "100%"
96- maxW = "85%"
97- color = "base.content.medium"
98- textStyle = "body-2"
99- >
100- { isUpdated && `updated ${ relativeUpdatedAt } ` }
101- { ! isUpdated && `created ${ relativeCreatedAt } ` }
102- </ Text >
110+ { showTimestamp && (
111+ < Text
112+ display = "inline-block"
113+ w = "100%"
114+ maxW = "85%"
115+ color = "base.content.medium"
116+ textStyle = "body-2"
117+ >
118+ { isUpdated && `updated ${ relativeUpdatedAt } ` }
119+ { ! isUpdated && `created ${ relativeCreatedAt } ` }
120+ </ Text >
121+ ) }
103122 </ VStack >
104123 </ GridItem >
105124 < GridItem area = "menu" >
@@ -111,7 +130,11 @@ export default function FlowRow(props: FlowRowProps): ReactElement {
111130 < Text > { flow ?. active ? 'Published' : 'Draft' } </ Text >
112131 </ Badge >
113132
114- < FlowContextMenu flow = { flow } />
133+ { showMenu ? (
134+ < FlowContextMenu flow = { flow } />
135+ ) : (
136+ < Icon boxSize = { 5 } as = { BiChevronRight } />
137+ ) }
115138 </ Flex >
116139 </ GridItem >
117140 </ Grid >
0 commit comments