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
@@ -4,16 +4,10 @@ import { APIClient } from '../hooks';
|
|
4
4
|
import { Account } from '../SelectAccount/SelectAccount.types';
|
5
5
|
export declare type CreateStudyProps = {
|
6
6
|
style?: CSSProperties;
|
7
|
-
controlledRecipeInputs?: {
|
8
|
-
[index: string]: {
|
9
|
-
value: string;
|
10
|
-
hidden?: boolean;
|
11
|
-
};
|
12
|
-
};
|
13
7
|
defaultAccount?: Account;
|
14
8
|
defaultProject?: Project;
|
15
9
|
defaultRecipe?: RecipeInterface;
|
16
|
-
|
10
|
+
onSuccess?: (accountName: string, projectName: string, studyId: string, isCloud: boolean) => any;
|
17
11
|
authUser?: UserPrivate;
|
18
12
|
client?: APIClient;
|
19
13
|
};
|
package/build/index.esm.js
CHANGED
@@ -40633,12 +40633,9 @@ var GetModel = function (_a) {
|
|
40633
40633
|
var sub = Boolean(optionsConfig) && typeof optionsConfig !== 'undefined' &&
|
40634
40634
|
typeof optionsConfig.subscribe !== 'undefined' &&
|
40635
40635
|
typeof optionsConfig.subscribe.selected !== 'undefined' ? optionsConfig.subscribe.selected : false;
|
40636
|
-
|
40637
|
-
typeof optionsConfig.preview !== 'undefined' &&
|
40638
|
-
typeof optionsConfig.preview.selected !== 'undefined' ? optionsConfig.preview.selected : false;
|
40636
|
+
// Do not trigger prev props - for streamlit
|
40639
40637
|
setSelection(sel);
|
40640
40638
|
setSubscribe(sub);
|
40641
|
-
setSubscribe(prev);
|
40642
40639
|
}, [optionsConfig]);
|
40643
40640
|
useEffect(function () {
|
40644
40641
|
if (!hbjson)
|
@@ -44659,84 +44656,72 @@ var defaultStyle = {
|
|
44659
44656
|
};
|
44660
44657
|
var CreateStudy = function (_a) {
|
44661
44658
|
var _b;
|
44662
|
-
var style = _a.style, defaultAccount = _a.defaultAccount, defaultProject = _a.defaultProject, defaultRecipe = _a.defaultRecipe,
|
44663
|
-
var
|
44664
|
-
var
|
44665
|
-
var
|
44666
|
-
var
|
44667
|
-
var _g = useState(undefined), currJobId = _g[0], setCurrJobId = _g[1];
|
44668
|
-
var _h = useState(undefined), isCloud = _h[0], setIsCloud = _h[1];
|
44669
|
-
// Single run only...
|
44670
|
-
var _j = useState(undefined); _j[0]; var setCurrRunId = _j[1];
|
44659
|
+
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;
|
44660
|
+
var _d = useState(0), activeTabIndex = _d[0], setActiveTabIndex = _d[1];
|
44661
|
+
var _e = useState(defaultAccount), selAccount = _e[0], setSelAccount = _e[1];
|
44662
|
+
var _f = useState(defaultProject), selProject = _f[0], setSelProject = _f[1];
|
44663
|
+
var _g = useState(defaultRecipe), selRecipe = _g[0], setSelRecipe = _g[1];
|
44671
44664
|
// @ts-ignore
|
44672
44665
|
var projectOwner = selAccount ? ((_b = selAccount.username) !== null && _b !== void 0 ? _b : selAccount.account_name) : undefined;
|
44673
44666
|
var projectSlug = selProject ? selProject.slug.split('/')[1] : undefined;
|
44674
|
-
var
|
44675
|
-
|
44667
|
+
var _h = useCreateStudy(projectOwner, projectSlug, client), host = _h.host, createStudy = _h.createStudy, createLocalStudy = _h.createLocalStudy;
|
44668
|
+
useRuns(client).listRuns;
|
44676
44669
|
useEffect(function () {
|
44677
44670
|
if (!selRecipe)
|
44678
44671
|
return;
|
44679
44672
|
setActiveTabIndex(1);
|
44680
44673
|
}, [selRecipe]);
|
44681
|
-
/*
|
44682
|
-
* If cloud job fetch the job and search the first run
|
44683
|
-
*/
|
44684
|
-
useEffect(function () {
|
44685
|
-
if (!currJobId || !selAccount || !selProject || isCloud)
|
44686
|
-
return;
|
44687
|
-
listRuns(selAccount === null || selAccount === void 0 ? void 0 : selAccount.name.toLowerCase(), selProject === null || selProject === void 0 ? void 0 : selProject.name, [currJobId])
|
44688
|
-
.then(function (d) {
|
44689
|
-
setCurrRunId(d.resources[0].id);
|
44690
|
-
setActiveTabIndex(2);
|
44691
|
-
})
|
44692
|
-
.catch(function () {
|
44693
|
-
setCurrRunId(undefined);
|
44694
|
-
setCurrJobId(undefined);
|
44695
|
-
setActiveTabIndex(1);
|
44696
|
-
});
|
44697
|
-
}, [currJobId]);
|
44698
44674
|
var basePath = useMemo(function () {
|
44699
44675
|
return client.config.basePath.replace('api', 'app');
|
44700
44676
|
}, [client]);
|
44701
|
-
var
|
44677
|
+
var _onSuccessCloud = function (accountName, projectName, studyId) {
|
44702
44678
|
if (!basePath) {
|
44703
44679
|
throw new Error('CreateStudy: client.configuration.basepath not defined.');
|
44704
44680
|
}
|
44705
|
-
|
44706
|
-
|
44707
|
-
|
44708
|
-
|
44709
|
-
|
44710
|
-
|
44711
|
-
|
44712
|
-
|
44713
|
-
|
44714
|
-
|
44715
|
-
|
44681
|
+
// Custom or default callback
|
44682
|
+
if (onSuccess) {
|
44683
|
+
onSuccess(accountName, projectName, studyId, true);
|
44684
|
+
}
|
44685
|
+
else {
|
44686
|
+
_t.success('Study submitted!', { duration: 4000, position: 'bottom-left', style: { minWidth: '300px', fontSize: '12px' }
|
44687
|
+
});
|
44688
|
+
setTimeout(function () {
|
44689
|
+
window.location.href = "".concat(basePath, "/").concat(accountName, "/projects/").concat(projectName, "/studies/").concat(studyId);
|
44690
|
+
}, 3000);
|
44691
|
+
}
|
44692
|
+
};
|
44693
|
+
var _onSuccessLocal = function (accountName, projectName, studyId) {
|
44694
|
+
if (!basePath) {
|
44695
|
+
throw new Error('CreateStudy: client.configuration.basepath not defined.');
|
44696
|
+
}
|
44697
|
+
// Custom or default callback
|
44698
|
+
// local study ID === run ID
|
44699
|
+
if (onSuccess) {
|
44700
|
+
onSuccess(accountName, projectName, studyId, false);
|
44701
|
+
}
|
44702
|
+
else {
|
44703
|
+
_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' } });
|
44704
|
+
}
|
44705
|
+
};
|
44716
44706
|
var handleCreateStudy = useCallback(function (name, jobArgs, description, localConfig) {
|
44717
44707
|
if (!selRecipe) {
|
44718
44708
|
return Promise.reject();
|
44719
44709
|
}
|
44720
|
-
setCurrRunId(undefined);
|
44721
|
-
setIsCloud(localConfig.isLocalJob);
|
44722
|
-
// Custom cloud action
|
44723
|
-
var handleCloudSuccess = createStudySuccess !== null && createStudySuccess !== void 0 ? createStudySuccess : handleCreateStudySuccess;
|
44724
|
-
var handleSuccess = localConfig && localConfig.isLocalJob ? handleCreateStudySuccessLocal : handleCloudSuccess;
|
44725
44710
|
if (host !== 'web' && localConfig) {
|
44726
44711
|
return createLocalStudy({
|
44727
44712
|
name: name,
|
44728
44713
|
recipe: selRecipe,
|
44729
44714
|
description: description !== null && description !== void 0 ? description : 'Study created from pollination',
|
44730
|
-
}, jobArgs, localConfig,
|
44715
|
+
}, jobArgs, localConfig, localConfig.isLocalJob ? _onSuccessLocal : _onSuccessCloud);
|
44731
44716
|
}
|
44732
44717
|
else {
|
44733
44718
|
return createStudy({
|
44734
44719
|
name: name,
|
44735
44720
|
recipe: selRecipe,
|
44736
44721
|
description: description !== null && description !== void 0 ? description : 'Study created from pollination',
|
44737
|
-
}, jobArgs,
|
44722
|
+
}, jobArgs, _onSuccessCloud);
|
44738
44723
|
}
|
44739
|
-
}, [selRecipe, host, createLocalStudy,
|
44724
|
+
}, [selRecipe, host, createLocalStudy, onSuccess, createStudy]);
|
44740
44725
|
return (React__default.createElement("div", { "data-testid": "CreateProject", style: __assign(__assign({}, defaultStyle), style) },
|
44741
44726
|
React__default.createElement(Tabs, { selectedIndex: activeTabIndex, onSelect: function (index) { return setActiveTabIndex(index); }, forceRenderTabPanel: true },
|
44742
44727
|
React__default.createElement("div", { style: {
|
@@ -44814,12 +44799,9 @@ var GetGeometry = function (_a) {
|
|
44814
44799
|
var sub = Boolean(optionsConfig) && typeof optionsConfig !== 'undefined' &&
|
44815
44800
|
typeof optionsConfig.subscribe !== 'undefined' &&
|
44816
44801
|
typeof optionsConfig.subscribe.selected !== 'undefined' ? optionsConfig.subscribe.selected : false;
|
44817
|
-
|
44818
|
-
typeof optionsConfig.preview !== 'undefined' &&
|
44819
|
-
typeof optionsConfig.preview.selected !== 'undefined' ? optionsConfig.preview.selected : false;
|
44802
|
+
// Do not trigger prev props - for streamlit
|
44820
44803
|
setSelection(sel);
|
44821
44804
|
setSubscribe(sub);
|
44822
|
-
setPreview(prev);
|
44823
44805
|
}, [optionsConfig]);
|
44824
44806
|
useEffect(function () {
|
44825
44807
|
if (!geometry || !setParentState)
|