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

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.4",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "peerDependencies": {
@@ -81,6 +81,7 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
81
81
  const classes = useStyles();
82
82
  const history = useHistory();
83
83
  const [branchSnapshots, setBranchSnapshots] = useState([]);
84
+ const [selectedBranchKey, setSelectedBranchKey] = useState('main|');
84
85
  const { load, branchesList, getBranchesError, createBranch, createBranchError, isBranchesLoading, isCreatingBranch, getSnapshots, snapshotsError, } = stores.main;
85
86
  const handleSubmit = async (values) => {
86
87
  await createBranch({
@@ -102,9 +103,9 @@ 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
+ setSelectedBranchKey(compositeKey);
108
109
  formik.setFieldValue('baseBranch', branchName);
109
110
  await fetchSnapshots(branchName, dataset);
110
111
  };
@@ -116,21 +117,25 @@ 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);
119
- const dataset = selected === null || selected === void 0 ? void 0 : selected.baseDataset;
120
- fetchSnapshots(formik.values.baseBranch, dataset);
121
- }, [branchesList, formik.values.baseBranch]);
120
+ if (!selected)
121
+ return;
122
+ const compositeKey = `${selected.name}|${selected.baseDataset || ''}`;
123
+ setSelectedBranchKey(compositeKey);
124
+ fetchSnapshots(selected.name, selected.baseDataset);
125
+ }, [branchesList]);
122
126
  if (isBranchesLoading) {
123
127
  return _jsx(StubSpinner, {});
124
128
  }
125
129
  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
130
  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
131
+ }, 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: selectedBranchKey, disabled: !branchesList || formik.isSubmitting, onChange: handleParentBranchChange, error: Boolean(formik.errors.baseBranch), items: branchesList
128
132
  ? branchesList.map((branch) => {
129
133
  const displayName = branch.baseDataset
130
134
  ? `${branch.name} (${branch.baseDataset})`
131
135
  : branch.name;
136
+ const compositeValue = `${branch.name}|${branch.baseDataset || ''}`;
132
137
  return {
133
- value: branch.name,
138
+ value: compositeValue,
134
139
  children: displayName,
135
140
  };
136
141
  })