@postgres.ai/shared 4.0.0-pr-1028.6 → 4.0.0-pr-1028.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postgres.ai/shared",
3
- "version": "4.0.0-pr-1028.6",
3
+ "version": "4.0.0-pr-1028.8",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "peerDependencies": {
@@ -2,6 +2,7 @@
2
2
  import { Host } from './context';
3
3
  declare type Props = Host & {
4
4
  isPlatform?: boolean;
5
+ hideInstanceTabs?: boolean;
5
6
  };
6
7
  export declare const BranchesPage: ((props: Props) => JSX.Element) & {
7
8
  displayName: string;
@@ -131,7 +131,7 @@ export const BranchesPage = observer((props) => {
131
131
  return acc;
132
132
  }
133
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 }) })] }));
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, hideInstanceTabs: props.hideInstanceTabs }) })] }));
135
135
  useEffect(() => {
136
136
  load(props.branchId, props.instanceId);
137
137
  }, []);
@@ -2,6 +2,7 @@
2
2
  import { Host } from './context';
3
3
  declare type Props = Host & {
4
4
  isPlatform?: boolean;
5
+ hideInstanceTabs?: boolean;
5
6
  };
6
7
  export declare const Clone: ((props: Props) => JSX.Element) & {
7
8
  displayName: string;
@@ -176,7 +176,7 @@ export const Clone = observer((props) => {
176
176
  stores.main.load(props.instanceId, props.cloneId);
177
177
  }, []);
178
178
  const { instance, snapshots, clone, isResettingClone, isDestroyingClone, isReloading, isUpdatingClone, isCloneStable, } = stores.main;
179
- const headRendered = (_jsxs(_Fragment, { children: [_jsx("style", { children: 'p { margin: 0;}' }), props.elements.breadcrumbs, _jsx(SectionTitle, { className: classes.title, tag: "h1", level: 1, text: `Clone ${props.cloneId}`, children: _jsx(InstanceTabs, { tab: TABS_INDEX.CLONES, isPlatform: props.isPlatform, instanceId: props.instanceId, hasLogs: props.api.initWS !== undefined }) })] }));
179
+ const headRendered = (_jsxs(_Fragment, { children: [_jsx("style", { children: 'p { margin: 0;}' }), props.elements.breadcrumbs, _jsx(SectionTitle, { className: classes.title, tag: "h1", level: 1, text: `Clone ${props.cloneId}`, children: _jsx(InstanceTabs, { tab: TABS_INDEX.CLONES, isPlatform: props.isPlatform, instanceId: props.instanceId, hasLogs: props.api.initWS !== undefined, hideInstanceTabs: props.hideInstanceTabs }) })] }));
180
180
  const cloneErrorMessage = ((_a = stores.main.instanceError) === null || _a === void 0 ? void 0 : _a.message) || ((_b = stores.main.cloneError) === null || _b === void 0 ? void 0 : _b.message);
181
181
  const cloneErrorTitle = ((_c = stores.main.instanceError) === null || _c === void 0 ? void 0 : _c.title) || ((_d = stores.main.cloneError) === null || _d === void 0 ? void 0 : _d.title);
182
182
  if (cloneErrorMessage && cloneErrorTitle)
@@ -10,8 +10,9 @@ interface CreateBranchProps {
10
10
  breadcrumbs: React.ReactNode;
11
11
  };
12
12
  isPlatform?: boolean;
13
+ hideInstanceTabs?: boolean;
13
14
  }
14
- export declare const CreateBranchPage: (({ instanceId, api, elements, routes, isPlatform }: CreateBranchProps) => JSX.Element) & {
15
+ export declare const CreateBranchPage: (({ instanceId, api, elements, routes, isPlatform, hideInstanceTabs }: CreateBranchProps) => JSX.Element) & {
15
16
  displayName: string;
16
17
  };
17
18
  export {};
@@ -76,7 +76,7 @@ const useStyles = makeStyles({
76
76
  whiteSpace: 'initial',
77
77
  },
78
78
  }, { index: 1 });
