@postgres.ai/shared 4.0.1 → 4.0.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 +1 -1
- package/pages/CreateBranch/index.js +25 -9
- package/pages/CreateBranch/stores/Main.d.ts +1 -1
- package/pages/CreateBranch/stores/Main.js +2 -1
- package/pages/Instance/Configuration/utils/index.js +2 -1
- package/types/api/endpoints/getBranches.d.ts +4 -0
- package/types/api/endpoints/getSnapshots.d.ts +1 -0
package/package.json
CHANGED
|
@@ -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({
|
|
@@ -92,8 +93,8 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
|
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
};
|
|
95
|
-
const fetchSnapshots = async (branchName) => {
|
|
96
|
-
await getSnapshots(instanceId, branchName).then((response) => {
|
|
96
|
+
const fetchSnapshots = async (branchName, dataset) => {
|
|
97
|
+
await getSnapshots(instanceId, branchName, dataset).then((response) => {
|
|
97
98
|
var _a;
|
|
98
99
|
if (response) {
|
|
99
100
|
setBranchSnapshots(response);
|
|
@@ -102,25 +103,40 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
|
|
|
102
103
|
});
|
|
103
104
|
};
|
|
104
105
|
const handleParentBranchChange = async (e) => {
|
|
105
|
-
const
|
|
106
|
+
const compositeKey = e.target.value;
|
|
107
|
+
const [branchName, dataset] = compositeKey.split('|');
|
|
108
|
+
setSelectedBranchKey(compositeKey);
|
|
106
109
|
formik.setFieldValue('baseBranch', branchName);
|
|
107
|
-
await fetchSnapshots(branchName);
|
|
110
|
+
await fetchSnapshots(branchName, dataset);
|
|
108
111
|
};
|
|
109
112
|
const [{ formik }] = useForm(handleSubmit);
|
|
110
113
|
useEffect(() => {
|
|
111
114
|
load(instanceId);
|
|
112
|
-
|
|
113
|
-
|
|
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]);
|
|
114
126
|
if (isBranchesLoading) {
|
|
115
127
|
return _jsx(StubSpinner, {});
|
|
116
128
|
}
|
|
117
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: {
|
|
118
130
|
shrink: true,
|
|
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:
|
|
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
|
|
120
132
|
? branchesList.map((branch) => {
|
|
133
|
+
const displayName = branch.baseDataset
|
|
134
|
+
? `${branch.name} (${branch.baseDataset})`
|
|
135
|
+
: branch.name;
|
|
136
|
+
const compositeValue = `${branch.name}|${branch.baseDataset || ''}`;
|
|
121
137
|
return {
|
|
122
|
-
value:
|
|
123
|
-
children:
|
|
138
|
+
value: compositeValue,
|
|
139
|
+
children: displayName,
|
|
124
140
|
};
|
|
125
141
|
})
|
|
126
142
|
: [] }), _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) => Promise<{
|
|
28
|
+
getSnapshots: (instanceId: string, branchName?: string, dataset?: string) => Promise<{
|
|
29
29
|
createdAtDate: Date;
|
|
30
30
|
dataStateAtDate: Date;
|
|
31
31
|
numClones: string | number;
|
|
@@ -41,12 +41,13 @@ 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) => {
|
|
44
|
+
this.getSnapshots = async (instanceId, branchName, dataset) => {
|
|
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,
|
|
50
51
|
});
|
|
51
52
|
if (error) {
|
|
52
53
|
this.snapshotsError = await error.json().then((err) => err);
|
|
@@ -15,6 +15,7 @@ const dockerImagesConfig = {
|
|
|
15
15
|
'15': ['0.5.3', '0.5.2', '0.5.1'],
|
|
16
16
|
'16': ['0.5.3', '0.5.2', '0.5.1'],
|
|
17
17
|
'17': ['0.5.3', '0.5.2', '0.5.1'],
|
|
18
|
+
'18': ['0.6.1'],
|
|
18
19
|
};
|
|
19
20
|
export const uniqueChipValue = (values) => {
|
|
20
21
|
const splitChipArray = values.split(/[,(\s)(\n)(\r)(\t)(\r\n)]/);
|
|
@@ -119,7 +120,7 @@ export const postUniqueCustomOptions = (options) => {
|
|
|
119
120
|
};
|
|
120
121
|
export const customOrGenericImage = (dockerImage) => dockerImage === 'Generic Postgres' || dockerImage === 'custom';
|
|
121
122
|
export const createFallbackDockerImage = (dockerPath, dockerTag) => {
|
|
122
|
-
const majorVersion = getImageMajorVersion(dockerPath) || '
|
|
123
|
+
const majorVersion = getImageMajorVersion(dockerPath) || '18'; // Default to 18 if version can't be extracted
|
|
123
124
|
return {
|
|
124
125
|
package_group: 'postgresai',
|
|
125
126
|
pg_major_version: majorVersion,
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
export interface Branch {
|
|
2
2
|
name: string;
|
|
3
|
+
baseDataset: string;
|
|
3
4
|
parent: string;
|
|
4
5
|
dataStateAt: string;
|
|
5
6
|
snapshotID: string;
|
|
7
|
+
dataset: string;
|
|
6
8
|
numSnapshots: number;
|
|
7
9
|
}
|
|
8
10
|
export declare const formatBranchesDto: (dto: Branch[]) => {
|
|
9
11
|
dataStateAt: string;
|
|
10
12
|
name: string;
|
|
13
|
+
baseDataset: string;
|
|
11
14
|
parent: string;
|
|
12
15
|
snapshotID: string;
|
|
16
|
+
dataset: string;
|
|
13
17
|
numSnapshots: number;
|
|
14
18
|
}[];
|
|
15
19
|
export declare type GetBranches = (instanceId: string) => Promise<{
|