@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,21 @@
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
+ export const destroyRestriction = (cloneId: string) => {
9
+ const message = `The clone "${cloneId}" is marked as protected. To destroy it, disable the destroy protection first.`
10
+ window.alert(message)
11
+ }
12
+
13
+ export const getResetApprove = (cloneId: string) => {
14
+ const message = `Are you sure you want to reset the Database Lab clone: "${cloneId}"?`
15
+ return window.confirm(message)
16
+ }
17
+
18
+ export const getDestroyApprove = (cloneId: string) => {
19
+ const message = `Are you sure you want to destroy the Database Lab clone: "${cloneId}"?`
20
+ return window.confirm(message)
21
+ }
@@ -0,0 +1,189 @@
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 { useState } from 'react'
9
+ import cn from 'classnames'
10
+ import { formatDistanceToNowStrict } from 'date-fns'
11
+ import { useHistory } from 'react-router-dom'
12
+
13
+ import {
14
+ Table,
15
+ TableHead,
16
+ TableRow,
17
+ TableHeaderCell,
18
+ TableBody,
19
+ TableBodyCell,
20
+ } from '@postgres.ai/shared/components/Table'
21
+ import { ArrowDropDownIcon } from '@postgres.ai/shared/icons/ArrowDropDown'
22
+ import { ShieldIcon } from '@postgres.ai/shared/icons/Shield'
23
+ import { RenewableIcon } from '@postgres.ai/shared/icons/Renewable'
24
+ import { InfoIcon } from '@postgres.ai/shared/icons/Info'
25
+ import { HorizontalScrollContainer } from '@postgres.ai/shared/components/HorizontalScrollContainer'
26
+ import { Status } from '@postgres.ai/shared/components/Status'
27
+ import { Tooltip } from '@postgres.ai/shared/components/Tooltip'
28
+ import { Clone } from '@postgres.ai/shared/types/api/entities/clone'
29
+ import { useHost } from '@postgres.ai/shared/pages/Instance/context'
30
+ import {
31
+ getCloneStatusType,
32
+ getCloneStatusText,
33
+ } from '@postgres.ai/shared/utils/clone'
34
+ import { formatBytesIEC } from '@postgres.ai/shared/utils/units'
35
+
36
+ import { MenuCell } from './MenuCell'
37
+ import { ConnectionModal } from './ConnectionModal'
38
+
39
+ import styles from './styles.module.scss'
40
+
41
+ type Props = {
42
+ clones?: Clone[]
43
+ isDisabled: boolean
44
+ emptyStubText: string
45
+ }
46
+
47
+ export const ClonesList = (props: Props) => {
48
+ const host = useHost()
49
+ const history = useHistory()
50
+
51
+ const [cloneIdForConnect, setCloneIdForConnect] = useState<null | string>(
52
+ null,
53
+ )
54
+ const [isOpenConnectionModal, setIsOpenConnectionModal] = useState(false)
55
+
56
+ const openConnectionModal = (cloneId: string) => {
57
+ setCloneIdForConnect(cloneId)
58
+ setIsOpenConnectionModal(true)
59
+ }
60
+
61
+ const closeConnectionModal = () => {
62
+ setIsOpenConnectionModal(false)
63
+ }
64
+
65
+ if (!props.clones?.length)
66
+ return <p className={styles.emptyStub}>{props.emptyStubText}</p>
67
+
68
+ return (
69
+ <>
70
+ <HorizontalScrollContainer>
71
+ <Table>
72
+ <TableHead>
73
+ <TableRow>
74
+ <TableHeaderCell />
75
+ <TableHeaderCell>Status</TableHeaderCell>
76
+ <TableHeaderCell>ID</TableHeaderCell>
77
+ <TableHeaderCell>
78
+ <Tooltip content="When enabled, neither manual nor automated deletion of this clone is possible. Note that abandoned protected clones may lead to out-of-disk-space events because they hold old data, blocking cleanup and refresh processes.">
79
+ <div className={styles.verticalCentered}>
80
+ Protected
81
+ <InfoIcon className={styles.infoIcon} />
82
+ </div>
83
+ </Tooltip>
84
+ </TableHeaderCell>
85
+ <TableHeaderCell>
86
+ <div className={styles.verticalCentered}>
87
+ Created
88
+ <ArrowDropDownIcon className={styles.sortIcon} />
89
+ </div>
90
+ </TableHeaderCell>
91
+ <TableHeaderCell>Port</TableHeaderCell>
92
+ <TableHeaderCell>DB user</TableHeaderCell>
93
+ <TableHeaderCell>
94
+ <Tooltip content="Clone's own size – how much data was added or modified.">
95
+ <div className={styles.verticalCentered}>
96
+ Diff size
97
+ <InfoIcon className={styles.infoIcon} />
98
+ </div>
99
+ </Tooltip>
100
+ </TableHeaderCell>
101
+ <TableHeaderCell>Disk</TableHeaderCell>
102
+ <TableHeaderCell>Data state time</TableHeaderCell>
103
+ </TableRow>
104
+ </TableHead>
105
+ <TableBody>
106
+ {props.clones.map((clone) => {
107
+ const clonePagePath = host.routes.clone(clone.id)
108
+
109
+ return (
110
+ <TableRow
111
+ hover={!props.isDisabled}
112
+ key={clone.id}
113
+ onClick={
114
+ props.isDisabled
115
+ ? undefined
116
+ : () => history.push(clonePagePath)
117
+ }
118
+ className={cn(!props.isDisabled && styles.interactiveRow)}
119
+ >
120
+ <MenuCell
121
+ clone={clone}
122
+ onConnect={openConnectionModal}
123
+ clonePagePath={clonePagePath}
124
+ />
125
+ <TableBodyCell>
126
+ <Tooltip content={clone.status.message}>
127
+ <Status type={getCloneStatusType(clone.status.code)}>
128
+ {getCloneStatusText(clone.status.code)}
129
+ </Status>
130
+ </Tooltip>
131
+ </TableBodyCell>
132
+ <TableBodyCell>{clone.id}</TableBodyCell>
133
+ <TableBodyCell>
134
+ {clone.protected ? (
135
+ <Tooltip content="Clone is protected from manual and automated deletion. Note that abandoned protected clones may lead to out-of-disk-space events because they hold old data, blocking cleanup and refresh processes.">
136
+ <ShieldIcon className={styles.protectionIcon} />
137
+ </Tooltip>
138
+ ) : (
139
+ <Tooltip content="Clone is not protected from deletion. To save disk space it will be automatically deleted if there is no activity for a long time.">
140
+ <RenewableIcon className={styles.protectionIcon} />
141
+ </Tooltip>
142
+ )}
143
+ </TableBodyCell>
144
+ <TableBodyCell>
145
+ {clone.createdAt} (
146
+ {formatDistanceToNowStrict(clone.createdAtDate, {
147
+ addSuffix: true,
148
+ })}
149
+ )
150
+ </TableBodyCell>
151
+ <TableBodyCell>{clone.db.port}</TableBodyCell>
152
+ <TableBodyCell>{clone.db.username}</TableBodyCell>
153
+ <TableBodyCell>
154
+ {formatBytesIEC(clone.metadata.cloneDiffSize)}
155
+ </TableBodyCell>
156
+ <TableBodyCell>{clone.snapshot?.pool ?? '-'}</TableBodyCell>
157
+ <TableBodyCell>
158
+ {clone.snapshot ? (
159
+ <>
160
+ {clone.snapshot.dataStateAt} (
161
+ {formatDistanceToNowStrict(
162
+ clone.snapshot.dataStateAtDate,
163
+ {
164
+ addSuffix: true,
165
+ },
166
+ )}
167
+ )
168
+ </>
169
+ ) : (
170
+ '-'
171
+ )}
172
+ </TableBodyCell>
173
+ </TableRow>
174
+ )
175
+ })}
176
+ </TableBody>
177
+ </Table>
178
+ </HorizontalScrollContainer>
179
+
180
+ {cloneIdForConnect && (
181
+ <ConnectionModal
182
+ cloneId={cloneIdForConnect}
183
+ isOpen={isOpenConnectionModal}
184
+ onClose={closeConnectionModal}
185
+ />
186
+ )}
187
+ </>
188
+ )
189
+ }
@@ -0,0 +1,32 @@
1
+ @import '@postgres.ai/shared/styles/vars';
2
+
3
+ .interactiveRow {
4
+ cursor: pointer;
5
+ }
6
+
7
+ .verticalCentered {
8
+ display: flex;
9
+ align-items: center;
10
+ }
11
+
12
+ .infoIcon {
13
+ margin-left: 4px;
14
+ height: 12px;
15
+ width: 12px;
16
+ }
17
+
18
+ .sortIcon {
19
+ margin-left: 8px;
20
+ width: 10px;
21
+ }
22
+
23
+ .protectionIcon {
24
+ display: block;
25
+ margin-left: 5px;
26
+ height: 1em;
27
+ color: $color-gray-semi-dark;
28
+ }
29
+
30
+ .emptyStub {
31
+ margin-top: 16px;
32
+ }
@@ -0,0 +1,77 @@
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 { Paper, makeStyles } from '@material-ui/core'
10
+ import clsx from 'clsx'
11
+
12
+ type Props = {
13
+ title?: string
14
+ message: string
15
+ className?: string
16
+ size?: 'big' | 'normal'
17
+ }
18
+
19
+ const useStyles = makeStyles(
20
+ {
21
+ '*': {
22
+ margin: 0,
23
+ },
24
+ root: {
25
+ color: '#c00111',
26
+ overflowWrap: 'break-word',
27
+ },
28
+ rootBig: {
29
+ padding: '16px 24px',
30
+
31
+ '& $title': {
32
+ fontSize: '16px',
33
+ },
34
+ '& $message': {
35
+ marginTop: '16px',
36
+ fontSize: '14px',
37
+ },
38
+ },
39
+ rootNormal: {
40
+ padding: '8px 16px',
41
+
42
+ '& $title': {
43
+ fontSize: '14px',
44
+ },
45
+ '& $message': {
46
+ marginTop: '12px',
47
+ fontSize: '12px',
48
+ },
49
+ },
50
+ title: {
51
+ fontWeight: 700,
52
+ textTransform: 'uppercase',
53
+ },
54
+ message: {},
55
+ },
56
+ { index: 1 },
57
+ )
58
+
59
+ export const ErrorStub = (props: Props) => {
60
+ const { title = 'Unknown error', message, className, size = 'big' } = props
61
+
62
+ const classes = useStyles()
63
+
64
+ return (
65
+ <Paper
66
+ className={clsx(
67
+ classes.root,
68
+ size === 'big' && classes.rootBig,
69
+ size === 'normal' && classes.rootNormal,
70
+ className,
71
+ )}
72
+ >
73
+ <h2 className={classes.title}>{title}</h2>
74
+ <p className={classes.message}>{message}</p>
75
+ </Paper>
76
+ )
77
+ }
@@ -0,0 +1,43 @@
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 { makeStyles } from '@material-ui/core'
9
+
10
+ import { Button } from '@postgres.ai/shared/components/Button2'
11
+
12
+ type Props = {
13
+ isReloading: boolean
14
+ onReload: () => void
15
+ }
16
+
17
+ const useStyles = makeStyles(
18
+ {
19
+ spinner: {
20
+ margin: '5px',
21
+ },
22
+ content: {
23
+ flex: '0 0 auto',
24
+ alignSelf: 'flex-start',
25
+ },
26
+ },
27
+ { index: 1 },
28
+ )
29
+
30
+ export const ModalReloadButton = (props: Props) => {
31
+ const classes = useStyles()
32
+
33
+ return (
34
+ <Button
35
+ onClick={props.onReload}
36
+ className={classes.content}
37
+ isLoading={props.isReloading}
38
+ isDisabled={props.isReloading}
39
+ >
40
+ Reload info
41
+ </Button>
42
+ )
43
+ }
@@ -0,0 +1,60 @@
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
+ import { HorizontalScrollContainer } from '@postgres.ai/shared/components/HorizontalScrollContainer'
12
+ import { colors } from '@postgres.ai/shared/styles/vars'
13
+
14
+ type Props = {
15
+ name: string
16
+ children: React.ReactNode
17
+ }
18
+
19
+ const useStyles = makeStyles(
20
+ {
21
+ root: {
22
+ fontSize: '12px',
23
+ marginRight: '8px',
24
+ marginBottom: '8px',
25
+ borderRadius: '12px',
26
+ background: colors.gray,
27
+ },
28
+ content: {
29
+ padding: '5px 8px',
30
+ whiteSpace: 'nowrap',
31
+ },
32
+ curtainLeft: {
33
+ background: 'linear-gradient(to right, rgba(0,0,0,0.1), transparent);',
34
+ },
35
+ curtainRight: {
36
+ background: 'linear-gradient(to left, rgba(0,0,0,0.1), transparent);',
37
+ },
38
+ value: {
39
+ fontWeight: 700,
40
+ },
41
+ },
42
+ { index: 1 },
43
+ )
44
+
45
+ export const Tag = (props: Props) => {
46
+ const classes = useStyles()
47
+
48
+ return (
49
+ <HorizontalScrollContainer
50
+ classes={{
51
+ root: classes.root,
52
+ content: classes.content,
53
+ curtainLeft: classes.curtainLeft,
54
+ curtainRight: classes.curtainRight,
55
+ }}
56
+ >
57
+ {props.name}: <span className={classes.value}>{props.children}</span>
58
+ </HorizontalScrollContainer>
59
+ )
60
+ }
@@ -0,0 +1,42 @@
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
+ import { Tag } from './Tag'
12
+
13
+ export type TagsProps = {
14
+ data: { name: string; value: string }[]
15
+ }
16
+
17
+ const useStyles = makeStyles(
18
+ {
19
+ root: {
20
+ display: 'flex',
21
+ flexWrap: 'wrap',
22
+ marginRight: '-8px',
23
+ },
24
+ },
25
+ { index: 1 },
26
+ )
27
+
28
+ export const Tags = (props: TagsProps) => {
29
+ const classes = useStyles()
30
+
31
+ return (
32
+ <div className={classes.root}>
33
+ {props.data.map((tag) => {
34
+ return (
35
+ <Tag key={tag.name} name={tag.name}>
36
+ {tag.value}
37
+ </Tag>
38
+ )
39
+ })}
40
+ </div>
41
+ )
42
+ }
@@ -0,0 +1,39 @@
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 { createStrictContext } from '@postgres.ai/shared/utils/react'
9
+
10
+ import { Api } from './stores/Main'
11
+ import { Stores } from './useCreatedStores'
12
+
13
+ export type Host = {
14
+ instanceId: string
15
+ routes: {
16
+ createClone: () => string
17
+ clone: (cloneId: string) => string
18
+ }
19
+ api: Api
20
+ title: string
21
+ callbacks?: {
22
+ showDeprecatedApiBanner: () => void
23
+ hideDeprecatedApiBanner: () => void
24
+ }
25
+ elements: {
26
+ breadcrumbs: React.ReactNode
27
+ }
28
+ wsHost?: string
29
+ isPlatform?: boolean
30
+ setProjectAlias?: (alias: string) => void
31
+ }
32
+
33
+ // Host context.
34
+ export const { useStrictContext: useHost, Provider: HostProvider } =
35
+ createStrictContext<Host>()
36
+
37
+ // Stores context.
38
+ export const { useStrictContext: useStores, Provider: StoresProvider } =
39
+ createStrictContext<Stores>()