79
- export const CreateBranchPage = observer(({ instanceId, api, elements, routes, isPlatform }) => {
79
+ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, isPlatform, hideInstanceTabs }) => {
80
80
  const stores = useCreatedStores(api);
81
81
  const classes = useStyles();
82
82
  const history = useHistory();
@@ -114,7 +114,7 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
114
114
  if (isBranchesLoading) {
115
115
  return _jsx(StubSpinner, {});
116
116
  }
117
- return (_jsxs(_Fragment, { children: [elements.breadcrumbs, _jsx(SectionTitle, { tag: "h1", level: 1, text: "Create branch", className: classes.title, children: _jsx(InstanceTabs, { tab: TABS_INDEX.BRANCHES, isPlatform: isPlatform, instanceId: instanceId, hasLogs: api.initWS !== undefined }) }), _jsxs("div", { className: classes.wrapper, children: [_jsxs("div", { className: classes.container, children: [(snapshotsError || getBranchesError) && (_jsx("div", { className: classes.marginTop, children: _jsx(ErrorStub, { message: (snapshotsError === null || snapshotsError === void 0 ? void 0 : snapshotsError.message) || (getBranchesError === null || getBranchesError === void 0 ? void 0 : getBranchesError.message) }) })), _jsxs("div", { className: classes.form, children: [_jsx(TextField, { label: "Branch name", variant: "outlined", required: true, fullWidth: true, size: "small", InputLabelProps: {
117
+ return (_jsxs(_Fragment, { children: [elements.breadcrumbs, _jsx(SectionTitle, { tag: "h1", level: 1, text: "Create branch", className: classes.title, children: _jsx(InstanceTabs, { tab: TABS_INDEX.BRANCHES, isPlatform: isPlatform, instanceId: instanceId, hasLogs: api.initWS !== undefined, hideInstanceTabs: hideInstanceTabs }) }), _jsxs("div", { className: classes.wrapper, children: [_jsxs("div", { className: classes.container, children: [(snapshotsError || getBranchesError) && (_jsx("div", { className: classes.marginTop, children: _jsx(ErrorStub, { message: (snapshotsError === null || snapshotsError === void 0 ? void 0 : snapshotsError.message) || (getBranchesError === null || getBranchesError === void 0 ? void 0 : getBranchesError.message) }) })), _jsxs("div", { className: classes.form, children: [_jsx(TextField, { label: "Branch name", variant: "outlined", required: true, fullWidth: true, size: "small", InputLabelProps: {
118
118
  shrink: true,
119
119
  }, value: formik.values.branchName, error: Boolean(formik.errors.branchName), className: classes.marginBottom, onChange: (e) => formik.setFieldValue('branchName', e.target.value) }), _jsx("p", { className: cn(classes.marginTop, classes.marginBottom), children: "Choose an existing branch. The new branch will initially point at the same snapshot as the parent branch but going further, their evolution paths will be independent - new snapshots can be created for both branches." }), _jsx(Select, { fullWidth: true, label: "Parent branch", value: formik.values.baseBranch, disabled: !branchesList || formik.isSubmitting, onChange: handleParentBranchChange, error: Boolean(formik.errors.baseBranch), items: branchesList
120
120
  ? branchesList.map((branch) => {
@@ -12,6 +12,7 @@ declare type Host = {
12
12
  };
13
13
  declare type Props = Host & {
14
14
  isPlatform?: boolean;
15
+ hideInstanceTabs?: boolean;
15
16
  };
16
17
  export declare const CreateClone: ((props: Props) => JSX.Element) & {
17
18
  displayName: string;
@@ -105,7 +105,7 @@ export const CreateClone = observer((props) => {
105
105
  return;
106
106
  history.push(props.routes.clone(stores.main.clone.id));
107
107
  }, [stores.main.clone, stores.main.isCloneStable]);
108
- const headRendered = (_jsxs(_Fragment, { children: [_jsx("style", { children: 'p { margin: 0; }' }), props.elements.breadcrumbs, _jsx(SectionTitle, { tag: "h1", level: 1, text: "Create clone", className: styles.pageTitle, children: _jsx(InstanceTabs, { tab: TABS_INDEX.CLONES, isPlatform: props.isPlatform, instanceId: props.instanceId, hasLogs: props.api.initWS !== undefined }) })] }));
108
+ const headRendered = (_jsxs(_Fragment, { children: [_jsx("style", { children: 'p { margin: 0; }' }), props.elements.breadcrumbs, _jsx(SectionTitle, { tag: "h1", level: 1, text: "Create clone", className: styles.pageTitle, children: _jsx(InstanceTabs, { tab: TABS_INDEX.CLONES, isPlatform: props.isPlatform, instanceId: props.instanceId, hasLogs: props.api.initWS !== undefined, hideInstanceTabs: props.hideInstanceTabs }) })] }));
109
109
  // Initial loading spinner.
110
110
  if (!stores.main.instance || isLoadingSnapshots)
111
111
  return (_jsxs(_Fragment, { children: [headRendered, _jsx(StubSpinner, {})] }));
@@ -10,8 +10,9 @@ interface CreateSnapshotProps {
10
10
  breadcrumbs: React.ReactNode;
11
11
  };
12
12
  isPlatform?: boolean;
13
+ hideInstanceTabs?: boolean;
13
14
  }
14
- export declare const CreateSnapshotPage: (({ instanceId, api, elements, routes, isPlatform }: CreateSnapshotProps) => JSX.Element) & {
15
+ export declare const CreateSnapshotPage: (({ instanceId, api, elements, routes, isPlatform, hideInstanceTabs }: CreateSnapshotProps) => JSX.Element) & {
15
16
  displayName: string;
16
17
  };
17
18
  export {};
@@ -71,7 +71,7 @@ const useStyles = makeStyles({
71
71
  lineHeight: '26px'
72
72
  },
73
73
  }, { index: 1 });
74
- export const CreateSnapshotPage = observer(({ instanceId, api, elements, routes, isPlatform }) => {
74
+ export const CreateSnapshotPage = observer(({ instanceId, api, elements, routes, isPlatform, hideInstanceTabs }) => {
75
75
  var _a, _b;
76
76
  const stores = useCreatedStores(api);
77
77
  const classes = useStyles();
@@ -104,7 +104,7 @@ export const CreateSnapshotPage = observer(({ instanceId, api, elements, routes,
104
104
  return;
105
105
  formik.setFieldValue('cloneID', cloneID);
106
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
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, hideInstanceTabs: hideInstanceTabs }) }), _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
108
  ? clonesList.map((clone, i) => {
109
109
  var _a, _b;
110
110
  const isLatest = i === 0;
@@ -30,22 +30,9 @@ export const PlatformTabs = ({ value, handleChange, hasLogs, hideInstanceTabs, }
30
30
  to: 'clones',
31
31
  value: TABS_INDEX.CLONES,
32
32
  hide: hideInstanceTabs,
33
- },
34
- {
35
- label: '📓 Logs',
36
- to: 'logs',
37
- value: TABS_INDEX.LOGS,
38
- disabled: !hasLogs,
39
- hide: hideInstanceTabs,
40
- },
41
- {
42
- label: '🛠️ Configuration',
43
- to: 'configuration',
44
- value: TABS_INDEX.CONFIGURATION,
45
- hide: hideInstanceTabs,
46
- },
33
+ }
47
34
  ];
48
- return (_jsx(TabsComponent, { value: value, onChange: handleChange, classes: { root: classes.tabsRoot, indicator: classes.tabsIndicator }, children: tabs.map(({ label, to, value, hide, disabled }) => (_jsx(Link, { to: `/${org}/instances/${instanceId}/${to}`, children: _jsx(TabComponent, { label: label, value: value, disabled: disabled, classes: {
35
+ return (_jsx(TabsComponent, { value: value, onChange: handleChange, classes: { root: classes.tabsRoot, indicator: classes.tabsIndicator }, children: tabs.map(({ label, to, value, hide }) => (_jsx(Link, { to: `/${org}/instances/${instanceId}/${to}`, children: _jsx(TabComponent, { label: label, value: value, classes: {
49
36
  root: hide ? classes.tabHidden : classes.tabRoot,
50
37
  }, onClick: (event) => handleChange(event, value) }) }, value))) }));
51
38
  };
@@ -21,6 +21,7 @@ declare type InstanceTabProps = {
21
21
  onTabChange?: (tabID: number) => void;
22
22
  instanceId: string;
23
23
  hasLogs: boolean;
24
+ hideInstanceTabs?: boolean;
24
25
  };
25
26
  export declare const InstanceTabs: (props: InstanceTabProps) => JSX.Element;
26
27
  export {};
@@ -53,23 +53,24 @@ export const Tabs = ({ value, handleChange, hasLogs, hideInstanceTabs, }) => {
53
53
  } }) }, value))) }));
54
54
  };
55
55
  export const InstanceTabs = (props) => {
56
+ const { instanceId, onTabChange, tab, hasLogs, hideInstanceTabs = false } = props;
56
57
  const stores = useCreatedStores({});
57
58
  const { load, } = stores.main;
58
59
  const switchTab = (_, tabID) => {
59
60
  const contentElement = document.getElementById('content-container');
60
- if (props.onTabChange) {
61
- props.onTabChange(tabID);
61
+ if (onTabChange) {
62
+ onTabChange(tabID);
62
63
  }
63
64
  if (tabID === 0) {
64
- load(props.instanceId);
65
+ load(instanceId);
65
66
  }
66
67
  contentElement === null || contentElement === void 0 ? void 0 : contentElement.scrollTo(0, 0);
67
68
  };
68
69
  const tabProps = {
69
- value: props.tab,
70
+ value: tab,
70
71
  handleChange: switchTab,
71
- hasLogs: Boolean(props.hasLogs),
72
- hideInstanceTabs: Boolean(props.isPlatform),
72
+ hasLogs: Boolean(hasLogs),
73
+ hideInstanceTabs: hideInstanceTabs,
73
74
  };
74
75
  return props.isPlatform ? _jsx(PlatformTabs, { ...tabProps }) : _jsx(Tabs, { ...tabProps });
75
76
  };
@@ -1,7 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { Host } from './context';
3
3
  import './styles.scss';
4
- declare type Props = Host;
4
+ declare type Props = Host & {
5
+ hideInstanceTabs?: boolean;
6
+ };
5
7
  export declare const Instance: ((props: Props) => JSX.Element) & {
6
8
  displayName: string;
7
9
  };
@@ -85,7 +85,7 @@ export const Instance = observer((props) => {
85
85
  setHasBeenRedirected(true);
86
86
  }
87
87
  }, [instance, hasBeenRedirected]);
88
- return (_jsx(HostProvider, { value: props, children: _jsxs(StoresProvider, { value: stores, children: [props.elements.breadcrumbs, _jsx(SectionTitle, { text: props.title, level: 1, tag: "h1", className: classes.title, rightContent: _jsx(Button, { onClick: () => load(props.instanceId, isPlatform), isDisabled: !instance && !instanceError, className: classes.reloadButton, children: "Reload info" }), children: isInstanceIntegrated && (_jsx(InstanceTabs, { instanceId: props.instanceId, tab: activeTab, onTabChange: (tabID) => setActiveTab(tabID), isPlatform: isPlatform, hasLogs: api.initWS !== undefined })) }), instanceError && (_jsx(ErrorStub, { ...instanceError, className: classes.errorStub })), isInstanceIntegrated ? (_jsxs(_Fragment, { children: [_jsxs(TabPanel, { value: activeTab, index: TABS_INDEX.OVERVIEW, children: [!instanceError && (_jsx("div", { className: classes.content, children: instance && ((_b = (_a = instance.state) === null || _a === void 0 ? void 0 : _a.retrieving) === null || _b === void 0 ? void 0 : _b.status) ? (_jsxs(_Fragment, { children: [_jsx(Clones, {}), _jsx(Info, {})] })) : (_jsx(StubSpinner, {})) })), _jsx(ClonesModal, {}), _jsx(SnapshotsModal, {})] }), _jsx(TabPanel, { value: activeTab, index: TABS_INDEX.CLONES, children: activeTab === TABS_INDEX.CLONES && (_jsx("div", { className: classes.content, children: !instanceError &&
88
+ return (_jsx(HostProvider, { value: props, children: _jsxs(StoresProvider, { value: stores, children: [props.elements.breadcrumbs, _jsx(SectionTitle, { text: props.title, level: 1, tag: "h1", className: classes.title, rightContent: _jsx(Button, { onClick: () => load(props.instanceId, isPlatform), isDisabled: !instance && !instanceError, className: classes.reloadButton, children: "Reload info" }), children: isInstanceIntegrated && (_jsx(InstanceTabs, { instanceId: props.instanceId, tab: activeTab, onTabChange: (tabID) => setActiveTab(tabID), isPlatform: isPlatform, hasLogs: api.initWS !== undefined, hideInstanceTabs: props.hideInstanceTabs })) }), instanceError && (_jsx(ErrorStub, { ...instanceError, className: classes.errorStub })), isInstanceIntegrated ? (_jsxs(_Fragment, { children: [_jsxs(TabPanel, { value: activeTab, index: TABS_INDEX.OVERVIEW, children: [!instanceError && (_jsx("div", { className: classes.content, children: instance && ((_b = (_a = instance.state) === null || _a === void 0 ? void 0 : _a.retrieving) === null || _b === void 0 ? void 0 : _b.status) ? (_jsxs(_Fragment, { children: [_jsx(Clones, {}), _jsx(Info, {})] })) : (_jsx(StubSpinner, {})) })), _jsx(ClonesModal, {}), _jsx(SnapshotsModal, {})] }), _jsx(TabPanel, { value: activeTab, index: TABS_INDEX.CLONES, children: activeTab === TABS_INDEX.CLONES && (_jsx("div", { className: classes.content, children: !instanceError &&
89
89
  (instance ? _jsx(Clones, { onlyRenderList: true }) : _jsx(StubSpinner, {})) })) }), _jsx(TabPanel, { value: activeTab, index: TABS_INDEX.LOGS, children: activeTab === TABS_INDEX.LOGS && (_jsx(Logs, { api: api, instanceId: props.instanceId })) }), _jsx(TabPanel, { value: activeTab, index: TABS_INDEX.CONFIGURATION, children: activeTab === TABS_INDEX.CONFIGURATION && (_jsx(Configuration, { instanceId: instanceId, switchActiveTab: switchTab, isConfigurationActive: isConfigurationActive, reload: () => load(props.instanceId), disableConfigModification: (_c = instance === null || instance === void 0 ? void 0 : instance.state) === null || _c === void 0 ? void 0 : _c.engine.disableConfigModification })) }), _jsx(TabPanel, { value: activeTab, index: TABS_INDEX.SNAPSHOTS, children: activeTab === TABS_INDEX.SNAPSHOTS && (_jsx(Snapshots, { instanceId: instanceId })) }), _jsx(TabPanel, { value: activeTab, index: TABS_INDEX.BRANCHES, children: activeTab === TABS_INDEX.BRANCHES && (_jsx(Branches, { instanceId: instanceId })) })] })) : !isLoadingInstance && !instanceError ? (_jsx(TabPanel, { value: activeTab, index: activeTab, children: _jsx(InactiveInstance, { instance: instance, org: (_d = props.elements.breadcrumbs) === null || _d === void 0 ? void 0 : _d.props.org }) })) : (!instanceError && (_jsx(TabPanel, { value: activeTab, index: activeTab, children: _jsx("div", { className: classes.content, children: _jsx(StubSpinner, {}) }) })))] }) }));
90
90
  });
91
91
  function TabPanel(props) {
@@ -2,6 +2,7 @@
2
2
  import { Host } from './context';
3
3
  declare type Props = Host & {
4
4
  isPlatform?: boolean;
5
+ hideInstanceTabs?: boolean;
5
6
  };
6
7
  export declare const SnapshotPage: ((props: Props) => JSX.Element) & {
7
8
  displayName: string;
@@ -134,7 +134,7 @@ export const SnapshotPage = observer((props) => {
134
134
  history.push(props.routes.snapshots());
135
135
  load(props.snapshotId, props.instanceId);
136
136
  };
137
- const headRendered = (_jsxs(_Fragment, { children: [_jsx("style", { children: 'p { margin: 0;}' }), props.elements.breadcrumbs, _jsx(SectionTitle, { className: classes.title, tag: "h1", level: 1, text: `Snapshot ${props.snapshotId}`, children: _jsx(InstanceTabs, { tab: TABS_INDEX.SNAPSHOTS, isPlatform: props.isPlatform, instanceId: props.instanceId, hasLogs: props.api.initWS !== undefined }) })] }));
137
+ const headRendered = (_jsxs(_Fragment, { children: [_jsx("style", { children: 'p { margin: 0;}' }), props.elements.breadcrumbs, _jsx(SectionTitle, { className: classes.title, tag: "h1", level: 1, text: `Snapshot ${props.snapshotId}`, children: _jsx(InstanceTabs, { tab: TABS_INDEX.SNAPSHOTS, isPlatform: props.isPlatform, instanceId: props.instanceId, hasLogs: props.api.initWS !== undefined, hideInstanceTabs: props.hideInstanceTabs }) })] }));
138
138
  useEffect(() => {
139
139
  load(props.snapshotId, props.instanceId);
140
140
  }, []);