pollination-react-io 1.56.2 → 1.57.0

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
  }
@@ -38030,7 +38030,8 @@ var usePollinationPanel = function () {
38030
38030
  return job;
38031
38031
  }
38032
38032
  catch (error) {
38033
- throw error;
38033
+ // Do nothing. It is written at the end
38034
+ return undefined;
38034
38035
  }
38035
38036
  }, [panel]);
38036
38037
  return {
@@ -48720,23 +48721,28 @@ var formatDuration = function (duration) {
48720
48721
  };
48721
48722
  var RunCard = function (_a) {
48722
48723
  var _b;
48723
- var _c, _d, _e, _f, _g, _h, _j, _k;
48724
- 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;
48725
- 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
+ }, []);
48726
48732
  /*
48727
48733
  * Fetch run
48728
48734
  */
48729
48735
  var fetchJob = useJobs(client).fetchJob;
48730
- var _q = useRuns(client), fetchRun = _q.fetchRun, statusMap = _q.statusMap, getDuration = _q.getDuration, cancelRun = _q.cancelRun;
48731
- var _r = useWindowDimensions(), width = _r.width; _r.height;
48732
- var _s = useState(false), seeDescription = _s[0], setSeeDescription = _s[1];
48733
- var _t = useState(false), seeAction = _t[0], setSeeAction = _t[1];
48734
- var _u = useState(false), stopRefresh = _u[0], setStopRefresh = _u[1];
48735
- 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];
48736
48742
  /*
48737
48743
  * From run and stop when it is done
48738
48744
  */
48739
- 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, {
48740
48746
  revalidateOnFocus: false,
48741
48747
  refreshInterval: stopRefresh ? undefined : interval,
48742
48748
  fallbackData: localRun ? undefined : _run,
@@ -48745,13 +48751,13 @@ var RunCard = function (_a) {
48745
48751
  if (localRun) {
48746
48752
  var jobInfo = fetchLocalJob(_run.id);
48747
48753
  setLocalStudy(jobInfo);
48748
- }
48754
+ } // It is written at the end of the simulation
48749
48755
  sendRun(run);
48750
48756
  if (run.status.finished_at)
48751
48757
  setStopRefresh(true);
48752
48758
  setIsReady(true);
48753
48759
  },
48754
- }), run = _w.data, error = _w.error; _w.isValidating;
48760
+ }), run = _z.data, error = _z.error;
48755
48761
  var sendRun = useCallback(function (run) { return getValue(run); }, [run]);
48756
48762
  /**
48757
48763
  * Fetch job just one time
@@ -48775,9 +48781,9 @@ var RunCard = function (_a) {
48775
48781
  return undefined;
48776
48782
  return run.status.status;
48777
48783
  }, [run]);
48778
- var _x = useState(), study = _x[0], setStudy = _x[1];
48779
- var _y = useState(), localStudy = _y[0], setLocalStudy = _y[1];
48780
- 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];
48781
48787
  useEffect(function () {
48782
48788
  if (!run)
48783
48789
  return undefined;
@@ -48808,7 +48814,7 @@ var RunCard = function (_a) {
48808
48814
  info: false,
48809
48815
  settings: false,
48810
48816
  };
48811
- 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];
48812
48818
  var toggleHover = useCallback(function (id, value) {
48813
48819
  if (value === void 0) { value = false; }
48814
48820
  setHover(function (prevHover) {
@@ -48823,10 +48829,28 @@ var RunCard = function (_a) {
48823
48829
  var _a;
48824
48830
  setHover(__assign(__assign({}, initialValues), (_a = {}, _a[defaultTab] = true, _a)));
48825
48831
  }, [defaultTab]);
48832
+ /**
48833
+ * Rendering - if error
48834
+ */
48826
48835
  if (error)
48827
- 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")));
48828
48852
  return (React__default.createElement("div", { className: enableClick ? "grid-container ".concat(isReady && !run.status.finished_at && 'blink-effect')
48829
- : "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 () {
48830
48854
  if (!enableClick)
48831
48855
  return;
48832
48856
  if (!localRun) {
@@ -48842,7 +48866,7 @@ var RunCard = function (_a) {
48842
48866
  window.location.href = "/".concat(run.owner.name);
48843
48867
  }
48844
48868
  } },
48845
- 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 })),
48846
48870
  React__default.createElement("span", { style: { marginRight: '0.75rem' } }, "/"),
48847
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) {
48848
48872
  e.stopPropagation();
@@ -48924,9 +48948,8 @@ var RunCard = function (_a) {
48924
48948
  window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/studies/").concat(study.id);
48925
48949
  }
48926
48950
  }, style: { all: 'unset', cursor: 'pointer', color: "".concat(hover.study
48927
- ? '#40a9ff' : '#000') } },
48928
- !localRun && study ? (_f = study.spec.name) !== null && _f !== void 0 ? _f : "Study: ".concat(study.id) : '',
48929
- 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) : '--')),
48930
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) {
48931
48954
  e.stopPropagation();
48932
48955
  setSeeDescription(function (prev) { return !prev; });
@@ -48936,7 +48959,7 @@ var RunCard = function (_a) {
48936
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') : '--'),
48937
48960
  React__default.createElement("div", { className: 'item5' },
48938
48961
  React__default.createElement("span", { style: { marginRight: '0.75rem' } },
48939
- 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 })),
48940
48963
  React__default.createElement("a", { className: 'link', onClick: function (e) {
48941
48964
  e.stopPropagation();
48942
48965
  if (!localRun) {
@@ -48944,7 +48967,7 @@ var RunCard = function (_a) {
48944
48967
  return;
48945
48968
  window.location.href = "/".concat(run.author.name);
48946
48969
  }
48947
- }, 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) : '--')),
48948
48971
  React__default.createElement("div", { className: 'item6' },
48949
48972
  React__default.createElement("span", { style: { marginRight: '0.75rem' } },
48950
48973
  React__default.createElement(Avatar, { color: hover.recipe ? '#40a9ff' : undefined, src: run ? run.recipe.metadata.icon : '', size: 24 })),
@@ -48963,7 +48986,7 @@ var RunCard = function (_a) {
48963
48986
  React__default.createElement("span", { className: 'status-label', style: { marginRight: '0.75rem' } }, run ? status : '--'),
48964
48987
  React__default.createElement("span", { className: 'light-text' },
48965
48988
  !isReady && React__default.createElement(LoadingOutlined$1, null),
48966
- study && run && width > 600 &&
48989
+ run && width > 600 &&
48967
48990
  "".concat(run.meta.progress.completed, " / ").concat(run.meta.progress.total, " steps"))),
48968
48991
  React__default.createElement("div", { className: 'item9', title: 'CPU usage' },
48969
48992
  React__default.createElement(Cpu$1, { size: 18, style: { marginRight: '0.15rem' } }),