pollination-react-io 1.62.6 → 1.63.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.
package/build/index.js CHANGED
@@ -38146,6 +38146,25 @@ var usePollinationPanel = function () {
38146
38146
  return undefined;
38147
38147
  }
38148
38148
  };
38149
+ /**
38150
+ * Delete job with the same input/ouput folder from DB
38151
+ * @param projectSlug Project slug
38152
+ * @param path Location where files are
38153
+ * @returns Message with number of deleted records
38154
+ */
38155
+ var deleteJob = function (projectSlug, path) {
38156
+ if (!panel)
38157
+ return;
38158
+ try {
38159
+ var message = panel.DeleteJob(projectSlug, path);
38160
+ var count = JSON.parse(message.data);
38161
+ return count;
38162
+ }
38163
+ catch (error) {
38164
+ // Do nothing. It is written at the end
38165
+ return undefined;
38166
+ }
38167
+ };
38149
38168
  return {
38150
38169
  getFileBase64: getFileBase64,
38151
38170
  saveFileBase64: saveFileBase64,
@@ -38156,7 +38175,8 @@ var usePollinationPanel = function () {
38156
38175
  fetchLocalLog: fetchLocalLog,
38157
38176
  fileExplorer: fileExplorer,
38158
38177
  getPaginatedJob: getPaginatedJob,
38159
- getJob: getJob
38178
+ getJob: getJob,
38179
+ deleteJob: deleteJob
38160
38180
  };
38161
38181
  };
38162
38182
 
