@postgres.ai/shared 3.5.0-pr-1027.1 → 4.0.0-pr-1028.1
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/components/DestroyCloneModal/index.js +3 -3
- package/components/DestroyCloneRestrictionModal/index.js +1 -1
- package/components/MenuButton/index.d.ts +2 -0
- package/components/MenuButton/index.js +1 -1
- package/components/ResetCloneModal/index.js +5 -3
- package/icons/ArrowDropDown/index.d.ts +1 -0
- package/icons/ArrowDropDown/index.js +1 -1
- package/icons/PostgresSQL/index.d.ts +2 -0
- package/icons/PostgresSQL/index.js +40 -0
- package/package.json +1 -1
- package/pages/Branches/Branch/context.d.ts +22 -0
- package/pages/Branches/Branch/context.js +3 -0
- package/pages/Branches/Branch/index.d.ts +9 -0
- package/pages/Branches/Branch/index.js +172 -0
- package/pages/Branches/Branch/stores/Main.d.ts +37 -0
- package/pages/Branches/Branch/stores/Main.js +90 -0
- package/pages/Branches/Branch/useCreatedStores.d.ts +6 -0
- package/pages/Branches/Branch/useCreatedStores.js +5 -0
- package/pages/Branches/components/BranchesTable/index.d.ts +10 -0
- package/pages/Branches/components/BranchesTable/index.js +107 -0
- package/pages/Branches/components/Modals/DeleteBranchModal/index.d.ts +11 -0
- package/pages/Branches/components/Modals/DeleteBranchModal/index.js +49 -0
- package/pages/Branches/components/Modals/types.d.ts +4 -0
- package/pages/Branches/components/Modals/types.js +1 -0
- package/pages/Branches/index.d.ts +6 -0
- package/pages/Branches/index.js +60 -0
- package/pages/Clone/context.d.ts +2 -0
- package/pages/Clone/index.d.ts +3 -1
- package/pages/Clone/index.js +54 -23
- package/pages/Clone/stores/Main.d.ts +4 -2
- package/pages/Clone/utils/index.d.ts +4 -0
- package/pages/Clone/utils/index.js +12 -0
- package/pages/CreateBranch/index.d.ts +17 -0
- package/pages/CreateBranch/index.js +135 -0
- package/pages/CreateBranch/stores/Main.d.ts +43 -0
- package/pages/CreateBranch/stores/Main.js +59 -0
- package/pages/CreateBranch/useCreatedStores.d.ts +6 -0
- package/pages/CreateBranch/useCreatedStores.js +5 -0
- package/pages/CreateBranch/useForm.d.ts +51 -0
- package/pages/CreateBranch/useForm.js +30 -0
- package/pages/CreateBranch/utils/index.d.ts +2 -0
- package/pages/CreateBranch/utils/index.js +10 -0
- package/pages/CreateClone/index.d.ts +4 -2
- package/pages/CreateClone/index.js +92 -40
- package/pages/CreateClone/stores/Main.d.ts +25 -2
- package/pages/CreateClone/stores/Main.js +26 -2
- package/pages/CreateClone/styles.module.scss +47 -4
- package/pages/CreateClone/useForm.d.ts +1 -0
- package/pages/CreateClone/useForm.js +1 -0
- package/pages/CreateClone/utils/index.d.ts +3 -0
- package/pages/CreateClone/utils/index.js +17 -0
- package/pages/CreateSnapshot/index.d.ts +17 -0
- package/pages/CreateSnapshot/index.js +117 -0
- package/pages/CreateSnapshot/stores/Main.d.ts +21 -0
- package/pages/CreateSnapshot/stores/Main.js +31 -0
- package/pages/CreateSnapshot/useCreatedStores.d.ts +6 -0
- package/pages/CreateSnapshot/useCreatedStores.js +5 -0
- package/pages/CreateSnapshot/useForm.d.ts +53 -0
- package/pages/CreateSnapshot/useForm.js +25 -0
- package/pages/CreateSnapshot/utils/index.d.ts +1 -0
- package/pages/CreateSnapshot/utils/index.js +3 -0
- package/pages/Instance/{components → Clones}/ClonesList/MenuCell/index.js +1 -1
- package/pages/Instance/{components → Clones}/ClonesList/MenuCell/utils.js +2 -2
- package/pages/Instance/Clones/ClonesList/index.js +96 -0
- package/pages/Instance/{components → Clones}/ClonesList/styles.module.scss +10 -0
- package/pages/Instance/{ClonesModal → Clones/ClonesModal}/index.js +5 -5
- package/pages/Instance/Clones/Header/styles.module.scss +4 -1
- package/pages/Instance/Clones/index.d.ts +5 -1
- package/pages/Instance/Clones/index.js +6 -8
- package/pages/{Configuration → Instance/Configuration}/InputWithTooltip/index.js +15 -11
- package/pages/{Configuration → Instance/Configuration}/index.d.ts +2 -1
- package/pages/{Configuration → Instance/Configuration}/index.js +9 -6
- package/pages/{Configuration → Instance/Configuration}/tooltipText.js +1 -1
- package/pages/Instance/Info/Disks/Disk/index.js +6 -4
- package/pages/Instance/Info/Retrieval/RetrievalModal/index.js +0 -4
- package/pages/Instance/Info/Retrieval/index.js +1 -3
- package/pages/Instance/Info/Snapshots/Calendar/utils.d.ts +4 -0
- package/pages/Instance/Info/Snapshots/index.js +10 -5
- package/pages/Instance/Info/Snapshots/utils.d.ts +13 -2
- package/pages/Instance/Info/Snapshots/utils.js +16 -6
- package/pages/Instance/Info/Status/index.js +2 -2
- package/pages/Instance/Info/index.js +2 -1
- package/pages/Instance/Snapshots/components/SnapshotHeader/index.d.ts +11 -0
- package/pages/Instance/Snapshots/components/SnapshotHeader/index.js +36 -0
- package/pages/Instance/Snapshots/components/SnapshotsList/index.d.ts +11 -0
- package/pages/Instance/Snapshots/components/SnapshotsList/index.js +157 -0
- package/pages/Instance/Snapshots/components/SnapshotsTable/index.d.ts +6 -0
- package/pages/Instance/Snapshots/components/SnapshotsTable/index.js +125 -0
- package/pages/Instance/Snapshots/index.d.ts +6 -0
- package/pages/Instance/Snapshots/index.js +92 -0
- package/pages/Instance/Snapshots/utils/index.d.ts +16 -0
- package/pages/Instance/Snapshots/utils/index.js +30 -0
- package/pages/Instance/SnapshotsModal/index.js +1 -1
- package/pages/Instance/Tabs/PlatformTabs.d.ts +10 -0
- package/pages/Instance/Tabs/PlatformTabs.js +51 -0
- package/pages/Instance/Tabs/index.d.ts +19 -2
- package/pages/Instance/Tabs/index.js +71 -36
- package/pages/Instance/Tabs/styles.d.ts +1 -0
- package/pages/Instance/Tabs/styles.js +62 -0
- package/pages/Instance/components/ModalReloadButton/index.js +1 -1
- package/pages/Instance/context.d.ts +7 -0
- package/pages/Instance/index.js +14 -13
- package/pages/Instance/stores/Main.d.ts +36 -10
- package/pages/Instance/stores/Main.js +83 -24
- package/pages/Instance/styles.scss +1 -4
- package/pages/Logs/hooks/useWsScroll.js +6 -8
- package/pages/Logs/index.d.ts +2 -1
- package/pages/Logs/index.js +42 -31
- package/pages/Logs/wsLogs.d.ts +3 -2
- package/pages/Logs/wsLogs.js +24 -8
- package/pages/Logs/wsSnackbar.js +7 -7
- package/pages/Snapshots/Snapshot/DestorySnapshotModal/index.d.ts +12 -0
- package/pages/Snapshots/Snapshot/DestorySnapshotModal/index.js +69 -0
- package/pages/Snapshots/Snapshot/context.d.ts +23 -0
- package/pages/Snapshots/Snapshot/context.js +3 -0
- package/pages/Snapshots/Snapshot/index.d.ts +9 -0
- package/pages/Snapshots/Snapshot/index.js +171 -0
- package/pages/Snapshots/Snapshot/stores/Main.d.ts +33 -0
- package/pages/Snapshots/Snapshot/stores/Main.js +71 -0
- package/pages/Snapshots/Snapshot/useCreatedStores.d.ts +6 -0
- package/pages/Snapshots/Snapshot/useCreatedStores.js +5 -0
- package/stores/Snapshots.d.ts +12 -3
- package/stores/Snapshots.js +27 -3
- package/types/api/endpoints/createBranch.d.ts +12 -0
- package/types/api/endpoints/createBranch.js +1 -0
- package/types/api/endpoints/createClone.d.ts +1 -0
- package/types/api/endpoints/createSnapshot.d.ts +5 -0
- package/types/api/endpoints/createSnapshot.js +1 -0
- package/types/api/endpoints/deleteBranch.d.ts +4 -0
- package/types/api/endpoints/deleteBranch.js +1 -0
- package/types/api/endpoints/destroySnapshot.d.ts +4 -0
- package/types/api/endpoints/destroySnapshot.js +1 -0
- package/types/api/endpoints/getBranchSnapshot.d.ts +5 -0
- package/types/api/endpoints/getBranchSnapshot.js +1 -0
- package/types/api/endpoints/getBranches.d.ts +18 -0
- package/types/api/endpoints/getBranches.js +5 -0
- package/types/api/endpoints/getConfig.d.ts +2 -2
- package/types/api/endpoints/getEngine.d.ts +1 -1
- package/types/api/endpoints/getFullConfig.d.ts +1 -1
- package/types/api/endpoints/getSnapshotList.d.ts +10 -0
- package/types/api/endpoints/getSnapshotList.js +1 -0
- package/types/api/endpoints/getSnapshots.d.ts +1 -0
- package/types/api/endpoints/updateConfig.d.ts +1 -1
- package/types/api/entities/branchSnapshot.d.ts +6 -0
- package/types/api/entities/branchSnapshot.js +1 -0
- package/types/api/entities/branchSnapshots.d.ts +15 -0
- package/types/api/entities/branchSnapshots.js +7 -0
- package/types/api/entities/clone.d.ts +6 -0
- package/types/api/entities/config.js +1 -1
- package/types/api/entities/createBranch.d.ts +5 -0
- package/types/api/entities/createBranch.js +1 -0
- package/types/api/entities/createSnapshot.d.ts +5 -0
- package/types/api/entities/createSnapshot.js +1 -0
- package/types/api/entities/dbSource.d.ts +1 -0
- package/types/api/entities/instance.d.ts +5 -0
- package/types/api/entities/instanceState.d.ts +5 -0
- package/types/api/entities/snapshot.d.ts +8 -0
- package/types/api/entities/snapshot.js +1 -1
- package/utils/date.d.ts +2 -0
- package/utils/date.js +7 -0
- package/utils/snapshot.d.ts +5 -2
- package/utils/snapshot.js +6 -1
- package/pages/Instance/components/ClonesList/index.js +0 -52
- /package/pages/Instance/{components → Clones}/ClonesList/ConnectionModal/index.d.ts +0 -0
- /package/pages/Instance/{components → Clones}/ClonesList/ConnectionModal/index.js +0 -0
- /package/pages/Instance/{components → Clones}/ClonesList/MenuCell/index.d.ts +0 -0
- /package/pages/Instance/{components → Clones}/ClonesList/MenuCell/utils.d.ts +0 -0
- /package/pages/Instance/{components → Clones}/ClonesList/index.d.ts +0 -0
- /package/pages/Instance/{ClonesModal → Clones/ClonesModal}/index.d.ts +0 -0
- /package/pages/Instance/{ClonesModal → Clones/ClonesModal}/utils.d.ts +0 -0
- /package/pages/Instance/{ClonesModal → Clones/ClonesModal}/utils.js +0 -0
- /package/pages/{Configuration → Instance/Configuration}/Header/index.d.ts +0 -0
- /package/pages/{Configuration → Instance/Configuration}/Header/index.js +0 -0
- /package/pages/{Configuration → Instance/Configuration}/InputWithTooltip/index.d.ts +0 -0
- /package/pages/{Configuration → Instance/Configuration}/ResponseMessage/index.d.ts +0 -0
- /package/pages/{Configuration → Instance/Configuration}/ResponseMessage/index.js +0 -0
- /package/pages/{Configuration → Instance/Configuration}/configOptions.d.ts +0 -0
- /package/pages/{Configuration → Instance/Configuration}/configOptions.js +0 -0
- /package/pages/{Configuration → Instance/Configuration}/styles.module.scss +0 -0
- /package/pages/{Configuration → Instance/Configuration}/tooltipText.d.ts +0 -0
- /package/pages/{Configuration → Instance/Configuration}/useForm.d.ts +0 -0
- /package/pages/{Configuration → Instance/Configuration}/useForm.js +0 -0
- /package/pages/{Configuration → Instance/Configuration}/utils/index.d.ts +0 -0
- /package/pages/{Configuration → Instance/Configuration}/utils/index.js +0 -0
- /package/pages/Instance/{SnapshotsModal → Snapshots/components/SnapshotsModal}/utils.d.ts +0 -0
- /package/pages/Instance/{SnapshotsModal → Snapshots/components/SnapshotsModal}/utils.js +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*--------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
|
|
4
|
+
* All Rights Reserved. Proprietary and confidential.
|
|
5
|
+
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
6
|
+
*--------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import { useEffect } from 'react';
|
|
9
|
+
import { useHistory } from 'react-router';
|
|
10
|
+
import { observer } from 'mobx-react-lite';
|
|
11
|
+
import { makeStyles } from '@material-ui/core';
|
|
12
|
+
import { Button } from '@postgres.ai/shared/components/Button';
|
|
13
|
+
import { ResponseMessage } from '@postgres.ai/shared/pages/Instance/Configuration/ResponseMessage';
|
|
14
|
+
import { Select } from '@postgres.ai/shared/components/Select';
|
|
15
|
+
import { SectionTitle } from '@postgres.ai/shared/components/SectionTitle';
|
|
16
|
+
import { SyntaxHighlight } from '@postgres.ai/shared/components/SyntaxHighlight';
|
|
17
|
+
import { StubSpinner } from '@postgres.ai/shared/components/StubSpinnerFlex';
|
|
18
|
+
import { Spinner } from '@postgres.ai/shared/components/Spinner';
|
|
19
|
+
import { generateSnapshotPageId } from '@postgres.ai/shared/pages/Instance/Snapshots/utils';
|
|
20
|
+
import { TextField } from '@postgres.ai/shared/components/TextField';
|
|
21
|
+
import { useForm } from './useForm';
|
|
22
|
+
import { useCreatedStores } from './useCreatedStores';
|
|
23
|
+
import { getCliCreateSnapshotCommand } from './utils';
|
|
24
|
+
import { InstanceTabs, TABS_INDEX } from "../Instance/Tabs";
|
|
25
|
+
const useStyles = makeStyles({
|
|
26
|
+
wrapper: {
|
|
27
|
+
display: 'flex',
|
|
28
|
+
gap: '60px',
|
|
29
|
+
maxWidth: '1200px',
|
|
30
|
+
fontSize: '14px',
|
|
31
|
+
marginTop: '20px',
|
|
32
|
+
'@media (max-width: 1300px)': {
|
|
33
|
+
flexDirection: 'column',
|
|
34
|
+
gap: '20px',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
container: {
|
|
38
|
+
maxWidth: '100%',
|
|
39
|
+
flex: '1 1 0',
|
|
40
|
+
minWidth: 0,
|
|
41
|
+
'& p,span': {
|
|
42
|
+
fontSize: 14,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
snippetContainer: {
|
|
46
|
+
flex: '1 1 0',
|
|
47
|
+
minWidth: 0,
|
|
48
|
+
boxShadow: 'rgba(0, 0, 0, 0.1) 0px 4px 12px',
|
|
49
|
+
padding: '10px 20px 10px 20px',
|
|
50
|
+
height: 'max-content',
|
|
51
|
+
borderRadius: '4px',
|
|
52
|
+
},
|
|
53
|
+
marginBottom: {
|
|
54
|
+
marginBottom: '8px',
|
|
55
|
+
},
|
|
56
|
+
marginBottom2x: {
|
|
57
|
+
marginBottom: '16px',
|
|
58
|
+
},
|
|
59
|
+
marginTop: {
|
|
60
|
+
marginTop: '8px',
|
|
61
|
+
},
|
|
62
|
+
marginTop2x: {
|
|
63
|
+
marginTop: '16px',
|
|
64
|
+
},
|
|
65
|
+
spinner: {
|
|
66
|
+
marginLeft: '8px',
|
|
67
|
+
color: '#fff',
|
|
68
|
+
},
|
|
69
|
+
title: {
|
|
70
|
+
marginTop: '8px',
|
|
71
|
+
lineHeight: '26px'
|
|
72
|
+
},
|
|
73
|
+
}, { index: 1 });
|
|
74
|
+
export const CreateSnapshotPage = observer(({ instanceId, api, elements, routes, isPlatform }) => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const stores = useCreatedStores(api);
|
|
77
|
+
const classes = useStyles();
|
|
78
|
+
const history = useHistory();
|
|
79
|
+
const { load, instance, createSnapshot, isCreatingSnapshot, snapshotError, } = stores.main;
|
|
80
|
+
const clonesList = ((_b = (_a = instance === null || instance === void 0 ? void 0 : instance.instance) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.cloning.clones) || [];
|
|
81
|
+
const handleSubmit = async (values) => {
|
|
82
|
+
await createSnapshot(values.cloneID, values.message, instanceId).then((snapshot) => {
|
|
83
|
+
if (snapshot && generateSnapshotPageId(snapshot.snapshotID)) {
|
|
84
|
+
history.push(routes.snapshot(generateSnapshotPageId(snapshot.snapshotID)));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
const [{ formik }] = useForm(handleSubmit);
|
|
89
|
+
if (!clonesList) {
|
|
90
|
+
return _jsx(StubSpinner, {});
|
|
91
|
+
}
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
load(instanceId);
|
|
94
|
+
}, []);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!history.location.search)
|
|
97
|
+
return;
|
|
98
|
+
const queryString = history.location.search.split('?')[1];
|
|
99
|
+
if (!queryString)
|
|
100
|
+
return;
|
|
101
|
+
const params = new URLSearchParams(queryString);
|
|
102
|
+
const cloneID = params.get('clone_id');
|
|
103
|
+
if (!cloneID)
|
|
104
|
+
return;
|
|
105
|
+
formik.setFieldValue('cloneID', cloneID);
|
|
106
|
+
}, [history.location.search, formik.initialValues]);
|
|
107
|
+
return (_jsxs(_Fragment, { children: [elements.breadcrumbs, _jsx(SectionTitle, { tag: "h1", level: 1, text: "Create snapshot", className: classes.title, children: _jsx(InstanceTabs, { tab: TABS_INDEX.SNAPSHOTS, isPlatform: isPlatform, instanceId: instanceId, hasLogs: api.initWS !== undefined }) }), _jsxs("div", { className: classes.wrapper, children: [_jsx("div", { className: classes.container, children: _jsxs("div", { className: classes.marginTop2x, children: [_jsx("strong", { children: "Clone ID" }), _jsx("p", { className: classes.marginTop, children: "Choose a clone ID from the dropdown below. This will be the starting point for your new snapshot." }), _jsx(Select, { fullWidth: true, label: "Clone ID *", value: formik.values.cloneID, disabled: formik.isSubmitting, className: classes.marginBottom2x, onChange: (e) => formik.setFieldValue('cloneID', e.target.value), error: Boolean(formik.errors.cloneID), items: clonesList
|
|
108
|
+
? clonesList.map((clone, i) => {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
const isLatest = i === 0;
|
|
111
|
+
return {
|
|
112
|
+
value: clone.id,
|
|
113
|
+
children: (_jsxs("div", { children: [_jsxs("strong", { children: [clone.id, " ", isLatest && _jsx("span", { children: "Latest" })] }), _jsxs("p", { children: ["Created: ", (_a = clone === null || clone === void 0 ? void 0 : clone.snapshot) === null || _a === void 0 ? void 0 : _a.createdAt] }), _jsxs("p", { children: ["Data state at: ", (_b = clone === null || clone === void 0 ? void 0 : clone.snapshot) === null || _b === void 0 ? void 0 : _b.dataStateAt] })] })),
|
|
114
|
+
};
|
|
115
|
+
})
|
|
116
|
+
: [] }), _jsx("strong", { children: "Message" }), _jsx("p", { className: classes.marginTop, children: "Message to be added to the snapshot." }), _jsx(TextField, { label: "Message *", fullWidth: true, className: classes.marginBottom2x, value: formik.values.message, error: Boolean(formik.errors.message), onChange: (e) => formik.setFieldValue('message', e.target.value) }), _jsxs(Button, { variant: "primary", size: "medium", className: classes.marginTop, onClick: formik.submitForm, children: ["Create snapshot", isCreatingSnapshot && (_jsx(Spinner, { size: "sm", className: classes.spinner }))] }), snapshotError && (_jsx(ResponseMessage, { type: 'error', message: snapshotError }))] }) }), ' ', _jsxs("div", { className: classes.snippetContainer, children: [_jsx(SectionTitle, { tag: "h1", level: 1, text: "The same using CLI" }), _jsx("p", { className: classes.marginTop, children: "Alternatively, you can create a new snapshot using CLI. Fill the form, copy the command below and paste it into your terminal." }), _jsx(SyntaxHighlight, { content: getCliCreateSnapshotCommand(formik.values.cloneID, formik.values.message) })] })] })] }));
|
|
117
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CreateSnapshot } from '@postgres.ai/shared/types/api/endpoints/createSnapshot';
|
|
2
|
+
import { MainStore as InstanceStore, Api as InstanceStoreApi } from '@postgres.ai/shared/pages/Instance/stores/Main';
|
|
3
|
+
import { InitWS } from '@postgres.ai/shared/types/api/endpoints/initWS';
|
|
4
|
+
declare type Error = {
|
|
5
|
+
title?: string;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type MainStoreApi = InstanceStoreApi & {
|
|
9
|
+
createSnapshot: CreateSnapshot;
|
|
10
|
+
initWS: InitWS;
|
|
11
|
+
};
|
|
12
|
+
export declare class MainStore {
|
|
13
|
+
snapshotError: Error | null;
|
|
14
|
+
isCreatingSnapshot: boolean;
|
|
15
|
+
readonly instance: InstanceStore;
|
|
16
|
+
private readonly api;
|
|
17
|
+
constructor(api: MainStoreApi);
|
|
18
|
+
load: (instanceId: string) => Promise<void>;
|
|
19
|
+
createSnapshot: (cloneID: string, message: string, instanceId: string) => Promise<import("../../../types/api/entities/createSnapshot").CreateSnapshotDTO | null | undefined>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
import { makeAutoObservable } from 'mobx';
|
|
8
|
+
import { MainStore as InstanceStore, } from '@postgres.ai/shared/pages/Instance/stores/Main';
|
|
9
|
+
export class MainStore {
|
|
10
|
+
constructor(api) {
|
|
11
|
+
this.snapshotError = null;
|
|
12
|
+
this.isCreatingSnapshot = false;
|
|
13
|
+
this.load = async (instanceId) => {
|
|
14
|
+
this.instance.load(instanceId);
|
|
15
|
+
};
|
|
16
|
+
this.createSnapshot = async (cloneID, message, instanceId) => {
|
|
17
|
+
if (!this.api.createSnapshot)
|
|
18
|
+
return;
|
|
19
|
+
this.snapshotError = null;
|
|
20
|
+
this.isCreatingSnapshot = true;
|
|
21
|
+
const { response, error } = await this.api.createSnapshot(cloneID, message, instanceId);
|
|
22
|
+
this.isCreatingSnapshot = false;
|
|
23
|
+
if (error)
|
|
24
|
+
this.snapshotError = await error.json().then((err) => err.message);
|
|
25
|
+
return response;
|
|
26
|
+
};
|
|
27
|
+
this.api = api;
|
|
28
|
+
this.instance = new InstanceStore(api);
|
|
29
|
+
makeAutoObservable(this);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type FormValues = {
|
|
3
|
+
cloneID: string;
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const useForm: (onSubmit: (values: FormValues) => void) => {
|
|
7
|
+
formik: {
|
|
8
|
+
initialValues: FormValues;
|
|
9
|
+
initialErrors: import("formik").FormikErrors<unknown>;
|
|
10
|
+
initialTouched: import("formik").FormikTouched<unknown>;
|
|
11
|
+
initialStatus: any;
|
|
12
|
+
handleBlur: {
|
|
13
|
+
(e: import("react").FocusEvent<any, Element>): void;
|
|
14
|
+
<T = any>(fieldOrEvent: T): T extends string ? (e: any) => void : void;
|
|
15
|
+
};
|
|
16
|
+
handleChange: {
|
|
17
|
+
(e: import("react").ChangeEvent<any>): void;
|
|
18
|
+
<T_1 = string | import("react").ChangeEvent<any>>(field: T_1): T_1 extends import("react").ChangeEvent<any> ? void : (e: string | import("react").ChangeEvent<any>) => void;
|
|
19
|
+
};
|
|
20
|
+
handleReset: (e: any) => void;
|
|
21
|
+
handleSubmit: (e?: import("react").FormEvent<HTMLFormElement> | undefined) => void;
|
|
22
|
+
resetForm: (nextState?: Partial<import("formik").FormikState<FormValues>> | undefined) => void;
|
|
23
|
+
setErrors: (errors: import("formik").FormikErrors<FormValues>) => void;
|
|
24
|
+
setFormikState: (stateOrCb: import("formik").FormikState<FormValues> | ((state: import("formik").FormikState<FormValues>) => import("formik").FormikState<FormValues>)) => void;
|
|
25
|
+
setFieldTouched: (field: string, touched?: boolean | undefined, shouldValidate?: boolean | undefined) => Promise<void> | Promise<import("formik").FormikErrors<FormValues>>;
|
|
26
|
+
setFieldValue: (field: string, value: any, shouldValidate?: boolean | undefined) => Promise<void> | Promise<import("formik").FormikErrors<FormValues>>;
|
|
27
|
+
setFieldError: (field: string, value: string | undefined) => void;
|
|
28
|
+
setStatus: (status: any) => void;
|
|
29
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
30
|
+
setTouched: (touched: import("formik").FormikTouched<FormValues>, shouldValidate?: boolean | undefined) => Promise<void> | Promise<import("formik").FormikErrors<FormValues>>;
|
|
31
|
+
setValues: (values: import("react").SetStateAction<FormValues>, shouldValidate?: boolean | undefined) => Promise<void> | Promise<import("formik").FormikErrors<FormValues>>;
|
|
32
|
+
submitForm: () => Promise<any>;
|
|
33
|
+
validateForm: (values?: FormValues | undefined) => Promise<import("formik").FormikErrors<FormValues>>;
|
|
34
|
+
validateField: (name: string) => Promise<void> | Promise<string | undefined>;
|
|
35
|
+
isValid: boolean;
|
|
36
|
+
dirty: boolean;
|
|
37
|
+
unregisterField: (name: string) => void;
|
|
38
|
+
registerField: (name: string, { validate }: any) => void;
|
|
39
|
+
getFieldProps: (nameOrOptions: any) => import("formik").FieldInputProps<any>;
|
|
40
|
+
getFieldMeta: (name: string) => import("formik").FieldMetaProps<any>;
|
|
41
|
+
getFieldHelpers: (name: string) => import("formik").FieldHelperProps<any>;
|
|
42
|
+
validateOnBlur: boolean;
|
|
43
|
+
validateOnChange: boolean;
|
|
44
|
+
validateOnMount: boolean;
|
|
45
|
+
values: FormValues;
|
|
46
|
+
errors: import("formik").FormikErrors<FormValues>;
|
|
47
|
+
touched: import("formik").FormikTouched<FormValues>;
|
|
48
|
+
isSubmitting: boolean;
|
|
49
|
+
isValidating: boolean;
|
|
50
|
+
status?: any;
|
|
51
|
+
submitCount: number;
|
|
52
|
+
};
|
|
53
|
+
}[];
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import { useFormik } from 'formik';
|
|
8
|
+
import * as Yup from 'yup';
|
|
9
|
+
const Schema = Yup.object().shape({
|
|
10
|
+
cloneID: Yup.string().required('Clone ID is required'),
|
|
11
|
+
message: Yup.string().required('Message is required'),
|
|
12
|
+
});
|
|
13
|
+
export const useForm = (onSubmit) => {
|
|
14
|
+
const formik = useFormik({
|
|
15
|
+
initialValues: {
|
|
16
|
+
cloneID: '',
|
|
17
|
+
message: '',
|
|
18
|
+
},
|
|
19
|
+
validationSchema: Schema,
|
|
20
|
+
onSubmit,
|
|
21
|
+
validateOnBlur: false,
|
|
22
|
+
validateOnChange: false,
|
|
23
|
+
});
|
|
24
|
+
return [{ formik }];
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCliCreateSnapshotCommand: (cloneID: string, message: string) => string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*--------------------------------------------------------------------------
|
|
6
6
|
*/
|
|
7
7
|
export const destroyRestriction = (cloneId) => {
|
|
8
|
-
const message = `The clone "${cloneId}" is marked as protected. To
|
|
8
|
+
const message = `The clone "${cloneId}" is marked as protected. To delete it, disable the delete protection first.`;
|
|
9
9
|
window.alert(message);
|
|
10
10
|
};
|
|
11
11
|
export const getResetApprove = (cloneId) => {
|
|
@@ -13,6 +13,6 @@ export const getResetApprove = (cloneId) => {
|
|
|
13
13
|
return window.confirm(message);
|
|
14
14
|
};
|
|
15
15
|
export const getDestroyApprove = (cloneId) => {
|
|
16
|
-
const message = `Are you sure you want to
|
|
16
|
+
const message = `Are you sure you want to delete the Database Lab clone: "${cloneId}"?`;
|
|
17
17
|
return window.confirm(message);
|
|
18
18
|
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*--------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
|
|
4
|
+
* All Rights Reserved. Proprietary and confidential.
|
|
5
|
+
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
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
|
+
import { Table, TableHead, TableRow, TableHeaderCell, TableBody, TableBodyCell, } from '@postgres.ai/shared/components/Table';
|
|
13
|
+
import { ArrowDropDownIcon } from '@postgres.ai/shared/icons/ArrowDropDown';
|
|
14
|
+
import { ShieldIcon } from '@postgres.ai/shared/icons/Shield';
|
|
15
|
+
import { RenewableIcon } from '@postgres.ai/shared/icons/Renewable';
|
|
16
|
+
import { InfoIcon } from '@postgres.ai/shared/icons/Info';
|
|
17
|
+
import { HorizontalScrollContainer } from '@postgres.ai/shared/components/HorizontalScrollContainer';
|
|
18
|
+
import { Status } from '@postgres.ai/shared/components/Status';
|
|
19
|
+
import { Tooltip } from '@postgres.ai/shared/components/Tooltip';
|
|
20
|
+
import { useHost } from '@postgres.ai/shared/pages/Instance/context';
|
|
21
|
+
import { getCloneStatusType, getCloneStatusText, } from '@postgres.ai/shared/utils/clone';
|
|
22
|
+
import { formatBytesIEC } from '@postgres.ai/shared/utils/units';
|
|
23
|
+
import { isValidDate } from '@postgres.ai/shared/utils/date';
|
|
24
|
+
import { MenuCell } from './MenuCell';
|
|
25
|
+
import { ConnectionModal } from './ConnectionModal';
|
|
26
|
+
import styles from './styles.module.scss';
|
|
27
|
+
export const ClonesList = (props) => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
const host = useHost();
|
|
30
|
+
const history = useHistory();
|
|
31
|
+
const [state, setState] = useState({
|
|
32
|
+
sortByBranch: 'desc',
|
|
33
|
+
sortByCreated: 'desc',
|
|
34
|
+
clones: (_a = props.clones) !== null && _a !== void 0 ? _a : [],
|
|
35
|
+
});
|
|
36
|
+
const [cloneIdForConnect, setCloneIdForConnect] = useState(null);
|
|
37
|
+
const [isOpenConnectionModal, setIsOpenConnectionModal] = useState(false);
|
|
38
|
+
const openConnectionModal = (cloneId) => {
|
|
39
|
+
setCloneIdForConnect(cloneId);
|
|
40
|
+
setIsOpenConnectionModal(true);
|
|
41
|
+
};
|
|
42
|
+
const closeConnectionModal = () => {
|
|
43
|
+
setIsOpenConnectionModal(false);
|
|
44
|
+
};
|
|
45
|
+
const handleSortByBranch = () => {
|
|
46
|
+
const sortByBranch = state.sortByBranch === 'desc' ? 'asc' : 'desc';
|
|
47
|
+
const sortedClones = [...state.clones].sort((a, b) => {
|
|
48
|
+
if (sortByBranch === 'asc') {
|
|
49
|
+
return a.branch.localeCompare(b.branch);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return b.branch.localeCompare(a.branch);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
setState({
|
|
56
|
+
...state,
|
|
57
|
+
sortByBranch,
|
|
58
|
+
clones: sortedClones,
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const handleSortByCreated = () => {
|
|
62
|
+
const sortByCreated = state.sortByCreated === 'desc' ? 'asc' : 'desc';
|
|
63
|
+
const sortedClones = [...state.clones].sort((a, b) => {
|
|
64
|
+
if (sortByCreated === 'asc') {
|
|
65
|
+
return (new Date(a.createdAtDate).getTime() -
|
|
66
|
+
new Date(b.createdAtDate).getTime());
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
return (new Date(b.createdAtDate).getTime() -
|
|
70
|
+
new Date(a.createdAtDate).getTime());
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
setState({
|
|
74
|
+
...state,
|
|
75
|
+
sortByCreated,
|
|
76
|
+
clones: sortedClones,
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
if (!((_b = state.clones) === null || _b === void 0 ? void 0 : _b.length))
|
|
80
|
+
return _jsx("p", { className: styles.emptyStub, children: props.emptyStubText });
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsx(HorizontalScrollContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableHeaderCell, {}), _jsx(TableHeaderCell, { children: "Status" }), _jsx(TableHeaderCell, { children: "ID" }), _jsx(TableHeaderCell, { children: _jsxs("div", { onClick: handleSortByBranch, className: cn(styles.interactiveRow, styles.verticalCentered), children: ["Branch", _jsx(ArrowDropDownIcon, { className: cn(state.sortByCreated === 'asc' && styles.hideSortIcon, state.sortByBranch === 'asc' && styles.sortIconUp, styles.sortIcon) })] }) }), _jsx(TableHeaderCell, { children: _jsx(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.", children: _jsxs("div", { className: styles.verticalCentered, children: ["Protected", _jsx(InfoIcon, { className: styles.infoIcon })] }) }) }), _jsx(TableHeaderCell, { children: _jsxs("div", { onClick: handleSortByCreated, className: cn(styles.interactiveRow, styles.verticalCentered), children: ["Created", _jsx(ArrowDropDownIcon, { className: cn(state.sortByBranch === 'asc' && styles.hideSortIcon, state.sortByCreated === 'asc' && styles.sortIconUp, styles.sortIcon) })] }) }), _jsx(TableHeaderCell, { children: "Port" }), _jsx(TableHeaderCell, { children: "DB user" }), _jsx(TableHeaderCell, { children: _jsx(Tooltip, { content: "Clone's own size \u2013 how much data was added or modified.", children: _jsxs("div", { className: styles.verticalCentered, children: ["Diff size", _jsx(InfoIcon, { className: styles.infoIcon })] }) }) }), _jsx(TableHeaderCell, { children: "Disk" }), _jsx(TableHeaderCell, { children: "Data state time" })] }) }), _jsx(TableBody, { children: state.clones.map((clone) => {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
const clonePagePath = host.routes.clone(clone.id);
|
|
84
|
+
return (_jsxs(TableRow, { hover: !props.isDisabled, onClick: props.isDisabled
|
|
85
|
+
? undefined
|
|
86
|
+
: () => history.push(clonePagePath), className: cn(!props.isDisabled && styles.interactiveRow), children: [_jsx(MenuCell, { clone: clone, onConnect: openConnectionModal, clonePagePath: clonePagePath }), _jsx(TableBodyCell, { children: _jsx(Tooltip, { content: clone.status.message, children: _jsx(Status, { type: getCloneStatusType(clone.status.code), children: getCloneStatusText(clone.status.code) }) }) }), _jsx(TableBodyCell, { children: clone.id }), _jsx(TableBodyCell, { children: clone.branch }), _jsx(TableBodyCell, { children: clone.protected ? (_jsx(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.", children: _jsx(ShieldIcon, { className: styles.protectionIcon }) })) : (_jsx(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.", children: _jsx(RenewableIcon, { className: styles.protectionIcon }) })) }), _jsxs(TableBodyCell, { children: [clone.createdAt, " (", isValidDate(clone.createdAtDate)
|
|
87
|
+
? formatDistanceToNowStrict(clone.createdAtDate, {
|
|
88
|
+
addSuffix: true,
|
|
89
|
+
})
|
|
90
|
+
: '-', ")"] }), _jsx(TableBodyCell, { children: clone.db.port }), _jsx(TableBodyCell, { children: clone.db.username }), _jsx(TableBodyCell, { children: formatBytesIEC(clone.metadata.cloneDiffSize) }), _jsx(TableBodyCell, { children: (_b = (_a = clone.snapshot) === null || _a === void 0 ? void 0 : _a.pool) !== null && _b !== void 0 ? _b : '-' }), _jsx(TableBodyCell, { children: clone.snapshot ? (_jsxs(_Fragment, { children: [clone.snapshot.dataStateAt, " (", isValidDate(clone.snapshot.dataStateAtDate)
|
|
91
|
+
? formatDistanceToNowStrict(clone.snapshot.dataStateAtDate, {
|
|
92
|
+
addSuffix: true,
|
|
93
|
+
})
|
|
94
|
+
: '-', ")"] })) : ('-') })] }, clone.id));
|
|
95
|
+
}) })] }) }), cloneIdForConnect && (_jsx(ConnectionModal, { cloneId: cloneIdForConnect, isOpen: isOpenConnectionModal, onClose: closeConnectionModal }))] }));
|
|
96
|
+
};
|
|
@@ -9,7 +9,7 @@ import { makeStyles } from '@material-ui/core';
|
|
|
9
9
|
import { observer } from 'mobx-react-lite';
|
|
10
10
|
import { useStores } from '@postgres.ai/shared/pages/Instance/context';
|
|
11
11
|
import { Modal } from '@postgres.ai/shared/components/Modal';
|
|
12
|
-
import { ClonesList } from '@postgres.ai/shared/pages/Instance/
|
|
12
|
+
import { ClonesList } from '@postgres.ai/shared/pages/Instance/Clones/ClonesList';
|
|
13
13
|
import { Tags } from '@postgres.ai/shared/pages/Instance/components/Tags';
|
|
14
14
|
import { ModalReloadButton } from '@postgres.ai/shared/pages/Instance/components/ModalReloadButton';
|
|
15
15
|
import { getTags } from './utils';
|
|
@@ -19,20 +19,20 @@ const useStyles = makeStyles({
|
|
|
19
19
|
},
|
|
20
20
|
}, { index: 1 });
|
|
21
21
|
export const ClonesModal = observer(() => {
|
|
22
|
-
var _a, _b;
|
|
22
|
+
var _a, _b, _c;
|
|
23
23
|
const classes = useStyles();
|
|
24
24
|
const stores = useStores();
|
|
25
25
|
const { instance } = stores.main;
|
|
26
26
|
if (!instance)
|
|
27
27
|
return null;
|
|
28
28
|
const { pool, snapshotId, isOpenModal, closeModal } = stores.clonesModal;
|
|
29
|
-
return (_jsx(Modal, { title: `Clones (${(_a = instance.state) === null || _a === void 0 ? void 0 : _a.cloning.clones.length})`, isOpen: isOpenModal, onClose: closeModal, size: "md", titleRightContent: _jsx(ModalReloadButton, { isReloading: stores.main.isReloadingClones, onReload: stores.main.reloadClones }), headerContent: _jsx(Tags, { data: getTags({
|
|
29
|
+
return (_jsx(Modal, { title: `Clones (${(_b = (_a = instance.state) === null || _a === void 0 ? void 0 : _a.cloning.clones) === null || _b === void 0 ? void 0 : _b.length})`, isOpen: isOpenModal, onClose: closeModal, size: "md", titleRightContent: _jsx(ModalReloadButton, { isReloading: stores.main.isReloadingClones, onReload: stores.main.reloadClones }), headerContent: _jsx(Tags, { data: getTags({
|
|
30
30
|
pool,
|
|
31
31
|
snapshotId,
|
|
32
|
-
}) }), classes: { content: classes.root }, children: _jsx(ClonesList, { isDisabled: false, clones: (
|
|
32
|
+
}) }), classes: { content: classes.root }, children: _jsx(ClonesList, { isDisabled: false, clones: (_c = instance.state) === null || _c === void 0 ? void 0 : _c.cloning.clones.filter((clone) => {
|
|
33
33
|
var _a, _b;
|
|
34
34
|
const isMatchedByPool = !pool || pool === ((_a = clone.snapshot) === null || _a === void 0 ? void 0 : _a.pool);
|
|
35
35
|
const isMatchedBySnapshot = !snapshotId || snapshotId === ((_b = clone.snapshot) === null || _b === void 0 ? void 0 : _b.id);
|
|
36
36
|
return isMatchedByPool && isMatchedBySnapshot;
|
|
37
|
-
}), emptyStubText: "No clones found" }) }));
|
|
37
|
+
}), emptyStubText: "No clones found." }) }));
|
|
38
38
|
});
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
interface ClonesProps {
|
|
3
|
+
onlyRenderList?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const Clones: ((props: ClonesProps) => JSX.Element | null) & {
|
|
3
6
|
displayName: string;
|
|
4
7
|
};
|
|
8
|
+
export {};
|
|
@@ -15,7 +15,7 @@ import { round } from '@postgres.ai/shared/utils/numbers';
|
|
|
15
15
|
import { Tooltip } from '@postgres.ai/shared/components/Tooltip';
|
|
16
16
|
import { InfoIcon } from '@postgres.ai/shared/icons/Info';
|
|
17
17
|
import { useStores, useHost } from '@postgres.ai/shared/pages/Instance/context';
|
|
18
|
-
import { ClonesList } from '
|
|
18
|
+
import { ClonesList } from './ClonesList';
|
|
19
19
|
import { Header } from './Header';
|
|
20
20
|
const SHORT_LIST_SIZE = 3;
|
|
21
21
|
const useStyles = makeStyles((theme) => ({
|
|
@@ -29,9 +29,6 @@ const useStyles = makeStyles((theme) => ({
|
|
|
29
29
|
marginRight: 0,
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
|
-
tableTitle: {
|
|
33
|
-
marginTop: '5px',
|
|
34
|
-
},
|
|
35
32
|
listSizeButton: {
|
|
36
33
|
marginTop: '12px',
|
|
37
34
|
},
|
|
@@ -42,8 +39,9 @@ const useStyles = makeStyles((theme) => ({
|
|
|
42
39
|
color: '#808080',
|
|
43
40
|
},
|
|
44
41
|
}), { index: 1 });
|
|
45
|
-
export const Clones = observer(() => {
|
|
42
|
+
export const Clones = observer((props) => {
|
|
46
43
|
var _a, _b, _c;
|
|
44
|
+
const onlyRenderList = props === null || props === void 0 ? void 0 : props.onlyRenderList;
|
|
47
45
|
const classes = useStyles();
|
|
48
46
|
const history = useHistory();
|
|
49
47
|
const isMobile = useMediaQuery((theme) => theme.breakpoints.down('sm'));
|
|
@@ -53,14 +51,14 @@ export const Clones = observer(() => {
|
|
|
53
51
|
const { instance } = stores.main;
|
|
54
52
|
if (!instance || !instance.state)
|
|
55
53
|
return null;
|
|
56
|
-
const isShortList = isMobile && isShortListForMobile;
|
|
54
|
+
const isShortList = isMobile && isShortListForMobile && !onlyRenderList;
|
|
57
55
|
const toggleListSize = () => setIsShortListForMobile(!isShortListForMobile);
|
|
58
56
|
const goToCloneAddPage = () => history.push(host.routes.createClone());
|
|
59
57
|
const showListSizeButton = ((_b = (_a = instance.state) === null || _a === void 0 ? void 0 : _a.cloning.clones) === null || _b === void 0 ? void 0 : _b.length) > SHORT_LIST_SIZE && isMobile;
|
|
60
58
|
const isLoadingSnapshots = stores.main.snapshots.isLoading;
|
|
61
59
|
const hasSnapshots = Boolean((_c = stores.main.snapshots.data) === null || _c === void 0 ? void 0 : _c.length);
|
|
62
60
|
const canCreateClone = hasSnapshots && !stores.main.isDisabledInstance;
|
|
63
|
-
return (_jsxs("div", { className: classes.root, children: [_jsx(SectionTitle, { level: 2, tag: "h2", text: "Cloning summary" }), _jsx(Header, { expectedCloningTimeS: round(instance.state.cloning.expectedCloningTime, 2), logicalSize: instance.state.dataSize, clonesCount: instance.state.cloning.clones.length }), _jsx(SectionTitle, {
|
|
61
|
+
return (_jsxs("div", { className: classes.root, children: [!onlyRenderList && (_jsxs(_Fragment, { children: [_jsx(SectionTitle, { level: 2, tag: "h2", text: "Cloning summary" }), _jsx(Header, { expectedCloningTimeS: round(instance.state.cloning.expectedCloningTime, 2), logicalSize: instance.state.dataSize, clonesCount: instance.state.cloning.clones.length })] })), _jsx(SectionTitle, { level: 2, tag: "h3", text: `Clones (${instance.state.cloning.clones.length})`, rightContent: _jsxs(_Fragment, { children: [_jsx(Button, { theme: "primary", onClick: goToCloneAddPage, isDisabled: !canCreateClone, isLoading: isLoadingSnapshots, children: "Create clone" }), !hasSnapshots && (_jsx(Tooltip, { content: "No snapshots", children: _jsx("div", { style: { display: 'flex' }, children: _jsx(InfoIcon, { className: classes.infoIcon }) }) }))] }) }), _jsx(ClonesList, { clones: isShortList
|
|
64
62
|
? instance.state.cloning.clones.slice(0, SHORT_LIST_SIZE)
|
|
65
|
-
: instance.state.cloning.clones, isDisabled: stores.main.isDisabledInstance, emptyStubText: "This instance has no active clones" }), showListSizeButton && (_jsx(Button, { className: classes.listSizeButton, onClick: toggleListSize, children: isShortList ? 'Show more' : 'Show less' }))] }));
|
|
63
|
+
: instance.state.cloning.clones, isDisabled: stores.main.isDisabledInstance, emptyStubText: "This instance has no active clones." }), showListSizeButton && !onlyRenderList && (_jsx(Button, { className: classes.listSizeButton, onClick: toggleListSize, children: isShortList ? 'Show more' : 'Show less' }))] }));
|
|
66
64
|
});
|
|
@@ -11,7 +11,7 @@ import styles from '../styles.module.scss';
|
|
|
11
11
|
const useStyles = makeStyles({
|
|
12
12
|
textField: {
|
|
13
13
|
'& .MuiOutlinedInput-notchedOutline': {
|
|
14
|
-
borderColor: '#000',
|
|
14
|
+
borderColor: '#000 !important',
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
selectField: {
|
|
@@ -29,6 +29,9 @@ const useStyles = makeStyles({
|
|
|
29
29
|
error: {
|
|
30
30
|
color: '#f44336',
|
|
31
31
|
},
|
|
32
|
+
infoIcon: {
|
|
33
|
+
position: 'relative',
|
|
34
|
+
},
|
|
32
35
|
absoluteSpinner: {
|
|
33
36
|
position: 'absolute',
|
|
34
37
|
left: 'calc(50% - 40px)',
|
|
@@ -37,24 +40,25 @@ const useStyles = makeStyles({
|
|
|
37
40
|
}, { index: 1 });
|
|
38
41
|
export const InputWithTooltip = ({ value, label, error, onChange, tooltipText, disabled, type, }) => {
|
|
39
42
|
const classes = useStyles();
|
|
40
|
-
return (_jsxs(Box, { mt: 2, mb: 2, display: "flex", flexDirection: "column", justifyContent: "flex-start", alignItems: "flex-start", gap: "5px", children: [_jsx("label", { className: classNames(error && classes.error, classes.label), children: label }), _jsxs(Box, { display: "flex", alignItems: "center", width: "100%", children: [_jsx(TextField, { type: type || 'text', className: classNames(!disabled && classes.textField, styles.textField), variant: "outlined", size: "small", value: value, error: Boolean(error), onChange: onChange, disabled: disabled, multiline: type === 'textarea', spellCheck: false }), _jsx(Tooltip, { interactive: true, content: _jsx("p", { children: tooltipText() }), children: _jsx(
|
|
43
|
+
return (_jsxs(Box, { mt: 2, mb: 2, display: "flex", flexDirection: "column", justifyContent: "flex-start", alignItems: "flex-start", gap: "5px", children: [_jsx("label", { className: classNames(error && classes.error, classes.label), children: label }), _jsxs(Box, { display: "flex", alignItems: "center", width: "100%", children: [_jsx(TextField, { type: type || 'text', className: classNames(!disabled && classes.textField, styles.textField), variant: "outlined", size: "small", value: value, error: Boolean(error), onChange: onChange, disabled: disabled, multiline: type === 'textarea', spellCheck: false }), _jsx(Tooltip, { interactive: true, content: _jsx("p", { children: tooltipText() }), children: _jsx("div", { className: styles.infoIcon, children: _jsx(InfoIcon, {}) }) })] })] }));
|
|
41
44
|
};
|
|
42
45
|
export const InputWithChip = ({ value, label, id, onChange, tooltipText, disabled, handleDeleteChip, }) => {
|
|
43
46
|
const classes = useStyles();
|
|
44
|
-
return (_jsxs(Box, { mt: 2, mb:
|
|
47
|
+
return (_jsxs(Box, { mt: 2, mb: 2, children: [_jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(TextField, { className: classNames(!disabled && classes.textField, styles.textField), variant: "outlined", onChange: onChange, value: value, multiline: true, disabled: disabled, label: label, inputProps: {
|
|
45
48
|
name: id,
|
|
46
49
|
id: id,
|
|
47
50
|
}, InputLabelProps: {
|
|
48
51
|
shrink: true,
|
|
49
|
-
} }), _jsx(Tooltip, { interactive: true, content: _jsx("p", { children: tooltipText() }), children: _jsx(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
} }), _jsx(Tooltip, { interactive: true, content: _jsx("p", { children: tooltipText() }), children: _jsx("div", { className: styles.infoIcon, children: _jsx(InfoIcon, {}) }) })] }), _jsx("div", { className: styles.chipContainer, children: value &&
|
|
53
|
+
uniqueChipValue(value)
|
|
54
|
+
.split(' ')
|
|
55
|
+
.map((uniqueValue, index) => {
|
|
56
|
+
if (uniqueValue !== '') {
|
|
57
|
+
return (_jsx(Chip, { className: styles.chip, label: uniqueValue, disabled: disabled, onDelete: (event) => handleDeleteChip(event, uniqueValue, id), color: "primary" }, index));
|
|
58
|
+
}
|
|
59
|
+
}) })] }));
|
|
56
60
|
};
|
|
57
61
|
export const SelectWithTooltip = ({ value, label, error, onChange, tooltipText, disabled, loading, items, }) => {
|
|
58
62
|
const classes = useStyles();
|
|
59
|
-
return (_jsxs(Box, { mt: 1, display: "flex", flexDirection: "column", justifyContent: "flex-start", alignItems: "flex-start", position: "relative", gap: "5px", children: [_jsx("label", { className: classNames(error && classes.error, classes.label), children: label }), _jsxs(Box, { display: "flex", alignItems: "center", width: "100%", children: [loading && _jsx(Spinner, { className: classes.absoluteSpinner }), _jsx(Select, { className: classNames(classes.selectField, !disabled && classes.textField, styles.textField), label:
|
|
63
|
+
return (_jsxs(Box, { mt: 1, display: "flex", flexDirection: "column", justifyContent: "flex-start", alignItems: "flex-start", position: "relative", gap: "5px", children: [_jsx("label", { className: classNames(error && classes.error, classes.label), children: label }), _jsxs(Box, { display: "flex", alignItems: "center", width: "100%", children: [loading && _jsx(Spinner, { className: classes.absoluteSpinner }), _jsx(Select, { className: classNames(classes.selectField, !disabled && classes.textField, styles.textField), label: '', error: error, value: value, disabled: disabled, onChange: onChange, items: items }), _jsx(Tooltip, { interactive: true, content: _jsx("p", { children: tooltipText() }), children: _jsx("div", { className: styles.infoIcon, children: _jsx(InfoIcon, {}) }) })] })] }));
|
|
60
64
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const Configuration: (({ switchActiveTab, reload, isConfigurationActive, disableConfigModification, }: {
|
|
2
|
+
export declare const Configuration: (({ instanceId, switchActiveTab, reload, isConfigurationActive, disableConfigModification, }: {
|
|
3
|
+
instanceId: string;
|
|
3
4
|
switchActiveTab: (_: null, activeTab: number) => void;
|
|
4
5
|
reload: () => void;
|
|
5
6
|
isConfigurationActive: boolean;
|