pollination-react-io 1.56.3 → 1.57.1

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.
@@ -1,5 +1,5 @@
1
1
  import { Run, UserPrivate } from '@pollination-solutions/pollination-sdk';
2
- import { CSSProperties } from 'react';
2
+ import { CSSProperties, ReactElement } from 'react';
3
3
  import { APIClient } from '../hooks';
4
4
  export declare enum RunTabs {
5
5
  details = "details",
@@ -20,4 +20,5 @@ export interface RunCardProps {
20
20
  getValue?: (run: Run) => any;
21
21
  canWrite?: boolean;
22
22
  localRun?: boolean;
23
+ loaderNode?: ReactElement<any, any>;
23
24
  }
@@ -4,10 +4,14 @@ import { APIClient } from '../hooks';
4
4
  import { FileCardProps } from './Cards/FileCard';
5
5
  import { FolderCardProps } from './Cards/FolderCard';
6
6
  export interface LocalRun {
7
- meta: any;
8
- status: any;
9
- recipe: any;
10
7
  id: string;
8
+ author: any;
9
+ owner: any;
10
+ recipe: any;
11
+ generation: any;
12
+ status: any;
13
+ meta: any;
14
+ name: string;
11
15
  }
12
16
  export interface RunDetailsProps {
13
17
  projectOwner: string;
@@ -48721,23 +48721,28 @@ var formatDuration = function (duration) {
48721
48721
  };
48722
48722
  var RunCard = function (_a) {
48723
48723
  var _b;
48724
- var _c, _d, _e, _f, _g, _h, _j, _k;
48725
- var projectName = _a.projectName, projectOwner = _a.projectOwner, _run = _a.run, style = _a.style, authUser = _a.authUser, client = _a.client, enableClick = _a.enableClick, getTab = _a.getTab, defaultTab = _a.defaultTab, getValue = _a.getValue, _l = _a.interval, interval = _l === void 0 ? 5000 : _l, _m = _a.canWrite, canWrite = _m === void 0 ? false : _m, _o = _a.localRun, localRun = _o === void 0 ? false : _o;
48726
- var _p = usePollinationPanel(), fetchLocalRun = _p.fetchLocalRun, fetchLocalJob = _p.fetchLocalJob;
48724
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
48725
+ var projectName = _a.projectName, projectOwner = _a.projectOwner, _run = _a.run, style = _a.style, authUser = _a.authUser, client = _a.client, enableClick = _a.enableClick, getTab = _a.getTab, defaultTab = _a.defaultTab, getValue = _a.getValue, _o = _a.interval, interval = _o === void 0 ? 5000 : _o, _p = _a.canWrite, canWrite = _p === void 0 ? false : _p, _q = _a.localRun, localRun = _q === void 0 ? false : _q, _r = _a.loaderNode, loaderNode = _r === void 0 ? undefined : _r;
48726
+ var _s = usePollinationPanel(), fetchLocalRun = _s.fetchLocalRun, fetchLocalJob = _s.fetchLocalJob;
48727
+ var disabled = useMemo(function () {
48728
+ if (!localRun)
48729
+ return;
48730
+ return !checkPollinationPanel();
48731
+ }, []);
48727
48732
  /*
48728
48733
  * Fetch run
48729
48734
  */
48730
48735
  var fetchJob = useJobs(client).fetchJob;
48731
- var _q = useRuns(client), fetchRun = _q.fetchRun, statusMap = _q.statusMap, getDuration = _q.getDuration, cancelRun = _q.cancelRun;
48732
- var _r = useWindowDimensions(), width = _r.width; _r.height;
48733
- var _s = useState(false), seeDescription = _s[0], setSeeDescription = _s[1];
48734
- var _t = useState(false), seeAction = _t[0], setSeeAction = _t[1];
48735
- var _u = useState(false), stopRefresh = _u[0], setStopRefresh = _u[1];
48736
- var _v = useState(false), isReady = _v[0], setIsReady = _v[1];
48736
+ var _t = useRuns(client), fetchRun = _t.fetchRun, statusMap = _t.statusMap, getDuration = _t.getDuration, cancelRun = _t.cancelRun;
48737
+ var _u = useWindowDimensions(), width = _u.width; _u.height;
48738
+ var _v = useState(false), seeDescription = _v[0], setSeeDescription = _v[1];
48739
+ var _w = useState(false), seeAction = _w[0], setSeeAction = _w[1];
48740
+ var _x = useState(false), stopRefresh = _x[0], setStopRefresh = _x[1];
48741
+ var _y = useState(false), isReady = _y[0], setIsReady = _y[1];
48737
48742
  /*
48738
48743
  * From run and stop when it is done
48739
48744
  */
48740
- var _w = useSWR(authUser && _run ? (!localRun ? [projectOwner, projectName, _run.id] : [_run.id]) : undefined, localRun ? fetchLocalRun : fetchRun, {
48745
+ var _z = useSWR(authUser && _run ? (!localRun ? [projectOwner, projectName, _run.id] : [_run.id]) : undefined, localRun ? fetchLocalRun : fetchRun, {
48741
48746
  revalidateOnFocus: false,
48742
48747
  refreshInterval: stopRefresh ? undefined : interval,
48743
48748
  fallbackData: localRun ? undefined : _run,
@@ -48746,13 +48751,13 @@ var RunCard = function (_a) {
48746
48751
  if (localRun) {
48747
48752
  var jobInfo = fetchLocalJob(_run.id);
48748
48753
  setLocalStudy(jobInfo);
48749
- }
48754
+ } // It is written at the end of the simulation
48750
48755
  sendRun(run);
48751
48756
  if (run.status.finished_at)
48752
48757
  setStopRefresh(true);
48753
48758
  setIsReady(true);
48754
48759
  },
48755
- }), run = _w.data, error = _w.error; _w.isValidating;
48760
+ }), run = _z.data, error = _z.error;
48756
48761
  var sendRun = useCallback(function (run) { return getValue(run); }, [run]);
48757
48762
  /**
48758
48763
  * Fetch job just one time
@@ -48776,9 +48781,9 @@ var RunCard = function (_a) {
48776
48781
  return undefined;
48777
48782
  return run.status.status;
48778
48783
  }, [run]);
48779
- var _x = useState(), study = _x[0], setStudy = _x[1];
48780
- var _y = useState(), localStudy = _y[0], setLocalStudy = _y[1];
48781
- var _z = useState(getDuration(run)), duration = _z[0], setDuration = _z[1];
48784
+ var _0 = useState(), study = _0[0], setStudy = _0[1];
48785
+ var _1 = useState(), localStudy = _1[0], setLocalStudy = _1[1];
48786
+ var _2 = useState(getDuration(run)), duration = _2[0], setDuration = _2[1];
48782
48787
  useEffect(function () {
48783
48788
  if (!run)
48784
48789
  return undefined;
@@ -48809,7 +48814,7 @@ var RunCard = function (_a) {
48809
48814
  info: false,
48810
48815
  settings: false,
48811
48816
  };
48812
- var _0 = useState(__assign(__assign({}, initialValues), (_b = {}, _b[defaultTab] = true, _b))), hover = _0[0], setHover = _0[1];
48817
+ var _3 = useState(__assign(__assign({}, initialValues), (_b = {}, _b[defaultTab] = true, _b))), hover = _3[0], setHover = _3[1];
48813
48818
  var toggleHover = useCallback(function (id, value) {
48814
48819
  if (value === void 0) { value = false; }
48815
48820
  setHover(function (prevHover) {
@@ -48824,10 +48829,28 @@ var RunCard = function (_a) {
48824
48829
  var _a;
48825
48830
  setHover(__assign(__assign({}, initialValues), (_a = {}, _a[defaultTab] = true, _a)));
48826
48831
  }, [defaultTab]);
48832
+ /**
48833
+ * Rendering - if error
48834
+ */
48827
48835
  if (error)
48828
- return React__default.createElement(Logo, null);
48836
+ return loaderNode !== null && loaderNode !== void 0 ? loaderNode : React__default.createElement(Logo, null);
48837
+ /**
48838
+ * Rendering - if CAD by web
48839
+ */
48840
+ if (disabled)
48841
+ return React__default.createElement("div", { className: enableClick ? "grid-container ".concat(isReady && !run.status.finished_at && 'blink-effect')
48842
+ : "grid-container disable-click ".concat(isReady && !run.status.finished_at && 'blink-effect'), tabIndex: 0, role: 'button', style: {
48843
+ borderColor: (_d = (_c = statusMap[status]) === null || _c === void 0 ? void 0 : _c.color) !== null && _d !== void 0 ? _d : '#d0d7de',
48844
+ backgroundColor: '#f5f5f5',
48845
+ textAlign: 'center'
48846
+ } },
48847
+ React__default.createElement("div", { className: 'item1' },
48848
+ React__default.createElement("button", { className: 'link', style: { all: 'unset', cursor: 'pointer', marginRight: '0.75rem' } },
48849
+ React__default.createElement(Avatar, { src: '', size: 32, color: hover.account ? '#40a9ff' : undefined })),
48850
+ React__default.createElement("span", { style: { marginRight: '0.75rem' } }, "/"),
48851
+ React__default.createElement("button", { className: 'link', style: { all: 'unset' } }, "Enabled in Pollination CAD plugins")));
48829
48852
  return (React__default.createElement("div", { className: enableClick ? "grid-container ".concat(isReady && !run.status.finished_at && 'blink-effect')
48830
- : "grid-container disable-click ".concat(isReady && !run.status.finished_at && 'blink-effect'), tabIndex: 0, role: 'button', style: __assign({ borderColor: (_d = (_c = statusMap[status]) === null || _c === void 0 ? void 0 : _c.color) !== null && _d !== void 0 ? _d : '#d0d7de' }, style), onClick: function () {
48853
+ : "grid-container disable-click ".concat(isReady && !run.status.finished_at && 'blink-effect'), tabIndex: 0, role: 'button', style: __assign({ borderColor: (_f = (_e = statusMap[status]) === null || _e === void 0 ? void 0 : _e.color) !== null && _f !== void 0 ? _f : '#d0d7de' }, style), onClick: function () {
48831
48854
  if (!enableClick)
48832
48855
  return;
48833
48856
  if (!localRun) {
@@ -48843,7 +48866,7 @@ var RunCard = function (_a) {
48843
48866
  window.location.href = "/".concat(run.owner.name);
48844
48867
  }
48845
48868
  } },
48846
- React__default.createElement(Avatar, { src: run ? (_e = run.owner) === null || _e === void 0 ? void 0 : _e.picture_url : '', size: 32, color: hover.account ? '#40a9ff' : undefined })),
48869
+ React__default.createElement(Avatar, { src: run ? (_g = run.owner) === null || _g === void 0 ? void 0 : _g.picture_url : '', size: 32, color: hover.account ? '#40a9ff' : undefined })),
48847
48870
  React__default.createElement("span", { style: { marginRight: '0.75rem' } }, "/"),
48848
48871
  React__default.createElement("button", { className: 'link', title: 'Go to project page', onMouseOver: function (e) { return toggleHover('project', true); }, onMouseLeave: function (e) { return toggleHover('project', false); }, onClick: function (e) {
48849
48872
  e.stopPropagation();
@@ -48925,9 +48948,8 @@ var RunCard = function (_a) {
48925
48948
  window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/studies/").concat(study.id);
48926
48949
  }
48927
48950
  }, style: { all: 'unset', cursor: 'pointer', color: "".concat(hover.study
48928
- ? '#40a9ff' : '#000') } },
48929
- !localRun && study ? (_f = study.spec.name) !== null && _f !== void 0 ? _f : "Study: ".concat(study.id) : '',
48930
- localRun && localStudy && localStudy.name),
48951
+ ? '#40a9ff' : '#000') } }, localRun ? (localStudy ? localStudy.name : _run['studyName'] // Get name from _run
48952
+ ) : (study ? (_h = study.spec.name) !== null && _h !== void 0 ? _h : "Study: ".concat(study.id) : '--')),
48931
48953
  React__default.createElement("button", { style: { all: 'unset', margin: '0 0 0 8px', cursor: 'pointer' }, onMouseOver: function (e) { return toggleHover('info', true); }, onMouseLeave: function (e) { return toggleHover('info', false); }, onClick: function (e) {
48932
48954
  e.stopPropagation();
48933
48955
  setSeeDescription(function (prev) { return !prev; });
@@ -48937,7 +48959,7 @@ var RunCard = function (_a) {
48937
48959
  React__default.createElement("div", { className: 'item4', title: run && dayjs_min(run.status.started_at).format('[on] MMM DD YYYY [at] hh:mm') }, run ? dayjs_min(run.status.started_at).format('[on] MMM DD YYYY') : '--'),
48938
48960
  React__default.createElement("div", { className: 'item5' },
48939
48961
  React__default.createElement("span", { style: { marginRight: '0.75rem' } },
48940
- React__default.createElement(Avatar, { color: hover.author ? '#40a9ff' : undefined, src: run ? (_g = run.author) === null || _g === void 0 ? void 0 : _g.picture_url : '', size: 24 })),
48962
+ React__default.createElement(Avatar, { color: hover.author ? '#40a9ff' : undefined, src: run ? (_j = run.author) === null || _j === void 0 ? void 0 : _j.picture_url : '', size: 24 })),
48941
48963
  React__default.createElement("a", { className: 'link', onClick: function (e) {
48942
48964
  e.stopPropagation();
48943
48965
  if (!localRun) {
@@ -48945,7 +48967,7 @@ var RunCard = function (_a) {
48945
48967
  return;
48946
48968
  window.location.href = "/".concat(run.author.name);
48947
48969
  }
48948
- }, title: 'Go to author page', target: '_blank', rel: 'noreferrer', onMouseOver: function (e) { return toggleHover('author', true); }, onMouseLeave: function (e) { return toggleHover('author', false); }, style: hover.author ? { color: '#40a9ff' } : {} }, run ? ((_j = (_h = run.author) === null || _h === void 0 ? void 0 : _h.display_name) !== null && _j !== void 0 ? _j : (_k = run.author) === null || _k === void 0 ? void 0 : _k.name) : '--')),
48970
+ }, title: 'Go to author page', target: '_blank', rel: 'noreferrer', onMouseOver: function (e) { return toggleHover('author', true); }, onMouseLeave: function (e) { return toggleHover('author', false); }, style: hover.author ? { color: '#40a9ff' } : {} }, run ? ((_l = (_k = run.author) === null || _k === void 0 ? void 0 : _k.display_name) !== null && _l !== void 0 ? _l : (_m = run.author) === null || _m === void 0 ? void 0 : _m.name) : '--')),
48949
48971
  React__default.createElement("div", { className: 'item6' },
48950
48972
  React__default.createElement("span", { style: { marginRight: '0.75rem' } },
48951
48973
  React__default.createElement(Avatar, { color: hover.recipe ? '#40a9ff' : undefined, src: run ? run.recipe.metadata.icon : '', size: 24 })),
@@ -48964,7 +48986,7 @@ var RunCard = function (_a) {
48964
48986
  React__default.createElement("span", { className: 'status-label', style: { marginRight: '0.75rem' } }, run ? status : '--'),
48965
48987
  React__default.createElement("span", { className: 'light-text' },
48966
48988
  !isReady && React__default.createElement(LoadingOutlined$1, null),
48967
- study && run && width > 600 &&
48989
+ run && width > 600 &&
48968
48990
  "".concat(run.meta.progress.completed, " / ").concat(run.meta.progress.total, " steps"))),
48969
48991
  React__default.createElement("div", { className: 'item9', title: 'CPU usage' },
48970
48992
  React__default.createElement(Cpu$1, { size: 18, style: { marginRight: '0.15rem' } }),
@@ -49554,20 +49576,18 @@ var RunDetails = function (_a) {
49554
49576
  var _b = useState([]), extraInputs = _b[0], setExtraInputs = _b[1];
49555
49577
  var _c = useState([]), recipeInputs = _c[0], setRecipeInputs = _c[1];
49556
49578
  var _d = useState([]), outputs = _d[0], setOutputs = _d[1];
49557
- var _e = useState(), currRun = _e[0], setCurrRun = _e[1];
49558
- useEffect(function () { return setCurrRun(run); }, [run]);
49559
49579
  useEffect(function () {
49560
- if (!currRun)
49580
+ if (!run)
49561
49581
  return;
49562
49582
  var recipeInputNames = [];
49563
- if (currRun.recipe && currRun.recipe.inputs) {
49564
- recipeInputNames = currRun.recipe.inputs.map(function (i) { return i.name; });
49583
+ if (run.recipe && run.recipe.inputs) {
49584
+ recipeInputNames = run.recipe.inputs.map(function (i) { return i.name; });
49565
49585
  }
49566
49586
  var outputs = [];
49567
49587
  var recipeInputs = [];
49568
49588
  var extraInputs = [];
49569
49589
  if (run.status) {
49570
- currRun.status.inputs.forEach(function (i) {
49590
+ run.status.inputs.forEach(function (i) {
49571
49591
  if (recipeInputNames.includes(i.name)) {
49572
49592
  recipeInputs.push(i);
49573
49593
  }
@@ -49575,12 +49595,12 @@ var RunDetails = function (_a) {
49575
49595
  extraInputs.push(i);
49576
49596
  }
49577
49597
  });
49578
- currRun.status.outputs.map(function (o) { return outputs.push(o); });
49598
+ run.status.outputs.map(function (o) { return outputs.push(o); });
49579
49599
  }
49580
49600
  setExtraInputs(extraInputs);
49581
49601
  setRecipeInputs(recipeInputs);
49582
49602
  setOutputs(outputs);
49583
- }, [currRun]);
49603
+ }, [run]);
49584
49604
  return (React__default.createElement("div", null,
49585
49605
  outputs &&
49586
49606
  React__default.createElement(RunContent, { title: 'Outputs', inputData: outputs, projectName: projectName, projectOwner: projectOwner, studyId: run.status.job_id, runId: run.id || runId, client: client, style: style, getFileCard: getFileCard, getFolderCard: getFolderCard }),