@postgres.ai/shared 3.5.1-pr-1027.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/.gitlab-ci.yml +60 -0
  2. package/components/AlertSnackbar/index.tsx +23 -0
  3. package/components/AlertSnackbar/useAlertSnackbar.tsx +65 -0
  4. package/components/Button/index.tsx +79 -0
  5. package/components/Button2/index.tsx +43 -0
  6. package/components/Button2/styles.module.scss +82 -0
  7. package/components/DestroyCloneModal/index.tsx +56 -0
  8. package/components/DestroyCloneRestrictionModal/index.tsx +50 -0
  9. package/components/ErrorStub/index.tsx +83 -0
  10. package/components/FormattedText/index.tsx +44 -0
  11. package/components/FormattedText/styles.module.scss +34 -0
  12. package/components/GatewayLink/index.tsx +33 -0
  13. package/components/HorizontalScrollContainer/index.tsx +131 -0
  14. package/components/HorizontalScrollContainer/types.ts +12 -0
  15. package/components/HorizontalScrollContainer/utils.ts +16 -0
  16. package/components/ImportantText/index.tsx +29 -0
  17. package/components/Link2/index.tsx +31 -0
  18. package/components/Link2/styles.module.scss +12 -0
  19. package/components/MenuButton/index.tsx +80 -0
  20. package/components/MenuButton/styles.module.scss +42 -0
  21. package/components/Modal/index.tsx +93 -0
  22. package/components/PageSpinner/index.tsx +18 -0
  23. package/components/PageSpinner/styles.module.scss +13 -0
  24. package/components/ResetCloneModal/index.tsx +154 -0
  25. package/components/SectionTitle/index.tsx +74 -0
  26. package/components/Select/index.tsx +42 -0
  27. package/components/SimpleModalControls/index.tsx +56 -0
  28. package/components/Spinner/icon.tsx +29 -0
  29. package/components/Spinner/index.tsx +16 -0
  30. package/components/Spinner/styles.module.scss +33 -0
  31. package/components/Status/index.tsx +61 -0
  32. package/components/Status/styles.module.scss +45 -0
  33. package/components/StubContainer/index.tsx +41 -0
  34. package/components/StubSpinner/index.tsx +49 -0
  35. package/components/StubSpinnerFlex/index.tsx +20 -0
  36. package/components/StubSpinnerFlex/styles.module.scss +20 -0
  37. package/components/SyntaxHighlight/index.tsx +107 -0
  38. package/components/Table/RowMenu/index.tsx +111 -0
  39. package/components/Table/index.tsx +140 -0
  40. package/components/Text/index.tsx +28 -0
  41. package/components/TextField/index.tsx +117 -0
  42. package/components/Tooltip/index.tsx +52 -0
  43. package/config/index.ts +32 -0
  44. package/config/links.ts +6 -0
  45. package/craco.config.js +80 -0
  46. package/helpers/getEntropy.ts +232 -0
  47. package/helpers/localStorage.ts +15 -0
  48. package/helpers/request.ts +47 -0
  49. package/hooks/useWindowDimensions.ts +16 -0
  50. package/icons/ArrowDropDown/index.tsx +29 -0
  51. package/icons/Circle/index.tsx +27 -0
  52. package/icons/External/index.tsx +14 -0
  53. package/icons/Info/index.tsx +12 -0
  54. package/icons/Renewable/index.tsx +65 -0
  55. package/icons/Shield/index.tsx +33 -0
  56. package/icons/Warning/index.tsx +29 -0
  57. package/meta.json +1 -0
  58. package/package.json +55 -0
  59. package/pages/Clone/Status/index.tsx +73 -0
  60. package/pages/Clone/context.ts +22 -0
  61. package/pages/Clone/index.tsx +634 -0
  62. package/pages/Clone/stores/Main.ts +206 -0
  63. package/pages/Clone/useCreatedStores.ts +11 -0
  64. package/pages/Configuration/Header/index.tsx +84 -0
  65. package/pages/Configuration/InputWithTooltip/index.tsx +240 -0
  66. package/pages/Configuration/ResponseMessage/index.tsx +71 -0
  67. package/pages/Configuration/configOptions.ts +60 -0
  68. package/pages/Configuration/index.tsx +1184 -0
  69. package/pages/Configuration/styles.module.scss +122 -0
  70. package/pages/Configuration/tooltipText.tsx +157 -0
  71. package/pages/Configuration/useForm.ts +108 -0
  72. package/pages/Configuration/utils/index.ts +153 -0
  73. package/pages/CreateClone/index.tsx +311 -0
  74. package/pages/CreateClone/stores/Main.ts +107 -0
  75. package/pages/CreateClone/styles.module.scss +71 -0
  76. package/pages/CreateClone/useCreatedStores.ts +11 -0
  77. package/pages/CreateClone/useForm.ts +36 -0
  78. package/pages/Instance/Clones/Header/Item/index.tsx +15 -0
  79. package/pages/Instance/Clones/Header/Item/styles.module.scss +17 -0
  80. package/pages/Instance/Clones/Header/index.tsx +74 -0
  81. package/pages/Instance/Clones/Header/styles.module.scss +11 -0
  82. package/pages/Instance/Clones/index.tsx +135 -0
  83. package/pages/Instance/ClonesModal/index.tsx +71 -0
  84. package/pages/Instance/ClonesModal/utils.ts +21 -0
  85. package/pages/Instance/InactiveInstance/index.tsx +165 -0
  86. package/pages/Instance/InactiveInstance/utils.ts +9 -0
  87. package/pages/Instance/Info/Connection/ConnectModal/Content/index.tsx +176 -0
  88. package/pages/Instance/Info/Connection/ConnectModal/Content/utils.ts +24 -0
  89. package/pages/Instance/Info/Connection/ConnectModal/index.tsx +36 -0
  90. package/pages/Instance/Info/Connection/index.tsx +81 -0
  91. package/pages/Instance/Info/Details/index.tsx +20 -0
  92. package/pages/Instance/Info/Disks/Disk/ActionsMenu/index.tsx +100 -0
  93. package/pages/Instance/Info/Disks/Disk/Marker/index.tsx +26 -0
  94. package/pages/Instance/Info/Disks/Disk/ProgressBar/PointerIcon.tsx +20 -0
  95. package/pages/Instance/Info/Disks/Disk/ProgressBar/index.tsx +73 -0
  96. package/pages/Instance/Info/Disks/Disk/Status/index.tsx +75 -0
  97. package/pages/Instance/Info/Disks/Disk/index.tsx +168 -0
  98. package/pages/Instance/Info/Disks/index.tsx +65 -0
  99. package/pages/Instance/Info/Icons/index.tsx +39 -0
  100. package/pages/Instance/Info/Retrieval/RefreshFailedAlert/index.tsx +32 -0
  101. package/pages/Instance/Info/Retrieval/RefreshFailedAlert/styles.module.scss +33 -0
  102. package/pages/Instance/Info/Retrieval/RetrievalModal/index.tsx +49 -0
  103. package/pages/Instance/Info/Retrieval/RetrievalModal/styles.module.scss +6 -0
  104. package/pages/Instance/Info/Retrieval/RetrievalTable/index.tsx +53 -0
  105. package/pages/Instance/Info/Retrieval/RetrievalTable/styles.module.scss +29 -0
  106. package/pages/Instance/Info/Retrieval/index.tsx +95 -0
  107. package/pages/Instance/Info/Retrieval/utils.ts +10 -0
  108. package/pages/Instance/Info/Snapshots/Calendar/Day/index.tsx +125 -0
  109. package/pages/Instance/Info/Snapshots/Calendar/index.tsx +133 -0
  110. package/pages/Instance/Info/Snapshots/Calendar/utils.ts +74 -0
  111. package/pages/Instance/Info/Snapshots/TimeLine/Day/index.tsx +79 -0
  112. package/pages/Instance/Info/Snapshots/TimeLine/index.tsx +57 -0
  113. package/pages/Instance/Info/Snapshots/index.tsx +97 -0
  114. package/pages/Instance/Info/Snapshots/utils.ts +18 -0
  115. package/pages/Instance/Info/Status/InstanceResponseModal/index.tsx +32 -0
  116. package/pages/Instance/Info/Status/InstanceResponseModal/styles.module.scss +3 -0
  117. package/pages/Instance/Info/Status/index.tsx +85 -0
  118. package/pages/Instance/Info/Status/styles.module.scss +12 -0
  119. package/pages/Instance/Info/Status/utils.ts +24 -0
  120. package/pages/Instance/Info/components/Property/index.tsx +32 -0
  121. package/pages/Instance/Info/components/Property/styles.module.scss +21 -0
  122. package/pages/Instance/Info/components/Section/index.tsx +50 -0
  123. package/pages/Instance/Info/components/ValueStatus/index.tsx +51 -0
  124. package/pages/Instance/Info/index.tsx +129 -0
  125. package/pages/Instance/SnapshotsModal/index.tsx +169 -0
  126. package/pages/Instance/SnapshotsModal/utils.ts +17 -0
  127. package/pages/Instance/Tabs/index.tsx +98 -0
  128. package/pages/Instance/components/ClonesList/ConnectionModal/index.tsx +196 -0
  129. package/pages/Instance/components/ClonesList/MenuCell/index.tsx +98 -0
  130. package/pages/Instance/components/ClonesList/MenuCell/utils.ts +21 -0
  131. package/pages/Instance/components/ClonesList/index.tsx +189 -0
  132. package/pages/Instance/components/ClonesList/styles.module.scss +32 -0
  133. package/pages/Instance/components/ErrorStub/index.tsx +77 -0
  134. package/pages/Instance/components/ModalReloadButton/index.tsx +43 -0
  135. package/pages/Instance/components/Tags/Tag/index.tsx +60 -0
  136. package/pages/Instance/components/Tags/index.tsx +42 -0
  137. package/pages/Instance/context.ts +39 -0
  138. package/pages/Instance/index.tsx +235 -0
  139. package/pages/Instance/stores/ClonesModal.ts +35 -0
  140. package/pages/Instance/stores/Main.ts +335 -0
  141. package/pages/Instance/stores/SnapshotsModal.ts +35 -0
  142. package/pages/Instance/styles.scss +40 -0
  143. package/pages/Instance/useCreatedStores.ts +14 -0
  144. package/pages/Logs/Icons/PlusIcon.tsx +8 -0
  145. package/pages/Logs/constants/index.ts +7 -0
  146. package/pages/Logs/hooks/useWsScroll.tsx +44 -0
  147. package/pages/Logs/index.tsx +267 -0
  148. package/pages/Logs/utils/index.ts +20 -0
  149. package/pages/Logs/wsLogs.ts +110 -0
  150. package/pages/Logs/wsSnackbar.ts +27 -0
  151. package/postgres.ai-shared-3.5.0.tgz +0 -0
  152. package/react-app-env.d.ts +71 -0
  153. package/scripts/copy-assets.js +30 -0
  154. package/scripts/pack.js +70 -0
  155. package/stores/Snapshots.ts +54 -0
  156. package/styles/colors.ts +67 -0
  157. package/styles/global.scss +29 -0
  158. package/styles/icons.tsx +1917 -0
  159. package/styles/mixins.scss +30 -0
  160. package/styles/styles.ts +87 -0
  161. package/styles/theme.ts +53 -0
  162. package/styles/vars.scss +43 -0
  163. package/styles/vars.ts +40 -0
  164. package/tsconfig.build.json +37 -0
  165. package/tsconfig.json +30 -0
  166. package/types/api/endpoints/createClone.ts +10 -0
  167. package/types/api/endpoints/destroyClone.ts +7 -0
  168. package/types/api/endpoints/getClone.ts +6 -0
  169. package/types/api/endpoints/getConfig.ts +6 -0
  170. package/types/api/endpoints/getEngine.ts +13 -0
  171. package/types/api/endpoints/getFullConfig.ts +4 -0
  172. package/types/api/endpoints/getInstance.ts +6 -0
  173. package/types/api/endpoints/getInstanceRetrieval.ts +6 -0
  174. package/types/api/endpoints/getSeImages.ts +22 -0
  175. package/types/api/endpoints/getSnapshots.ts +6 -0
  176. package/types/api/endpoints/getWSToken.ts +6 -0
  177. package/types/api/endpoints/initWS.ts +1 -0
  178. package/types/api/endpoints/refreshInstance.ts +4 -0
  179. package/types/api/endpoints/resetClone.ts +8 -0
  180. package/types/api/endpoints/testDbSource.ts +48 -0
  181. package/types/api/endpoints/updateClone.ts +10 -0
  182. package/types/api/endpoints/updateConfig.ts +6 -0
  183. package/types/api/entities/clone.ts +42 -0
  184. package/types/api/entities/config.ts +114 -0
  185. package/types/api/entities/dbSource.ts +13 -0
  186. package/types/api/entities/instance.ts +67 -0
  187. package/types/api/entities/instanceRetrieval.ts +46 -0
  188. package/types/api/entities/instanceState.ts +102 -0
  189. package/types/api/entities/pool.ts +27 -0
  190. package/types/api/entities/snapshot.ts +18 -0
  191. package/types/api/entities/wsToken.ts +7 -0
  192. package/types/byte-size/index.d.ts +22 -0
  193. package/utils/api.ts +30 -0
  194. package/utils/clone.ts +31 -0
  195. package/utils/connection.ts +38 -0
  196. package/utils/date.ts +87 -0
  197. package/utils/instance.ts +10 -0
  198. package/utils/numbers.ts +11 -0
  199. package/utils/react.ts +10 -0
  200. package/utils/snapshot.ts +4 -0
  201. package/utils/strings.ts +11 -0
  202. package/utils/units.ts +23 -0
