@bento-core/table 1.0.1-ccdiintegrated.5 → 1.0.1-ccdiintegrated.7

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.
@@ -643,7 +643,7 @@ const CPIModal = _ref => {
643
643
  style: viewInExploreButton,
644
644
  onClick: () => {
645
645
  onClose();
646
- navigation("/explore?p_id=".concat(participantId, "&dbgap_accession=").concat(studyId));
646
+ navigation("/exploreParticipants?p_id=".concat(participantId, "&dbgap_accession=").concat(studyId));
647
647
  },
648
648
  disableRipple: true
649
649
  }, "VIEW IN EXPLORE"), /*#__PURE__*/_react.default.createElement("div", {
@@ -654,31 +654,36 @@ const CPIModal = _ref => {
654
654
  className: "".concat(classes.button, " ").concat(dropdownOpen ? classes.buttonOpen : ''),
655
655
  onClick: handleDropdownToggle,
656
656
  disableRipple: true
657
- }, /*#__PURE__*/_react.default.createElement("span", null, "ADD TO OR GO TO CART"), dropdownOpen ? /*#__PURE__*/_react.default.createElement(_ExpandLess.default, null) : /*#__PURE__*/_react.default.createElement(_ExpandMore.default, null)), dropdownOpen && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
657
+ }, /*#__PURE__*/_react.default.createElement("span", null, "ADD TO OR GO TO CART"), dropdownOpen ? /*#__PURE__*/_react.default.createElement(_ExpandLess.default, null) : /*#__PURE__*/_react.default.createElement(_ExpandMore.default, null)), dropdownOpen && /*#__PURE__*/_react.default.createElement("div", {
658
658
  style: {
659
659
  position: 'fixed',
660
660
  top: 0,
661
661
  left: 0,
662
662
  right: 0,
663
663
  bottom: 0,
664
- zIndex: 9998
664
+ zIndex: 1
665
665
  },
666
666
  onClick: () => setDropdownOpen(false)
667
667
  }), /*#__PURE__*/_react.default.createElement("div", {
668
- className: classes.dropdown
668
+ className: classes.dropdown,
669
+ style: {
670
+ display: dropdownOpen ? 'block' : 'none'
671
+ }
669
672
  }, /*#__PURE__*/_react.default.createElement("div", {
670
673
  className: classes.dropdownList
671
674
  }, /*#__PURE__*/_react.default.createElement("div", {
672
675
  className: classes.dropdownItem
673
676
  }, /*#__PURE__*/_react.default.createElement(_ReduxAddFile.default, _extends({}, wrapperConfig.items[0], {
674
677
  buttonStyle: addAllFilesButton,
675
- rowID: row.id
678
+ rowID: row.id,
679
+ onOptionClick: () => setDropdownOpen(false)
676
680
  }))), /*#__PURE__*/_react.default.createElement("div", {
677
681
  className: classes.dropdownItem
678
682
  }, /*#__PURE__*/_react.default.createElement(_ReduxAddFile.default, _extends({}, wrapperConfig.items[1], {
679
683
  buttonStyle: addSelectedFilesButton,
680
684
  rowID: row.id,
681
- disabled: selectedIds.length === 0
685
+ disabled: selectedIds.length === 0,
686
+ onOptionClick: () => setDropdownOpen(false)
682
687
  }))), /*#__PURE__*/_react.default.createElement("div", {
683
688
  className: classes.dropdownItem
684
689
  }, /*#__PURE__*/_react.default.createElement(_core.Button, {
@@ -689,7 +694,7 @@ const CPIModal = _ref => {
689
694
  navigation('/fileCentricCart');
690
695
  },
691
696
  disableRipple: true
692
- }, "GO TO CART"))))))), /*#__PURE__*/_react.default.createElement("div", {
697
+ }, "GO TO CART")))))), /*#__PURE__*/_react.default.createElement("div", {
693
698
  className: "footer",
694
699
  style: footer
695
700
  }, /*#__PURE__*/_react.default.createElement("span", null, "For more information about CPI, click", ' ', /*#__PURE__*/_react.default.createElement("a", {
@@ -7,7 +7,7 @@ exports.default = exports.btnTypes = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _client = require("@apollo/client");
9
9
  var _CPIFilesView = _interopRequireDefault(require("./CPIFilesView/CPIFilesView"));
10
- var _Snackbar = _interopRequireDefault(require("./Snackbar/Snackbar"));
10
+ var _CartToast = _interopRequireDefault(require("./Snackbar/CartToast"));
11
11
  var _AddToCartDialogAlertView = _interopRequireDefault(require("./AddToCartDialog/AddToCartDialogAlertView"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -19,29 +19,20 @@ const btnTypes = {
19
19
  DOWNLOAD_MANIFEST: 'DOWNLOAD_MANIFEST'
20
20
  };
21
21
  /**
22
- * customize button based on configuration
23
- * refer config table (wrapper component config)
22
+ * Explore CPI add-files button. Uses CartToast (body portal) instead of the
23
+ * Global Search MUI Snackbar so the toast stays visible above the Explore Modal.
24
24
  */
25
25
  exports.btnTypes = btnTypes;
26
26
  const AddFilesView = props => {
27
27
  const {
28
28
  count,
29
+ alreadyInCartCount,
29
30
  alertMessage,
30
31
  cartFiles,
31
32
  buttonStyle
32
33
  } = props;
33
- /**
34
- * snackbar state
35
- */
36
34
  const [openSnackbar, setOpenSnackbar] = (0, _react.useState)(false);
37
-
38
- /**
39
- * conditionally display max file Alter/Error dialog view
40
- */
41
35
  const [displayAlter, setAlterDisplay] = (0, _react.useState)(false);
42
- /**
43
- * acess bento app client via ApolloProvider
44
- */
45
36
  const client = (0, _client.useApolloClient)();
46
37
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CPIFilesView.default, _extends({}, props, {
47
38
  client: client,
@@ -49,9 +40,10 @@ const AddFilesView = props => {
49
40
  setOpenSnackbar: setOpenSnackbar,
50
41
  cartFiles: cartFiles,
51
42
  buttonStyle: buttonStyle
52
- })), /*#__PURE__*/_react.default.createElement(_Snackbar.default, {
43
+ })), /*#__PURE__*/_react.default.createElement(_CartToast.default, {
53
44
  open: openSnackbar,
54
45
  count: count,
46
+ alreadyInCartCount: alreadyInCartCount,
55
47
  onClose: () => setOpenSnackbar(false)
56
48
  }), displayAlter && /*#__PURE__*/_react.default.createElement(_AddToCartDialogAlertView.default, {
57
49
  alertMessage: alertMessage,
@@ -69,7 +69,8 @@ const AddToCartView = props => {
69
69
  fileId,
70
70
  buttonStyle,
71
71
  addFiles,
72
- count
72
+ count,
73
+ alreadyInCartCount
73
74
  } = props;
74
75
 
75
76
  // const [isDataloading, setIsDataloading] = useState(false);
@@ -90,14 +91,14 @@ const AddToCartView = props => {
90
91
  */
91
92
  const addAllFiles = () => {
92
93
  const idsInitial = fileId || [];
93
- const ids = [idsInitial];
94
+ const ids = Array.isArray(idsInitial) ? idsInitial : [idsInitial];
94
95
  const fileCount = ids.length;
95
96
  const upperLimit = 200000;
96
97
  const cartCount = cartFiles.length;
97
98
  if (fileCount <= upperLimit && cartCount < upperLimit) {
98
99
  const newIds = checkDuplicate(cartFiles, ids);
99
100
  if (cartCount + newIds.length <= upperLimit) {
100
- addFiles(newIds);
101
+ addFiles(ids);
101
102
  setOpenSnackbar(true);
102
103
  } else {
103
104
  setAlterDisplay(true);
@@ -115,6 +116,7 @@ const AddToCartView = props => {
115
116
  }, "ADD TO CART"), /*#__PURE__*/_react.default.createElement(_Snackbar.default, {
116
117
  open: openSnackbar,
117
118
  count: count,
119
+ alreadyInCartCount: alreadyInCartCount,
118
120
  onClose: () => setOpenSnackbar(false)
119
121
  }), displayAlter && /*#__PURE__*/_react.default.createElement(_AddToCartDialogAlertView.default, {
120
122
  alertMessage: "The cart is limited to 200,000 files. Please narrow the search criteria or remove some files from the cart to add more.",
@@ -16,6 +16,7 @@ const AddToCartRedux = props => /*#__PURE__*/_react.default.createElement(_AddTo
16
16
  */
17
17
  const mapStateToProps = state => ({
18
18
  count: state.cartReducer && state.cartReducer.count,
19
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
19
20
  cartFiles: state.cartReducer && state.cartReducer.filesId
20
21
  });
21
22
  const mapDispatchToProps = dispatch => ({
@@ -67,7 +67,7 @@ const ToolTipView = props => {
67
67
  // };
68
68
  exports.ToolTipView = ToolTipView;
69
69
  const checkDuplicate = (cartFiles, ids) => ids.filter(id => !cartFiles[id]);
70
- const addFileQuery = (0, _graphqlTag.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\nquery search ( \n $participant_ids: [String],\n){\n fileIDsFromList ( \n participant_ids: $participant_ids,\n ) \n}\n "])));
70
+ const addFileQuery = (0, _graphqlTag.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\nquery search (\n $pid: [String],\n){\n fileIDsFromList (\n pid: $pid,\n )\n}\n "])));
71
71
  const CPIFilesComponent = props => {
72
72
  const {
73
73
  title,
@@ -82,7 +82,8 @@ const CPIFilesComponent = props => {
82
82
  cartFiles,
83
83
  participantIds,
84
84
  buttonStyle,
85
- rowID
85
+ rowID,
86
+ onOptionClick
86
87
  } = props;
87
88
  /**
88
89
  * conditionally display dialog view
@@ -106,21 +107,26 @@ const CPIFilesComponent = props => {
106
107
  * verify and set file ids
107
108
  */
108
109
  const addAllFiles = () => {
110
+ if (typeof onOptionClick === 'function') {
111
+ onOptionClick();
112
+ }
109
113
  let toAdd = [];
110
114
  if (btnType === 'ADD_ALL_FILES') {
115
+ // Always include the modal participant pid plus any internal CPI-mapped ids.
116
+ toAdd = rowID ? [rowID] : [];
111
117
  participantIds.forEach(e => {
112
118
  if (e.data_type === 'internal' && e.p_id) {
113
119
  toAdd = toAdd.concat(e.p_id);
114
120
  }
115
- toAdd = toAdd.concat(rowID);
116
121
  });
117
122
  } else {
118
- toAdd = participantIds.concat(rowID);
123
+ toAdd = (rowID ? [rowID] : []).concat(participantIds);
119
124
  }
125
+ toAdd = [...new Set(toAdd.filter(id => typeof id === 'string' && id))];
120
126
  const fileIds = (0, _WrapperService.getFilesID)({
121
127
  client,
122
128
  variables: {
123
- participant_ids: toAdd
129
+ pid: toAdd
124
130
  },
125
131
  query: addFileQuery
126
132
  });
@@ -136,7 +142,7 @@ const CPIFilesComponent = props => {
136
142
  setOpen(true);
137
143
  setAddFilesId(ids);
138
144
  } else {
139
- const newIds = checkDuplicate(cartFiles, ids);
145
+ const newIds = checkDuplicate(cartFilesDict, ids);
140
146
  if (cartCount + newIds.length <= upperLimit) {
141
147
  setOpen(true);
142
148
  setAddFilesId(newIds);
@@ -16,6 +16,7 @@ const AddFilesRedux = props => /*#__PURE__*/_react.default.createElement(_AddFil
16
16
  */
17
17
  const mapStateToProps = state => ({
18
18
  count: state.cartReducer && state.cartReducer.count,
19
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
19
20
  cartFiles: state.cartReducer && state.cartReducer.filesId
20
21
  });
21
22
  const mapDispatchToProps = dispatch => ({
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactDom = _interopRequireDefault(require("react-dom"));
9
+ var _cart = require("@bento-core/cart");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ /**
14
+ * Explore CPI cart toast.
15
+ * Body portal keeps it visible above the Explore Modal; styling matches the
16
+ * Global Search CPI MUI snackbar. Dropdown closes on option click so the toast
17
+ * does not need width hacks to avoid overlap.
18
+ */
19
+ const SuccessIcon = () => /*#__PURE__*/_react.default.createElement("svg", {
20
+ xmlns: "http://www.w3.org/2000/svg",
21
+ width: "24",
22
+ height: "24",
23
+ viewBox: "0 0 24 24",
24
+ "aria-hidden": "true",
25
+ focusable: "false",
26
+ style: {
27
+ display: 'block',
28
+ fill: 'currentColor'
29
+ }
30
+ }, /*#__PURE__*/_react.default.createElement("path", {
31
+ d: "M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"
32
+ }));
33
+ const CartToast = _ref => {
34
+ let {
35
+ open,
36
+ count,
37
+ alreadyInCartCount = 0,
38
+ onClose
39
+ } = _ref;
40
+ (0, _react.useEffect)(() => {
41
+ if (!open) {
42
+ return undefined;
43
+ }
44
+ const timer = setTimeout(() => {
45
+ onClose();
46
+ }, 3000);
47
+ return () => clearTimeout(timer);
48
+ }, [open, onClose]);
49
+ if (!open || typeof document === 'undefined') {
50
+ return null;
51
+ }
52
+ return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement("div", {
53
+ className: "snackBar exploreCpiCartToast",
54
+ role: "status",
55
+ "aria-live": "polite",
56
+ style: {
57
+ position: 'fixed',
58
+ bottom: '20px',
59
+ right: '24px',
60
+ zIndex: 99999,
61
+ pointerEvents: 'none'
62
+ }
63
+ }, /*#__PURE__*/_react.default.createElement("div", {
64
+ className: "snackBarMessage",
65
+ style: {
66
+ display: 'flex',
67
+ alignItems: 'center',
68
+ backgroundColor: '#323232',
69
+ color: '#fff',
70
+ padding: '6px 16px',
71
+ borderRadius: '4px',
72
+ boxShadow: '0px 3px 5px -1px rgba(0,0,0,0.2), 0px 6px 10px 0px rgba(0,0,0,0.14), 0px 1px 18px 0px rgba(0,0,0,0.12)',
73
+ minWidth: 288,
74
+ maxWidth: 568,
75
+ boxSizing: 'border-box',
76
+ fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
77
+ fontWeight: 400,
78
+ fontSize: '0.875rem',
79
+ lineHeight: 1.43,
80
+ letterSpacing: '0.01071em'
81
+ }
82
+ }, /*#__PURE__*/_react.default.createElement("span", {
83
+ className: "snackBarMessageIcon",
84
+ style: {
85
+ display: 'inline-flex',
86
+ alignItems: 'center',
87
+ marginRight: 8,
88
+ color: '#fff',
89
+ flexShrink: 0
90
+ }
91
+ }, /*#__PURE__*/_react.default.createElement(SuccessIcon, null)), /*#__PURE__*/_react.default.createElement("span", {
92
+ className: "snackBarText"
93
+ }, (0, _cart.formatCartAddMessage)(count, alreadyInCartCount)))), document.body);
94
+ };
95
+ var _default = CartToast;
96
+ exports.default = _default;
@@ -6,11 +6,17 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _core = require("@material-ui/core");
9
+ var _cart = require("@bento-core/cart");
9
10
  var _SuccessOutlined = _interopRequireDefault(require("./SuccessOutlined"));
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ /**
13
+ * Legacy MUI snackbar kept for non-CPI table cart actions.
14
+ * Explore CPI uses CartToast instead.
15
+ */
11
16
  const SnackbarView = props => {
12
17
  const {
13
18
  count,
19
+ alreadyInCartCount = 0,
14
20
  open,
15
21
  onClose
16
22
  } = props;
@@ -29,7 +35,7 @@ const SnackbarView = props => {
29
35
  },
30
36
  style: {
31
37
  bottom: '-45%',
32
- zIndex: '-10000',
38
+ zIndex: 15000,
33
39
  pointerEvents: 'none'
34
40
  },
35
41
  message: /*#__PURE__*/_react.default.createElement("div", {
@@ -38,7 +44,7 @@ const SnackbarView = props => {
38
44
  className: "snackBarMessageIcon"
39
45
  }, /*#__PURE__*/_react.default.createElement(_SuccessOutlined.default, null), ' '), /*#__PURE__*/_react.default.createElement("span", {
40
46
  className: "snackBarText"
41
- }, count, ' ', "File(s) successfully added to your cart"))
47
+ }, (0, _cart.formatCartAddMessage)(count, alreadyInCartCount)))
42
48
  }));
43
49
  };
44
50
  var _default = SnackbarView;
@@ -10,7 +10,8 @@ var _Snackbar = _interopRequireDefault(require("./Snackbar"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  const ReduxSnackbar = props => /*#__PURE__*/_react.default.createElement(_Snackbar.default, props);
12
12
  const mapStateToProps = state => ({
13
- count: state.cartReducer.count
13
+ count: state.cartReducer && state.cartReducer.count,
14
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount
14
15
  });
15
16
  var _default = (0, _reactRedux.connect)(mapStateToProps, null)(ReduxSnackbar);
16
17
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ccdiintegrated.5",
3
+ "version": "1.0.1-ccdiintegrated.7",
4
4
  "homepage": "https://github.com/CBIIT/bento-frontend#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/CBIIT/bento-frontend/issues"
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@apollo/client": "^3.8.3",
23
- "@bento-core/cart": "1.0.1-ccdiintegrated.1",
23
+ "@bento-core/cart": "1.0.1-ccdiintegrated.2",
24
24
  "@bento-core/tool-tip": "1.0.1-ccdiintegrated.1",
25
25
  "@bento-core/util": "1.0.1-ccdiintegrated.1",
26
26
  "clsx": "^2.1.1",
@@ -687,7 +687,7 @@ const CPIModal = ({
687
687
  style={viewInExploreButton}
688
688
  onClick={() => {
689
689
  onClose();
690
- navigation(`/explore?p_id=${participantId}&dbgap_accession=${studyId}`);
690
+ navigation(`/exploreParticipants?p_id=${participantId}&dbgap_accession=${studyId}`);
691
691
  }}
692
692
  disableRipple
693
693
  >
@@ -706,52 +706,56 @@ const CPIModal = ({
706
706
  </Button>
707
707
 
708
708
  {dropdownOpen && (
709
- <>
710
- <div
711
- style={{
712
- position: 'fixed',
713
- top: 0,
714
- left: 0,
715
- right: 0,
716
- bottom: 0,
717
- zIndex: 9998,
718
- }}
719
- onClick={() => setDropdownOpen(false)}
720
- />
721
- <div className={classes.dropdown}>
722
- <div className={classes.dropdownList}>
723
- <div className={classes.dropdownItem}>
724
- <AddFileButtonView
725
- {...wrapperConfig.items[0]}
726
- buttonStyle={addAllFilesButton}
727
- rowID={row.id}
728
- />
729
- </div>
730
- <div className={classes.dropdownItem}>
731
- <AddFileButtonView
732
- {...wrapperConfig.items[1]}
733
- buttonStyle={addSelectedFilesButton}
734
- rowID={row.id}
735
- disabled={selectedIds.length === 0}
736
- />
737
- </div>
738
- <div className={classes.dropdownItem}>
739
- <Button
740
- style={goToCartButton}
741
- onClick={() => {
742
- onClose();
743
- setDropdownOpen(false);
744
- navigation('/fileCentricCart');
745
- }}
746
- disableRipple
747
- >
748
- GO TO CART
749
- </Button>
750
- </div>
751
- </div>
752
- </div>
753
- </>
709
+ <div
710
+ style={{
711
+ position: 'fixed',
712
+ top: 0,
713
+ left: 0,
714
+ right: 0,
715
+ bottom: 0,
716
+ zIndex: 1,
717
+ }}
718
+ onClick={() => setDropdownOpen(false)}
719
+ />
754
720
  )}
721
+ {/* Keep cart actions mounted while closed so the success toast is not unmounted. */}
722
+ <div
723
+ className={classes.dropdown}
724
+ style={{ display: dropdownOpen ? 'block' : 'none' }}
725
+ >
726
+ <div className={classes.dropdownList}>
727
+ <div className={classes.dropdownItem}>
728
+ <AddFileButtonView
729
+ {...wrapperConfig.items[0]}
730
+ buttonStyle={addAllFilesButton}
731
+ rowID={row.id}
732
+ onOptionClick={() => setDropdownOpen(false)}
733
+ />
734
+ </div>
735
+ <div className={classes.dropdownItem}>
736
+ <AddFileButtonView
737
+ {...wrapperConfig.items[1]}
738
+ buttonStyle={addSelectedFilesButton}
739
+ rowID={row.id}
740
+ disabled={selectedIds.length === 0}
741
+ onOptionClick={() => setDropdownOpen(false)}
742
+ />
743
+ </div>
744
+ <div className={classes.dropdownItem}>
745
+ <Button
746
+ style={goToCartButton}
747
+ onClick={() => {
748
+ onClose();
749
+ setDropdownOpen(false);
750
+ navigation('/fileCentricCart');
751
+ }}
752
+ disableRipple
753
+ >
754
+ GO TO CART
755
+ </Button>
756
+ </div>
757
+ </div>
758
+ </div>
755
759
  </div>
756
760
  </div>
757
761
  <div className="footer" style={footer}>
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from 'react';
2
2
  import { useApolloClient } from '@apollo/client';
3
3
  import CPIFilesView from './CPIFilesView/CPIFilesView';
4
- import SnackbarView from './Snackbar/Snackbar';
4
+ import CartToast from './Snackbar/CartToast';
5
5
  import AlertView from './AddToCartDialog/AddToCartDialogAlertView';
6
6
 
7
7
  export const btnTypes = {
@@ -10,29 +10,21 @@ export const btnTypes = {
10
10
  DOWNLOAD_MANIFEST: 'DOWNLOAD_MANIFEST',
11
11
  };
12
12
  /**
13
- * customize button based on configuration
14
- * refer config table (wrapper component config)
13
+ * Explore CPI add-files button. Uses CartToast (body portal) instead of the
14
+ * Global Search MUI Snackbar so the toast stays visible above the Explore Modal.
15
15
  */
16
16
  const AddFilesView = (props) => {
17
17
  const {
18
18
  count,
19
+ alreadyInCartCount,
19
20
  alertMessage,
20
21
  cartFiles,
21
22
  buttonStyle,
22
23
  } = props;
23
- /**
24
- * snackbar state
25
- */
26
24
  const [openSnackbar, setOpenSnackbar] = useState(false);
27
-
28
- /**
29
- * conditionally display max file Alter/Error dialog view
30
- */
31
25
  const [displayAlter, setAlterDisplay] = useState(false);
32
- /**
33
- * acess bento app client via ApolloProvider
34
- */
35
26
  const client = useApolloClient();
27
+
36
28
  return (
37
29
  <>
38
30
  <CPIFilesView
@@ -43,9 +35,10 @@ const AddFilesView = (props) => {
43
35
  cartFiles={cartFiles}
44
36
  buttonStyle={buttonStyle}
45
37
  />
46
- <SnackbarView
38
+ <CartToast
47
39
  open={openSnackbar}
48
40
  count={count}
41
+ alreadyInCartCount={alreadyInCartCount}
49
42
  onClose={() => setOpenSnackbar(false)}
50
43
  />
51
44
  {(displayAlter) && (
@@ -66,6 +66,7 @@ const AddToCartView = (props) => {
66
66
  buttonStyle,
67
67
  addFiles,
68
68
  count,
69
+ alreadyInCartCount,
69
70
  } = props;
70
71
 
71
72
  // const [isDataloading, setIsDataloading] = useState(false);
@@ -85,14 +86,14 @@ const AddToCartView = (props) => {
85
86
  */
86
87
  const addAllFiles = () => {
87
88
  const idsInitial = fileId || [];
88
- const ids = [idsInitial];
89
+ const ids = Array.isArray(idsInitial) ? idsInitial : [idsInitial];
89
90
  const fileCount = ids.length;
90
91
  const upperLimit = 200000;
91
92
  const cartCount = cartFiles.length;
92
93
  if (fileCount <= upperLimit && cartCount < upperLimit) {
93
94
  const newIds = checkDuplicate(cartFiles, ids);
94
95
  if (cartCount + newIds.length <= upperLimit) {
95
- addFiles(newIds);
96
+ addFiles(ids);
96
97
  setOpenSnackbar(true);
97
98
  } else {
98
99
  setAlterDisplay(true);
@@ -116,6 +117,7 @@ const AddToCartView = (props) => {
116
117
  <SnackbarView
117
118
  open={openSnackbar}
118
119
  count={count}
120
+ alreadyInCartCount={alreadyInCartCount}
119
121
  onClose={() => setOpenSnackbar(false)}
120
122
  />
121
123
  {displayAlter && (
@@ -10,6 +10,7 @@ const AddToCartRedux = (props) => <AddToCartView {...props} />;
10
10
  */
11
11
  const mapStateToProps = (state) => ({
12
12
  count: state.cartReducer && state.cartReducer.count,
13
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
13
14
  cartFiles: state.cartReducer && state.cartReducer.filesId,
14
15
  });
15
16
 
@@ -62,12 +62,12 @@ export const ToolTipView = (props) => {
62
62
  const checkDuplicate = (cartFiles, ids) => (ids.filter((id) => !cartFiles[id]));
63
63
 
64
64
  const addFileQuery = gql`
65
- query search (
66
- $participant_ids: [String],
65
+ query search (
66
+ $pid: [String],
67
67
  ){
68
- fileIDsFromList (
69
- participant_ids: $participant_ids,
70
- )
68
+ fileIDsFromList (
69
+ pid: $pid,
70
+ )
71
71
  }
72
72
  `;
73
73
 
@@ -86,6 +86,7 @@ const CPIFilesComponent = (props) => {
86
86
  participantIds,
87
87
  buttonStyle,
88
88
  rowID,
89
+ onOptionClick,
89
90
  } = props;
90
91
  /**
91
92
  * conditionally display dialog view
@@ -108,20 +109,25 @@ const CPIFilesComponent = (props) => {
108
109
  * verify and set file ids
109
110
  */
110
111
  const addAllFiles = () => {
112
+ if (typeof onOptionClick === 'function') {
113
+ onOptionClick();
114
+ }
111
115
  let toAdd = [];
112
116
  if (btnType === 'ADD_ALL_FILES') {
117
+ // Always include the modal participant pid plus any internal CPI-mapped ids.
118
+ toAdd = rowID ? [rowID] : [];
113
119
  participantIds.forEach((e) => {
114
120
  if (e.data_type === 'internal' && e.p_id) {
115
121
  toAdd = toAdd.concat(e.p_id);
116
122
  }
117
- toAdd = toAdd.concat(rowID);
118
123
  });
119
124
  } else {
120
- toAdd = participantIds.concat(rowID);
125
+ toAdd = (rowID ? [rowID] : []).concat(participantIds);
121
126
  }
127
+ toAdd = [...new Set(toAdd.filter((id) => typeof id === 'string' && id))];
122
128
  const fileIds = getFilesID({
123
129
  client,
124
- variables: { participant_ids: toAdd },
130
+ variables: { pid: toAdd },
125
131
  query: addFileQuery,
126
132
  });
127
133
  const upperLimit = 200000;
@@ -136,7 +142,7 @@ const CPIFilesComponent = (props) => {
136
142
  setOpen(true);
137
143
  setAddFilesId(ids);
138
144
  } else {
139
- const newIds = checkDuplicate(cartFiles, ids);
145
+ const newIds = checkDuplicate(cartFilesDict, ids);
140
146
  if (cartCount + newIds.length <= upperLimit) {
141
147
  setOpen(true);
142
148
  setAddFilesId(newIds);
@@ -10,6 +10,7 @@ const AddFilesRedux = (props) => <AddFiles {...props} />;
10
10
  */
11
11
  const mapStateToProps = (state) => ({
12
12
  count: state.cartReducer && state.cartReducer.count,
13
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
13
14
  cartFiles: state.cartReducer && state.cartReducer.filesId,
14
15
  });
15
16
 
@@ -0,0 +1,99 @@
1
+ import React, { useEffect } from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import { formatCartAddMessage } from '@bento-core/cart';
4
+
5
+ /**
6
+ * Explore CPI cart toast.
7
+ * Body portal keeps it visible above the Explore Modal; styling matches the
8
+ * Global Search CPI MUI snackbar. Dropdown closes on option click so the toast
9
+ * does not need width hacks to avoid overlap.
10
+ */
11
+ const SuccessIcon = () => (
12
+ <svg
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ width="24"
15
+ height="24"
16
+ viewBox="0 0 24 24"
17
+ aria-hidden="true"
18
+ focusable="false"
19
+ style={{ display: 'block', fill: 'currentColor' }}
20
+ >
21
+ <path d="M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z" />
22
+ </svg>
23
+ );
24
+
25
+ const CartToast = ({
26
+ open,
27
+ count,
28
+ alreadyInCartCount = 0,
29
+ onClose,
30
+ }) => {
31
+ useEffect(() => {
32
+ if (!open) {
33
+ return undefined;
34
+ }
35
+ const timer = setTimeout(() => {
36
+ onClose();
37
+ }, 3000);
38
+ return () => clearTimeout(timer);
39
+ }, [open, onClose]);
40
+
41
+ if (!open || typeof document === 'undefined') {
42
+ return null;
43
+ }
44
+
45
+ return ReactDOM.createPortal(
46
+ <div
47
+ className="snackBar exploreCpiCartToast"
48
+ role="status"
49
+ aria-live="polite"
50
+ style={{
51
+ position: 'fixed',
52
+ bottom: '20px',
53
+ right: '24px',
54
+ zIndex: 99999,
55
+ pointerEvents: 'none',
56
+ }}
57
+ >
58
+ <div
59
+ className="snackBarMessage"
60
+ style={{
61
+ display: 'flex',
62
+ alignItems: 'center',
63
+ backgroundColor: '#323232',
64
+ color: '#fff',
65
+ padding: '6px 16px',
66
+ borderRadius: '4px',
67
+ boxShadow: '0px 3px 5px -1px rgba(0,0,0,0.2), 0px 6px 10px 0px rgba(0,0,0,0.14), 0px 1px 18px 0px rgba(0,0,0,0.12)',
68
+ minWidth: 288,
69
+ maxWidth: 568,
70
+ boxSizing: 'border-box',
71
+ fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
72
+ fontWeight: 400,
73
+ fontSize: '0.875rem',
74
+ lineHeight: 1.43,
75
+ letterSpacing: '0.01071em',
76
+ }}
77
+ >
78
+ <span
79
+ className="snackBarMessageIcon"
80
+ style={{
81
+ display: 'inline-flex',
82
+ alignItems: 'center',
83
+ marginRight: 8,
84
+ color: '#fff',
85
+ flexShrink: 0,
86
+ }}
87
+ >
88
+ <SuccessIcon />
89
+ </span>
90
+ <span className="snackBarText">
91
+ {formatCartAddMessage(count, alreadyInCartCount)}
92
+ </span>
93
+ </div>
94
+ </div>,
95
+ document.body,
96
+ );
97
+ };
98
+
99
+ export default CartToast;
@@ -1,10 +1,16 @@
1
1
  import React from 'react';
2
2
  import { Snackbar } from '@material-ui/core';
3
+ import { formatCartAddMessage } from '@bento-core/cart';
3
4
  import SuccessOutlinedIcon from './SuccessOutlined';
4
5
 
6
+ /**
7
+ * Legacy MUI snackbar kept for non-CPI table cart actions.
8
+ * Explore CPI uses CartToast instead.
9
+ */
5
10
  const SnackbarView = (props) => {
6
11
  const {
7
12
  count,
13
+ alreadyInCartCount = 0,
8
14
  open,
9
15
  onClose,
10
16
  } = props;
@@ -22,7 +28,7 @@ const SnackbarView = (props) => {
22
28
  open={open}
23
29
  autoHideDuration={3000}
24
30
  anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
25
- style={{ bottom: '-45%', zIndex: '-10000', pointerEvents: 'none' }}
31
+ style={{ bottom: '-45%', zIndex: 15000, pointerEvents: 'none' }}
26
32
  message={(
27
33
  <div className="snackBarMessage">
28
34
  <span className="snackBarMessageIcon">
@@ -30,9 +36,7 @@ const SnackbarView = (props) => {
30
36
  {' '}
31
37
  </span>
32
38
  <span className="snackBarText">
33
- {count}
34
- {' '}
35
- File(s) successfully added to your cart
39
+ {formatCartAddMessage(count, alreadyInCartCount)}
36
40
  </span>
37
41
  </div>
38
42
  )}
@@ -5,7 +5,8 @@ import SnackbarView from './Snackbar';
5
5
  const ReduxSnackbar = ((props) => <SnackbarView {...props} />);
6
6
 
7
7
  const mapStateToProps = (state) => ({
8
- count: state.cartReducer.count,
8
+ count: state.cartReducer && state.cartReducer.count,
9
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
9
10
  });
10
11
 
11
12
  export default connect(mapStateToProps, null)(ReduxSnackbar);