@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,79 @@
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/styles'
9
+
10
+ import { colors } from '@postgres.ai/shared/styles/colors'
11
+
12
+ type Props = {
13
+ text: string
14
+ }
15
+
16
+ const useStyles = makeStyles(
17
+ {
18
+ root: {
19
+ flex: '0 1 auto',
20
+ display: 'flex',
21
+ flexDirection: 'column',
22
+ alignItems: 'center',
23
+ '&:first-child': {
24
+ alignItems: 'flex-start',
25
+
26
+ '& $division': {
27
+ marginLeft: '9px',
28
+ },
29
+
30
+ '& $date': {
31
+ color: colors.black,
32
+ },
33
+ },
34
+ '&:last-child': {
35
+ alignItems: 'flex-end',
36
+
37
+ '& $division': {
38
+ marginRight: '9px',
39
+ },
40
+
41
+ '& $date': {
42
+ color: colors.black,
43
+ },
44
+ },
45
+ },
46
+ point: {
47
+ width: '19px',
48
+ flex: '0 0 19px',
49
+ borderRadius: '50%',
50
+ background: colors.secondary2.lightLight,
51
+ border: `1px solid ${colors.secondary2.main}`,
52
+ },
53
+ division: {
54
+ marginTop: '4px',
55
+ flex: '0 0 4px',
56
+ width: '1px',
57
+ background: colors.pgaiDarkGray,
58
+ },
59
+ date: {
60
+ fontSize: '10px',
61
+ marginTop: '4px',
62
+ color: colors.pgaiDarkGray,
63
+ },
64
+ },
65
+ { index: 1 },
66
+ )
67
+
68
+ export const Day = (props: Props) => {
69
+ const { text } = props
70
+ const classes = useStyles()
71
+
72
+ return (
73
+ <div className={classes.root}>
74
+ <div className={classes.point} />
75
+ <div className={classes.division} />
76
+ <span className={classes.date}>{text}</span>
77
+ </div>
78
+ )
79
+ }
@@ -0,0 +1,57 @@
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/styles'
9
+
10
+ import { colors } from '@postgres.ai/shared/styles/colors'
11
+
12
+ import { Day } from './Day'
13
+
14
+ const useStyles = makeStyles(
15
+ {
16
+ root: {
17
+ marginTop: '10px',
18
+ },
19
+ container: {
20
+ display: 'flex',
21
+ justifyContent: 'space-between',
22
+ position: 'relative',
23
+ },
24
+ line: {
25
+ margin: '0 9px -23px 9px',
26
+ paddingTop: '22px',
27
+ borderBottom: `1px solid ${colors.pgaiDarkGray}`,
28
+ },
29
+ label: {
30
+ fontSize: '12px',
31
+ },
32
+ },
33
+ { index: 1 },
34
+ )
35
+
36
+ export const TimeLine = () => {
37
+ const classes = useStyles()
38
+
39
+ return (
40
+ <div className={classes.root}>
41
+ <div className={classes.line} />
42
+ <div className={classes.container}>
43
+ <Day text="Jun 20" />
44
+ <Day text="Jun 21" />
45
+ <Day text="Jun 22" />
46
+ <Day text="Jun 23" />
47
+ <Day text="Jun 24" />
48
+ <Day text="Jun 25" />
49
+ <Day text="Jun 26" />
50
+ </div>
51
+ <div className={classes.container}>
52
+ <span className={classes.label}>16:33:20 UTC</span>
53
+ <span className={classes.label}>10:30:00 UTC</span>
54
+ </div>
55
+ </div>
56
+ )
57
+ }
@@ -0,0 +1,97 @@
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/styles'
9
+ import { observer } from 'mobx-react-lite'
10
+ import { formatDistanceToNowStrict } from 'date-fns'
11
+
12
+ import { Button } from '@postgres.ai/shared/components/Button2'
13
+ import { Spinner } from '@postgres.ai/shared/components/Spinner'
14
+ import { ErrorStub } from '@postgres.ai/shared/components/ErrorStub'
15
+ import { useStores } from '@postgres.ai/shared/pages/Instance/context'
16
+
17
+ import { Section } from '../components/Section'
18
+ import { Property } from '../components/Property'
19
+
20
+ import { getEdgeSnapshots } from './utils'
21
+ import { Calendar } from './Calendar'
22
+
23
+ const useStyles = makeStyles(
24
+ {
25
+ button: {
26
+ marginTop: '20px',
27
+ },
28
+ },
29
+ { index: 1 },
30
+ )
31
+
32
+ export const Snapshots = observer(() => {
33
+ const stores = useStores()
34
+
35
+ const { snapshots } = stores.main
36
+
37
+ const classes = useStyles()
38
+
39
+ const { firstSnapshot, lastSnapshot } = getEdgeSnapshots(snapshots.data ?? [])
40
+
41
+ return (
42
+ <Section
43
+ title="Snapshots"
44
+ rightContent={
45
+ !snapshots.data && !snapshots.error && <Spinner size="sm" />
46
+ }
47
+ >
48
+ {snapshots.error && <ErrorStub message={snapshots.error} size="normal" />}
49
+
50
+ {snapshots.data && !snapshots.error && (
51
+ <>
52
+ <Property name="Number of snapshots">
53
+ {snapshots.data.length}
54
+ </Property>
55
+
56
+ <Property name="Oldest data state time">
57
+ {lastSnapshot && (
58
+ <>
59
+ {lastSnapshot.dataStateAt} (
60
+ {formatDistanceToNowStrict(lastSnapshot.dataStateAtDate, {
61
+ addSuffix: true,
62
+ })}
63
+ )
64
+ </>
65
+ )}
66
+ {!lastSnapshot && '-'}
67
+ </Property>
68
+
69
+ <Property name="Newest data state time">
70
+ {firstSnapshot && (
71
+ <>
72
+ {firstSnapshot.dataStateAt} (
73
+ {formatDistanceToNowStrict(firstSnapshot.dataStateAtDate, {
74
+ addSuffix: true,
75
+ })}
76
+ )
77
+ </>
78
+ )}
79
+ {!firstSnapshot && '-'}
80
+ </Property>
81
+
82
+ <Calendar
83
+ snapshots={snapshots.data}
84
+ onSelectDate={(date) => stores.snapshotsModal.openModal({ date })}
85
+ />
86
+
87
+ <Button
88
+ className={classes.button}
89
+ onClick={() => stores.snapshotsModal.openModal()}
90
+ >
91
+ Show all snapshots
92
+ </Button>
93
+ </>
94
+ )}
95
+ </Section>
96
+ )
97
+ })
@@ -0,0 +1,18 @@
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 { Snapshot } from '@postgres.ai/shared/types/api/entities/snapshot'
9
+
10
+ export const getEdgeSnapshots = (snapshots: Snapshot[]) => {
11
+ const list = [...snapshots]
12
+ const [first] = list
13
+ const [last] = list.reverse()
14
+ return {
15
+ firstSnapshot: (first as Snapshot | undefined) ?? null,
16
+ lastSnapshot: (last as Snapshot | undefined) ?? null
17
+ }
18
+ }
@@ -0,0 +1,32 @@
1
+ import { observer } from 'mobx-react-lite'
2
+
3
+ import { Modal } from '@postgres.ai/shared/components/Modal'
4
+ import { FormattedText } from '@postgres.ai/shared/components/FormattedText'
5
+ import { useStores } from '@postgres.ai/shared/pages/Instance/context'
6
+
7
+ import styles from './styles.module.scss'
8
+
9
+ type Props = {
10
+ isOpen: boolean
11
+ onClose: () => void
12
+ }
13
+
14
+ export const InstanceResponseModal = observer((props: Props) => {
15
+ const stores = useStores()
16
+
17
+ if (!stores.main.instance) return null
18
+
19
+ return (
20
+ <Modal
21
+ isOpen={props.isOpen}
22
+ onClose={props.onClose}
23
+ title="Instance Full Response"
24
+ size="md"
25
+ >
26
+ <FormattedText
27
+ value={JSON.stringify(stores.main.instance.dto, null, 2)}
28
+ className={styles.formattedText}
29
+ />
30
+ </Modal>
31
+ )
32
+ })
@@ -0,0 +1,3 @@
1
+ .formattedText {
2
+ max-height: 400px;
3
+ }
@@ -0,0 +1,85 @@
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 { observer } from 'mobx-react-lite'
10
+
11
+ import { GatewayLink } from '@postgres.ai/shared/components/GatewayLink'
12
+ import { Status as StatusIndicator } from '@postgres.ai/shared/components/Status'
13
+ import { useStores } from '@postgres.ai/shared/pages/Instance/context'
14
+ import { formatDateStd } from '@postgres.ai/shared/utils/date'
15
+ import { Button } from '@postgres.ai/shared/components/Button2'
16
+ import { linksConfig } from '@postgres.ai/shared/config/links'
17
+
18
+ import { Section } from '../components/Section'
19
+ import { Property } from '../components/Property'
20
+
21
+ import { InstanceResponseModal } from './InstanceResponseModal'
22
+
23
+ import { getType, getText } from './utils'
24
+
25
+ import styles from './styles.module.scss'
26
+
27
+ export const Status = observer(() => {
28
+ const [isOpenInstanceResponseModal, setIsOpenInstanceResponseModal] =
29
+ useState(false)
30
+ const stores = useStores()
31
+
32
+ const { instance } = stores.main
33
+ if (!instance || !instance.state) return null
34
+
35
+ const { code, message } = instance.state.status
36
+ const { version, startedAt } = instance.state.engine
37
+
38
+ const isStatusOk = code === 'OK'
39
+
40
+ return (
41
+ <Section title="Status">
42
+ <Property name="Status">
43
+ <StatusIndicator type={getType(code)}>
44
+ {getText(code)}
45
+ {!isStatusOk && (
46
+ <>
47
+ <br />
48
+ {message}
49
+ </>
50
+ )}
51
+ </StatusIndicator>
52
+ </Property>
53
+ {startedAt && (
54
+ <Property name="Started">
55
+ {formatDateStd(startedAt, { withDistance: true })}
56
+ </Property>
57
+ )}
58
+ {instance.createdAt && (
59
+ <Property name="Registered">
60
+ {formatDateStd(instance.createdAt, { withDistance: true })}
61
+ </Property>
62
+ )}
63
+ {version && <Property name="Version">{version}</Property>}
64
+
65
+ {!isStatusOk && (
66
+ <div className={styles.controls}>
67
+ <Button
68
+ onClick={() => setIsOpenInstanceResponseModal(true)}
69
+ className={styles.button}
70
+ >
71
+ Show full response
72
+ </Button>
73
+ <GatewayLink className={styles.button} href={linksConfig.support}>
74
+ <Button theme="accent">Ask support</Button>
75
+ </GatewayLink>
76
+ </div>
77
+ )}
78
+
79
+ <InstanceResponseModal
80
+ isOpen={isOpenInstanceResponseModal}
81
+ onClose={() => setIsOpenInstanceResponseModal(false)}
82
+ />
83
+ </Section>
84
+ )
85
+ })
@@ -0,0 +1,12 @@
1
+ .controls {
2
+ display: flex;
3
+ margin-top: 24px;
4
+ }
5
+
6
+ .button {
7
+ text-decoration: none;
8
+
9
+ & + .button {
10
+ margin-left: 8px;
11
+ }
12
+ }
@@ -0,0 +1,24 @@
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 { capitalize } from '@postgres.ai/shared/utils/strings'
9
+
10
+ const STATUS_CODE_TO_TYPE = {
11
+ OK: 'ok' as const,
12
+ WARNING: 'warning' as const,
13
+ NO_RESPONSE: 'error' as const
14
+ }
15
+
16
+ export const getType = (code: keyof typeof STATUS_CODE_TO_TYPE) => {
17
+ return STATUS_CODE_TO_TYPE[code] ?? 'unknown'
18
+ }
19
+
20
+ export const getText = (code: keyof typeof STATUS_CODE_TO_TYPE) => {
21
+ if (code === 'OK') return code
22
+ if (code === 'NO_RESPONSE') return 'No response'
23
+ return capitalize(code)
24
+ }
@@ -0,0 +1,32 @@
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 cn from 'classnames'
9
+
10
+ import styles from './styles.module.scss'
11
+
12
+ type Props = {
13
+ name: React.ReactNode
14
+ children: React.ReactNode
15
+ classes?: {
16
+ name?: string
17
+ content?: string
18
+ }
19
+ }
20
+
21
+ export const Property = (props: Props) => {
22
+ const { name, children } = props
23
+
24
+ return (
25
+ <div className={styles.root}>
26
+ <label className={cn(styles.name, props.classes?.name)}>{name}</label>
27
+ <div className={cn(styles.content, props.classes?.content)}>
28
+ {children}
29
+ </div>
30
+ </div>
31
+ )
32
+ }
@@ -0,0 +1,21 @@
1
+ .root {
2
+ display: flex;
3
+ margin-top: 4px;
4
+ font-size: 12px;
5
+ }
6
+
7
+ .name {
8
+ flex: 0 0 134px;
9
+ margin-right: 14px;
10
+
11
+ @media screen and (max-width: '600px') {
12
+ flex: 1 1 100%;
13
+ margin-right: 7px;
14
+ }
15
+ }
16
+
17
+ .content {
18
+ flex: 1 1 100%;
19
+ font-weight: 700;
20
+ width: 0;
21
+ }
@@ -0,0 +1,50 @@
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/styles'
10
+
11
+ import { SectionTitle } from '@postgres.ai/shared/components/SectionTitle'
12
+
13
+ type Props = {
14
+ title: string
15
+ children: React.ReactNode
16
+ rightContent?: React.ReactNode
17
+ }
18
+
19
+ const useStyles = makeStyles(
20
+ {
21
+ root: {
22
+ '& + $root': {
23
+ marginTop: '28px',
24
+ },
25
+ },
26
+ content: {
27
+ marginTop: '8px',
28
+ },
29
+ },
30
+ { index: 1 },
31
+ )
32
+
33
+ export const Section = (props: Props) => {
34
+ const { title, children, rightContent } = props
35
+
36
+ const classes = useStyles()
37
+
38
+ return (
39
+ <div className={classes.root}>
40
+ <SectionTitle
41
+ text={title}
42
+ level={2}
43
+ tag="h3"
44
+ rightContent={rightContent}
45
+ />
46
+
47
+ <div className={classes.content}>{children}</div>
48
+ </div>
49
+ )
50
+ }
@@ -0,0 +1,51 @@
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 {
12
+ Status,
13
+ Props as StatusProps,
14
+ } from '@postgres.ai/shared/components/Status'
15
+
16
+ type Props = {
17
+ children: React.ReactNode
18
+ type?: StatusProps['type']
19
+ icon?: StatusProps['icon']
20
+ }
21
+
22
+ const useStyles = makeStyles(
23
+ {
24
+ root: {
25
+ fontWeight: 400,
26
+ marginTop: '2px',
27
+ fontSize: '10px',
28
+ },
29
+ icon: {
30
+ alignSelf: 'flex-start',
31
+ },
32
+ },
33
+ { index: 1 },
34
+ )
35
+
36
+ export const ValueStatus = (props: Props) => {
37
+ const { children, type, icon } = props
38
+
39
+ const classes = useStyles()
40
+
41
+ return (
42
+ <Status
43
+ className={classes.root}
44
+ classNameIcon={classes.icon}
45
+ type={type}
46
+ icon={icon}
47
+ >
48
+ {children}
49
+ </Status>
50
+ )
51
+ }