pollination-react-io 1.53.5 → 1.53.7
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/build/CreateStudy/CreateStudy.types.d.ts +1 -7
- package/build/index.esm.js +38 -56
- package/build/index.esm.js.map +1 -1
- package/build/index.js +38 -56
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
@@ -40659,12 +40659,9 @@ var GetModel = function (_a) {
|
|
40659
40659
|
var sub = Boolean(optionsConfig) && typeof optionsConfig !== 'undefined' &&
|
40660
40660
|
typeof optionsConfig.subscribe !== 'undefined' &&
|
40661
40661
|
typeof optionsConfig.subscribe.selected !== 'undefined' ? optionsConfig.subscribe.selected : false;
|
40662
|
-
|
40663
|
-
typeof optionsConfig.preview !== 'undefined' &&
|
40664
|
-
typeof optionsConfig.preview.selected !== 'undefined' ? optionsConfig.preview.selected : false;
|
40662
|
+
// Do not trigger prev props - for streamlit
|
40665
40663
|
setSelection(sel);
|
40666
40664
|
setSubscribe(sub);
|
40667
|
-
setSubscribe(prev);
|
40668
40665
|
}, [optionsConfig]);
|
40669
40666
|
React.useEffect(function () {
|
40670
40667
|
if (!hbjson)
|
@@ -44685,84 +44682,72 @@ var defaultStyle = {
|
|
44685
44682
|
};
|
44686
44683
|
var CreateStudy = function (_a) {
|
44687
44684
|
var _b;
|
44688
|
-
var style = _a.style, defaultAccount = _a.defaultAccount, defaultProject = _a.defaultProject, defaultRecipe = _a.defaultRecipe,
|
44689
|
-
var
|
44690
|
-
var
|
44691
|
-
var
|
44692
|
-
var
|
44693
|
-
var _g = React.useState(undefined), currJobId = _g[0], setCurrJobId = _g[1];
|
44694
|
-
var _h = React.useState(undefined), isCloud = _h[0], setIsCloud = _h[1];
|
44695
|
-
// Single run only...
|
44696
|
-
var _j = React.useState(undefined); _j[0]; var setCurrRunId = _j[1];
|
44685
|
+
var style = _a.style, defaultAccount = _a.defaultAccount, defaultProject = _a.defaultProject, defaultRecipe = _a.defaultRecipe, authUser = _a.authUser, client = _a.client, _c = _a.onSuccess, onSuccess = _c === void 0 ? undefined : _c;
|
44686
|
+
var _d = React.useState(0), activeTabIndex = _d[0], setActiveTabIndex = _d[1];
|
44687
|
+
var _e = React.useState(defaultAccount), selAccount = _e[0], setSelAccount = _e[1];
|
44688
|
+
var _f = React.useState(defaultProject), selProject = _f[0], setSelProject = _f[1];
|
44689
|
+
var _g = React.useState(defaultRecipe), selRecipe = _g[0], setSelRecipe = _g[1];
|
44697
44690
|
// @ts-ignore
|
44698
44691
|
var projectOwner = selAccount ? ((_b = selAccount.username) !== null && _b !== void 0 ? _b : selAccount.account_name) : undefined;
|
44699
44692
|
var projectSlug = selProject ? selProject.slug.split('/')[1] : undefined;
|
44700
|
-
var
|
44701
|
-
|
44693
|
+
var _h = useCreateStudy(projectOwner, projectSlug, client), host = _h.host, createStudy = _h.createStudy, createLocalStudy = _h.createLocalStudy;
|
44694
|
+
useRuns(client).listRuns;
|
44702
44695
|
React.useEffect(function () {
|
44703
44696
|
if (!selRecipe)
|
44704
44697
|
return;
|
44705
44698
|
setActiveTabIndex(1);
|
44706
44699
|
}, [selRecipe]);
|
44707
|
-
/*
|
44708
|
-
* If cloud job fetch the job and search the first run
|
44709
|
-
*/
|
44710
|
-
React.useEffect(function () {
|
44711
|
-
if (!currJobId || !selAccount || !selProject || isCloud)
|
44712
|
-
return;
|
44713
|
-
listRuns(selAccount === null || selAccount === void 0 ? void 0 : selAccount.name.toLowerCase(), selProject === null || selProject === void 0 ? void 0 : selProject.name, [currJobId])
|
44714
|
-
.then(function (d) {
|
44715
|
-
setCurrRunId(d.resources[0].id);
|
44716
|
-
setActiveTabIndex(2);
|
44717
|
-
})
|
44718
|
-
.catch(function () {
|
44719
|
-
setCurrRunId(undefined);
|
44720
|
-
setCurrJobId(undefined);
|
44721
|
-
setActiveTabIndex(1);
|
44722
|
-
});
|
44723
|
-
}, [currJobId]);
|
44724
44700
|
var basePath = React.useMemo(function () {
|
44725
44701
|
return client.config.basePath.replace('api', 'app');
|
44726
44702
|
}, [client]);
|
44727
|
-
var
|
44703
|
+
var _onSuccessCloud = function (accountName, projectName, studyId) {
|
44728
44704
|
if (!basePath) {
|
44729
44705
|
throw new Error('CreateStudy: client.configuration.basepath not defined.');
|
44730
44706
|
}
|
44731
|
-
|
44732
|
-
|
44733
|
-
|
44734
|
-
|
44735
|
-
|
44736
|
-
|
44737
|
-
|
44738
|
-
|
44739
|
-
|
44740
|
-
|
44741
|
-
|
44707
|
+
// Custom or default callback
|
44708
|
+
if (onSuccess) {
|
44709
|
+
onSuccess(accountName, projectName, studyId, true);
|
44710
|
+
}
|
44711
|
+
else {
|
44712
|
+
_t.success('Study submitted!', { duration: 4000, position: 'bottom-left', style: { minWidth: '300px', fontSize: '12px' }
|
44713
|
+
});
|
44714
|
+
setTimeout(function () {
|
44715
|
+
window.location.href = "".concat(basePath, "/").concat(accountName, "/projects/").concat(projectName, "/studies/").concat(studyId);
|
44716
|
+
}, 3000);
|
44717
|
+
}
|
44718
|
+
};
|
44719
|
+
var _onSuccessLocal = function (accountName, projectName, studyId) {
|
44720
|
+
if (!basePath) {
|
44721
|
+
throw new Error('CreateStudy: client.configuration.basepath not defined.');
|
44722
|
+
}
|
44723
|
+
// Custom or default callback
|
44724
|
+
// local study ID === run ID
|
44725
|
+
if (onSuccess) {
|
44726
|
+
onSuccess(accountName, projectName, studyId, false);
|
44727
|
+
}
|
44728
|
+
else {
|
44729
|
+
_t.success("Study is running! Do not close the console.\nYou will find output here ".concat(studyId, "."), { duration: 4000, position: 'bottom-left', style: { minWidth: '300px', fontSize: '12px' } });
|
44730
|
+
}
|
44731
|
+
};
|
44742
44732
|
var handleCreateStudy = React.useCallback(function (name, jobArgs, description, localConfig) {
|
44743
44733
|
if (!selRecipe) {
|
44744
44734
|
return Promise.reject();
|
44745
44735
|
}
|
44746
|
-
setCurrRunId(undefined);
|
44747
|
-
setIsCloud(localConfig.isLocalJob);
|
44748
|
-
// Custom cloud action
|
44749
|
-
var handleCloudSuccess = createStudySuccess !== null && createStudySuccess !== void 0 ? createStudySuccess : handleCreateStudySuccess;
|
44750
|
-
var handleSuccess = localConfig && localConfig.isLocalJob ? handleCreateStudySuccessLocal : handleCloudSuccess;
|
44751
44736
|
if (host !== 'web' && localConfig) {
|
44752
44737
|
return createLocalStudy({
|
44753
44738
|
name: name,
|
44754
44739
|
recipe: selRecipe,
|
44755
44740
|
description: description !== null && description !== void 0 ? description : 'Study created from pollination',
|
44756
|
-
}, jobArgs, localConfig,
|
44741
|
+
}, jobArgs, localConfig, localConfig.isLocalJob ? _onSuccessLocal : _onSuccessCloud);
|
44757
44742
|
}
|
44758
44743
|
else {
|
44759
44744
|
return createStudy({
|
44760
44745
|
name: name,
|
44761
44746
|
recipe: selRecipe,
|
44762
44747
|
description: description !== null && description !== void 0 ? description : 'Study created from pollination',
|
44763
|
-
}, jobArgs,
|
44748
|
+
}, jobArgs, _onSuccessCloud);
|
44764
44749
|
}
|
44765
|
-
}, [selRecipe, host, createLocalStudy,
|
44750
|
+
}, [selRecipe, host, createLocalStudy, onSuccess, createStudy]);
|
44766
44751
|
return (React__default["default"].createElement("div", { "data-testid": "CreateProject", style: __assign(__assign({}, defaultStyle), style) },
|
44767
44752
|
React__default["default"].createElement(Tabs, { selectedIndex: activeTabIndex, onSelect: function (index) { return setActiveTabIndex(index); }, forceRenderTabPanel: true },
|
44768
44753
|
React__default["default"].createElement("div", { style: {
|
@@ -44840,12 +44825,9 @@ var GetGeometry = function (_a) {
|
|
44840
44825
|
var sub = Boolean(optionsConfig) && typeof optionsConfig !== 'undefined' &&
|
44841
44826
|
typeof optionsConfig.subscribe !== 'undefined' &&
|
44842
44827
|
typeof optionsConfig.subscribe.selected !== 'undefined' ? optionsConfig.subscribe.selected : false;
|
44843
|
-
|
44844
|
-
typeof optionsConfig.preview !== 'undefined' &&
|
44845
|
-
typeof optionsConfig.preview.selected !== 'undefined' ? optionsConfig.preview.selected : false;
|
44828
|
+
// Do not trigger prev props - for streamlit
|
44846
44829
|
setSelection(sel);
|
44847
44830
|
setSubscribe(sub);
|
44848
|
-
setPreview(prev);
|
44849
44831
|
}, [optionsConfig]);
|
44850
44832
|
React.useEffect(function () {
|
44851
44833
|
if (!geometry || !setParentState)
|