pollination-react-io 1.24.4 → 1.25.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.
@@ -10,4 +10,6 @@ export interface StudyCardProps {
10
10
  style?: CSSProperties;
11
11
  authUser?: UserPrivate;
12
12
  client?: APIClient;
13
+ showMenu: boolean;
14
+ onDelete?: () => void;
13
15
  }
@@ -38012,6 +38012,9 @@ var useCreateStudy = function (accountName, projectName, client) {
38012
38012
  // then save it to the users machine and provide
38013
38013
  // the name to the jobInfo object
38014
38014
  if (typeof value.key === 'string') {
38015
+ if (value.name == null) {
38016
+ reject("'name' attribute of ".concat(value.key, " is null. Job will be invalid."));
38017
+ }
38015
38018
  downloadArtifact(value.key)
38016
38019
  .then(function (url) {
38017
38020
  fetch(url)
@@ -38118,8 +38121,7 @@ var useCreateStudy = function (accountName, projectName, client) {
38118
38121
  arguments: [jobArguments]
38119
38122
  });
38120
38123
  }).catch(function (err) {
38121
- var data = err.response.data;
38122
- console.error(data.detail);
38124
+ console.error(err);
38123
38125
  })];
38124
38126
  case 1:
38125
38127
  job = _c.sent();
@@ -46616,14 +46618,14 @@ var formatDuration = function (duration) {
46616
46618
  };
