pollination-react-io 1.53.6 → 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 +36 -48
- package/build/index.esm.js.map +1 -1
- package/build/index.js +36 -48
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
@@ -44682,84 +44682,72 @@ var defaultStyle = {
|
|
44682
44682
|
};
|
44683
44683
|
var CreateStudy = function (_a) {
|
44684
44684
|
var _b;
|
44685
|
-
var style = _a.style, defaultAccount = _a.defaultAccount, defaultProject = _a.defaultProject, defaultRecipe = _a.defaultRecipe,
|
44686
|
-
var
|
44687
|
-
var
|
44688
|
-
var
|
44689
|
-
var
|
44690
|
-
var _g = React.useState(undefined), currJobId = _g[0], setCurrJobId = _g[1];
|
44691
|
-
var _h = React.useState(undefined), isCloud = _h[0], setIsCloud = _h[1];
|
44692
|
-
// Single run only...
|
44693
|
-
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];
|
44694
44690
|
// @ts-ignore
|
44695
44691
|
var projectOwner = selAccount ? ((_b = selAccount.username) !== null && _b !== void 0 ? _b : selAccount.account_name) : undefined;
|
44696
44692
|
var projectSlug = selProject ? selProject.slug.split('/')[1] : undefined;
|
44697
|
-
var
|
44698
|
-
|
44693
|
+
var _h = useCreateStudy(projectOwner, projectSlug, client), host = _h.host, createStudy = _h.createStudy, createLocalStudy = _h.createLocalStudy;
|
44694
|
+
useRuns(client).listRuns;
|
44699
44695
|
React.useEffect(function () {
|
44700
44696
|
if (!selRecipe)
|
44701
44697
|
return;
|
44702
44698
|
setActiveTabIndex(1);
|
44703
44699
|
}, [selRecipe]);
|
44704
|
-
/*
|
44705
|
-
* If cloud job fetch the job and search the first run
|
44706
|
-
*/
|
44707
|
-
React.useEffect(function () {
|
44708
|
-
if (!currJobId || !selAccount || !selProject || isCloud)
|
44709
|
-
return;
|
44710
|
-
listRuns(selAccount === null || selAccount === void 0 ? void 0 : selAccount.name.toLowerCase(), selProject === null || selProject === void 0 ? void 0 : selProject.name, [currJobId])
|
44711
|
-
.then(function (d) {
|
44712
|
-
setCurrRunId(d.resources[0].id);
|
44713
|
-
setActiveTabIndex(2);
|
44714
|
-
})
|
44715
|
-
.catch(function () {
|
44716
|
-
setCurrRunId(undefined);
|
44717
|
-
setCurrJobId(undefined);
|
44718
|
-
setActiveTabIndex(1);
|
44719
|
-
});
|
44720
|
-
}, [currJobId]);
|
44721
44700
|
var basePath = React.useMemo(function () {
|
44722
44701
|
return client.config.basePath.replace('api', 'app');
|
44723
44702
|
}, [client]);
|
44724
|
-
var
|
44703
|
+
var _onSuccessCloud = function (accountName, projectName, studyId) {
|
44725
44704
|
if (!basePath) {
|
44726
44705
|
throw new Error('CreateStudy: client.configuration.basepath not defined.');
|
44727
44706
|
}
|
44728
|
-
|
44729
|
-
|
44730
|
-
|
44731
|
-
|
44732
|
-
|
44733
|
-
|
44734
|
-
|
44735
|
-
|
44736
|
-
|
44737
|
-
|
44738
|
-
|
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
|
+
};
|
44739
44732
|
var handleCreateStudy = React.useCallback(function (name, jobArgs, description, localConfig) {
|
44740
44733
|
if (!selRecipe) {
|
44741
44734
|
return Promise.reject();
|
44742
44735
|
}
|
44743
|
-
setCurrRunId(undefined);
|
44744
|
-
setIsCloud(localConfig.isLocalJob);
|
44745
|
-
// Custom cloud action
|
44746
|
-
var handleCloudSuccess = createStudySuccess !== null && createStudySuccess !== void 0 ? createStudySuccess : handleCreateStudySuccess;
|
44747
|
-
var handleSuccess = localConfig && localConfig.isLocalJob ? handleCreateStudySuccessLocal : handleCloudSuccess;
|
44748
44736
|
if (host !== 'web' && localConfig) {
|
44749
44737
|
return createLocalStudy({
|
44750
44738
|
name: name,
|
44751
44739
|
recipe: selRecipe,
|
44752
44740
|
description: description !== null && description !== void 0 ? description : 'Study created from pollination',
|
44753
|
-
}, jobArgs, localConfig,
|
44741
|
+
}, jobArgs, localConfig, localConfig.isLocalJob ? _onSuccessLocal : _onSuccessCloud);
|
44754
44742
|
}
|
44755
44743
|
else {
|
44756
44744
|
return createStudy({
|
44757
44745
|
name: name,
|
44758
44746
|
recipe: selRecipe,
|
44759
44747
|
description: description !== null && description !== void 0 ? description : 'Study created from pollination',
|
44760
|
-
}, jobArgs,
|
44748
|
+
}, jobArgs, _onSuccessCloud);
|
44761
44749
|
}
|
44762
|
-
}, [selRecipe, host, createLocalStudy,
|
44750
|
+
}, [selRecipe, host, createLocalStudy, onSuccess, createStudy]);
|
44763
44751
|
return (React__default["default"].createElement("div", { "data-testid": "CreateProject", style: __assign(__assign({}, defaultStyle), style) },
|
44764
44752
|
React__default["default"].createElement(Tabs, { selectedIndex: activeTabIndex, onSelect: function (index) { return setActiveTabIndex(index); }, forceRenderTabPanel: true },
|
44765
44753
|
React__default["default"].createElement("div", { style: {
|