@bydata/react-supertabs 1.2.4 → 1.2.5
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/dist/TabContext.js +46 -10
- package/package.json +1 -1
package/dist/TabContext.js
CHANGED
|
@@ -293,6 +293,8 @@ function TabProvider(_ref9) {
|
|
|
293
293
|
setTabModePreference = _useState26[1];
|
|
294
294
|
var previousEntityId = (0, _usePrevious["default"])(currentEntityId);
|
|
295
295
|
var closeTabFailedRequestsRef = (0, _react.useRef)({});
|
|
296
|
+
/** AbortController per client tab id for in-flight open_tab API */
|
|
297
|
+
var openTabAbortByClientIdRef = (0, _react.useRef)({});
|
|
296
298
|
(0, _react.useEffect)(function () {
|
|
297
299
|
localStorage.setItem(SITE_PREFIX + "tab_mode_preference", JSON.stringify(tabModePreference));
|
|
298
300
|
}, [tabModePreference]);
|
|
@@ -570,6 +572,7 @@ function TabProvider(_ref9) {
|
|
|
570
572
|
isSubTab,
|
|
571
573
|
_ref16$keepInactive,
|
|
572
574
|
keepInactive,
|
|
575
|
+
openTabAbortController,
|
|
573
576
|
_payload$tab_info,
|
|
574
577
|
isEditMode,
|
|
575
578
|
unique_identifier,
|
|
@@ -586,6 +589,8 @@ function TabProvider(_ref9) {
|
|
|
586
589
|
payload,
|
|
587
590
|
storedExpandedIds,
|
|
588
591
|
isExpanded,
|
|
592
|
+
clientTabId,
|
|
593
|
+
previousOpenAbort,
|
|
589
594
|
response,
|
|
590
595
|
_tabId,
|
|
591
596
|
newTab,
|
|
@@ -595,6 +600,8 @@ function TabProvider(_ref9) {
|
|
|
595
600
|
while (1) switch (_context5.p = _context5.n) {
|
|
596
601
|
case 0:
|
|
597
602
|
_ref16 = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, tab = _ref16.tab, _ref16$isHomeTab = _ref16.isHomeTab, isHomeTab = _ref16$isHomeTab === void 0 ? false : _ref16$isHomeTab, _ref16$isSubTab = _ref16.isSubTab, isSubTab = _ref16$isSubTab === void 0 ? false : _ref16$isSubTab, _ref16$keepInactive = _ref16.keepInactive, keepInactive = _ref16$keepInactive === void 0 ? false : _ref16$keepInactive;
|
|
603
|
+
// return;
|
|
604
|
+
openTabAbortController = null;
|
|
598
605
|
_context5.p = 1;
|
|
599
606
|
if (!isSubTab) {
|
|
600
607
|
updateActiveTab(tab);
|
|
@@ -643,10 +650,16 @@ function TabProvider(_ref9) {
|
|
|
643
650
|
}
|
|
644
651
|
}
|
|
645
652
|
(_payload$tab_info = payload.tab_info) === null || _payload$tab_info === void 0 || delete _payload$tab_info.isClientChanged;
|
|
646
|
-
|
|
653
|
+
clientTabId = tab.id;
|
|
654
|
+
previousOpenAbort = openTabAbortByClientIdRef.current[clientTabId];
|
|
655
|
+
if (previousOpenAbort) {
|
|
656
|
+
previousOpenAbort.abort();
|
|
657
|
+
}
|
|
658
|
+
openTabAbortController = new AbortController();
|
|
659
|
+
openTabAbortByClientIdRef.current[clientTabId] = openTabAbortController;
|
|
647
660
|
currentOpenTabCallerRef.current = payload.tab_info;
|
|
648
661
|
_context5.n = 3;
|
|
649
|
-
return handleOpenTab(payload);
|
|
662
|
+
return handleOpenTab(payload, openTabAbortController);
|
|
650
663
|
case 3:
|
|
651
664
|
response = _context5.v;
|
|
652
665
|
if (!(response.status === 1)) {
|
|
@@ -749,12 +762,19 @@ function TabProvider(_ref9) {
|
|
|
749
762
|
case 9:
|
|
750
763
|
_context5.p = 9;
|
|
751
764
|
_t = _context5.v;
|
|
752
|
-
if (
|
|
753
|
-
|
|
765
|
+
if (_t instanceof DOMException && _t.name === 'AbortError') {
|
|
766
|
+
// Tab closed or superseded while open was in progress
|
|
767
|
+
} else {
|
|
768
|
+
if (window.isDebugOn) {
|
|
769
|
+
alertService === null || alertService === void 0 || alertService.error(_t.message ? _t.message : 'Error in opening tab!');
|
|
770
|
+
}
|
|
771
|
+
console.log("openTab - error", _t);
|
|
754
772
|
}
|
|
755
|
-
console.log("openTab - error", _t);
|
|
756
773
|
case 10:
|
|
757
774
|
_context5.p = 10;
|
|
775
|
+
if (openTabAbortController != null && openTabAbortByClientIdRef.current[tab.id] === openTabAbortController) {
|
|
776
|
+
delete openTabAbortByClientIdRef.current[tab.id];
|
|
777
|
+
}
|
|
758
778
|
currentOpenTabCallerRef.current = null;
|
|
759
779
|
return _context5.f(10);
|
|
760
780
|
case 11:
|
|
@@ -1094,8 +1114,10 @@ function TabProvider(_ref9) {
|
|
|
1094
1114
|
tab,
|
|
1095
1115
|
_ref25$isSubTab,
|
|
1096
1116
|
isSubTab,
|
|
1097
|
-
|
|
1117
|
+
pendingOpenAbort,
|
|
1098
1118
|
_activeSubTabRef$curr5,
|
|
1119
|
+
response,
|
|
1120
|
+
_activeSubTabRef$curr6,
|
|
1099
1121
|
tabId,
|
|
1100
1122
|
updatedTabModePreference,
|
|
1101
1123
|
_args8 = arguments,
|
|
@@ -1231,7 +1253,21 @@ function TabProvider(_ref9) {
|
|
|
1231
1253
|
break;
|
|
1232
1254
|
}
|
|
1233
1255
|
console.log('Tab id not found', tab);
|
|
1234
|
-
|
|
1256
|
+
pendingOpenAbort = openTabAbortByClientIdRef.current[tab.id];
|
|
1257
|
+
if (pendingOpenAbort) {
|
|
1258
|
+
pendingOpenAbort.abort();
|
|
1259
|
+
delete openTabAbortByClientIdRef.current[tab.id];
|
|
1260
|
+
}
|
|
1261
|
+
if (isSubTab && activeSubTabRef.current) {
|
|
1262
|
+
if (isSubTab && ((_activeSubTabRef$curr5 = activeSubTabRef.current) === null || _activeSubTabRef$curr5 === void 0 ? void 0 : _activeSubTabRef$curr5.open_order) > 2) {
|
|
1263
|
+
updateCurrentTab({
|
|
1264
|
+
tab: activeSubTabRef.current,
|
|
1265
|
+
isSubTab: true,
|
|
1266
|
+
parentId: activeTabRef.current.id
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
activeSubTabRef.current.open_order = 1;
|
|
1270
|
+
}
|
|
1235
1271
|
return _context8.a(2);
|
|
1236
1272
|
case 2:
|
|
1237
1273
|
_context8.n = 3;
|
|
@@ -1245,7 +1281,7 @@ function TabProvider(_ref9) {
|
|
|
1245
1281
|
console.log('closeTab - response.current_tab_id', response.current_tab_id, activeSubTabRef.current);
|
|
1246
1282
|
// if (isSubTab && response.current_tab_id !== activeSubTabRef.current?.tabId ) {
|
|
1247
1283
|
if (isSubTab && activeSubTabRef.current) {
|
|
1248
|
-
if (isSubTab && ((_activeSubTabRef$
|
|
1284
|
+
if (isSubTab && ((_activeSubTabRef$curr6 = activeSubTabRef.current) === null || _activeSubTabRef$curr6 === void 0 ? void 0 : _activeSubTabRef$curr6.open_order) > 2) {
|
|
1249
1285
|
updateCurrentTab({
|
|
1250
1286
|
tab: activeSubTabRef.current,
|
|
1251
1287
|
isSubTab: true,
|
|
@@ -1486,7 +1522,7 @@ function TabProvider(_ref9) {
|
|
|
1486
1522
|
if (currentEntityId != null && currentEntityId != undefined) {
|
|
1487
1523
|
var fetchTabDetails = /*#__PURE__*/function () {
|
|
1488
1524
|
var _ref29 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
1489
|
-
var href, orgId, payload, response, _response$current_tab, _response$current_tab2, _response$current_tab4, pathName, isHomeTab, tabsOutputWithoutDuplicates, tabsOutput, _activeTab, _activeSubTab, currentActiveTab, _activeTab2, _response$current_tab3, tab_info, rest, flattenedObj, isCurrentTabOpen, openedParentTab, updatedParentTab, flattenedParentObj, parentTab, _activeSubTabRef$
|
|
1525
|
+
var href, orgId, payload, response, _response$current_tab, _response$current_tab2, _response$current_tab4, pathName, isHomeTab, tabsOutputWithoutDuplicates, tabsOutput, _activeTab, _activeSubTab, currentActiveTab, _activeTab2, _response$current_tab3, tab_info, rest, flattenedObj, isCurrentTabOpen, openedParentTab, updatedParentTab, flattenedParentObj, parentTab, _activeSubTabRef$curr7, parentTabFromData, _flattenedParentObj, _tab_info, _rest, _flattenedObj, isSubTab, parent, parentTabInfo, parentRest, _flattenedParentObj2, tabsMap, restTabs, id, _tabsMap$id, _activeSubTab$tabId, _activeSubTab2, _activeTab3, tabId, isEditMode, tempTabModePreference, updated, _t8;
|
|
1490
1526
|
return _regenerator().w(function (_context10) {
|
|
1491
1527
|
while (1) switch (_context10.p = _context10.n) {
|
|
1492
1528
|
case 0:
|
|
@@ -1617,7 +1653,7 @@ function TabProvider(_ref9) {
|
|
|
1617
1653
|
name: 'Loading...',
|
|
1618
1654
|
title: ''
|
|
1619
1655
|
});
|
|
1620
|
-
if ((_activeSubTabRef$
|
|
1656
|
+
if ((_activeSubTabRef$curr7 = activeSubTabRef.current) !== null && _activeSubTabRef$curr7 !== void 0 && _activeSubTabRef$curr7.tabId) _activeSubTab.tabId = activeSubTabRef.current.tabId;
|
|
1621
1657
|
case 10:
|
|
1622
1658
|
_context10.n = 12;
|
|
1623
1659
|
break;
|