@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.
- package/.gitlab-ci.yml +60 -0
- package/components/AlertSnackbar/index.tsx +23 -0
- package/components/AlertSnackbar/useAlertSnackbar.tsx +65 -0
- package/components/Button/index.tsx +79 -0
- package/components/Button2/index.tsx +43 -0
- package/components/Button2/styles.module.scss +82 -0
- package/components/DestroyCloneModal/index.tsx +56 -0
- package/components/DestroyCloneRestrictionModal/index.tsx +50 -0
- package/components/ErrorStub/index.tsx +83 -0
- package/components/FormattedText/index.tsx +44 -0
- package/components/FormattedText/styles.module.scss +34 -0
- package/components/GatewayLink/index.tsx +33 -0
- package/components/HorizontalScrollContainer/index.tsx +131 -0
- package/components/HorizontalScrollContainer/types.ts +12 -0
- package/components/HorizontalScrollContainer/utils.ts +16 -0
- package/components/ImportantText/index.tsx +29 -0
- package/components/Link2/index.tsx +31 -0
- package/components/Link2/styles.module.scss +12 -0
- package/components/MenuButton/index.tsx +80 -0
- package/components/MenuButton/styles.module.scss +42 -0
- package/components/Modal/index.tsx +93 -0
- package/components/PageSpinner/index.tsx +18 -0
- package/components/PageSpinner/styles.module.scss +13 -0
- package/components/ResetCloneModal/index.tsx +154 -0
- package/components/SectionTitle/index.tsx +74 -0
- package/components/Select/index.tsx +42 -0
- package/components/SimpleModalControls/index.tsx +56 -0
- package/components/Spinner/icon.tsx +29 -0
- package/components/Spinner/index.tsx +16 -0
- package/components/Spinner/styles.module.scss +33 -0
- package/components/Status/index.tsx +61 -0
- package/components/Status/styles.module.scss +45 -0
- package/components/StubContainer/index.tsx +41 -0
- package/components/StubSpinner/index.tsx +49 -0
- package/components/StubSpinnerFlex/index.tsx +20 -0
- package/components/StubSpinnerFlex/styles.module.scss +20 -0
- package/components/SyntaxHighlight/index.tsx +107 -0
- package/components/Table/RowMenu/index.tsx +111 -0
- package/components/Table/index.tsx +140 -0
- package/components/Text/index.tsx +28 -0
- package/components/TextField/index.tsx +117 -0
- package/components/Tooltip/index.tsx +52 -0
- package/config/index.ts +32 -0
- package/config/links.ts +6 -0
- package/craco.config.js +80 -0
- package/helpers/getEntropy.ts +232 -0
- package/helpers/localStorage.ts +15 -0
- package/helpers/request.ts +47 -0
- package/hooks/useWindowDimensions.ts +16 -0
- package/icons/ArrowDropDown/index.tsx +29 -0
- package/icons/Circle/index.tsx +27 -0
- package/icons/External/index.tsx +14 -0
- package/icons/Info/index.tsx +12 -0
- package/icons/Renewable/index.tsx +65 -0
- package/icons/Shield/index.tsx +33 -0
- package/icons/Warning/index.tsx +29 -0
- package/meta.json +1 -0
- package/package.json +55 -0
- package/pages/Clone/Status/index.tsx +73 -0
- package/pages/Clone/context.ts +22 -0
- package/pages/Clone/index.tsx +634 -0
- package/pages/Clone/stores/Main.ts +206 -0
- package/pages/Clone/useCreatedStores.ts +11 -0
- package/pages/Configuration/Header/index.tsx +84 -0
- package/pages/Configuration/InputWithTooltip/index.tsx +240 -0
- package/pages/Configuration/ResponseMessage/index.tsx +71 -0
- package/pages/Configuration/configOptions.ts +60 -0
- package/pages/Configuration/index.tsx +1184 -0
- package/pages/Configuration/styles.module.scss +122 -0
- package/pages/Configuration/tooltipText.tsx +157 -0
- package/pages/Configuration/useForm.ts +108 -0
- package/pages/Configuration/utils/index.ts +153 -0
- package/pages/CreateClone/index.tsx +311 -0
- package/pages/CreateClone/stores/Main.ts +107 -0
- package/pages/CreateClone/styles.module.scss +71 -0
- package/pages/CreateClone/useCreatedStores.ts +11 -0
- package/pages/CreateClone/useForm.ts +36 -0
- package/pages/Instance/Clones/Header/Item/index.tsx +15 -0
- package/pages/Instance/Clones/Header/Item/styles.module.scss +17 -0
- package/pages/Instance/Clones/Header/index.tsx +74 -0
- package/pages/Instance/Clones/Header/styles.module.scss +11 -0
- package/pages/Instance/Clones/index.tsx +135 -0
- package/pages/Instance/ClonesModal/index.tsx +71 -0
- package/pages/Instance/ClonesModal/utils.ts +21 -0
- package/pages/Instance/InactiveInstance/index.tsx +165 -0
- package/pages/Instance/InactiveInstance/utils.ts +9 -0
- package/pages/Instance/Info/Connection/ConnectModal/Content/index.tsx +176 -0
- package/pages/Instance/Info/Connection/ConnectModal/Content/utils.ts +24 -0
- package/pages/Instance/Info/Connection/ConnectModal/index.tsx +36 -0
- package/pages/Instance/Info/Connection/index.tsx +81 -0
- package/pages/Instance/Info/Details/index.tsx +20 -0
- package/pages/Instance/Info/Disks/Disk/ActionsMenu/index.tsx +100 -0
- package/pages/Instance/Info/Disks/Disk/Marker/index.tsx +26 -0
- package/pages/Instance/Info/Disks/Disk/ProgressBar/PointerIcon.tsx +20 -0
- package/pages/Instance/Info/Disks/Disk/ProgressBar/index.tsx +73 -0
- package/pages/Instance/Info/Disks/Disk/Status/index.tsx +75 -0
- package/pages/Instance/Info/Disks/Disk/index.tsx +168 -0
- package/pages/Instance/Info/Disks/index.tsx +65 -0
- package/pages/Instance/Info/Icons/index.tsx +39 -0
- package/pages/Instance/Info/Retrieval/RefreshFailedAlert/index.tsx +32 -0
- package/pages/Instance/Info/Retrieval/RefreshFailedAlert/styles.module.scss +33 -0
- package/pages/Instance/Info/Retrieval/RetrievalModal/index.tsx +49 -0
- package/pages/Instance/Info/Retrieval/RetrievalModal/styles.module.scss +6 -0
- package/pages/Instance/Info/Retrieval/RetrievalTable/index.tsx +53 -0
- package/pages/Instance/Info/Retrieval/RetrievalTable/styles.module.scss +29 -0
- package/pages/Instance/Info/Retrieval/index.tsx +95 -0
- package/pages/Instance/Info/Retrieval/utils.ts +10 -0
- package/pages/Instance/Info/Snapshots/Calendar/Day/index.tsx +125 -0
- package/pages/Instance/Info/Snapshots/Calendar/index.tsx +133 -0
- package/pages/Instance/Info/Snapshots/Calendar/utils.ts +74 -0
- package/pages/Instance/Info/Snapshots/TimeLine/Day/index.tsx +79 -0
- package/pages/Instance/Info/Snapshots/TimeLine/index.tsx +57 -0
- package/pages/Instance/Info/Snapshots/index.tsx +97 -0
- package/pages/Instance/Info/Snapshots/utils.ts +18 -0
- package/pages/Instance/Info/Status/InstanceResponseModal/index.tsx +32 -0
- package/pages/Instance/Info/Status/InstanceResponseModal/styles.module.scss +3 -0
- package/pages/Instance/Info/Status/index.tsx +85 -0
- package/pages/Instance/Info/Status/styles.module.scss +12 -0
- package/pages/Instance/Info/Status/utils.ts +24 -0
- package/pages/Instance/Info/components/Property/index.tsx +32 -0
- package/pages/Instance/Info/components/Property/styles.module.scss +21 -0
- package/pages/Instance/Info/components/Section/index.tsx +50 -0
- package/pages/Instance/Info/components/ValueStatus/index.tsx +51 -0
- package/pages/Instance/Info/index.tsx +129 -0
- package/pages/Instance/SnapshotsModal/index.tsx +169 -0
- package/pages/Instance/SnapshotsModal/utils.ts +17 -0
- package/pages/Instance/Tabs/index.tsx +98 -0
- package/pages/Instance/components/ClonesList/ConnectionModal/index.tsx +196 -0
- package/pages/Instance/components/ClonesList/MenuCell/index.tsx +98 -0
- package/pages/Instance/components/ClonesList/MenuCell/utils.ts +21 -0
- package/pages/Instance/components/ClonesList/index.tsx +189 -0
- package/pages/Instance/components/ClonesList/styles.module.scss +32 -0
- package/pages/Instance/components/ErrorStub/index.tsx +77 -0
- package/pages/Instance/components/ModalReloadButton/index.tsx +43 -0
- package/pages/Instance/components/Tags/Tag/index.tsx +60 -0
- package/pages/Instance/components/Tags/index.tsx +42 -0
- package/pages/Instance/context.ts +39 -0
- package/pages/Instance/index.tsx +235 -0
- package/pages/Instance/stores/ClonesModal.ts +35 -0
- package/pages/Instance/stores/Main.ts +335 -0
- package/pages/Instance/stores/SnapshotsModal.ts +35 -0
- package/pages/Instance/styles.scss +40 -0
- package/pages/Instance/useCreatedStores.ts +14 -0
- package/pages/Logs/Icons/PlusIcon.tsx +8 -0
- package/pages/Logs/constants/index.ts +7 -0
- package/pages/Logs/hooks/useWsScroll.tsx +44 -0
- package/pages/Logs/index.tsx +267 -0
- package/pages/Logs/utils/index.ts +20 -0
- package/pages/Logs/wsLogs.ts +110 -0
- package/pages/Logs/wsSnackbar.ts +27 -0
- package/postgres.ai-shared-3.5.0.tgz +0 -0
- package/react-app-env.d.ts +71 -0
- package/scripts/copy-assets.js +30 -0
- package/scripts/pack.js +70 -0
- package/stores/Snapshots.ts +54 -0
- package/styles/colors.ts +67 -0
- package/styles/global.scss +29 -0
- package/styles/icons.tsx +1917 -0
- package/styles/mixins.scss +30 -0
- package/styles/styles.ts +87 -0
- package/styles/theme.ts +53 -0
- package/styles/vars.scss +43 -0
- package/styles/vars.ts +40 -0
- package/tsconfig.build.json +37 -0
- package/tsconfig.json +30 -0
- package/types/api/endpoints/createClone.ts +10 -0
- package/types/api/endpoints/destroyClone.ts +7 -0
- package/types/api/endpoints/getClone.ts +6 -0
- package/types/api/endpoints/getConfig.ts +6 -0
- package/types/api/endpoints/getEngine.ts +13 -0
- package/types/api/endpoints/getFullConfig.ts +4 -0
- package/types/api/endpoints/getInstance.ts +6 -0
- package/types/api/endpoints/getInstanceRetrieval.ts +6 -0
- package/types/api/endpoints/getSeImages.ts +22 -0
- package/types/api/endpoints/getSnapshots.ts +6 -0
- package/types/api/endpoints/getWSToken.ts +6 -0
- package/types/api/endpoints/initWS.ts +1 -0
- package/types/api/endpoints/refreshInstance.ts +4 -0
- package/types/api/endpoints/resetClone.ts +8 -0
- package/types/api/endpoints/testDbSource.ts +48 -0
- package/types/api/endpoints/updateClone.ts +10 -0
- package/types/api/endpoints/updateConfig.ts +6 -0
- package/types/api/entities/clone.ts +42 -0
- package/types/api/entities/config.ts +114 -0
- package/types/api/entities/dbSource.ts +13 -0
- package/types/api/entities/instance.ts +67 -0
- package/types/api/entities/instanceRetrieval.ts +46 -0
- package/types/api/entities/instanceState.ts +102 -0
- package/types/api/entities/pool.ts +27 -0
- package/types/api/entities/snapshot.ts +18 -0
- package/types/api/entities/wsToken.ts +7 -0
- package/types/byte-size/index.d.ts +22 -0
- package/utils/api.ts +30 -0
- package/utils/clone.ts +31 -0
- package/utils/connection.ts +38 -0
- package/utils/date.ts +87 -0
- package/utils/instance.ts +10 -0
- package/utils/numbers.ts +11 -0
- package/utils/react.ts +10 -0
- package/utils/snapshot.ts +4 -0
- package/utils/strings.ts +11 -0
- 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
|
+
}
|