pollination-react-io 1.53.6 → 1.53.8

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.
@@ -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
- createStudySuccess?: (accountName: string, projectName: string, studyId: string) => void;
10
+ onSuccess?: (accountName: string, projectName: string, studyId: string, isCloud: boolean) => any;
17
11
  authUser?: UserPrivate;
18
12
  client?: APIClient;
19
13
  };
@@ -44656,84 +44656,72 @@ var defaultStyle = {
44656
44656
  };
44657
44657
  var CreateStudy = function (_a) {
44658
44658
  var _b;
44659
- var style = _a.style, defaultAccount = _a.defaultAccount, defaultProject = _a.defaultProject, defaultRecipe = _a.defaultRecipe, createStudySuccess = _a.createStudySuccess, authUser = _a.authUser, client = _a.client;
44660
- var _c = useState(0), activeTabIndex = _c[0], setActiveTabIndex = _c[1];
44661
- var _d = useState(defaultAccount), selAccount = _d[0], setSelAccount = _d[1];
44662
- var _e = useState(defaultProject), selProject = _e[0], setSelProject = _e[1];
44663
- var _f = useState(defaultRecipe), selRecipe = _f[0], setSelRecipe = _f[1];
44664
- var _g = useState(undefined), currJobId = _g[0], setCurrJobId = _g[1];
44665
- var _h = useState(undefined), isCloud = _h[0], setIsCloud = _h[1];
44666
- // Single run only...
44667
- 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];
44668
44664
  // @ts-ignore
44669
44665
  var projectOwner = selAccount ? ((_b = selAccount.username) !== null && _b !== void 0 ? _b : selAccount.account_name) : undefined;
44670
44666
  var projectSlug = selProject ? selProject.slug.split('/')[1] : undefined;
44671
- var _k = useCreateStudy(projectOwner, projectSlug, client), host = _k.host, createStudy = _k.createStudy, createLocalStudy = _k.createLocalStudy;
44672
- var listRuns = useRuns(client).listRuns;
44667
+ var _h = useCreateStudy(projectOwner, projectSlug, client), host = _h.host, createStudy = _h.createStudy, createLocalStudy = _h.createLocalStudy;
44668
+ useRuns(client).listRuns;
44673
44669
  useEffect(function () {
44674
44670
  if (!selRecipe)
44675
44671
  return;
44676
44672
  setActiveTabIndex(1);
44677
44673
  }, [selRecipe]);
44678
- /*
44679
- * If cloud job fetch the job and search the first run
44680
- */
44681
- useEffect(function () {
44682
- if (!currJobId || !selAccount || !selProject || isCloud)
44683
- return;
44684
- listRuns(selAccount === null || selAccount === void 0 ? void 0 : selAccount.name.toLowerCase(), selProject === null || selProject === void 0 ? void 0 : selProject.name, [currJobId])
44685
- .then(function (d) {
44686
- setCurrRunId(d.resources[0].id);
44687
- setActiveTabIndex(2);
44688
- })
44689
- .catch(function () {
44690
- setCurrRunId(undefined);
44691
- setCurrJobId(undefined);
44692
- setActiveTabIndex(1);
44693
- });
44694
- }, [currJobId]);
44695
44674
  var basePath = useMemo(function () {
44696
44675
  return client.config.basePath.replace('api', 'app');
44697
44676
  }, [client]);
44698
- var handleCreateStudySuccess = useCallback(function (accountName, projectName, studyId) {
44677
+ var _onSuccessCloud = function (accountName, projectName, studyId) {
44699
44678
  if (!basePath) {
44700
44679
  throw new Error('CreateStudy: client.configuration.basepath not defined.');
44701
44680
  }
44702
- setCurrJobId(studyId);
44703
- // If success fetch the job and get the studyId
44704
- window.location.href = "".concat(basePath, "/").concat(accountName, "/projects/").concat(projectName, "/studies/").concat(studyId);
44705
- }, []);
44706
- var handleCreateStudySuccessLocal = useCallback(function (accountName, projectName, studyId) {
44707
- _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' } });
44708
- // Local studyId == path
44709
- setCurrJobId(studyId);
44710
- setCurrRunId(studyId);
44711
- setActiveTabIndex(2);
44712
- }, []);
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
+ };
44713
44706
  var handleCreateStudy = useCallback(function (name, jobArgs, description, localConfig) {
44714
44707
  if (!selRecipe) {
44715
44708
  return Promise.reject();
44716
44709
  }
44717
- setCurrRunId(undefined);
44718
- setIsCloud(localConfig.isLocalJob);
44719
- // Custom cloud action
44720
- var handleCloudSuccess = createStudySuccess !== null && createStudySuccess !== void 0 ? createStudySuccess : handleCreateStudySuccess;
44721
- var handleSuccess = localConfig && localConfig.isLocalJob ? handleCreateStudySuccessLocal : handleCloudSuccess;
44722
44710
  if (host !== 'web' && localConfig) {
44723
44711
  return createLocalStudy({
44724
44712
  name: name,
44725
44713
  recipe: selRecipe,
44726
44714
  description: description !== null && description !== void 0 ? description : 'Study created from pollination',
44727
- }, jobArgs, localConfig, handleSuccess);
44715
+ }, jobArgs, localConfig, localConfig.isLocalJob ? _onSuccessLocal : _onSuccessCloud);
44728
44716
  }
44729
44717
  else {
44730
44718
  return createStudy({
44731
44719
  name: name,
44732
44720
  recipe: selRecipe,
44733
44721
  description: description !== null && description !== void 0 ? description : 'Study created from pollination',
44734
- }, jobArgs, handleCloudSuccess);
44722
+ }, jobArgs, _onSuccessCloud);
44735
44723
  }
44736
- }, [selRecipe, host, createLocalStudy, handleCreateStudySuccess, createStudySuccess, createStudy]);
44724
+ }, [selRecipe, host, createLocalStudy, onSuccess, createStudy]);
44737
44725
  return (React__default.createElement("div", { "data-testid": "CreateProject", style: __assign(__assign({}, defaultStyle), style) },
44738
44726
  React__default.createElement(Tabs, { selectedIndex: activeTabIndex, onSelect: function (index) { return setActiveTabIndex(index); }, forceRenderTabPanel: true },
44739
44727
  React__default.createElement("div", { style: {
@@ -48503,7 +48491,7 @@ var StudyCard = function (_a) {
48503
48491
  if (!enableClick)
48504
48492
  return;
48505
48493
  if (study && total > 1) {
48506
- window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/studies/").concat(study.id, "?tab=details");
48494
+ window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/studies/").concat(study.id, "?tab=details&limit=5&status=null&page=1");
48507
48495
  }
48508
48496
  else if (study && run) {
48509
48497
  window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/studies/").concat(study.id, "/runs/").concat(run.id, "?tab=details");