@@ -48838,8 +48858,8 @@ var formatDuration = function (duration) {
48838
48858
  var RunCard = function (_a) {
48839
48859
  var _b;
48840
48860
  var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
48841
- 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;
48842
- var _s = usePollinationPanel(), fetchLocalRun = _s.fetchLocalRun, fetchLocalJob = _s.fetchLocalJob, fileExplorer = _s.fileExplorer;
48861
+ var projectName = _a.projectName, projectOwner = _a.projectOwner, _run = _a.run, authUser = _a.authUser, client = _a.client, _o = _a.enableClick, enableClick = _o === void 0 ? true : _o, _p = _a.style, style = _p === void 0 ? {} : _p, _q = _a.getTab, getTab = _q === void 0 ? function (tab) { return undefined; } : _q, _r = _a.defaultTab, defaultTab = _r === void 0 ? RunTabs.details : _r, _s = _a.getValue, getValue = _s === void 0 ? function (run) { return undefined; } : _s, _t = _a.interval, interval = _t === void 0 ? 5000 : _t, _u = _a.canWrite, canWrite = _u === void 0 ? false : _u, _v = _a.localRun, localRun = _v === void 0 ? false : _v, _w = _a.loaderNode, loaderNode = _w === void 0 ? undefined : _w;
48862
+ var _x = usePollinationPanel(), fetchLocalRun = _x.fetchLocalRun, fetchLocalJob = _x.fetchLocalJob, fileExplorer = _x.fileExplorer, deleteJob = _x.deleteJob;
48843
48863
  var disabled = React.useMemo(function () {
48844
48864
  if (!localRun)
48845
48865
  return;
@@ -48849,16 +48869,16 @@ var RunCard = function (_a) {
48849
48869
  * Fetch run
48850
48870
  */
48851
48871
  var fetchJob = useJobs(client).fetchJob;
48852
- var _t = useRuns(client), fetchRun = _t.fetchRun, statusMap = _t.statusMap, getDuration = _t.getDuration, cancelRun = _t.cancelRun;
48853
- var _u = useWindowDimensions(), width = _u.width; _u.height;
48854
- var _v = React.useState(false), seeDescription = _v[0], setSeeDescription = _v[1];
48855
- var _w = React.useState(false), seeAction = _w[0], setSeeAction = _w[1];
48856
- var _x = React.useState(false), stopRefresh = _x[0], setStopRefresh = _x[1];
48857
- var _y = React.useState(false), isReady = _y[0], setIsReady = _y[1];
48872
+ var _y = useRuns(client), fetchRun = _y.fetchRun, statusMap = _y.statusMap, getDuration = _y.getDuration, cancelRun = _y.cancelRun;
48873
+ var _z = useWindowDimensions(), width = _z.width; _z.height;
48874
+ var _0 = React.useState(false), seeDescription = _0[0], setSeeDescription = _0[1];
48875
+ var _1 = React.useState(false), seeAction = _1[0], setSeeAction = _1[1];
48876
+ var _2 = React.useState(false), stopRefresh = _2[0], setStopRefresh = _2[1];
48877
+ var _3 = React.useState(false), isReady = _3[0], setIsReady = _3[1];
48858
48878
  /*
48859
48879
  * From run and stop when it is done
48860
48880
  */
48861
- var _z = useSWR(authUser && _run ? (!localRun ? [projectOwner, projectName, _run.id] : [_run.id]) : undefined, localRun ? fetchLocalRun : fetchRun, {
48881
+ var _4 = useSWR(authUser && _run ? (!localRun ? [projectOwner, projectName, _run.id] : [_run.id]) : undefined, localRun ? fetchLocalRun : fetchRun, {
48862
48882
  revalidateOnFocus: false,
48863
48883
  refreshInterval: stopRefresh ? undefined : interval,
48864
48884
  fallbackData: localRun ? undefined : _run,
@@ -48873,7 +48893,7 @@ var RunCard = function (_a) {
48873
48893
  setStopRefresh(true);
48874
48894
  setIsReady(true);
48875
48895
  },
48876
- }), run = _z.data, error = _z.error;
48896
+ }), run = _4.data, error = _4.error;
48877
48897
  var sendRun = React.useCallback(function (run) { return getValue(run); }, [run]);
48878
48898
  /**
48879
48899
  * Fetch job just one time
@@ -48897,9 +48917,9 @@ var RunCard = function (_a) {
48897
48917
  return undefined;
48898
48918
  return run.status.status;
48899
48919
  }, [run]);
48900
- var _0 = React.useState(), study = _0[0], setStudy = _0[1];
48901
- var _1 = React.useState(), localStudy = _1[0], setLocalStudy = _1[1];
48902
- var _2 = React.useState(getDuration(run)), duration = _2[0], setDuration = _2[1];
48920
+ var _5 = React.useState(), study = _5[0], setStudy = _5[1];
48921
+ var _6 = React.useState(), localStudy = _6[0], setLocalStudy = _6[1];
48922
+ var _7 = React.useState(getDuration(run)), duration = _7[0], setDuration = _7[1];
48903
48923
  React.useEffect(function () {
48904
48924
  if (!run)
48905
48925
  return undefined;
@@ -48930,7 +48950,7 @@ var RunCard = function (_a) {
48930
48950
  info: false,
48931
48951
  settings: false,
48932
48952
  };
48933
- var _3 = React.useState(__assign(__assign({}, initialValues), (_b = {}, _b[defaultTab] = true, _b))), hover = _3[0], setHover = _3[1];
48953
+ var _8 = React.useState(__assign(__assign({}, initialValues), (_b = {}, _b[defaultTab] = true, _b))), hover = _8[0], setHover = _8[1];
48934
48954
  var toggleHover = React.useCallback(function (id, value) {
48935
48955
  if (value === void 0) { value = false; }
48936
48956
  setHover(function (prevHover) {
@@ -49141,21 +49161,35 @@ var RunCard = function (_a) {
49141
49161
  localRun && localStudy && localStudy.description)),
49142
49162
  seeAction && width && React__default["default"].createElement(React__default["default"].Fragment, null,
49143
49163
  React__default["default"].createElement("div", { className: 'item7' },
49144
- React__default["default"].createElement(Button, { style: (width > 600) ? { display: 'inline' } : { display: 'inline', float: 'left' }, disabled: !run || (run.status.status === dist$1.RunStatusEnum.Failed ||
49164
+ !localRun && React__default["default"].createElement(Button, { disabled: !run || (run.status.status === dist$1.RunStatusEnum.Failed ||
49145
49165
  run.status.status === dist$1.RunStatusEnum.Succeeded ||
49146
49166
  run.status.status === dist$1.RunStatusEnum.Cancelled ||
49147
49167
  run.status.status === dist$1.RunStatusEnum.Unknown), onClick: function (e) {
49148
49168
  e.stopPropagation();
49149
49169
  if (!run)
49150
49170
  return;
49151
- if (!localRun) {
49152
- cancelRun(projectOwner, projectName, run.id)
49153
- .then(function (d) { return console.log(d); })
49154
- .catch(function (e) { return console.log(e); });
49155
- }
49171
+ cancelRun(projectOwner, projectName, run.id)
49172
+ .then(function (d) { return console.log(d); })
49173
+ .catch(function (e) { return console.log(e); });
49156
49174
  } },
49157
49175
  React__default["default"].createElement(XOctagon$1, { style: { display: 'inline', margin: '0 5px 0 0' } }),
49158
- " Cancel")))));
49176
+ " Cancel"),
49177
+ localRun && React__default["default"].createElement(Button, { disabled: !run || !run.status.finished_at, onClick: function (e) {
49178
+ e.stopPropagation();
49179
+ if (!run)
49180
+ return;
49181
+ var count = deleteJob("".concat(projectOwner, "/").concat(projectName), _run.id);
49182
+ if (count > 0) {
49183
+ if (window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/localStudies/").concat(localStudyURLname, "/?path=").concat(_run.id)) {
49184
+ window.history.back();
49185
+ }
49186
+ else {
49187
+ window.location.reload();
49188
+ }
49189
+ }
49190
+ } },
49191
+ React__default["default"].createElement(Trash$1, { style: { display: 'inline', margin: '0 5px 0 0' } }),
49192
+ " Delete")))));
49159
49193
  };
49160
49194
 
49161
49195
  var css_248z$5 = "";