@postgres.ai/shared 4.0.1-pr-1059 → 4.0.1-pr-1059.2

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.1-pr-1059",
3
+ "version": "4.0.1-pr-1059.2",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "peerDependencies": {
@@ -77,7 +77,7 @@ export const BranchesTable = ({ branches, emptyTableText, deleteBranch, branches
77
77
  if (!state.branches.length) {
78
78
  return _jsx("p", { className: classes.marginTop, children: emptyTableText });
79
79
  }
80
- return (_jsx(HorizontalScrollContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableHeaderCell, {}), _jsx(TableHeaderCell, { children: "Branch" }), _jsx(TableHeaderCell, { children: "Dataset" }), _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) => {
80
+ 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) => {
81
81
  const branchPagePath = host.routes.branch(branch.name);
82
82
  return (_jsxs(TableRow, { hover: true, onClick: () => history.push(branchPagePath), className: classes.pointerCursor, children: [_jsx(TableBodyCellMenu, { actions: [
83
83
  {
@@ -91,7 +91,7 @@ export const BranchesTable = ({ branches, emptyTableText, deleteBranch, branches
91
91
  setIsOpenDestroyModal(true);
92
92
  },
93
93
  },
94
- ] }), _jsx(TableBodyCell, { children: branch.name }), _jsx(TableBodyCell, { children: branch.dataset }), _jsx(TableBodyCell, { children: branch.parent }), _jsx(TableBodyCell, { children: formatDateWithDistance(branch.dataStateAt, new Date(branch.dataStateAt)) }), _jsx(TableBodyCell, { children: branch.snapshotID }), _jsx(TableBodyCell, { children: branch.numSnapshots })] }, branch.name));
94
+ ] }), _jsx(TableBodyCell, { children: branch.name }), _jsx(TableBodyCell, { children: branch.parent }), _jsx(TableBodyCell, { children: formatDateWithDistance(branch.dataStateAt, new Date(branch.dataStateAt)) }), _jsx(TableBodyCell, { children: branch.snapshotID }), _jsx(TableBodyCell, { children: branch.numSnapshots })] }, branch.name));
95
95
  }) }), _jsx(DeleteBranchModal, { isOpen: isOpenDestroyModal, onClose: () => {
96
96
  setIsOpenDestroyModal(false);
97
97
  setBranchId('');
@@ -104,18 +104,21 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
104
104
  const handleParentBranchChange = async (e) => {
105
105
  const branchName = e.target.value;
106
106
  const selectedBranch = branchesList === null || branchesList === void 0 ? void 0 : branchesList.find((b) => b.name === branchName);
107
- const dataset = selectedBranch === null || selectedBranch === void 0 ? void 0 : selectedBranch.dataset;
107
+ const dataset = selectedBranch === null || selectedBranch === void 0 ? void 0 : selectedBranch.baseDataset;
108
108
  formik.setFieldValue('baseBranch', branchName);
109
109
  await fetchSnapshots(branchName, dataset);
110
110
  };
111
111
  const [{ formik }] = useForm(handleSubmit);
112
112
  useEffect(() => {
113
- load(instanceId).then(() => {
114
- const selectedBranch = branchesList === null || branchesList === void 0 ? void 0 : branchesList.find((b) => b.name === formik.values.baseBranch);
115
- const dataset = selectedBranch === null || selectedBranch === void 0 ? void 0 : selectedBranch.dataset;
116
- fetchSnapshots(formik.values.baseBranch, dataset);
117
- });
118
- }, [formik.values.baseBranch]);
113
+ load(instanceId);
114
+ }, [instanceId]);
115
+ useEffect(() => {
116
+ if (!(branchesList === null || branchesList === void 0 ? void 0 : branchesList.length))
117
+ return;
118
+ const selected = branchesList.find(b => b.name === formik.values.baseBranch);
119
+ const dataset = selected === null || selected === void 0 ? void 0 : selected.baseDataset;
120
+ fetchSnapshots(formik.values.baseBranch, dataset);
121
+ }, [branchesList, formik.values.baseBranch]);
119
122
  if (isBranchesLoading) {
120
123
  return _jsx(StubSpinner, {});
121
124
  }
@@ -123,8 +126,8 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
123
126
  shrink: true,
124
127
  }, value: formik.values.branchName, error: Boolean(formik.errors.branchName), helperText: 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
125
128
  ? branchesList.map((branch) => {
126
- const displayName = branch.dataset
127
- ? `${branch.name} (${branch.dataset})`
129
+ const displayName = branch.baseDataset
130
+ ? `${branch.name} (${branch.baseDataset})`
128
131
  : branch.name;
129
132
  return {
130
133
  value: branch.name,
@@ -1,5 +1,6 @@
1
1
  export interface Branch {
2
2
  name: string;
3
+ baseDataset: string;
3
4
  parent: string;
4
5
  dataStateAt: string;
5
6
  snapshotID: string;
@@ -9,6 +10,7 @@ export interface Branch {
9
10
  export declare const formatBranchesDto: (dto: Branch[]) => {
10
11
  dataStateAt: string;
11
12
  name: string;
13
+ baseDataset: string;
12
14
  parent: string;
13
15
  snapshotID: string;
14
16
  dataset: string;