@@ -0,0 +1,111 @@
1
+ /*--------------------------------------------------------------------------
2
+ * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
3
+ * All Rights Reserved. Proprietary and confidential.
4
+ * Unauthorized copying of this file, via any medium is strictly prohibited
5
+ *--------------------------------------------------------------------------
6
+ */
7
+
8
+ import React, { useState } from 'react'
9
+ import { Menu, MenuItem, IconButton, makeStyles } from '@material-ui/core'
10
+ import { MoreVert } from '@material-ui/icons'
11
+ import clsx from 'clsx'
12
+
13
+ import { StubSpinner } from '@postgres.ai/shared/components/StubSpinnerFlex'
14
+
15
+ const DIRECTION_TO_ORIGIN = {
16
+ left: 'right',
17
+ right: 'left',
18
+ } as const
19
+
20
+ type Action = {
21
+ name: string
22
+ onClick: () => void
23
+ isDisabled?: boolean
24
+ }
25
+
26
+ export type Props = {
27
+ actions: Action[]
28
+ isDisabled?: boolean
29
+ isLoading?: boolean
30
+ direction?: 'left' | 'right'
31
+ }
32
+
33
+ const useStyles = makeStyles(
34
+ {
35
+ button: {
36
+ '&:disabled': {
37
+ cursor: 'not-allowed',
38
+ pointerEvents: 'all',
39
+ },
40
+ },
41
+ spinner: {
42
+ background: 'transparent',
43
+ },
44
+ hiddenIcon: {
45
+ visibility: 'hidden',
46
+ },
47
+ },
48
+ { index: 1 },
49
+ )
50
+
51
+ export const RowMenu = (props: Props) => {
52
+ const {
53
+ actions,
54
+ isDisabled = false,
55
+ isLoading = false,
56
+ direction = 'right',
57
+ } = props
58
+ const classes = useStyles()
59
+ const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null)
60
+
61
+ const isOpen = Boolean(anchorEl)
62
+
63
+ const openMenu: React.MouseEventHandler<HTMLButtonElement> = (e) =>
64
+ setAnchorEl(e.currentTarget)
65
+
66
+ const closeMenu = () => setAnchorEl(null)
67
+
68
+ return (
69
+ <>
70
+ <IconButton
71
+ onClick={openMenu}
72
+ disabled={isDisabled || isLoading}
73
+ className={classes.button}
74
+ >
75
+ <MoreVert className={clsx(isLoading && classes.hiddenIcon)} />
76
+ {isLoading && (
77
+ <StubSpinner size="sm" mode="absolute" className={classes.spinner} />
78
+ )}
79
+ </IconButton>
80
+ <Menu
81
+ anchorOrigin={{
82
+ vertical: 'top',
83
+ horizontal: DIRECTION_TO_ORIGIN[direction],
84
+ }}
85
+ transformOrigin={{
86
+ vertical: 'top',
87
+ horizontal: DIRECTION_TO_ORIGIN[direction],
88
+ }}
89
+ anchorEl={anchorEl}
90
+ keepMounted
91
+ open={isOpen}
92
+ onClose={closeMenu}
93
+ >
94
+ {actions.map((action, i) => {
95
+ return (
96
+ <MenuItem
97
+ key={i}
98
+ onClick={() => {
99
+ closeMenu()
100
+ action.onClick()
101
+ }}
102
+ disabled={action.isDisabled}
103
+ >
104
+ {action.name}
105
+ </MenuItem>
106
+ )
107
+ })}
108
+ </Menu>
109
+ </>
110
+ )
111
+ }
@@ -0,0 +1,140 @@
1
+ /*--------------------------------------------------------------------------
2
+ * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
3
+ * All Rights Reserved. Proprietary and confidential.
4
+ * Unauthorized copying of this file, via any medium is strictly prohibited
5
+ *--------------------------------------------------------------------------
6
+ */
7
+
8
+ import React from 'react'
9
+ import {
10
+ Table as TableBase,
11
+ TableProps as TableBaseProps,
12
+ TableHead,
13
+ TableRow,
14
+ TableCell as TableCellBase,
15
+ TableCellProps as TableCellBaseProps,
16
+ TableBody,
17
+ makeStyles,
18
+ } from '@material-ui/core'
19
+ import clsx from 'clsx'
20
+
21
+ import { colors } from '@postgres.ai/shared/styles/colors'
22
+
23
+ import { RowMenu, Props as RowMenuProps } from './RowMenu'
24
+
25
+ const cellStyles = {
26
+ paddingLeft: '8px',
27
+ paddingRight: '8px',
28
+ borderColor: colors.consoleStroke,
29
+ }
30
+
31
+ // Table.
32
+ type TableProps = TableBaseProps
33
+
34
+ const useTableStyles = makeStyles(
35
+ {
36
+ root: {
37
+ whiteSpace: 'nowrap',
38
+
39
+ '& .MuiTableCell-root': {
40
+ lineHeight: 'normal',
41
+ },
42
+ },
43
+ },
44
+ { index: 1 },
45
+ )
46
+
47
+ const Table = (props: TableProps) => {
48
+ const classes = useTableStyles()
49
+ return (
50
+ <TableBase {...props} className={clsx(props.className, classes.root)} />
51
+ )
52
+ }
53
+
54
+ // TableHeaderCell.
55
+ type TableHeaderCellProps = TableCellBaseProps
56
+
57
+ const useTableHeaderCellStyles = makeStyles(
58
+ {
59
+ root: {
60
+ ...cellStyles,
61
+ color: colors.pgaiDarkGray,
62
+ paddingTop: '12px',
63
+ paddingBottom: '12px',
64
+ },
65
+ },
66
+ { index: 1 },
67
+ )
68
+
69
+ const TableHeaderCell = (props: TableHeaderCellProps) => {
70
+ const classes = useTableHeaderCellStyles()
71
+
72
+ return (
73
+ <TableCellBase {...props} className={clsx(props.className, classes.root)} />
74
+ )
75
+ }
76
+
77
+ // TableBodyCell.
78
+ type TableBodyCellProps = TableCellBaseProps
79
+
80
+ const useTableBodyCellStyles = makeStyles(
81
+ {
82
+ root: {
83
+ ...cellStyles,
84
+ fontSize: '12px',
85
+ paddingTop: '8px',
86
+ paddingBottom: '8px',
87
+ },
88
+ },
89
+ { index: 1 },
90
+ )
91
+
92
+ const TableBodyCell = (props: TableBodyCellProps) => {
93
+ const classes = useTableBodyCellStyles()
94
+
95
+ return (
96
+ <TableCellBase {...props} className={clsx(props.className, classes.root)} />
97
+ )
98
+ }
99
+
100
+ // TableBodyCellMenu.
101
+ type TableBodyCellMenuProps = TableBodyCellProps & RowMenuProps
102
+
103
+ const useTableBodyCellMenuStyles = makeStyles(
104
+ {
105
+ root: {
106
+ padding: 0,
107
+ },
108
+ },
109
+ { index: 1 },
110
+ )
111
+
112
+ const TableBodyCellMenu = (props: TableBodyCellMenuProps) => {
113
+ const classes = useTableBodyCellMenuStyles()
114
+
115
+ const { isLoading, isDisabled, children, ...hiddenProps } = props
116
+
117
+ const handleClick: React.MouseEventHandler<HTMLTableDataCellElement> = (e) =>
118
+ e.stopPropagation()
119
+
120
+ return (
121
+ <TableBodyCell
122
+ {...hiddenProps}
123
+ className={classes.root}
124
+ onClick={handleClick}
125
+ >
126
+ <RowMenu {...hiddenProps} isLoading={isLoading} isDisabled={isDisabled} />
127
+ {children}
128
+ </TableBodyCell>
129
+ )
130
+ }
131
+
132
+ export {
133
+ Table,
134
+ TableHead,
135
+ TableRow,
136
+ TableBody,
137
+ TableHeaderCell,
138
+ TableBodyCell,
139
+ TableBodyCellMenu,
140
+ }
@@ -0,0 +1,28 @@
1
+ /*--------------------------------------------------------------------------
2
+ * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
3
+ * All Rights Reserved. Proprietary and confidential.
4
+ * Unauthorized copying of this file, via any medium is strictly prohibited
5
+ *--------------------------------------------------------------------------
6
+ */
7
+
8
+ import React from 'react'
9
+ import { makeStyles } from '@material-ui/core'
10
+
11
+ type Props = {
12
+ children: React.ReactNode
13
+ }
14
+
15
+ const useStyles = makeStyles(
16
+ {
17
+ root: {
18
+ margin: 0,
19
+ },
20
+ },
21
+ { index: 1 },
22
+ )
23
+
24
+ export const Text = (props: Props) => {
25
+ const classes = useStyles()
26
+
27
+ return <p className={classes.root}>{props.children}</p>
28
+ }
@@ -0,0 +1,117 @@
1
+ /*--------------------------------------------------------------------------
2
+ * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
3
+ * All Rights Reserved. Proprietary and confidential.
4
+ * Unauthorized copying of this file, via any medium is strictly prohibited
5
+ *--------------------------------------------------------------------------
6
+ */
7
+
8
+ import React from 'react'
9
+ import {
10
+ TextField as TextFieldBase,
11
+ makeStyles,
12
+ InputProps,
13
+ TextFieldProps as TextFieldPropsBase,
14
+ } from '@material-ui/core'
15
+ import clsx from 'clsx'
16
+
17
+ export type TextFieldProps = {
18
+ label?: string
19
+ disabled?: boolean
20
+ defaultValue?: string
21
+ value?: TextFieldPropsBase['value']
22
+ className?: string
23
+ fullWidth?: boolean
24
+ autoFocus?: boolean
25
+ id?: TextFieldPropsBase['id']
26
+ multiline?: TextFieldPropsBase['multiline']
27
+ onKeyDown?: TextFieldPropsBase['onKeyDown']
28
+ onChange?: TextFieldPropsBase['onChange']
29
+ InputProps?: InputProps
30
+ InputLabelProps?: TextFieldPropsBase['InputLabelProps']
31
+ children?: TextFieldPropsBase['children']
32
+ select?: TextFieldPropsBase['select']
33
+ type?: 'text' | 'password'
34
+ error?: boolean
35
+ placeholder?: string
36
+ onBlur?: TextFieldPropsBase['onBlur']
37
+ onFocus?: TextFieldPropsBase['onFocus']
38
+ name?: TextFieldPropsBase['name']
39
+ helperText?: TextFieldPropsBase['helperText']
40
+ }
41
+
42
+ const useStyles = makeStyles(
43
+ {
44
+ root: {
45
+ fontSize: '14px',
46
+ },
47
+ selectIcon: {
48
+ fontSize: '24px',
49
+ },
50
+ inputRoot: {
51
+ padding: 0,
52
+ },
53
+ input: {
54
+ padding: '8px',
55
+ },
56
+ helperText: {
57
+ fontSize: 12
58
+ }
59
+ },
60
+ { index: 1 },
61
+ )
62
+
63
+ export const TextField = (props: TextFieldProps) => {
64
+ const classes = useStyles()
65
+
66
+ return (
67
+ <TextFieldBase
68
+ onKeyDown={props.onKeyDown}
69
+ autoFocus={props.autoFocus}
70
+ id={props.id}
71
+ multiline={props.multiline}
72
+ label={props.label}
73
+ variant="outlined"
74
+ disabled={props.disabled}
75
+ className={clsx(classes.root, props.className)}
76
+ defaultValue={props.defaultValue}
77
+ value={props.value}
78
+ margin="normal"
79
+ fullWidth={props.fullWidth}
80
+ classes={{ }}
81
+ InputProps={{
82
+ ...props.InputProps,
83
+
84
+ classes: {
85
+ root: classes.inputRoot,
86
+ input: classes.input,
87
+ ...props.InputProps?.classes,
88
+ },
89
+ }}
90
+ SelectProps={{
91
+ classes: {
92
+ icon: classes.selectIcon,
93
+ },
94
+ }}
95
+ InputLabelProps={{
96
+ shrink: true,
97
+
98
+ ...props.InputLabelProps,
99
+ }}
100
+ FormHelperTextProps={{
101
+ classes: {
102
+ root: classes.helperText
103
+ }
104
+ }}
105
+ onChange={props.onChange}
106
+ children={props.children}
107
+ select={props.select}
108
+ type={props.type}
109
+ error={props.error}
110
+ placeholder={props.placeholder}
111
+ onBlur={props.onBlur}
112
+ onFocus={props.onFocus}
113
+ name={props.name}
114
+ helperText={props.helperText}
115
+ />
116
+ )
117
+ }
@@ -0,0 +1,52 @@
1
+ /*--------------------------------------------------------------------------
2
+ * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
3
+ * All Rights Reserved. Proprietary and confidential.
4
+ * Unauthorized copying of this file, via any medium is strictly prohibited
5
+ *--------------------------------------------------------------------------
6
+ */
7
+
8
+ import {
9
+ Tooltip as TooltipBase,
10
+ TooltipProps,
11
+ makeStyles,
12
+ } from '@material-ui/core'
13
+
14
+ type Props = {
15
+ children: JSX.Element
16
+ content: string | JSX.Element
17
+ disableTouchListener?: boolean
18
+ placement?: TooltipProps['placement']
19
+ interactive?: TooltipProps['interactive']
20
+ enterTouchDelay?: TooltipProps['enterTouchDelay']
21
+ }
22
+
23
+ const useStyles = makeStyles(
24
+ {
25
+ tooltip: {
26
+ fontSize: '10px',
27
+ padding: '4px 8px',
28
+ },
29
+ },
30
+ { index: 1 },
31
+ )
32
+
33
+ export const Tooltip = (props: Props) => {
34
+ const {
35
+ content,
36
+ placement = 'top',
37
+ enterTouchDelay = 0,
38
+ ...otherProps
39
+ } = props
40
+
41
+ const classes = useStyles()
42
+
43
+ return (
44
+ <TooltipBase
45
+ {...otherProps}
46
+ enterTouchDelay={enterTouchDelay}
47
+ placement={placement}
48
+ title={content}
49
+ classes={{ tooltip: classes.tooltip }}
50
+ />
51
+ )
52
+ }
@@ -0,0 +1,32 @@
1
+ import { Locale } from 'date-fns'
2
+ import { enUS } from 'date-fns/locale'
3
+ import { getUserLocale } from 'get-user-locale'
4
+
5
+ type Config = {
6
+ dateFnsLocale: Locale
7
+ appName: string
8
+ }
9
+
10
+ export const config: Config = {
11
+ dateFnsLocale: enUS,
12
+ appName: 'Postgres.ai',
13
+ }
14
+
15
+ const loadDateFnsLocale = async () => {
16
+ const userLocale = getUserLocale()
17
+
18
+ // We are already using this locale.
19
+ if (userLocale === config.dateFnsLocale.code) return
20
+
21
+ try {
22
+ const locale = await import(`date-fns/locale/${userLocale}`)
23
+ config.dateFnsLocale = locale.default
24
+ return
25
+ } catch (e) {
26
+ // Unavailable locale.
27
+ }
28
+ }
29
+
30
+ export const initConfig = async () => {
31
+ await loadDateFnsLocale()
32
+ }
@@ -0,0 +1,6 @@
1
+ export const linksConfig = {
2
+ cloudSignIn: 'https://postgres.ai/pricing',
3
+ docs: 'https://postgres.ai/docs',
4
+ support: 'https://postgres.ai/contact',
5
+ github: 'https://github.com/postgres-ai/database-lab-engine',
6
+ }
@@ -0,0 +1,80 @@
1
+ const path = require('path')
2
+
3
+ const {
4
+ getLoader,
5
+ loaderByName,
6
+ getPlugin,
7
+ pluginByName,
8
+ addPlugins,
9
+ whenProd,
10
+ } = require('@craco/craco')
11
+
12
+ const CreateFilePlugin = require('create-file-webpack')
13
+
14
+ const SHARED_PACKAGE_PATH = path.join(__dirname, '../shared')
15
+
16
+ const buildTimestamp = Date.now()
17
+
18
+ module.exports = (context) => ({
19
+ webpack: {
20
+ configure: (webpackConfig) => {
21
+ // Add shared to resolve.
22
+ const forkTsCheckerWebpackPlugin = getPlugin(
23
+ webpackConfig,
24
+ pluginByName('ForkTsCheckerWebpackPlugin'),
25
+ )
26
+
27
+ if (forkTsCheckerWebpackPlugin.isFound) {
28
+ forkTsCheckerWebpackPlugin.match.reportFiles = []
29
+ forkTsCheckerWebpackPlugin.match.options.reportFiles = []
30
+ }
31
+
32
+ const babelLoader = getLoader(webpackConfig, loaderByName('babel-loader'))
33
+
34
+ if (babelLoader.isFound) {
35
+ if (Array.isArray(babelLoader.match.loader.include)) {
36
+ babelLoader.match.loader.include.push(SHARED_PACKAGE_PATH)
37
+ } else {
38
+ babelLoader.match.loader.include = [
39
+ babelLoader.match.loader.include,
40
+ SHARED_PACKAGE_PATH,
41
+ ]
42
+ }
43
+ }
44
+
45
+ // Generating meta.json
46
+ whenProd(() =>
47
+ addPlugins(webpackConfig, [
48
+ new CreateFilePlugin({
49
+ path: context.paths.appBuild,
50
+ fileName: './meta.json',
51
+ content: JSON.stringify({
52
+ buildTimestamp,
53
+ // Backward compatibility with prev versions UI.
54
+ buildDate: buildTimestamp,
55
+ }),
56
+ }),
57
+ ]),
58
+ )
59
+
60
+ // Passing build timestamp.
61
+ const { match: definePlugin } = getPlugin(
62
+ webpackConfig,
63
+ pluginByName('DefinePlugin'),
64
+ )
65
+ if (definePlugin)
66
+ definePlugin.definitions[
67
+ 'process.env'
68
+ ].BUILD_TIMESTAMP = `${buildTimestamp}`
69
+
70
+ // Resolve polyfills.
71
+ webpackConfig.resolve.fallback = {
72
+ ...webpackConfig.resolve.fallback,
73
+ crypto: require.resolve('crypto-browserify'),
74
+ stream: require.resolve('stream-browserify'),
75
+ }
76
+
77
+ return webpackConfig
78
+ },
79
+ },
80
+ })