pollination-react-io 1.56.3 → 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.
- package/build/Cards/RunCard.types.d.ts +2 -1
- package/build/index.esm.js +47 -25
- package/build/index.esm.js.map +1 -1
- package/build/index.js +47 -25
- package/build/index.js.map +1 -1
- package/package.json +1 -1
@@ -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
|
}
|
package/build/index.esm.js
CHANGED
@@ -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,
|
48726
|
-
var
|
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
|
48732
|
-
var
|
48733
|
-
var
|
48734
|
-
var
|
48735
|
-
var
|
48736
|
-
var
|
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
|
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 =
|
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
|
48780
|
-
var
|
48781
|
-
var
|
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
|
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: (
|
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 ? (
|
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
|
-
|
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 ? (
|
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 ? ((
|
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
|
-
|
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' } }),
|