@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
|
@@ -9,15 +9,15 @@ export const DestroyCloneModal = (props) => {
|
|
|
9
9
|
onDestroyClone();
|
|
10
10
|
onClose();
|
|
11
11
|
};
|
|
12
|
-
return (_jsxs(Modal, { title: `
|
|
12
|
+
return (_jsxs(Modal, { title: `Delete clone ${cloneId}`, onClose: onClose, isOpen: isOpen, children: [_jsxs(Text, { children: ["Are you sure you want to delete clone", ' ', _jsx(ImportantText, { children: cloneId }), "? This action cannot be undone."] }), _jsx(SimpleModalControls, { items: [
|
|
13
13
|
{
|
|
14
14
|
text: 'Cancel',
|
|
15
15
|
onClick: onClose,
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
|
-
text: '
|
|
18
|
+
text: 'Delete clone',
|
|
19
19
|
variant: 'primary',
|
|
20
20
|
onClick: handleClickDestroy,
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
22
|
] })] }));
|
|
23
23
|
};
|
|
@@ -7,7 +7,7 @@ import { Text } from '@postgres.ai/shared/components/Text';
|
|
|
7
7
|
import { SimpleModalControls } from '@postgres.ai/shared/components/SimpleModalControls';
|
|
8
8
|
export const DestroyCloneRestrictionModal = observer((props) => {
|
|
9
9
|
const { isOpen, onClose, cloneId, clonePagePath } = props;
|
|
10
|
-
return (_jsxs(Modal, { title: "Cannot
|
|
10
|
+
return (_jsxs(Modal, { title: "Cannot delete clone", isOpen: isOpen, onClose: onClose, children: [_jsxs(Text, { children: ["Cannot delete clone ", _jsx(ImportantText, { children: cloneId }), " because deletion protection is enabled. You can disable deletion protection on", ' ', clonePagePath ? (_jsx(Link, { to: clonePagePath, children: "the clone page" })) : ('this page'), "."] }), _jsx(SimpleModalControls, { items: [
|
|
11
11
|
{
|
|
12
12
|
text: 'Close',
|
|
13
13
|
onClick: onClose,
|
|
@@ -4,6 +4,8 @@ declare type BaseProps = {
|
|
|
4
4
|
className?: string;
|
|
5
5
|
icon?: React.ReactNode;
|
|
6
6
|
isCollapsed?: boolean;
|
|
7
|
+
onMouseEnter?: React.MouseEventHandler<HTMLButtonElement>;
|
|
8
|
+
onMouseLeave?: React.MouseEventHandler<HTMLButtonElement>;
|
|
7
9
|
};
|
|
8
10
|
declare type ButtonProps = BaseProps & {
|
|
9
11
|
type?: 'button' | 'submit';
|
|
@@ -7,7 +7,7 @@ export const Button = (props) => {
|
|
|
7
7
|
const className = cn(styles.root, props.isCollapsed && styles.collapsed, props.className);
|
|
8
8
|
const children = (_jsxs(_Fragment, { children: [props.icon && (_jsx("span", { className: cn(styles.icon, props.isCollapsed && styles.collapsed), children: props.icon })), !props.isCollapsed && props.children] }));
|
|
9
9
|
if (!props.type || props.type === 'button' || props.type === 'submit')
|
|
10
|
-
return (_jsx("button", { className: className, onClick: props.onClick, disabled: props.disabled, children: children }));
|
|
10
|
+
return (_jsx("button", { className: className, onClick: props.onClick, disabled: props.disabled, onMouseEnter: props.onMouseEnter, onMouseLeave: props.onMouseLeave, children: children }));
|
|
11
11
|
if (props.type === 'link')
|
|
12
12
|
return (_jsx(NavLink, { className: className, to: props.to, activeClassName: props.activeClassName, children: children }));
|
|
13
13
|
if (props.type === 'gateway-link')
|
|
@@ -15,6 +15,7 @@ import { ImportantText } from '@postgres.ai/shared/components/ImportantText';
|
|
|
15
15
|
import { Spinner } from '@postgres.ai/shared/components/Spinner';
|
|
16
16
|
import { SimpleModalControls } from '@postgres.ai/shared/components/SimpleModalControls';
|
|
17
17
|
import { compareSnapshotsDesc } from '@postgres.ai/shared/utils/snapshot';
|
|
18
|
+
import { isValidDate } from '@postgres.ai/shared/utils/date';
|
|
18
19
|
const useStyles = makeStyles({
|
|
19
20
|
snapshots: {
|
|
20
21
|
margin: '16px 0 0 0',
|
|
@@ -63,9 +64,10 @@ export const ResetCloneModal = (props) => {
|
|
|
63
64
|
const isCurrent = snapshot.id === ((_a = clone.snapshot) === null || _a === void 0 ? void 0 : _a.id);
|
|
64
65
|
return {
|
|
65
66
|
value: snapshot.id,
|
|
66
|
-
children: (_jsxs(_Fragment, { children: [snapshot.dataStateAt, " (",
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
children: (_jsxs(_Fragment, { children: [snapshot.dataStateAt, " (", isValidDate(snapshot.dataStateAtDate) &&
|
|
68
|
+
formatDistanceToNowStrict(snapshot.dataStateAtDate, {
|
|
69
|
+
addSuffix: true,
|
|
70
|
+
}), ")", isLatest && (_jsx("span", { className: classes.snapshotTag, children: "Latest" })), isCurrent && (_jsx("span", { className: classes.snapshotTag, children: "Current" }))] })),
|
|
69
71
|
};
|
|
70
72
|
})) !== null && _a !== void 0 ? _a : [], onChange: (e) => setSelectedSnapshotId(e.target.value), fullWidth: true, className: classes.snapshots }), _jsx(SimpleModalControls, { items: [
|
|
71
73
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
export const ArrowDropDownIcon = (props) => {
|
|
3
|
-
return (_jsx("svg", { className: props.className, viewBox: "0 0 8 6", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", {
|
|
3
|
+
return (_jsx("svg", { className: props.className, viewBox: "0 0 8 6", fill: "none", xmlns: "http://www.w3.org/2000/svg", onClick: props.onClick, children: _jsx("path", {
|
|
4
4
|
// eslint-disable-next-line max-len
|
|
5
5
|
d: "M7.8515 0.898419C7.75261 0.799446 7.63538 0.75 7.49994 0.75H0.500038C0.364534 0.75 0.247392 0.799446 0.148419 0.898419C0.0494455 0.997501 0 1.11464 0 1.25006C0 1.38546 0.0494455 1.5026 0.148419 1.6016L3.64838 5.10156C3.74746 5.20054 3.86461 5.25009 4 5.25009C4.13539 5.25009 4.25265 5.20054 4.35154 5.10156L7.8515 1.60157C7.95036 1.5026 8 1.38546 8 1.25004C8 1.11464 7.95036 0.997501 7.8515 0.898419Z", fill: "currentColor" }) }));
|
|
6
6
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const PostgresSQLIcon = () => (_jsxs("svg", { className: "postgres-logo", width: "432.071pt", height: "445.383pt", viewBox: "0 0 432.071 445.383", xmlSpace: "preserve", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("g", { id: "orginal", style: {
|
|
3
|
+
fillRule: 'nonzero',
|
|
4
|
+
clipRule: 'nonzero',
|
|
5
|
+
stroke: '#000000',
|
|
6
|
+
strokeMiterlimit: 4,
|
|
7
|
+
} }), _jsxs("g", { id: "Layer_x0020_3", style: {
|
|
8
|
+
fillRule: 'nonzero',
|
|
9
|
+
clipRule: 'nonzero',
|
|
10
|
+
stroke: '#FFFFFF',
|
|
11
|
+
strokeWidth: 12.4651,
|
|
12
|
+
strokeLinecap: 'round',
|
|
13
|
+
strokeLinejoin: 'round',
|
|
14
|
+
strokeMiterlimit: 4,
|
|
15
|
+
}, children: [_jsx("path", { style: {
|
|
16
|
+
fill: '#000000',
|
|
17
|
+
stroke: '#000000',
|
|
18
|
+
strokeWidth: 37.3953,
|
|
19
|
+
strokeLinecap: 'butt',
|
|
20
|
+
strokeLinejoin: 'miter',
|
|
21
|
+
strokeMiterlimit: 4,
|
|
22
|
+
}, d: "M323.205,324.227c2.833-23.601,1.984-27.062,19.563-23.239l4.463,0.392c13.517,0.615,31.199-2.174,41.587-7c22.362-10.376,35.622-27.7,13.572-23.148c-50.297,10.376-53.755-6.655-53.755-6.655c53.111-78.803,75.313-178.836,56.149-203.322 C352.514-5.534,262.036,26.049,260.522,26.869l-0.482,0.089c-9.938-2.062-21.06-3.294-33.554-3.496c-22.761-0.374-40.032,5.967-53.133,15.904c0,0-161.408-66.498-153.899,83.628c1.597,31.936,45.777,241.655,98.47,178.31 c19.259-23.163,37.871-42.748,37.871-42.748c9.242,6.14,20.307,9.272,31.912,8.147l0.897-0.765c-0.281,2.876-0.157,5.689,0.359,9.019c-13.572,15.167-9.584,17.83-36.723,23.416c-27.457,5.659-11.326,15.734-0.797,18.367c12.768,3.193,42.305,7.716,62.268-20.224 l-0.795,3.188c5.325,4.26,4.965,30.619,5.72,49.452c0.756,18.834,2.017,36.409,5.856,46.771c3.839,10.36,8.369,37.05,44.036,29.406c29.809-6.388,52.6-15.582,54.677-101.107" }), _jsx("path", { style: {
|
|
23
|
+
fill: '#336791',
|
|
24
|
+
stroke: 'none',
|
|
25
|
+
}, d: "M402.395,271.23c-50.302,10.376-53.76-6.655-53.76-6.655c53.111-78.808,75.313-178.843,56.153-203.326c-52.27-66.785-142.752-35.2-144.262-34.38l-0.486,0.087c-9.938-2.063-21.06-3.292-33.56-3.496c-22.761-0.373-40.026,5.967-53.127,15.902 c0,0-161.411-66.495-153.904,83.63c1.597,31.938,45.776,241.657,98.471,178.312c19.26-23.163,37.869-42.748,37.869-42.748c9.243,6.14,20.308,9.272,31.908,8.147l0.901-0.765c-0.28,2.876-0.152,5.689,0.361,9.019c-13.575,15.167-9.586,17.83-36.723,23.416 c-27.459,5.659-11.328,15.734-0.796,18.367c12.768,3.193,42.307,7.716,62.266-20.224l-0.796,3.188c5.319,4.26,9.054,27.711,8.428,48.969c-0.626,21.259-1.044,35.854,3.147,47.254c4.191,11.4,8.368,37.05,44.042,29.406c29.809-6.388,45.256-22.942,47.405-50.555 c1.525-19.631,4.976-16.729,5.194-34.28l2.768-8.309c3.192-26.611,0.507-35.196,18.872-31.203l4.463,0.392c13.517,0.615,31.208-2.174,41.591-7c22.358-10.376,35.618-27.7,13.573-23.148z" }), _jsx("path", { d: "M215.866,286.484c-1.385,49.516,0.348,99.377,5.193,111.495c4.848,12.118,15.223,35.688,50.9,28.045c29.806-6.39,40.651-18.756,45.357-46.051c3.466-20.082,10.148-75.854,11.005-87.281" }), _jsx("path", { d: "M173.104,38.256c0,0-161.521-66.016-154.012,84.109c1.597,31.938,45.779,241.664,98.473,178.316c19.256-23.166,36.671-41.335,36.671-41.335" }), _jsx("path", { d: "M260.349,26.207c-5.591,1.753,89.848-34.889,144.087,34.417c19.159,24.484-3.043,124.519-56.153,203.329" }), _jsx("path", { style: {
|
|
26
|
+
strokeLinejoin: 'bevel',
|
|
27
|
+
}, d: "M348.282,263.953c0,0,3.461,17.036,53.764,6.653c22.04-4.552,8.776,12.774-13.577,23.155c-18.345,8.514-59.474,10.696-60.146-1.069c-1.729-30.355,21.647-21.133,19.96-28.739c-1.525-6.85-11.979-13.573-18.894-30.338 c-6.037-14.633-82.796-126.849,21.287-110.183c3.813-0.789-27.146-99.002-124.553-100.599c-97.385-1.597-94.19,119.762-94.19,119.762" }), _jsx("path", { d: "M188.604,274.334c-13.577,15.166-9.584,17.829-36.723,23.417c-27.459,5.66-11.326,15.733-0.797,18.365c12.768,3.195,42.307,7.718,62.266-20.229c6.078-8.509-0.036-22.086-8.385-25.547c-4.034-1.671-9.428-3.765-16.361,3.994z" }), _jsx("path", { d: "M187.715,274.069c-1.368-8.917,2.93-19.528,7.536-31.942c6.922-18.626,22.893-37.255,10.117-96.339c-9.523-44.029-73.396-9.163-73.436-3.193c-0.039,5.968,2.889,30.26-1.067,58.548c-5.162,36.913,23.488,68.132,56.479,64.938" }), _jsx("path", { style: {
|
|
28
|
+
fill: '#FFFFFF',
|
|
29
|
+
stroke: '#FFFFFF',
|
|
30
|
+
strokeWidth: 4.155,
|
|
31
|
+
strokeLinecap: 'butt',
|
|
32
|
+
strokeLinejoin: 'miter',
|
|
33
|
+
}, d: "M172.517,141.7c-0.288,2.039,3.733,7.48,8.976,8.207c5.234,0.73,9.714-3.522,9.998-5.559c0.284-2.039-3.732-4.285-8.977-5.015c-5.237-0.731-9.719,0.333-9.996,2.367z" }), _jsx("path", { style: {
|
|
34
|
+
fill: '#FFFFFF',
|
|
35
|
+
strokeWidth: 2.0775,
|
|
36
|
+
strokeLinecap: 'butt',
|
|
37
|
+
strokeLinejoin: 'miter',
|
|
38
|
+
}, d: "M331.941,137.543c0.284,2.039-3.732,7.48-8.976,8.207c-5.238,0.73-9.718-3.522-10.005-5.559c-0.277-2.039,3.74-4.285,8.979-5.015c5.239-0.73,9.718,0.333,10.002,2.368z" }), _jsx("path", { d: "M350.676,123.432c0.863,15.994-3.445,26.888-3.988,43.914c-0.804,24.748,11.799,53.074-7.191,81.435" }), _jsx("path", { style: {
|
|
39
|
+
strokeWidth: 3,
|
|
40
|
+
}, d: "M0,60.232" })] })] }));
|
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Api } from './stores/Main';
|
|
3
|
+
export declare type Host = {
|
|
4
|
+
branchId: string;
|
|
5
|
+
instanceId: string;
|
|
6
|
+
routes: {
|
|
7
|
+
branch: () => string;
|
|
8
|
+
branches: () => string;
|
|
9
|
+
snapshot: (snapshotId: string) => string;
|
|
10
|
+
createClone: (branchId: string) => string;
|
|
11
|
+
};
|
|
12
|
+
api: Api;
|
|
13
|
+
elements: {
|
|
14
|
+
breadcrumbs: React.ReactNode;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const useHost: () => Host, HostProvider: import("react").Provider<Host>;
|
|
18
|
+
export declare const useStores: () => {
|
|
19
|
+
main: import("./stores/Main").MainStore;
|
|
20
|
+
}, StoresProvider: import("react").Provider<{
|
|
21
|
+
main: import("./stores/Main").MainStore;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } 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, useState } from 'react';
|
|
9
|
+
import { useHistory } from 'react-router';
|
|
10
|
+
import { observer } from 'mobx-react-lite';
|
|
11
|
+
import copyToClipboard from 'copy-to-clipboard';
|
|
12
|
+
import { makeStyles, Button, TextField, IconButton, Table, TableHead, TableRow, TableBody, } from '@material-ui/core';
|
|
13
|
+
import { ErrorStub } from '@postgres.ai/shared/components/ErrorStub';
|
|
14
|
+
import { PageSpinner } from '@postgres.ai/shared/components/PageSpinner';
|
|
15
|
+
import { SectionTitle } from '@postgres.ai/shared/components/SectionTitle';
|
|
16
|
+
import { Spinner } from '@postgres.ai/shared/components/Spinner';
|
|
17
|
+
import { Tooltip } from '@postgres.ai/shared/components/Tooltip';
|
|
18
|
+
import { icons } from '@postgres.ai/shared/styles/icons';
|
|
19
|
+
import { styles } from '@postgres.ai/shared/styles/styles';
|
|
20
|
+
import { DeleteBranchModal } from '@postgres.ai/shared/pages/Branches/components/Modals/DeleteBranchModal';
|
|
21
|
+
import { HorizontalScrollContainer } from '@postgres.ai/shared/components/HorizontalScrollContainer';
|
|
22
|
+
import { generateSnapshotPageId } from '@postgres.ai/shared/pages/Instance/Snapshots/utils';
|
|
23
|
+
import { SyntaxHighlight } from '@postgres.ai/shared/components/SyntaxHighlight';
|
|
24
|
+
import { getCliBranchListCommand } from '@postgres.ai/shared/pages/CreateBranch/utils';
|
|
25
|
+
import { TableBodyCell, TableBodyCellMenu, TableHeaderCell, } from '@postgres.ai/shared/components/Table';
|
|
26
|
+
import { useCreatedStores } from './useCreatedStores';
|
|
27
|
+
import { InstanceTabs, TABS_INDEX } from "../../Instance/Tabs";
|
|
28
|
+
const useStyles = makeStyles(() => ({
|
|
29
|
+
wrapper: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
gap: '60px',
|
|
32
|
+
maxWidth: '100%',
|
|
33
|
+
fontSize: '14px',
|
|
34
|
+
marginTop: '20px',
|
|
35
|
+
'@media (max-width: 1300px)': {
|
|
36
|
+
flexDirection: 'column',
|
|
37
|
+
gap: '20px',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
marginTop: {
|
|
41
|
+
marginTop: '16px',
|
|
42
|
+
},
|
|
43
|
+
title: {
|
|
44
|
+
marginTop: '8px',
|
|
45
|
+
lineHeight: '26px'
|
|
46
|
+
},
|
|
47
|
+
container: {
|
|
48
|
+
maxWidth: '100%',
|
|
49
|
+
flex: '1 1 0',
|
|
50
|
+
minWidth: 0,
|
|
51
|
+
'& p,span': {
|
|
52
|
+
fontSize: 14,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
snippetContainer: {
|
|
56
|
+
flex: '1 1 0',
|
|
57
|
+
minWidth: 0,
|
|
58
|
+
boxShadow: 'rgba(0, 0, 0, 0.1) 0px 4px 12px',
|
|
59
|
+
padding: '10px 20px 10px 20px',
|
|
60
|
+
height: 'max-content',
|
|
61
|
+
borderRadius: '4px',
|
|
62
|
+
},
|
|
63
|
+
actions: {
|
|
64
|
+
display: 'flex',
|
|
65
|
+
marginRight: '-16px',
|
|
66
|
+
},
|
|
67
|
+
spinner: {
|
|
68
|
+
marginLeft: '8px',
|
|
69
|
+
},
|
|
70
|
+
actionButton: {
|
|
71
|
+
marginRight: '16px',
|
|
72
|
+
},
|
|
73
|
+
summary: {
|
|
74
|
+
marginTop: 20,
|
|
75
|
+
},
|
|
76
|
+
text: {
|
|
77
|
+
marginTop: '4px',
|
|
78
|
+
},
|
|
79
|
+
cliText: {
|
|
80
|
+
marginTop: '8px',
|
|
81
|
+
},
|
|
82
|
+
paramTitle: {
|
|
83
|
+
display: 'inline-block',
|
|
84
|
+
width: 200,
|
|
85
|
+
},
|
|
86
|
+
copyFieldContainer: {
|
|
87
|
+
position: 'relative',
|
|
88
|
+
display: 'block',
|
|
89
|
+
maxWidth: 525,
|
|
90
|
+
width: '100%',
|
|
91
|
+
},
|
|
92
|
+
textField: {
|
|
93
|
+
...styles.inputField,
|
|
94
|
+
'max-width': 525,
|
|
95
|
+
display: 'inline-block',
|
|
96
|
+
'& .MuiOutlinedInput-input': {
|
|
97
|
+
paddingRight: '32px!important',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
tableContainer: {
|
|
101
|
+
position: 'relative',
|
|
102
|
+
maxWidth: 525,
|
|
103
|
+
width: '100%',
|
|
104
|
+
},
|
|
105
|
+
copyButton: {
|
|
106
|
+
position: 'absolute',
|
|
107
|
+
top: 16,
|
|
108
|
+
right: 0,
|
|
109
|
+
zIndex: 100,
|
|
110
|
+
width: 32,
|
|
111
|
+
height: 32,
|
|
112
|
+
padding: 8,
|
|
113
|
+
},
|
|
114
|
+
pointerCursor: {
|
|
115
|
+
cursor: 'pointer',
|
|
116
|
+
},
|
|
117
|
+
}), { index: 1 });
|
|
118
|
+
export const BranchesPage = observer((props) => {
|
|
119
|
+
const classes = useStyles();
|
|
120
|
+
const history = useHistory();
|
|
121
|
+
const stores = useCreatedStores(props);
|
|
122
|
+
const [isOpenDestroyModal, setIsOpenDestroyModal] = useState(false);
|
|
123
|
+
const { branch, snapshotList, deleteBranch, reload, load, isReloading, isBranchesLoading, getBranchesError, snapshotListError, getBranchError, } = stores.main;
|
|
124
|
+
const hasBranchError = getBranchesError || getBranchError || snapshotListError;
|
|
125
|
+
const branchLogLength = snapshotList === null || snapshotList === void 0 ? void 0 : snapshotList.reduce((acc, snapshot) => {
|
|
126
|
+
var _a;
|
|
127
|
+
if ((snapshot === null || snapshot === void 0 ? void 0 : snapshot.branch) !== null) {
|
|
128
|
+
return acc + ((_a = snapshot.branch) === null || _a === void 0 ? void 0 : _a.length);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
return acc;
|
|
132
|
+
}
|
|
133
|
+
}, 0);
|
|
134
|
+
const headRendered = (_jsxs(_Fragment, { children: [_jsx("style", { children: 'p { margin: 0;}' }), props.elements.breadcrumbs, _jsx(SectionTitle, { className: classes.title, tag: "h1", level: 1, text: `Branch ${props.branchId}`, children: _jsx(InstanceTabs, { tab: TABS_INDEX.BRANCHES, isPlatform: props.isPlatform, instanceId: props.instanceId, hasLogs: props.api.initWS !== undefined }) })] }));
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
load(props.branchId, props.instanceId);
|
|
137
|
+
}, []);
|
|
138
|
+
if (isBranchesLoading)
|
|
139
|
+
return _jsx(PageSpinner, {});
|
|
140
|
+
if (hasBranchError) {
|
|
141
|
+
return (_jsxs(_Fragment, { children: [headRendered, _jsx(ErrorStub, { title: (getBranchesError === null || getBranchesError === void 0 ? void 0 : getBranchesError.title) ||
|
|
142
|
+
(getBranchError === null || getBranchError === void 0 ? void 0 : getBranchError.title) ||
|
|
143
|
+
(snapshotListError === null || snapshotListError === void 0 ? void 0 : snapshotListError.title), message: (getBranchesError === null || getBranchesError === void 0 ? void 0 : getBranchesError.message) ||
|
|
144
|
+
(getBranchError === null || getBranchError === void 0 ? void 0 : getBranchError.message) ||
|
|
145
|
+
(snapshotListError === null || snapshotListError === void 0 ? void 0 : snapshotListError.message), className: classes.marginTop })] }));
|
|
146
|
+
}
|
|
147
|
+
return (_jsxs(_Fragment, { children: [headRendered, _jsxs("div", { className: classes.wrapper, children: [_jsxs("div", { className: classes.container, children: [_jsxs("div", { className: classes.actions, children: [_jsx(Button, { variant: "contained", color: "primary", onClick: () => history.push(props.routes.createClone(props.branchId)), disabled: isReloading, title: 'Create clone', className: classes.actionButton, children: "Create clone" }), _jsx(Button, { variant: "contained", color: "primary", onClick: () => setIsOpenDestroyModal(true), disabled: isReloading, title: 'Delete this branch', className: classes.actionButton, children: "Delete branch" }), _jsxs(Button, { variant: "outlined", color: "secondary", onClick: () => reload(props.branchId, props.instanceId), disabled: isReloading, title: 'Refresh branch information', className: classes.actionButton, children: ["Reload info", isReloading && _jsx(Spinner, { size: "sm", className: classes.spinner })] })] }), _jsx("br", {}), _jsxs("div", { children: [_jsxs("div", { children: [_jsxs("p", { children: [_jsx("strong", { children: "Data state at" }), "\u00A0", _jsx(Tooltip, { content: _jsxs(_Fragment, { children: [_jsx("strong", { children: "Data state time" }), " is a time at which data is\u00A0 recovered for this branch."] }), children: icons.infoIcon })] }), _jsx("p", { className: classes.text, children: (branch === null || branch === void 0 ? void 0 : branch.dataStateAt) || '-' })] }), _jsxs("div", { className: classes.summary, children: [_jsxs("p", { children: [_jsx("strong", { children: "Summary" }), "\u00A0"] }), _jsxs("p", { className: classes.text, children: [_jsx("span", { className: classes.paramTitle, children: "Branch name:" }), branch === null || branch === void 0 ? void 0 : branch.name] }), _jsxs("p", { className: classes.text, children: [_jsx("span", { className: classes.paramTitle, children: "Parent branch:" }), branch === null || branch === void 0 ? void 0 : branch.parent] })] }), _jsx("br", {}), _jsx("p", { children: _jsx("strong", { children: "Snapshot info" }) }), _jsxs("div", { className: classes.copyFieldContainer, children: [_jsx(TextField, { variant: "outlined", label: "Snapshot ID", value: branch === null || branch === void 0 ? void 0 : branch.snapshotID, className: classes.textField, margin: "normal", fullWidth: true, InputLabelProps: {
|
|
148
|
+
shrink: true,
|
|
149
|
+
style: styles.inputFieldLabel,
|
|
150
|
+
}, FormHelperTextProps: {
|
|
151
|
+
style: styles.inputFieldHelper,
|
|
152
|
+
} }), _jsx(IconButton, { className: classes.copyButton, "aria-label": "Copy", onClick: () => copyToClipboard(String(branch === null || branch === void 0 ? void 0 : branch.snapshotID)), children: icons.copyIcon })] }), _jsx("br", {}), Number(branchLogLength) > 0 && (_jsxs(_Fragment, { children: [_jsxs("strong", { children: ["Branch log (", branchLogLength, ")"] }), _jsx(HorizontalScrollContainer, { children: _jsxs(Table, { className: classes.tableContainer, children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableHeaderCell, {}), _jsx(TableHeaderCell, { children: "Name" }), _jsx(TableHeaderCell, { children: "Snapshot ID" }), _jsx(TableHeaderCell, { children: "Data state at" }), _jsx(TableHeaderCell, { children: "Message" })] }) }), snapshotList === null || snapshotList === void 0 ? void 0 : snapshotList.map((snapshot, id) => {
|
|
153
|
+
var _a;
|
|
154
|
+
return (_jsx(TableBody, { children: (_a = snapshot === null || snapshot === void 0 ? void 0 : snapshot.branch) === null || _a === void 0 ? void 0 : _a.map((item, id) => {
|
|
155
|
+
var _a;
|
|
156
|
+
return (_jsxs(TableRow, { hover: true, className: classes.pointerCursor, onClick: () => generateSnapshotPageId(snapshot.id) &&
|
|
157
|
+
history.push(props.routes.snapshot(generateSnapshotPageId(snapshot.id) || '')), children: [_jsx(TableBodyCellMenu, { actions: [
|
|
158
|
+
{
|
|
159
|
+
name: 'Copy branch name',
|
|
160
|
+
onClick: () => copyToClipboard(item),
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: 'Copy snapshot ID',
|
|
164
|
+
onClick: () => copyToClipboard(snapshot.id || ''),
|
|
165
|
+
},
|
|
166
|
+
] }), _jsx(TableBodyCell, { children: item }), _jsx(TableBodyCell, { children: snapshot.id || '-' }), _jsx(TableBodyCell, { children: snapshot.dataStateAt || '-' }), _jsx(TableBodyCell, { children: (_a = snapshot.message) !== null && _a !== void 0 ? _a : '-' })] }, id));
|
|
167
|
+
}) }, id));
|
|
168
|
+
})] }) })] }))] })] }), _jsxs("div", { className: classes.snippetContainer, children: [_jsx(SectionTitle, { className: classes.marginTop, tag: "h2", level: 2, text: 'Delete branch using CLI' }), _jsx("p", { className: classes.cliText, children: "You can delete this branch using CLI. To do this, run the command below:" }), _jsx(SyntaxHighlight, { content: `dblab branch delete ${props.branchId}` }), _jsx(SectionTitle, { className: classes.marginTop, tag: "h2", level: 2, text: 'Get branches using CLI' }), _jsx("p", { className: classes.marginTop, children: "To list all branches using CLI, copy and paste it into your terminal." }), _jsx(SyntaxHighlight, { content: getCliBranchListCommand() }), _jsx(SectionTitle, { className: classes.marginTop, tag: "h2", level: 2, text: 'Get snapshots for this branch using CLI' }), _jsx("p", { className: classes.cliText, children: "You can get a list of snapshots for this branch using CLI. To do this, run the command below:" }), _jsx(SyntaxHighlight, { content: `dblab branch log ${props.branchId}` })] }), _jsx(DeleteBranchModal, { isOpen: isOpenDestroyModal, onClose: () => setIsOpenDestroyModal(false), deleteBranch: deleteBranch, branchName: props.branchId, instanceId: props.instanceId, afterSubmitClick: () => {
|
|
169
|
+
stores.main.reload(props.branchId, props.instanceId);
|
|
170
|
+
history.push(props.routes.branches());
|
|
171
|
+
} })] })] }));
|
|
172
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { GetBranches } from '@postgres.ai/shared/types/api/endpoints/getBranches';
|
|
2
|
+
import { Branch } from '@postgres.ai/shared/types/api/endpoints/getBranches';
|
|
3
|
+
import { DeleteBranch } from '@postgres.ai/shared/types/api/endpoints/deleteBranch';
|
|
4
|
+
import { SnapshotList, GetSnapshotList } from '@postgres.ai/shared/types/api/endpoints/getSnapshotList';
|
|
5
|
+
import { InitWS } from '@postgres.ai/shared/types/api/endpoints/initWS';
|
|
6
|
+
declare type Error = {
|
|
7
|
+
title?: string;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
export declare type Api = {
|
|
11
|
+
getBranches: GetBranches;
|
|
12
|
+
deleteBranch: DeleteBranch;
|
|
13
|
+
getSnapshotList: GetSnapshotList;
|
|
14
|
+
initWS: InitWS;
|
|
15
|
+
};
|
|
16
|
+
export declare class MainStore {
|
|
17
|
+
getBranchError: Error | null;
|
|
18
|
+
snapshotListError: Error | null;
|
|
19
|
+
getBranchesError: Error | null;
|
|
20
|
+
isReloading: boolean;
|
|
21
|
+
isBranchesLoading: boolean;
|
|
22
|
+
branches: Branch[] | null;
|
|
23
|
+
branch: Branch | null;
|
|
24
|
+
snapshotList: SnapshotList[] | null;
|
|
25
|
+
private readonly api;
|
|
26
|
+
constructor(api: Api);
|
|
27
|
+
load: (branchId: string, instanceId: string) => Promise<void>;
|
|
28
|
+
reload: (branchId: string, instanceId: string) => Promise<void>;
|
|
29
|
+
getBranches: (branchId: string, instanceId: string) => Promise<Branch[] | null | undefined>;
|
|
30
|
+
getBranch: (branchId: string, instanceId: string) => Promise<boolean>;
|
|
31
|
+
deleteBranch: (branchName: string, instanceId: string) => Promise<{
|
|
32
|
+
response: Response | null;
|
|
33
|
+
error: globalThis.Error | null;
|
|
34
|
+
} | undefined>;
|
|
35
|
+
getSnapshotList: (branchName: string, instanceId: string) => Promise<SnapshotList[] | null | undefined>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
export class MainStore {
|
|
9
|
+
constructor(api) {
|
|
10
|
+
this.getBranchError = null;
|
|
11
|
+
this.snapshotListError = null;
|
|
12
|
+
this.getBranchesError = null;
|
|
13
|
+
this.isReloading = false;
|
|
14
|
+
this.isBranchesLoading = false;
|
|
15
|
+
this.branches = null;
|
|
16
|
+
this.branch = null;
|
|
17
|
+
this.snapshotList = null;
|
|
18
|
+
this.load = async (branchId, instanceId) => {
|
|
19
|
+
if (!branchId)
|
|
20
|
+
return;
|
|
21
|
+
this.isBranchesLoading = true;
|
|
22
|
+
await this.getBranches(branchId, instanceId);
|
|
23
|
+
};
|
|
24
|
+
this.reload = async (branchId, instanceId) => {
|
|
25
|
+
if (!branchId)
|
|
26
|
+
return;
|
|
27
|
+
this.isReloading = true;
|
|
28
|
+
await this.getBranches(branchId, instanceId);
|
|
29
|
+
this.isReloading = false;
|
|
30
|
+
};
|
|
31
|
+
this.getBranches = async (branchId, instanceId) => {
|
|
32
|
+
if (!this.api.getBranches)
|
|
33
|
+
return;
|
|
34
|
+
const { response, error } = await this.api.getBranches(instanceId);
|
|
35
|
+
if (error) {
|
|
36
|
+
this.isBranchesLoading = false;
|
|
37
|
+
this.getBranchesError = await error.json().then((err) => err);
|
|
38
|
+
}
|
|
39
|
+
if (response) {
|
|
40
|
+
this.branches = response;
|
|
41
|
+
this.getBranch(branchId, instanceId);
|
|
42
|
+
}
|
|
43
|
+
return response;
|
|
44
|
+
};
|
|
45
|
+
this.getBranch = async (branchId, instanceId) => {
|
|
46
|
+
var _a;
|
|
47
|
+
const currentBranch = (_a = this.branches) === null || _a === void 0 ? void 0 : _a.filter((s) => {
|
|
48
|
+
return s.name === branchId;
|
|
49
|
+
});
|
|
50
|
+
if (currentBranch && (currentBranch === null || currentBranch === void 0 ? void 0 : currentBranch.length) > 0) {
|
|
51
|
+
this.branch = currentBranch[0];
|
|
52
|
+
this.getSnapshotList(currentBranch[0].name, instanceId);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.getBranchError = {
|
|
56
|
+
title: 'Error',
|
|
57
|
+
message: `Branch "${branchId}" not found`,
|
|
58
|
+
};
|
|
59
|
+
this.isBranchesLoading = false;
|
|
60
|
+
}
|
|
61
|
+
return !!currentBranch;
|
|
62
|
+
};
|
|
63
|
+
this.deleteBranch = async (branchName, instanceId) => {
|
|
64
|
+
var _a;
|
|
65
|
+
if (!branchName)
|
|
66
|
+
return;
|
|
67
|
+
const { response, error } = await this.api.deleteBranch(branchName, instanceId);
|
|
68
|
+
if (response) {
|
|
69
|
+
this.branches =
|
|
70
|
+
((_a = this.branches) === null || _a === void 0 ? void 0 : _a.filter((branch) => branch.name !== branchName)) || [];
|
|
71
|
+
}
|
|
72
|
+
return { response, error };
|
|
73
|
+
};
|
|
74
|
+
this.getSnapshotList = async (branchName, instanceId) => {
|
|
75
|
+
if (!this.api.getSnapshotList)
|
|
76
|
+
return;
|
|
77
|
+
const { response, error } = await this.api.getSnapshotList(branchName, instanceId);
|
|
78
|
+
this.isBranchesLoading = false;
|
|
79
|
+
if (error) {
|
|
80
|
+
this.snapshotListError = await error.json().then((err) => err);
|
|
81
|
+
}
|
|
82
|
+
if (response) {
|
|
83
|
+
this.snapshotList = response;
|
|
84
|
+
}
|
|
85
|
+
return response;
|
|
86
|
+
};
|
|
87
|
+
this.api = api;
|
|
88
|
+
makeAutoObservable(this);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Branch } from '@postgres.ai/shared/types/api/endpoints/getBranches';
|
|
3
|
+
import { DeleteBranch } from '@postgres.ai/shared/types/api/endpoints/deleteBranch';
|
|
4
|
+
export declare const BranchesTable: ({ branches, emptyTableText, deleteBranch, branchesRoute, reloadBranches, }: {
|
|
5
|
+
branches: Branch[];
|
|
6
|
+
emptyTableText: string;
|
|
7
|
+
deleteBranch: DeleteBranch;
|
|
8
|
+
branchesRoute: string;
|
|
9
|
+
reloadBranches: () => void;
|
|
10
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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 cn from 'classnames';
|
|
9
|
+
import { useEffect, useState } from 'react';
|
|
10
|
+
import copy from 'copy-to-clipboard';
|
|
11
|
+
import { makeStyles } from '@material-ui/core';
|
|
12
|
+
import { useHistory } from 'react-router-dom';
|
|
13
|
+
import { formatDistanceToNowStrict } from 'date-fns';
|
|
14
|
+
import { isValidDate } from '@postgres.ai/shared/utils/date';
|
|
15
|
+
import { ArrowDropDownIcon } from '@postgres.ai/shared/icons/ArrowDropDown';
|
|
16
|
+
import { HorizontalScrollContainer } from '@postgres.ai/shared/components/HorizontalScrollContainer';
|
|
17
|
+
import { useHost } from '@postgres.ai/shared/pages/Instance/context';
|
|
18
|
+
import { Table, TableHead, TableRow, TableBody, TableHeaderCell, TableBodyCell, TableBodyCellMenu, } from '@postgres.ai/shared/components/Table';
|
|
19
|
+
import { DeleteBranchModal } from '../Modals/DeleteBranchModal';
|
|
20
|
+
const useStyles = makeStyles({
|
|
21
|
+
cellContentCentered: {
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
},
|
|
25
|
+
pointerCursor: {
|
|
26
|
+
cursor: 'pointer',
|
|
27
|
+
},
|
|
28
|
+
sortIcon: {
|
|
29
|
+
marginLeft: '8px',
|
|
30
|
+
width: '10px',
|
|
31
|
+
},
|
|
32
|
+
interactiveRow: {
|
|
33
|
+
cursor: 'pointer',
|
|
34
|
+
},
|
|
35
|
+
verticalCentered: {
|
|
36
|
+
display: 'flex',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
},
|
|
39
|
+
marginTop: {
|
|
40
|
+
marginTop: '16px',
|
|
41
|
+
},
|
|
42
|
+
sortIconUp: {
|
|
43
|
+
transform: 'rotate(180deg)',
|
|
44
|
+
},
|
|
45
|
+
}, { index: 1 });
|
|
46
|
+
export const BranchesTable = ({ branches, emptyTableText, deleteBranch, branchesRoute, reloadBranches, }) => {
|
|
47
|
+
var _a;
|
|
48
|
+
const host = useHost();
|
|
49
|
+
const history = useHistory();
|
|
50
|
+
const classes = useStyles();
|
|
51
|
+
const [state, setState] = useState({
|
|
52
|
+
sortByParent: 'desc',
|
|
53
|
+
branches: [],
|
|
54
|
+
});
|
|
55
|
+
const [branchId, setBranchId] = useState('');
|
|
56
|
+
const [isOpenDestroyModal, setIsOpenDestroyModal] = useState(false);
|
|
57
|
+
const handlesortByParent = () => {
|
|
58
|
+
const sortByParent = state.sortByParent === 'desc' ? 'asc' : 'desc';
|
|
59
|
+
const sortedBranches = [...state.branches].sort((a, b) => {
|
|
60
|
+
if (sortByParent === 'asc') {
|
|
61
|
+
return a.parent.localeCompare(b.parent);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return b.parent.localeCompare(a.parent);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
setState({
|
|
68
|
+
sortByParent,
|
|
69
|
+
branches: sortedBranches,
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
setState({
|
|
74
|
+
sortByParent: 'desc',
|
|
75
|
+
branches: branches !== null && branches !== void 0 ? branches : [],
|
|
76
|
+
});
|
|
77
|
+
}, [branches]);
|
|
78
|
+
if (!state.branches.length) {
|
|
79
|
+
return _jsx("p", { className: classes.marginTop, children: emptyTableText });
|
|
80
|
+
}
|
|
81
|
+
return (_jsx(HorizontalScrollContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableHeaderCell, {}), _jsx(TableHeaderCell, { children: "Branch" }), _jsx(TableHeaderCell, { children: _jsxs("div", { onClick: handlesortByParent, className: cn(classes.interactiveRow, classes.verticalCentered), children: ["Parent", _jsx(ArrowDropDownIcon, { className: cn(state.sortByParent === 'asc' && classes.sortIconUp, classes.sortIcon) })] }) }), _jsx(TableHeaderCell, { children: "Data state time" }), _jsx(TableHeaderCell, { children: "Latest Snapshot ID" }), _jsx(TableHeaderCell, { children: "Number of snapshots" })] }) }), _jsx(TableBody, { children: (_a = state.branches) === null || _a === void 0 ? void 0 : _a.map((branch) => {
|
|
82
|
+
const branchPagePath = host.routes.branch(branch.name);
|
|
83
|
+
return (_jsxs(TableRow, { hover: true, onClick: () => history.push(branchPagePath), className: classes.pointerCursor, children: [_jsx(TableBodyCellMenu, { actions: [
|
|
84
|
+
{
|
|
85
|
+
name: 'Copy snapshot ID',
|
|
86
|
+
onClick: () => copy(branch.snapshotID),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'Delete branch',
|
|
90
|
+
onClick: () => {
|
|
91
|
+
setBranchId(branch.name);
|
|
92
|
+
setIsOpenDestroyModal(true);
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
] }), _jsx(TableBodyCell, { children: branch.name }), _jsx(TableBodyCell, { children: branch.parent }), _jsxs(TableBodyCell, { children: [branch.dataStateAt, " (", isValidDate(new Date(branch.dataStateAt))
|
|
96
|
+
? formatDistanceToNowStrict(new Date(branch.dataStateAt), {
|
|
97
|
+
addSuffix: true,
|
|
98
|
+
})
|
|
99
|
+
: '-', ")"] }), _jsx(TableBodyCell, { children: branch.snapshotID }), _jsx(TableBodyCell, { children: branch.numSnapshots })] }, branch.name));
|
|
100
|
+
}) }), _jsx(DeleteBranchModal, { isOpen: isOpenDestroyModal, onClose: () => {
|
|
101
|
+
setIsOpenDestroyModal(false);
|
|
102
|
+
setBranchId('');
|
|
103
|
+
}, deleteBranch: deleteBranch, branchName: branchId, instanceId: host.instanceId, afterSubmitClick: () => {
|
|
104
|
+
reloadBranches();
|
|
105
|
+
history.push(branchesRoute);
|
|
106
|
+
} })] }) }));
|
|
107
|
+
};
|