@copart/ops-tool-kit 1.13.0-beta.6 → 1.13.0-beta.8

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.
@@ -47,7 +47,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
47
47
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
48
48
 
49
49
  const name$1 = "@copart/ops-tool-kit";
50
- const version$3 = "1.13.0-beta.6";
50
+ const version$3 = "1.13.0-beta.8";
51
51
  const main$1 = "dist/ops-tool-kit.js";
52
52
  const style = "dist/ops-tool-kit.css";
53
53
  const files = [
@@ -28991,9 +28991,26 @@ var getCurrentApp = function getCurrentApp() {
28991
28991
  return app;
28992
28992
  };
28993
28993
  var buildTargetingClause = function buildTargetingClause(yardNumber, email) {
28994
- var app = encodeURIComponent(getCurrentApp());
28995
- var clauses = ["(facilities:".concat(yardNumber, " AND -user_details:* AND -applications:* AND -group_user_details:*)"), "(-facilities:* AND user_details:\"".concat(email, "\" AND -applications:* AND -group_user_details:*)"), "(-facilities:* AND -user_details:* AND applications:\"".concat(app, "\" AND -group_user_details:*)"), "(-facilities:* AND -user_details:* AND -applications:* AND group_user_details:\"".concat(email, "\")"), "(facilities:".concat(yardNumber, " AND user_details:\"").concat(email, "\" AND -applications:* AND -group_user_details:*)"), "(facilities:".concat(yardNumber, " AND -user_details:* AND applications:\"").concat(app, "\" AND -group_user_details:*)"), "(facilities:".concat(yardNumber, " AND -user_details:* AND -applications:* AND group_user_details:\"").concat(email, "\")"), "(-facilities:* AND user_details:\"".concat(email, "\" AND applications:\"").concat(app, "\" AND -group_user_details:*)"), "(-facilities:* AND user_details:\"".concat(email, "\" AND -applications:* AND group_user_details:\"").concat(email, "\")"), "(-facilities:* AND -user_details:* AND applications:\"".concat(app, "\" AND group_user_details:\"").concat(email, "\")"), "(facilities:".concat(yardNumber, " AND user_details:\"").concat(email, "\" AND applications:\"").concat(app, "\" AND -group_user_details:*)"), "(facilities:".concat(yardNumber, " AND user_details:\"").concat(email, "\" AND -applications:* AND group_user_details:\"").concat(email, "\")"), "(facilities:".concat(yardNumber, " AND -user_details:* AND applications:\"").concat(app, "\" AND group_user_details:\"").concat(email, "\")"), "(-facilities:* AND user_details:\"".concat(email, "\" AND applications:\"").concat(app, "\" AND group_user_details:\"").concat(email, "\")"), "(facilities:".concat(yardNumber, " AND user_details:\"").concat(email, "\" AND applications:\"").concat(app, "\" AND group_user_details:\"").concat(email, "\")")];
28996
- return clauses.join(' OR ');
28994
+ encodeURIComponent(getCurrentApp());
28995
+ // const clauses = [
28996
+ // `(facilities:${yardNumber} AND -user_details:* AND -applications:* AND -group_user_details:*)`,
28997
+ // `(-facilities:* AND user_details:"${email}" AND -applications:* AND -group_user_details:*)`,
28998
+ // `(-facilities:* AND -user_details:* AND applications:"${app}" AND -group_user_details:*)`,
28999
+ // `(-facilities:* AND -user_details:* AND -applications:* AND group_user_details:"${email}")`,
29000
+ // `(facilities:${yardNumber} AND user_details:"${email}" AND -applications:* AND -group_user_details:*)`,
29001
+ // `(facilities:${yardNumber} AND -user_details:* AND applications:"${app}" AND -group_user_details:*)`,
29002
+ // `(facilities:${yardNumber} AND -user_details:* AND -applications:* AND group_user_details:"${email}")`,
29003
+ // `(-facilities:* AND user_details:"${email}" AND applications:"${app}" AND -group_user_details:*)`,
29004
+ // `(-facilities:* AND user_details:"${email}" AND -applications:* AND group_user_details:"${email}")`,
29005
+ // `(-facilities:* AND -user_details:* AND applications:"${app}" AND group_user_details:"${email}")`,
29006
+ // `(facilities:${yardNumber} AND user_details:"${email}" AND applications:"${app}" AND -group_user_details:*)`,
29007
+ // `(facilities:${yardNumber} AND user_details:"${email}" AND -applications:* AND group_user_details:"${email}")`,
29008
+ // `(facilities:${yardNumber} AND -user_details:* AND applications:"${app}" AND group_user_details:"${email}")`,
29009
+ // `(-facilities:* AND user_details:"${email}" AND applications:"${app}" AND group_user_details:"${email}")`,
29010
+ // `(facilities:${yardNumber} AND user_details:"${email}" AND applications:"${app}" AND group_user_details:"${email}")`,
29011
+ // ]
29012
+ // return clauses.join(' OR ')
29013
+ return "(facilities:".concat(yardNumber, " OR user_details:\"").concat(email, "\" OR group_user_details:\"").concat(email, "\")");
28997
29014
  };
28998
29015
  var generateQuery = function generateQuery(yardNumber, email) {
28999
29016
  var startDateTs = moment(new Date()).add(1, 'days').local().format('YYYY-MM-DDTHH:mm:ss[Z]');
@@ -29092,6 +29109,9 @@ function fetchG2Notifications(updateNotifications, updateAllNotificationsList) {
29092
29109
  function startWebSocketConnection(updateNotifications, updateAllNotificationsList, reConnectSocket, updateUserStatus) {
29093
29110
  var _storage$getSessionIt, _storage$getSessionIt2;
29094
29111
  var callbacks = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
29112
+ if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
29113
+ return;
29114
+ }
29095
29115
  var onOpen = callbacks.onOpen,
29096
29116
  onClose = callbacks.onClose;
29097
29117
  var coreAppConfig = storage$2.getLocalItem('opsportal-core:config');
@@ -30496,6 +30516,7 @@ var AppBar = function AppBar(_ref) {
30496
30516
  document.removeEventListener('visibilitychange', handleVisibilityChange);
30497
30517
  };
30498
30518
  }, [socketClient]);
30519
+ var notificationsReloadPathKey = pathname === '/embedded' || pathname && pathname.startsWith('/embedded/') ? pathname : '__non_embedded__';
30499
30520
  React.useEffect(function () {
30500
30521
  setNotifications([]);
30501
30522
  setListOfAllNotifications([]);
@@ -30640,7 +30661,7 @@ var AppBar = function AppBar(_ref) {
30640
30661
  }
30641
30662
  }
30642
30663
  }
30643
- }, [selectedYard, pathname]);
30664
+ }, [selectedYard, notificationsReloadPathKey]);
30644
30665
  React.useEffect(function () {
30645
30666
  var interval = setInterval(function () {
30646
30667
  var allNotifications = listOfAllNotificationsRef.current;
@@ -30671,6 +30692,7 @@ var AppBar = function AppBar(_ref) {
30671
30692
  };
30672
30693
  }, []);
30673
30694
  React.useEffect(function () {
30695
+ if (coreAppConfig !== null && coreAppConfig !== void 0 && coreAppConfig.disableHeartbeat) return;
30674
30696
  var heartBeatEnabledStatuses = ((coreAppConfig === null || coreAppConfig === void 0 ? void 0 : coreAppConfig.heartBeatEnabledStatuses) || ['available']).map(function (s) {
30675
30697
  var _s$toLowerCase2;
30676
30698
  return (s === null || s === void 0 ? void 0 : (_s$toLowerCase2 = s.toLowerCase) === null || _s$toLowerCase2 === void 0 ? void 0 : _s$toLowerCase2.call(s)) || '';
@@ -63683,7 +63705,8 @@ var NavigationBar = function NavigationBar(_ref2) {
63683
63705
  showNavIconInHeader = _ref2.showNavIconInHeader,
63684
63706
  isNavBarOpen = _ref2.isNavBarOpen,
63685
63707
  _ref2$showLevel3Navig = _ref2.showLevel3Navigation,
63686
- showLevel3Navigation = _ref2$showLevel3Navig === void 0 ? false : _ref2$showLevel3Navig;
63708
+ showLevel3Navigation = _ref2$showLevel3Navig === void 0 ? false : _ref2$showLevel3Navig,
63709
+ basePath = _ref2.basePath;
63687
63710
  // const withCounts = getCounts && typeof getCounts === 'function'
63688
63711
  var navigateFunction = navigateTo || (history === null || history === void 0 ? void 0 : history.push) || defaultRedirect;
63689
63712
  var _useState = React.useState(null),
@@ -63765,7 +63788,8 @@ var NavigationBar = function NavigationBar(_ref2) {
63765
63788
  countsRef: countsRef,
63766
63789
  countAutoReloadDisabled: countAutoReloadDisabled,
63767
63790
  onNavSectionToggle: onNavSectionToggle,
63768
- showLevel3Navigation: showLevel3Navigation
63791
+ showLevel3Navigation: showLevel3Navigation,
63792
+ basePath: basePath
63769
63793
  }) : null, isConfigValid === false ? /*#__PURE__*/React__default["default"].createElement("div", null, "Please check your navigation config") : null);
63770
63794
  };
63771
63795
  var NavigationMenu = function NavigationMenu(_ref3) {
@@ -63786,8 +63810,10 @@ var NavigationMenu = function NavigationMenu(_ref3) {
63786
63810
  countAutoReloadDisabled = _ref3.countAutoReloadDisabled,
63787
63811
  onNavSectionToggle = _ref3.onNavSectionToggle,
63788
63812
  _ref3$showLevel3Navig = _ref3.showLevel3Navigation,
63789
- showLevel3Navigation = _ref3$showLevel3Navig === void 0 ? false : _ref3$showLevel3Navig;
63790
- var redirectUrl = window.location.pathname;
63813
+ showLevel3Navigation = _ref3$showLevel3Navig === void 0 ? false : _ref3$showLevel3Navig,
63814
+ basePath = _ref3.basePath;
63815
+ var rawUrl = window.location.pathname;
63816
+ var redirectUrl = basePath && rawUrl.startsWith(basePath) ? rawUrl.slice(basePath.length) || '/' : rawUrl;
63791
63817
  var _useState11 = React.useState(null),
63792
63818
  _useState12 = _slicedToArray(_useState11, 2),
63793
63819
  counts = _useState12[0],
@@ -63796,7 +63822,7 @@ var NavigationMenu = function NavigationMenu(_ref3) {
63796
63822
  React.useEffect(function () {
63797
63823
  if (redirectUrl != '/') {
63798
63824
  var splitUrl = redirectUrl.split('/');
63799
- if (!process.env.IS_CORE_APP) {
63825
+ if (!process.env.IS_CORE_APP && !basePath) {
63800
63826
  splitUrl.shift();
63801
63827
  }
63802
63828
  // if (splitUrl.length - 1 === configDepth) {
@@ -64588,7 +64614,8 @@ var AppFrame = function AppFrame(props) {
64588
64614
  onNavSectionToggle: props.onNavSectionToggle,
64589
64615
  showNavIconInHeader: props === null || props === void 0 ? void 0 : props.showNavIconInHeader,
64590
64616
  isNavBarOpen: isNavBarOpen,
64591
- showLevel3Navigation: props.showLevel3Navigation
64617
+ showLevel3Navigation: props.showLevel3Navigation,
64618
+ basePath: props.navBasePath
64592
64619
  }) : null, /*#__PURE__*/React__default["default"].createElement("div", {
64593
64620
  style: {
64594
64621
  marginLeft: props.showNavigation && !(props !== null && props !== void 0 && props.showNavIconInHeader) ? navigationWidth : '0px',
@@ -68292,6 +68319,27 @@ function setInitCache(initData) {
68292
68319
  if (initData.login != null) cache.local.login = initData.login;
68293
68320
  if (initData.settings != null) cache.local.settings = initData.settings;
68294
68321
  if (initData.dashboard != null) cache.session.dashboard = initData.dashboard;
68322
+ // Shell sends config/coreAppPermissions under shorthand keys; map to canonical keys bridge getters expect
68323
+ if (initData.config != null && initData['opsportal-core:config'] == null) {
68324
+ cache.local['opsportal-core:config'] = initData.config;
68325
+ console.log('[iframe-bridge/storage] setInitCache mapped config -> opsportal-core:config');
68326
+ }
68327
+ if (initData.coreAppPermissions != null && initData['ops_portal:permissions'] == null) {
68328
+ cache.local['ops_portal:permissions'] = initData.coreAppPermissions;
68329
+ console.log('[iframe-bridge/storage] setInitCache mapped coreAppPermissions -> ops_portal:permissions', {
68330
+ count: Array.isArray(initData.coreAppPermissions) ? initData.coreAppPermissions.length : 'not-array'
68331
+ });
68332
+ }
68333
+ var appPermKeys = Object.keys(initData).filter(function (k) {
68334
+ return k.endsWith(':permissions') && k !== 'ops_portal:permissions';
68335
+ });
68336
+ appPermKeys.forEach(function (k) {
68337
+ cache.local[k] = initData[k];
68338
+ console.log('[iframe-bridge/storage] setInitCache mapped app permissions', {
68339
+ key: k,
68340
+ count: Array.isArray(initData[k]) ? initData[k].length : 'not-array'
68341
+ });
68342
+ });
68295
68343
  }
68296
68344
  function setExtraLocal(key, value) {
68297
68345
  cache.local[key] = value;
@@ -68780,17 +68828,93 @@ Object.assign(fetcher, {
68780
68828
  }(),
68781
68829
  getPermissions: function () {
68782
68830
  var _getPermissions = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee3(appName, useAppScopes) {
68783
- var response;
68831
+ var permissions, userAppScopes, allAppScopesAndFunctions, appEntry, _appEntry$scopes, appFunctionsMap, _config$endpoints, _response$data, _response$data$applic, config, endpoint, url, country, response, appDetails, _t;
68784
68832
  return _regenerator().w(function (_context3) {
68785
- while (1) switch (_context3.n) {
68833
+ while (1) switch (_context3.p = _context3.n) {
68786
68834
  case 0:
68787
- _context3.n = 1;
68788
- return fetcher.get("/api/permissions/".concat(appName));
68789
- case 1:
68835
+ console.log('[iframe-bridge/fetcher] getPermissions called', {
68836
+ appName: appName,
68837
+ useAppScopes: useAppScopes
68838
+ });
68839
+ _context3.p = 1;
68840
+ permissions = [];
68841
+ if (!useAppScopes) {
68842
+ _context3.n = 2;
68843
+ break;
68844
+ }
68845
+ userAppScopes = Array.isArray(storage$1.userAppScopes) ? storage$1.userAppScopes : [];
68846
+ allAppScopesAndFunctions = storage$1.appScopesAndFunctions;
68847
+ appEntry = Array.isArray(allAppScopesAndFunctions) ? allAppScopesAndFunctions.find(function (s) {
68848
+ return s.appName === appName;
68849
+ }) : null;
68850
+ console.log('[iframe-bridge/fetcher] getPermissions (useAppScopes)', {
68851
+ appEntryFound: Boolean(appEntry),
68852
+ userAppScopesCount: userAppScopes.length
68853
+ });
68854
+ if (appEntry) {
68855
+ appFunctionsMap = {};
68856
+ (_appEntry$scopes = appEntry.scopes) === null || _appEntry$scopes === void 0 ? void 0 : _appEntry$scopes.forEach(function (scope) {
68857
+ var userHasScope = userAppScopes.find(function (s) {
68858
+ return s.appName === appName && s.scopeName === scope.appscope;
68859
+ });
68860
+ if (userHasScope) {
68861
+ var _scope$applicationFun;
68862
+ (_scope$applicationFun = scope.applicationFunctions) === null || _scope$applicationFun === void 0 ? void 0 : _scope$applicationFun.forEach(function (fn) {
68863
+ if (!appFunctionsMap[fn]) {
68864
+ appFunctionsMap[fn] = {
68865
+ name: fn,
68866
+ description: fn,
68867
+ hierarchyDetails: userHasScope.hierarchies
68868
+ };
68869
+ }
68870
+ });
68871
+ }
68872
+ });
68873
+ permissions = Object.values(appFunctionsMap);
68874
+ }
68875
+ _context3.n = 4;
68876
+ break;
68877
+ case 2:
68878
+ config = storage$1.getLocalItem('opsportal-core:config') || storage$1.getLocalItem('config');
68879
+ endpoint = config === null || config === void 0 ? void 0 : (_config$endpoints = config.endpoints) === null || _config$endpoints === void 0 ? void 0 : _config$endpoints.g2AppPermissions;
68880
+ url = endpoint ? "".concat(endpoint).concat(appName) : "/api/permissions/".concat(appName);
68881
+ country = storage$1.getSessionItem('dashboard', 'selectedCountryA3code');
68882
+ console.log('[iframe-bridge/fetcher] getPermissions fetching', {
68883
+ url: url,
68884
+ country: country
68885
+ });
68886
+ _context3.n = 3;
68887
+ return fetcher.get(url, {
68888
+ headers: {
68889
+ country: country,
68890
+ source: 'OPS_PORTAL'
68891
+ }
68892
+ });
68893
+ case 3:
68790
68894
  response = _context3.v;
68791
- return _context3.a(2, response.data);
68895
+ appDetails = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$applic = _response$data.applications) === null || _response$data$applic === void 0 ? void 0 : _response$data$applic.find(function (app) {
68896
+ return app.name === appName;
68897
+ });
68898
+ if (appDetails) {
68899
+ permissions = appDetails.applicationFunctions;
68900
+ }
68901
+ case 4:
68902
+ console.log('[iframe-bridge/fetcher] getPermissions stored', {
68903
+ appName: appName,
68904
+ count: permissions.length
68905
+ });
68906
+ storage$1.setLocalItem("".concat(appName, ":permissions"), permissions);
68907
+ return _context3.a(2, permissions);
68908
+ case 5:
68909
+ _context3.p = 5;
68910
+ _t = _context3.v;
68911
+ console.warn('[iframe-bridge/fetcher] getPermissions failed', {
68912
+ appName: appName,
68913
+ error: (_t === null || _t === void 0 ? void 0 : _t.message) || _t
68914
+ });
68915
+ return _context3.a(2, []);
68792
68916
  }
68793
- }, _callee3);
68917
+ }, _callee3, null, [[1, 5]]);
68794
68918
  }));
68795
68919
  function getPermissions(_x2, _x3) {
68796
68920
  return _getPermissions.apply(this, arguments);
@@ -68814,21 +68938,21 @@ Object.assign(fetcher, {
68814
68938
  getUserPreferences: function () {
68815
68939
  var _getUserPreferences = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee5() {
68816
68940
  var appName,
68817
- _config$endpoints,
68941
+ _config$endpoints2,
68818
68942
  config,
68819
68943
  urlTemplate,
68820
68944
  url,
68821
68945
  country,
68822
68946
  response,
68823
68947
  _args5 = arguments,
68824
- _t;
68948
+ _t2;
68825
68949
  return _regenerator().w(function (_context5) {
68826
68950
  while (1) switch (_context5.p = _context5.n) {
68827
68951
  case 0:
68828
68952
  appName = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : '';
68829
68953
  _context5.p = 1;
68830
68954
  config = storage$1.getLocalItem('opsportal-core:config');
68831
- urlTemplate = config === null || config === void 0 ? void 0 : (_config$endpoints = config.endpoints) === null || _config$endpoints === void 0 ? void 0 : _config$endpoints.userPreferences;
68955
+ urlTemplate = config === null || config === void 0 ? void 0 : (_config$endpoints2 = config.endpoints) === null || _config$endpoints2 === void 0 ? void 0 : _config$endpoints2.userPreferences;
68832
68956
  if (urlTemplate) {
68833
68957
  _context5.n = 2;
68834
68958
  break;
@@ -68849,8 +68973,8 @@ Object.assign(fetcher, {
68849
68973
  return _context5.a(2, response.data);
68850
68974
  case 4:
68851
68975
  _context5.p = 4;
68852
- _t = _context5.v;
68853
- return _context5.a(2, Promise.reject(_t));
68976
+ _t2 = _context5.v;
68977
+ return _context5.a(2, Promise.reject(_t2));
68854
68978
  }
68855
68979
  }, _callee5, null, [[1, 4]]);
68856
68980
  }));
@@ -68863,14 +68987,14 @@ Object.assign(fetcher, {
68863
68987
  var _setUserPreferences = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee6() {
68864
68988
  var appName,
68865
68989
  data,
68866
- _config$endpoints2,
68990
+ _config$endpoints3,
68867
68991
  config,
68868
68992
  urlTemplate,
68869
68993
  url,
68870
68994
  country,
68871
68995
  response,
68872
68996
  _args6 = arguments,
68873
- _t2;
68997
+ _t3;
68874
68998
  return _regenerator().w(function (_context6) {
68875
68999
  while (1) switch (_context6.p = _context6.n) {
68876
69000
  case 0:
@@ -68878,7 +69002,7 @@ Object.assign(fetcher, {
68878
69002
  data = _args6.length > 1 ? _args6[1] : undefined;
68879
69003
  _context6.p = 1;
68880
69004
  config = storage$1.getLocalItem('opsportal-core:config');
68881
- urlTemplate = config === null || config === void 0 ? void 0 : (_config$endpoints2 = config.endpoints) === null || _config$endpoints2 === void 0 ? void 0 : _config$endpoints2.userPreferences;
69005
+ urlTemplate = config === null || config === void 0 ? void 0 : (_config$endpoints3 = config.endpoints) === null || _config$endpoints3 === void 0 ? void 0 : _config$endpoints3.userPreferences;
68882
69006
  if (urlTemplate) {
68883
69007
  _context6.n = 2;
68884
69008
  break;
@@ -68899,8 +69023,8 @@ Object.assign(fetcher, {
68899
69023
  return _context6.a(2, response.statusText);
68900
69024
  case 4:
68901
69025
  _context6.p = 4;
68902
- _t2 = _context6.v;
68903
- return _context6.a(2, Promise.reject(_t2));
69026
+ _t3 = _context6.v;
69027
+ return _context6.a(2, Promise.reject(_t3));
68904
69028
  }
68905
69029
  }, _callee6, null, [[1, 4]]);
68906
69030
  }));
@@ -68911,13 +69035,13 @@ Object.assign(fetcher, {
68911
69035
  }(),
68912
69036
  getPrintersForYard: function () {
68913
69037
  var _getPrintersForYard = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee7(yardNumber) {
68914
- var _config$endpoints3, config, url, response;
69038
+ var _config$endpoints4, config, url, response;
68915
69039
  return _regenerator().w(function (_context7) {
68916
69040
  while (1) switch (_context7.p = _context7.n) {
68917
69041
  case 0:
68918
69042
  _context7.p = 0;
68919
69043
  config = storage$1.getLocalItem('opsportal-core:config');
68920
- url = config === null || config === void 0 ? void 0 : (_config$endpoints3 = config.endpoints) === null || _config$endpoints3 === void 0 ? void 0 : _config$endpoints3.printersByYard;
69044
+ url = config === null || config === void 0 ? void 0 : (_config$endpoints4 = config.endpoints) === null || _config$endpoints4 === void 0 ? void 0 : _config$endpoints4.printersByYard;
68921
69045
  if (url) {
68922
69046
  _context7.n = 1;
68923
69047
  break;