24
24
25
25
import React , { useContext , useEffect , useState } from "react"
26
26
import styled from "styled-components"
27
+ import { ErrorWarning } from '@styled-icons/remix-line'
27
28
import { Tree , collapseTransition } from "../../../components"
28
29
import { TreeNode , TreeNodeRenderParams , Text } from "../../../components"
29
30
import { ContextMenuTrigger } from "../../../components/ContextMenu"
@@ -34,6 +35,8 @@ import { useSelector, useDispatch } from "react-redux"
34
35
import { actions , selectors } from "../../../store"
35
36
import { QuestContext } from "../../../providers"
36
37
import { NotificationType } from "../../../types"
38
+ import { CopyButton } from '../../../components/CopyButton'
39
+ import { IconWithTooltip } from '../../../components'
37
40
38
41
type Props = QuestDB . Table &
39
42
Readonly < {
@@ -46,6 +49,7 @@ type Props = QuestDB.Table &
46
49
onChange : ( name : string ) => void
47
50
walTableData ?: QuestDB . WalTable
48
51
matViewData ?: QuestDB . MaterializedView
52
+ baseTableExists ?: boolean
49
53
selected : boolean
50
54
selectOpen : boolean
51
55
onSelectToggle : ( table_name : string ) => void
@@ -55,6 +59,7 @@ const Wrapper = styled.div`
55
59
position: relative;
56
60
display: flex;
57
61
margin-top: 0.5rem;
62
+ margin-bottom: 0.5rem;
58
63
align-items: stretch;
59
64
flex-direction: column;
60
65
overflow: hidden;
@@ -90,6 +95,27 @@ const Columns = styled.div`
90
95
}
91
96
`
92
97
98
+ const SuffixWrapper = styled . div `
99
+ display: flex;
100
+ align-items: center;
101
+ justify-content: space-between;
102
+
103
+ button {
104
+ border: 0;
105
+ height: 100%;
106
+ padding: 0.3rem 0.3rem;
107
+
108
+ svg {
109
+ height: 1.3rem;
110
+ }
111
+ }
112
+ `
113
+
114
+ const WarningIcon = styled ( ErrorWarning ) `
115
+ color: ${ color ( "orange" ) } ;
116
+ height: 1.9rem;
117
+ `
118
+
93
119
const columnRender =
94
120
( {
95
121
table_id,
@@ -130,6 +156,7 @@ const Table = ({
130
156
selectOpen,
131
157
onSelectToggle,
132
158
matView,
159
+ baseTableExists,
133
160
} : Props ) => {
134
161
const { quest } = useContext ( QuestContext )
135
162
const [ columns , setColumns ] = useState < QuestDB . Column [ ] > ( )
@@ -244,6 +271,15 @@ const Table = ({
244
271
kind = "info"
245
272
name = "Base table"
246
273
value = { matViewData ?. base_table_name }
274
+ suffix = { ! baseTableExists && (
275
+ < SuffixWrapper data-hook = "base-table-warning" >
276
+ < IconWithTooltip
277
+ icon = { < WarningIcon /> }
278
+ placement = "top"
279
+ tooltip = "Base table has been dropped"
280
+ />
281
+ </ SuffixWrapper >
282
+ ) }
247
283
/>
248
284
)
249
285
} )
@@ -259,6 +295,11 @@ const Table = ({
259
295
name = "Query"
260
296
value = { response . data [ 0 ] . ddl }
261
297
copyable = { true }
298
+ suffix = {
299
+ < SuffixWrapper >
300
+ < CopyButton text = { response . data [ 0 ] . ddl } iconOnly = { true } />
301
+ </ SuffixWrapper >
302
+ }
262
303
/>
263
304
)
264
305
} )
0 commit comments