@@ -5,7 +5,14 @@ import { MdOutlineRemoveRedEye } from 'react-icons/md'
55import { Link } from 'react-router-dom'
66import { useMutation } from '@apollo/client'
77import {
8+ AlertDialog ,
9+ AlertDialogBody ,
10+ AlertDialogContent ,
11+ AlertDialogFooter ,
12+ AlertDialogHeader ,
13+ AlertDialogOverlay ,
814 Box ,
15+ Button ,
916 Divider ,
1017 Flex ,
1118 Icon ,
@@ -22,7 +29,6 @@ import {
2229 useToast ,
2330} from '@opengovsg/design-system-react'
2431
25- import MenuAlertDialog from '@/components/MenuAlertDialog'
2632import * as URLS from '@/config/urls'
2733import type { TableMetadata } from '@/graphql/__generated__/graphql'
2834import { DELETE_TABLE } from '@/graphql/mutations/tiles/delete-table'
@@ -31,6 +37,14 @@ import { toPrettyDateString } from '@/helpers/dateTime'
3137
3238import { TileConnections } from '..'
3339
40+ import {
41+ flexStyles ,
42+ linkStyles ,
43+ pulsingDotStyles ,
44+ tagStyles ,
45+ textStyles ,
46+ } from './style'
47+
3448const TileListItem = ( {
3549 isConnectionsLoading,
3650 numConnections,
@@ -81,46 +95,32 @@ const TileListItem = ({
8195
8296 return (
8397 < Link to = { URLS . TILE ( table . id ) } >
84- < Flex
85- px = { 8 }
86- py = { 6 }
87- w = "100%"
88- justifyContent = "space-between"
89- alignItems = "center"
90- _hover = { {
91- bg : 'interaction.muted.neutral.hover' ,
92- '& .hover-remove-button' : {
93- visibility : 'visible' ,
94- } ,
95- } }
96- _active = { {
97- bg : 'interaction.muted.neutral.active' ,
98- } }
99- >
98+ < Flex { ...linkStyles } >
10099 < Box >
101- < Text textStyle = "h6" > { table . name } </ Text >
102- < Flex gap = { 1 } textStyle = "body-2" color = "base.content.medium" >
103- < Text > Last opened { toPrettyDateString ( + table . lastAccessedAt ) } </ Text >
104- { table . role !== 'viewer' && numConnections && (
105- < >
106- < Icon as = { BsDot } fontSize = "1.5em" />
107- < Skeleton isLoaded = { ! isConnectionsLoading } >
100+ < Flex alignItems = "center" >
101+ < Text textStyle = "h6" > { table . name } </ Text >
102+ </ Flex >
103+ < Flex { ...flexStyles . container } >
104+ < Text { ...textStyles . lastOpened } >
105+ Last opened { toPrettyDateString ( + table . lastAccessedAt ) }
106+ </ Text >
107+ { table . role !== 'viewer' && numConnections > 0 && (
108+ < Skeleton isLoaded = { ! isConnectionsLoading } >
109+ < Flex { ...flexStyles . usedInPipes } >
110+ < Icon
111+ as = { BsDot }
112+ color = "interaction.success.default"
113+ sx = { pulsingDotStyles }
114+ />
108115 < Text > Used in { numConnections } pipes</ Text >
109- </ Skeleton >
110- </ >
116+ </ Flex >
117+ </ Skeleton >
111118 ) }
112119 </ Flex >
113120 </ Box >
114121 < Flex alignItems = "center" gap = { 4 } >
115122 { table . role === 'viewer' && (
116- < Tag
117- colorScheme = "secondary"
118- size = "xs"
119- variant = "subtle"
120- py = { 2 }
121- gap = { 1 }
122- pointerEvents = "none"
123- >
123+ < Tag { ...tagStyles } >
124124 < TagLeftIcon as = { MdOutlineRemoveRedEye } />
125125 < TagLabel > View only</ TagLabel >
126126 </ Tag >
@@ -137,15 +137,42 @@ const TileListItem = ({
137137 ) }
138138 </ Flex >
139139 </ Flex >
140- < MenuAlertDialog
141- isDialogOpen = { isDialogOpen }
142- cancelRef = { cancelRef }
143- onDialogClose = { onDialogClose }
144- dialogHeader = "Tile"
145- dialogType = "delete"
146- onClick = { deleteTile }
147- isLoading = { isDeletingTable }
148- />
140+ < AlertDialog
141+ isOpen = { isDialogOpen }
142+ leastDestructiveRef = { cancelRef }
143+ onClose = { onDialogClose }
144+ >
145+ < AlertDialogOverlay >
146+ < AlertDialogContent >
147+ < AlertDialogHeader > Delete Tile</ AlertDialogHeader >
148+
149+ < AlertDialogBody >
150+ { numConnections > 0
151+ ? `Are you sure? This Tile is used in ${ numConnections } pipe(s). You can't undo this action afterwards.`
152+ : "Are you sure? You can't undo this action afterwards." }
153+ </ AlertDialogBody >
154+
155+ < AlertDialogFooter >
156+ < Button
157+ ref = { cancelRef }
158+ onClick = { onDialogClose }
159+ variant = "clear"
160+ colorScheme = "secondary"
161+ >
162+ Cancel
163+ </ Button >
164+ < Button
165+ colorScheme = "critical"
166+ onClick = { deleteTile }
167+ ml = { 3 }
168+ isLoading = { isDeletingTable }
169+ >
170+ Delete
171+ </ Button >
172+ </ AlertDialogFooter >
173+ </ AlertDialogContent >
174+ </ AlertDialogOverlay >
175+ </ AlertDialog >
149176 </ Link >
150177 )
151178}
0 commit comments