@postgres.ai/shared 4.0.1-pr-1059.5 → 4.0.1-pr-1060

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.5",
3
+ "version": "4.0.1-pr-1060",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "peerDependencies": {
@@ -81,7 +81,6 @@ 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|');
85
84
  const { load, branchesList, getBranchesError, createBranch, createBranchError, isBranchesLoading, isCreatingBranch, getSnapshots, snapshotsError, } = stores.main;
86
85
  const handleSubmit = async (values) => {
87
86
  await createBranch({
@@ -93,8 +92,8 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
93
92
  }
94
93
  });
95
94
  };
96
- const fetchSnapshots = async (branchName, dataset) => {
97
- await getSnapshots(instanceId, branchName, dataset).then((response) => {
95
+ const fetchSnapshots = async (branchName) => {
96
+ await getSnapshots(instanceId, branchName).then((response) => {
98
97
  var _a;
99
98
  if (response) {
100
99
  setBranchSnapshots(response);
@@ -103,40 +102,25 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
103
102
  });
104
103
  };
105
104
  const handleParentBranchChange = async (e) => {
106
- const compositeKey = e.target.value;
107
- const [branchName, dataset] = compositeKey.split('|');
108
- setSelectedBranchKey(compositeKey);
105
+ const branchName = e.target.value;
109
106
  formik.setFieldValue('baseBranch', branchName);
110
- await fetchSnapshots(branchName, dataset);
107
+ await fetchSnapshots(branchName);
111
108
  };
112
109
  const [{ formik }] = useForm(handleSubmit);
113
110
  useEffect(() => {
114
111
  load(instanceId);
115
- }, [instanceId]);
116
- useEffect(() => {
117
- if (!(branchesList === null || branchesList === void 0 ? void 0 : branchesList.length))
118
- return;
119
- const selected = branchesList.find(b => b.name === 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]);
112
+ fetchSnapshots(formik.values.baseBranch);
113
+ }, [formik.values.baseBranch]);
126
114
  if (isBranchesLoading) {
127
115
  return _jsx(StubSpinner, {});
128
116
  }
129
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: 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: {
130
118
  shrink: true,
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
119
+ }, 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
132
120
  ? branchesList.map((branch) => {
133
- const displayName = branch.baseDataset
134
- ? `${branch.name} (${branch.baseDataset})`
135
- : branch.name;
136
- const compositeValue = `${branch.name}|${branch.baseDataset || ''}`;
137
121
  return {
138
- value: compositeValue,
139
- children: displayName,
122
+ value: branch.name,
123
+ children: branch.name,
140
124
  };
141
125
  })
142
126
  : [] }), _jsx("strong", { children: "Snapshot ID" }), _jsx("p", { className: cn(classes.marginTop, classes.marginBottom), children: "Choose an existing snapshot. This snapshot will be memorized as a forking point for the new branch; it cannot be deleted while the branch exists." }), _jsx(Select, { fullWidth: true, className: classes.marginBottom2x, label: "Snapshot ID", value: formik.values.snapshotID, disabled: !branchesList || formik.isSubmitting, onChange: (e) => formik.setFieldValue('snapshotID', e.target.value), error: Boolean(formik.errors.baseBranch), items: branchSnapshots
@@ -25,7 +25,7 @@ export declare class MainStore {
25
25
  load: (instanceId: string) => Promise<void>;
26
26
  createBranch: (values: CreateBranchFormValues) => Promise<import("../../../types/api/entities/createBranch").CreateBranchDTO | null | undefined>;
27
27
  getBranches: (instanceId: string) => Promise<Branch[] | null | undefined>;
28
- getSnapshots: (instanceId: string, branchName?: string, dataset?: string) => Promise<{
28
+ getSnapshots: (instanceId: string, branchName?: string) => Promise<{
29
29
  createdAtDate: Date;
30
30
  dataStateAtDate: Date;
31
31
  numClones: string | number;
@@ -41,13 +41,12 @@ export class MainStore {
41
41
  this.getBranchesError = await error.json().then((err) => err);
42
42
  return response;
43
43
  };
44
- this.getSnapshots = async (instanceId, branchName, dataset) => {
44
+ this.getSnapshots = async (instanceId, branchName) => {
45
45
  if (!this.api.getSnapshots)
46
46
  return;
47
47
  const { response, error } = await this.api.getSnapshots({
48
48
  instanceId,
49
49
  branchName,
50
- dataset,
51
50
  });
52
51
  if (error) {
53
52
  this.snapshotsError = await error.json().then((err) => err);
@@ -1,19 +1,15 @@
1
1
  export interface Branch {
2
2
  name: string;
3
- baseDataset: string;
4
3
  parent: string;
5
4
  dataStateAt: string;
6
5
  snapshotID: string;
7
- dataset: string;
8
6
  numSnapshots: number;
9
7
  }
10
8
  export declare const formatBranchesDto: (dto: Branch[]) => {
11
9
  dataStateAt: string;
12
10
  name: string;
13
- baseDataset: string;
14
11
  parent: string;
15
12
  snapshotID: string;
16
- dataset: string;
17
13
  numSnapshots: number;
18
14
  }[];
19
15
  export declare type GetBranches = (instanceId: string) => Promise<{
@@ -2,7 +2,6 @@ import { Snapshot } from '@postgres.ai/shared/types/api/entities/snapshot';
2
2
  export declare type GetSnapshots = (args: {
3
3
  instanceId: string;
4
4
  branchName?: string;
5
- dataset?: string;
6
5
  }) => Promise<{
7
6
  response: Snapshot[] | null;
8
7
  error: Response | null;