46617
46619
  var StudyCard = function (_a) {
46618
46620
  var _b, _c;
46619
- var projectName = _a.projectName, projectOwner = _a.projectOwner, _study = _a.study, _d = _a.canWrite, canWrite = _d === void 0 ? false : _d, _e = _a.runList, runList = _e === void 0 ? true : _e, style = _a.style, authUser = _a.authUser, client = _a.client;
46620
- var _f = useJobs(client), cancelJob = _f.cancelJob, deleteJob = _f.deleteJob, fetchJob = _f.fetchJob;
46621
- var _g = useSWR(authUser && _study ? [projectOwner, projectName, _study.id] : undefined, fetchJob, {
46621
+ var projectName = _a.projectName, projectOwner = _a.projectOwner, _study = _a.study, _d = _a.canWrite, canWrite = _d === void 0 ? false : _d, _e = _a.runList, runList = _e === void 0 ? true : _e, style = _a.style, authUser = _a.authUser, client = _a.client, showMenu = _a.showMenu, _f = _a.onDelete, onDelete = _f === void 0 ? function () { return window.history.back(); } : _f;
46622
+ var _g = useJobs(client), cancelJob = _g.cancelJob, deleteJob = _g.deleteJob, fetchJob = _g.fetchJob;
46623
+ var _h = useSWR(authUser && _study ? [projectOwner, projectName, _study.id] : undefined, fetchJob, {
46622
46624
  revalidateOnFocus: false,
46623
46625
  refreshInterval: !_study || _study.status.finished_at ? undefined : 5000,
46624
46626
  fallbackData: _study,
46625
46627
  errorRetryCount: 3
46626
- }), study = _g.data; _g.error; var isValidating = _g.isValidating;
46628
+ }), study = _h.data; _h.error; var isValidating = _h.isValidating;
46627
46629
  var status = useMemo(function () {
46628
46630
  return ({
46629
46631
  pending: study && study.status.runs_pending ? study.status.runs_pending : 0,
@@ -46633,7 +46635,7 @@ var StudyCard = function (_a) {
46633
46635
  canceled: study && study.status.runs_cancelled ? study.status.runs_cancelled : 0,
46634
46636
  });
46635
46637
  }, [study]);
46636
- var _h = useState(getDuration(study)), duration = _h[0], setDuration = _h[1];
46638
+ var _j = useState(getDuration(study)), duration = _j[0], setDuration = _j[1];
46637
46639
  useEffect(function () {
46638
46640
  if (!study)
46639
46641
  return undefined;
@@ -46646,6 +46648,37 @@ var StudyCard = function (_a) {
46646
46648
  }, 1000);
46647
46649
  return study.status.finished_at ? undefined : function () { return clearInterval(handle); };
46648
46650
  }, [study]);
46651
+ var menu = (React__default.createElement("button", { type: 'button', style: {
46652
+ width: 32,
46653
+ height: 32,
46654
+ display: 'flex',
46655
+ justifyContent: 'center',
46656
+ alignItems: 'center',
46657
+ borderRadius: 9999,
46658
+ border: '1px solid #d0d7de',
46659
+ backgroundColor: 'white',
46660
+ outlineColor: 'var(--primary)',
46661
+ cursor: 'pointer'
46662
+ } }, isValidating ? React__default.createElement(LoadingIcon, null) : React__default.createElement(Gear$1, null)));
46663
+ var optionsDropdown = [
46664
+ {
46665
+ options: [{
46666
+ type: 'button',
46667
+ id: 'cancel-study',
46668
+ label: 'Cancel',
46669
+ icon: React__default.createElement(XOctagon$1, null),
46670
+ disabled: !study || (status.pending < 1 && status.running < 1),
46671
+ onSelect: function () { return cancelJob(projectOwner, projectName, study.id); }
46672
+ }, {
46673
+ type: 'button',
46674
+ id: 'delete-study',
46675
+ label: 'Delete',
46676
+ icon: React__default.createElement(Trash$1, null),
46677
+ onSelect: function () { return deleteJob(projectOwner, projectName, study.id)
46678
+ .then(onDelete); }
46679
+ },]
46680
+ }
46681
+ ];
46649
46682
  return (React__default.createElement("div", { "data-testid": "StudyCard", className: 'study-card', style: __assign({ borderRadius: 8, borderWidth: 1, borderStyle: 'solid', display: 'grid', gridTemplateColumns: 'minmax(200px, 18%) 1fr', gridTemplateRows: '1fr auto', columnGap: 8, rowGap: 0 }, style) },
46650
46683
  React__default.createElement("div", { style: {
46651
46684
  borderRight: '1px solid #d0d7de',
@@ -46718,41 +46751,12 @@ var StudyCard = function (_a) {
46718
46751
  textOverflow: 'ellipsis',
46719
46752
  display: 'inline-block'
46720
46753
  } }, study ? (_b = study.spec.name) !== null && _b !== void 0 ? _b : "Study: ".concat(study.id) : '--'),
46721
- canWrite && study &&
46754
+ showMenu && canWrite && study &&
46722
46755
  React__default.createElement("div", { style: {
46723
46756
  display: 'flex',
46724
46757
  alignItems: 'center'
46725
46758
  } },
46726
- React__default.createElement(Dropdown, { trigger: React__default.createElement("button", { type: 'button', style: {
46727
- width: 32,
46728
- height: 32,
46729
- display: 'flex',
46730
- justifyContent: 'center',
46731
- alignItems: 'center',
46732
- borderRadius: 9999,
46733
- border: '1px solid #d0d7de',
46734
- backgroundColor: 'white',
46735
- outlineColor: 'var(--primary)',
46736
- cursor: 'pointer'
46737
- } }, isValidating ? React__default.createElement(LoadingIcon, null) : React__default.createElement(Gear$1, null)), optionGroups: [
46738
- {
46739
- options: [{
46740
- type: 'button',
46741
- id: 'cancel-study',
46742
- label: 'Cancel',
46743
- icon: React__default.createElement(XOctagon$1, null),
46744
- disabled: !study || (status.pending < 1 && status.running < 1),
46745
- onSelect: function () { return cancelJob(projectOwner, projectName, study.id); }
46746
- }, {
46747
- type: 'button',
46748
- id: 'delete-study',
46749
- label: 'Delete',
46750
- icon: React__default.createElement(Trash$1, null),
46751
- onSelect: function () { return deleteJob(projectOwner, projectName, study.id)
46752
- .then(function () { return window.open("/".concat(projectOwner, "/projects/").concat(projectName)); }); }
46753
- },]
46754
- }
46755
- ], contentProps: {
46759
+ React__default.createElement(Dropdown, { trigger: menu, optionGroups: optionsDropdown, contentProps: {
46756
46760
  align: 'end',
46757
46761
  sideOffset: 2,
46758
46762
  } }))),