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

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.2",
3
+ "version": "4.0.1-pr-1059.3",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "peerDependencies": {
@@ -77,6 +77,7 @@ const useStyles = makeStyles({
77
77
  },
78
78
  }, { index: 1 });
79
79
  export const CreateBranchPage = observer(({ instanceId, api, elements, routes, isPlatform, hideBranchingFeatures }) => {
80
+ var _a;
80
81
  const stores = useCreatedStores(api);
81
82
  const classes = useStyles();
82
83
  const history = useHistory();
@@ -102,11 +103,11 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
102
103
  });
103
104
  };
104
105
  const handleParentBranchChange = async (e) => {
105
- const branchName = e.target.value;
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.baseDataset;
106
+ const compositeKey = e.target.value;
107
+ const [branchName, dataset] = compositeKey.split('|');
108
+ const selectedBranch = branchesList === null || branchesList === void 0 ? void 0 : branchesList.find((b) => b.name === branchName && b.baseDataset === dataset);
108
109
  formik.setFieldValue('baseBranch', branchName);
109
- await fetchSnapshots(branchName, dataset);
110
+ await fetchSnapshots(branchName, dataset || (selectedBranch === null || selectedBranch === void 0 ? void 0 : selectedBranch.baseDataset));
110
111
  };
111
112
  const [{ formik }] = useForm(handleSubmit);
112
113
  useEffect(() => {
@@ -116,6 +117,8 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
116
117
  if (!(branchesList === null || branchesList === void 0 ? void 0 : branchesList.length))
117
118
  return;
118
119
  const selected = branchesList.find(b => b.name === formik.values.baseBranch);
120
+ if (!selected)
121
+ return;
119
122
  const dataset = selected === null || selected === void 0 ? void 0 : selected.baseDataset;
120
123
  fetchSnapshots(formik.values.baseBranch, dataset);
121
124
  }, [branchesList, formik.values.baseBranch]);
@@ -124,13 +127,14 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
124
127
  }
125
128
  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: hideBranchingFeatures }) }), _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: {
126
129
  shrink: true,
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
130
+ }, 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}|${((_a = branchesList === null || branchesList === void 0 ? void 0 : branchesList.find(b => b.name === formik.values.baseBranch)) === null || _a === void 0 ? void 0 : _a.baseDataset) || ''}`, disabled: !branchesList || formik.isSubmitting, onChange: handleParentBranchChange, error: Boolean(formik.errors.baseBranch), items: branchesList
128
131
  ? branchesList.map((branch) => {
129
132
  const displayName = branch.baseDataset
130
133
  ? `${branch.name} (${branch.baseDataset})`
131
134
  : branch.name;
135
+ const compositeValue = `${branch.name}|${branch.baseDataset || ''}`;
132
136
  return {
133
- value: branch.name,
137
+ value: compositeValue,
134
138
  children: displayName,
135
139
  };
136
140
  })