@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
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,60 @@
1
+ # Conditions.
2
+ .only_ui_feature: &only_ui_feature
3
+ rules:
4
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
5
+
6
+ .only_ui_tag_release: &only_ui_tag_release
7
+ rules:
8
+ - if: $CI_COMMIT_TAG =~ /^v[a-zA-Z0-9_.-]*/
9
+
10
+ .shared_base: &shared_base
11
+ image: node:lts-alpine
12
+ cache:
13
+ key: "$CI_COMMIT_REF_SLUG"
14
+ paths:
15
+ - .pnpm-store
16
+ before_script:
17
+ - apk add --no-cache rsync
18
+ - corepack enable
19
+ - corepack prepare pnpm@8.9.2 --activate
20
+ - pnpm config set store-dir .pnpm-store
21
+ - pnpm --dir ui/packages/shared install --frozen-lockfile
22
+
23
+ build-and-pack-shared:
24
+ <<: *shared_base
25
+ stage: build
26
+ rules:
27
+ - changes:
28
+ - ui/packages/shared/**/*
29
+ script:
30
+ - cd ui/packages/shared
31
+ - pnpm run pack
32
+ artifacts:
33
+ paths:
34
+ - ui/packages/shared/postgres.ai-shared-*.tgz
35
+
36
+ publish-shared-preview:
37
+ <<: [*shared_base, *only_ui_feature]
38
+ stage: publish
39
+ needs:
40
+ - job: build-and-pack-shared
41
+ artifacts: true
42
+ script:
43
+ - cd ui/packages/shared
44
+ - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
45
+ - export PREID="pr-${CI_MERGE_REQUEST_IID:-preview}"
46
+ - npm version prerelease --preid $PREID --no-git-tag-version
47
+ - pnpm publish --no-git-checks --tag $PREID
48
+
49
+ publish-shared-release:
50
+ <<: [*shared_base, *only_ui_tag_release]
51
+ stage: publish
52
+ needs:
53
+ - job: build-and-pack-shared
54
+ artifacts: true
55
+ script:
56
+ - cd ui/packages/shared
57
+ - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
58
+ - export VERSION=${CI_COMMIT_TAG#"v"} # remove leading "v"
59
+ - npm version "$VERSION" --no-git-tag-version
60
+ - pnpm publish --no-git-checks
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ import Snackbar from '@mui/material/Snackbar';
3
+ import Alert from '@mui/material/Alert';
4
+ import {useAlertSnackbar} from "./useAlertSnackbar";
5
+
6
+ export const AlertSnackbar = () => {
7
+ const { snackbarMessage, closeSnackbar } = useAlertSnackbar();
8
+ return (
9
+ <Snackbar
10
+ open={!!snackbarMessage}
11
+ onClose={closeSnackbar}
12
+ >
13
+ <Alert
14
+ onClose={closeSnackbar}
15
+ severity="error"
16
+ variant="filled"
17
+ sx={{ width: '100%' }}
18
+ >
19
+ {snackbarMessage?.message}
20
+ </Alert>
21
+ </Snackbar>
22
+ )
23
+ }
@@ -0,0 +1,65 @@
1
+ import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
2
+ import {AlertSnackbar} from "./index";
3
+
4
+ type AlertSnackbarMessage = {
5
+ message: string,
6
+ key: number
7
+ }
8
+
9
+ type AlertSnackbarContextType = {
10
+ snackbarMessage: AlertSnackbarMessage | null;
11
+ showMessage: (message: string) => void;
12
+ closeSnackbar: () => void;
13
+ }
14
+
15
+ const AlertSnackbarContext = createContext<AlertSnackbarContextType | undefined>(undefined);
16
+
17
+ export const useAlertSnackbar = () => {
18
+ const context = useContext(AlertSnackbarContext);
19
+ if (context === undefined) {
20
+ throw new Error('useSnackbar must be used within a SnackbarProvider');
21
+ }
22
+ return context;
23
+ };
24
+
25
+ type SnackbarProviderProps = {
26
+ children: React.ReactNode
27
+ }
28
+
29
+ export const AlertSnackbarProvider = (props: SnackbarProviderProps) => {
30
+ const { children } = props;
31
+ const [snackbarMessage, setSnackbarMessage] = useState<AlertSnackbarMessage | null>(null);
32
+ const isMounted = useRef(true);
33
+
34
+ useEffect(() => {
35
+ return () => {
36
+ isMounted.current = false;
37
+ };
38
+ }, []);
39
+
40
+ const showMessage = useCallback((message: string) => {
41
+ if (isMounted.current) {
42
+ setSnackbarMessage({message, key: new Date().getTime()});
43
+ }
44
+ }, []);
45
+
46
+ const closeSnackbar = useCallback(() => {
47
+ if (isMounted.current) {
48
+ setSnackbarMessage(null);
49
+ }
50
+ }, []);
51
+
52
+ const value = {
53
+ snackbarMessage,
54
+ showMessage,
55
+ closeSnackbar,
56
+ };
57
+
58
+ return (
59
+ <AlertSnackbarContext.Provider value={value}>
60
+ {children}
61
+ <AlertSnackbar />
62
+ </AlertSnackbarContext.Provider>
63
+ );
64
+
65
+ }
@@ -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 React, { forwardRef } from 'react'
9
+ import { makeStyles } from '@material-ui/styles'
10
+ import { Button as ButtonBase, ButtonProps } from '@material-ui/core'
11
+ import clsx from 'clsx'
12
+
13
+ import { colors } from '@postgres.ai/shared/styles/colors'
14
+
15
+ type Props = Omit<
16
+ ButtonProps,
17
+ 'variant' | 'color' | 'className' | 'disabled'
18
+ > & {
19
+ variant?: 'primary' | 'secondary'
20
+ className?: string
21
+ isDisabled?: boolean
22
+ }
23
+
24
+ const useStyles = makeStyles(
25
+ {
26
+ root: {
27
+ whiteSpace: 'nowrap',
28
+
29
+ '&.MuiButton-outlinedPrimary': {
30
+ background: colors.white,
31
+
32
+ '&:hover': {
33
+ background: '#f4f6f7',
34
+ },
35
+ },
36
+
37
+ '&:disabled': {
38
+ cursor: 'not-allowed',
39
+ pointerEvents: 'all',
40
+
41
+ '&.MuiButton-outlinedPrimary:hover': {
42
+ background: colors.white,
43
+ border: '1px solid rgba(0, 0, 0, 0.12)',
44
+ },
45
+ },
46
+ },
47
+ },
48
+ { index: 1 },
49
+ )
50
+
51
+ const VARIANT_MAP = {
52
+ primary: 'contained' as const,
53
+ secondary: 'outlined' as const,
54
+ }
55
+
56
+ export const Button = forwardRef(
57
+ (props: Props, ref: React.Ref<HTMLButtonElement>) => {
58
+ const {
59
+ variant = 'secondary',
60
+ className,
61
+ isDisabled,
62
+ size = 'small',
63
+ ...buttonProps
64
+ } = props
65
+ const classes = useStyles()
66
+
67
+ return (
68
+ <ButtonBase
69
+ {...buttonProps}
70
+ size={size}
71
+ ref={ref}
72
+ disabled={isDisabled}
73
+ className={clsx(classes.root, className)}
74
+ variant={VARIANT_MAP[variant]}
75
+ color="primary"
76
+ />
77
+ )
78
+ },
79
+ )
@@ -0,0 +1,43 @@
1
+ import React from 'react'
2
+ import cn from 'classnames'
3
+
4
+ import { Spinner } from '@postgres.ai/shared/components/Spinner'
5
+
6
+ import styles from './styles.module.scss'
7
+
8
+ type Props = {
9
+ type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type']
10
+ children: React.ReactNode
11
+ onClick?: React.DOMAttributes<HTMLButtonElement>['onClick']
12
+ size?: 'sm' | 'md' | 'lg'
13
+ theme?: 'primary' | 'secondary' | 'accent'
14
+ className?: string
15
+ isDisabled?: boolean
16
+ isLoading?: boolean
17
+ }
18
+
19
+ export const Button = React.forwardRef<HTMLButtonElement, Props>(
20
+ (props, ref) => {
21
+ const { type = 'button', size = 'md', theme = 'secondary' } = props
22
+
23
+ const isDisabled = props.isDisabled || props.isLoading
24
+
25
+ return (
26
+ <button
27
+ ref={ref}
28
+ className={cn(
29
+ styles.root,
30
+ styles[size],
31
+ styles[theme],
32
+ props.className,
33
+ )}
34
+ type={type}
35
+ onClick={props.onClick}
36
+ disabled={isDisabled}
37
+ >
38
+ {props.children}
39
+ {props.isLoading && <Spinner size="sm" className={styles.spinner} />}
40
+ </button>
41
+ )
42
+ },
43
+ )
@@ -0,0 +1,82 @@
1
+ @import '@postgres.ai/shared/styles/vars';
2
+ @import '@postgres.ai/shared/styles/mixins';
3
+
4
+ .root {
5
+ display: inline-flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ padding: 0 8px;
9
+ border-radius: $border-radius--small;
10
+ border: none;
11
+ font-weight: 500;
12
+ cursor: pointer;
13
+ font-family: inherit;
14
+
15
+ @include touch-transition(background-color color box-shadow opacity);
16
+
17
+ &:disabled {
18
+ cursor: not-allowed;
19
+ opacity: .5;
20
+ }
21
+
22
+ // Sizes.
23
+ &.sm {
24
+ height: 20px;
25
+ font-size: 12px;
26
+ }
27
+
28
+ &.md {
29
+ min-height: 26px;
30
+ font-size: 14px;
31
+ }
32
+
33
+ &.lg {
34
+ height: 32px;
35
+ }
36
+
37
+ // Themes.
38
+ &.primary {
39
+ background: $color-blue-main;
40
+ color: $color-white;
41
+
42
+ &:hover {
43
+ background: darken($color-blue-main, 5);
44
+ }
45
+
46
+ &:active {
47
+ background: darken($color-blue-main, 10);
48
+ }
49
+ }
50
+
51
+ &.secondary {
52
+ background: $color-white;
53
+ border: 1px solid $color-blue-main;
54
+ color: $color-blue-main;
55
+
56
+ &:hover {
57
+ background: #f4f6f7;
58
+ }
59
+
60
+ &:active {
61
+ background: #bdd5dc;
62
+ }
63
+ }
64
+
65
+ &.accent {
66
+ background: $color-orange;
67
+ color: $color-white;
68
+
69
+ &:hover {
70
+ background: darken($color-orange, 5);
71
+ }
72
+
73
+ &:active {
74
+ background: darken($color-orange, 10);
75
+ }
76
+ }
77
+ }
78
+
79
+ .spinner {
80
+ margin-left: 8px;
81
+ color: inherit;
82
+ }
@@ -0,0 +1,56 @@
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
+
10
+ import { Modal } from '@postgres.ai/shared/components/Modal'
11
+ import { ImportantText } from '@postgres.ai/shared/components/ImportantText'
12
+ import { Text } from '@postgres.ai/shared/components/Text'
13
+ import { SimpleModalControls } from '@postgres.ai/shared/components/SimpleModalControls'
14
+
15
+ type Props = {
16
+ cloneId: string
17
+ isOpen: boolean
18
+ onClose: () => void
19
+ onDestroyClone: () => void
20
+ }
21
+
22
+ export const DestroyCloneModal = (props: Props) => {
23
+ const { cloneId, isOpen, onClose, onDestroyClone } = props
24
+
25
+ const handleClickDestroy = () => {
26
+ onDestroyClone()
27
+ onClose()
28
+ }
29
+
30
+ return (
31
+ <Modal
32
+ title={`Destroy clone ${cloneId}`}
33
+ onClose={onClose}
34
+ isOpen={isOpen}
35
+ >
36
+ <Text>
37
+ Are you sure you want to destroy clone{' '}
38
+ <ImportantText>{cloneId}</ImportantText>?
39
+ </Text>
40
+
41
+ <SimpleModalControls
42
+ items={[
43
+ {
44
+ text: 'Cancel',
45
+ onClick: onClose,
46
+ },
47
+ {
48
+ text: 'Destroy clone',
49
+ variant: 'primary',
50
+ onClick: handleClickDestroy,
51
+ }
52
+ ]}
53
+ />
54
+ </Modal>
55
+ )
56
+ }
@@ -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 { observer } from 'mobx-react-lite'
10
+
11
+ import { Modal } from '@postgres.ai/shared/components/Modal'
12
+ import { Link } from '@postgres.ai/shared/components/Link2'
13
+ import { ImportantText } from '@postgres.ai/shared/components/ImportantText'
14
+ import { Text } from '@postgres.ai/shared/components/Text'
15
+ import { SimpleModalControls } from '@postgres.ai/shared/components/SimpleModalControls'
16
+
17
+ type Props = {
18
+ isOpen: boolean
19
+ onClose: () => void
20
+ cloneId: string
21
+ clonePagePath?: string
22
+ }
23
+
24
+ export const DestroyCloneRestrictionModal = observer((props: Props) => {
25
+ const { isOpen, onClose, cloneId, clonePagePath } = props
26
+
27
+ return (
28
+ <Modal title="Cannot destroy clone" isOpen={isOpen} onClose={onClose}>
29
+ <Text>
30
+ Cannot destroy clone <ImportantText>{cloneId}</ImportantText> because
31
+ deletion protection is enabled. You can disable deletion protection on{' '}
32
+ {clonePagePath ? (
33
+ <Link to={clonePagePath}>the clone page</Link>
34
+ ) : (
35
+ 'this page'
36
+ )}
37
+ .
38
+ </Text>
39
+
40
+ <SimpleModalControls
41
+ items={[
42
+ {
43
+ text: 'Close',
44
+ onClick: onClose,
45
+ },
46
+ ]}
47
+ />
48
+ </Modal>
49
+ )
50
+ })
@@ -0,0 +1,83 @@
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?:
15
+ | string
16
+ | {
17
+ details: string
18
+ }
19
+ className?: string
20
+ size?: 'big' | 'normal'
21
+ }
22
+
23
+ const useStyles = makeStyles(
24
+ {
25
+ '*': {
26
+ margin: 0,
27
+ },
28
+ root: {
29
+ color: '#c00111',
30
+ overflowWrap: 'break-word',
31
+ },
32
+ rootBig: {
33
+ padding: '16px 24px',
34
+
35
+ '& $title': {
36
+ fontSize: '16px',
37
+ },
38
+ '& $message': {
39
+ marginTop: '16px',
40
+ fontSize: '14px',
41
+ },
42
+ },
43
+ rootNormal: {
44
+ padding: '8px 16px',
45
+
46
+ '& $title': {
47
+ fontSize: '14px',
48
+ },
49
+ '& $message': {
50
+ marginTop: '12px',
51
+ fontSize: '12px',
52
+ },
53
+ },
54
+ title: {
55
+ fontWeight: 700,
56
+ textTransform: 'uppercase',
57
+ },
58
+ message: {},
59
+ },
60
+ { index: 1 },
61
+ )
62
+
63
+ export const ErrorStub = (props: Props) => {
64
+ const { title = 'Error', message, className, size = 'big' } = props
65
+
66
+ const classes = useStyles()
67
+
68
+ return (
69
+ <Paper
70
+ className={clsx(
71
+ classes.root,
72
+ size === 'big' && classes.rootBig,
73
+ size === 'normal' && classes.rootNormal,
74
+ className,
75
+ )}
76
+ >
77
+ <h2 className={classes.title}>{title}</h2>
78
+ <p className={classes.message}>
79
+ {typeof message === 'object' ? message.details : message}
80
+ </p>
81
+ </Paper>
82
+ )
83
+ }
@@ -0,0 +1,44 @@
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 clsx from 'clsx'
9
+ import copy from 'copy-to-clipboard'
10
+ import useCountDown from 'react-countdown-hook'
11
+
12
+ import { Button } from '@postgres.ai/shared/components/Button2'
13
+
14
+ import styles from './styles.module.scss'
15
+
16
+ type Props = {
17
+ value: string
18
+ className?: string
19
+ }
20
+
21
+ const COOLDOWN_INTERVAL = 1000
22
+ const COOLDOWN_TIME = 1000
23
+
24
+ export const FormattedText = (props: Props) => {
25
+ const { value, className } = props
26
+
27
+ const [timeLeft, { start }] = useCountDown(0, COOLDOWN_INTERVAL)
28
+
29
+ const handleCopy = () => {
30
+ copy(value)
31
+ start(COOLDOWN_TIME)
32
+ }
33
+
34
+ return (
35
+ <div className={clsx(styles.root, className)}>
36
+ <pre className={styles.content}>{value}</pre>
37
+ <div className={styles.copyButtonContainer}>
38
+ <Button size="sm" onClick={handleCopy} className={styles.copyButton}>
39
+ {timeLeft ? 'Copied' : 'Copy'}
40
+ </Button>
41
+ </div>
42
+ </div>
43
+ )
44
+ }
@@ -0,0 +1,34 @@
1
+ @import '@postgres.ai/shared/styles/vars';
2
+ @import '@postgres.ai/shared/styles/mixins';
3
+
4
+ .root {
5
+ position: relative;
6
+ background: $color-white--100;
7
+ border: 1px solid $color-gray-100;
8
+ border-radius: $border-radius--small;
9
+ overflow: hidden;
10
+
11
+ &:hover .copyButtonContainer {
12
+ opacity: 1;
13
+ }
14
+ }
15
+
16
+ .content {
17
+ padding: 10px 80px 10px 10px;
18
+ line-height: 1.5;
19
+ overflow: auto;
20
+ max-height: inherit;
21
+ margin: 0;
22
+ }
23
+
24
+ .copyButtonContainer {
25
+ opacity: 0;
26
+
27
+ @include touch-transition(opacity);
28
+ }
29
+
30
+ .copyButton {
31
+ position: absolute;
32
+ top: 8.5px;
33
+ right: 8.5px;
34
+ }
@@ -0,0 +1,33 @@
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 '@postgres.ai/shared/components/Link2/styles.module.scss'
11
+
12
+ type Props = React.DetailedHTMLProps<
13
+ React.AnchorHTMLAttributes<HTMLAnchorElement>,
14
+ HTMLAnchorElement
15
+ >
16
+
17
+ export const GatewayLink = (props: Props) => {
18
+ const {
19
+ rel = 'noopener noreferrer',
20
+ target = '_blank',
21
+ className,
22
+ ...otherProps
23
+ } = props
24
+
25
+ return (
26
+ <a
27
+ {...otherProps}
28
+ target={target}
29
+ rel={rel}
30
+ className={cn(styles.root, className)}
31
+ />
32
+ )
33
+ }