@copart/ops-tool-kit 1.12.13-alpha.2 → 1.13.0-beta.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.
@@ -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.12.13-alpha.2";
50
+ const version$3 = "1.13.0-beta.1";
51
51
  const main$1 = "dist/ops-tool-kit.js";
52
52
  const style = "dist/ops-tool-kit.css";
53
53
  const files = [
@@ -9340,55 +9340,76 @@ var ConfigFetcher = /*#__PURE__*/function (_React$Component) {
9340
9340
  _defineProperty$2(_this, "state", {
9341
9341
  gotConfig: false
9342
9342
  });
9343
+ _defineProperty$2(_this, "_fetchVersion", 0);
9344
+ _defineProperty$2(_this, "fetchConfig", /*#__PURE__*/_asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee() {
9345
+ var _window$toolkitEnv, _window$toolkitEnv2, _window$toolkitEnv3;
9346
+ var fetchVersion, isCoreApp, configUri, config;
9347
+ return _regenerator().w(function (_context) {
9348
+ while (1) switch (_context.n) {
9349
+ case 0:
9350
+ fetchVersion = ++_this._fetchVersion;
9351
+ isCoreApp = (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
9352
+ if (!(isCoreApp && (isCoreRoute || isAuthRoute) && !storage$1.isAuthenticated)) {
9353
+ _context.n = 1;
9354
+ break;
9355
+ }
9356
+ return _context.a(2, _this.setState({
9357
+ gotConfig: true
9358
+ }));
9359
+ case 1:
9360
+ configUri = (_window$toolkitEnv2 = window.toolkitEnv) !== null && _window$toolkitEnv2 !== void 0 && _window$toolkitEnv2.CONFIG_URI ? window.toolkitEnv.CONFIG_URI : process.env.CONFIG_URI;
9361
+ console.log('[ConfigFetcher] fetching config from:', configUri, 'APP_NAME:', (_window$toolkitEnv3 = window.toolkitEnv) === null || _window$toolkitEnv3 === void 0 ? void 0 : _window$toolkitEnv3.APP_NAME);
9362
+ _context.n = 2;
9363
+ return fetcher.getConfig(configUri);
9364
+ case 2:
9365
+ config = _context.v;
9366
+ if (!(_this._fetchVersion !== fetchVersion)) {
9367
+ _context.n = 3;
9368
+ break;
9369
+ }
9370
+ return _context.a(2);
9371
+ case 3:
9372
+ storage$1.setItem('config', config);
9373
+ if (config.instanaKey) {
9374
+ window.setUpInstana(config.instanaKey, isCoreApp);
9375
+ }
9376
+ _this.setState({
9377
+ gotConfig: true
9378
+ });
9379
+ case 4:
9380
+ return _context.a(2);
9381
+ }
9382
+ }, _callee);
9383
+ })));
9343
9384
  return _this;
9344
9385
  }
9345
9386
  _inherits$2(ConfigFetcher, _React$Component);
9346
9387
  return _createClass$2(ConfigFetcher, [{
9347
9388
  key: "componentDidMount",
9348
9389
  value: function () {
9349
- var _componentDidMount = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee() {
9350
- var _window$toolkitEnv, _window$toolkitEnv2;
9351
- var isCoreApp, configUri, config;
9352
- return _regenerator().w(function (_context) {
9353
- while (1) switch (_context.n) {
9390
+ var _componentDidMount = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee2() {
9391
+ return _regenerator().w(function (_context2) {
9392
+ while (1) switch (_context2.n) {
9354
9393
  case 0:
9355
- // If it is the core app and we are on a core route or auth route
9356
- // and the user is not authenticated, don't fetch config.
9357
- isCoreApp = (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
9358
- if (!(isCoreApp && (isCoreRoute || isAuthRoute) && !storage$1.isAuthenticated)) {
9359
- _context.n = 1;
9360
- break;
9361
- }
9362
- return _context.a(2, this.setState(function (state) {
9363
- return {
9364
- gotConfig: true
9365
- };
9366
- }));
9394
+ _context2.n = 1;
9395
+ return this.fetchConfig();
9367
9396
  case 1:
9368
- configUri = (_window$toolkitEnv2 = window.toolkitEnv) !== null && _window$toolkitEnv2 !== void 0 && _window$toolkitEnv2.CONFIG_URI ? window.toolkitEnv.CONFIG_URI : process.env.CONFIG_URI;
9369
- _context.n = 2;
9370
- return fetcher.getConfig(configUri);
9397
+ window.addEventListener('toolkitenv-changed', this.fetchConfig);
9371
9398
  case 2:
9372
- config = _context.v;
9373
- storage$1.setItem('config', config);
9374
- if (config.instanaKey) {
9375
- window.setUpInstana(config.instanaKey, isCoreApp);
9376
- }
9377
- this.setState(function (state) {
9378
- return {
9379
- gotConfig: true
9380
- };
9381
- });
9382
- case 3:
9383
- return _context.a(2);
9399
+ return _context2.a(2);
9384
9400
  }
9385
- }, _callee, this);
9401
+ }, _callee2, this);
9386
9402
  }));
9387
9403
  function componentDidMount() {
9388
9404
  return _componentDidMount.apply(this, arguments);
9389
9405
  }
9390
9406
  return componentDidMount;
9391
9407
  }()
9408
+ }, {
9409
+ key: "componentWillUnmount",
9410
+ value: function componentWillUnmount() {
9411
+ window.removeEventListener('toolkitenv-changed', this.fetchConfig);
9412
+ }
9392
9413
  }, {
9393
9414
  key: "render",
9394
9415
  value: function render() {
@@ -30245,6 +30266,7 @@ var AppBar = function AppBar(_ref) {
30245
30266
  var socketRetryCountRef = React.useRef(0);
30246
30267
  var socketClientRef = React.useRef(null);
30247
30268
  var reconnectingRef = React.useRef(false);
30269
+ var heartbeatStopRef = React.useRef(null);
30248
30270
  var _useState15 = React.useState(null),
30249
30271
  _useState16 = _slicedToArray(_useState15, 2),
30250
30272
  pingInterval = _useState16[0],
@@ -30413,6 +30435,9 @@ var AppBar = function AppBar(_ref) {
30413
30435
  handleUserStatusUpdate(availableStatus);
30414
30436
  };
30415
30437
  var handleSystemOfflineStayOffline = function handleSystemOfflineStayOffline() {
30438
+ var _heartbeatStopRef$cur;
30439
+ (_heartbeatStopRef$cur = heartbeatStopRef.current) === null || _heartbeatStopRef$cur === void 0 ? void 0 : _heartbeatStopRef$cur.call(heartbeatStopRef);
30440
+ heartbeatStopRef.current = null;
30416
30441
  var offlineStatus = getOfflineStatusFromAvailable(availableStatuses);
30417
30442
  handleUserStatusUpdate(offlineStatus);
30418
30443
  };
@@ -30502,25 +30527,23 @@ var AppBar = function AppBar(_ref) {
30502
30527
  if (history.location.pathname !== '/logout' && history.location.pathname !== '/login' && localStorage.getItem('login') && tileConfigAccess) {
30503
30528
  if (notificationsSource.includes('Nchan')) {
30504
30529
  fetchG2Notifications(updateNotifications, updateAllNotificationsList);
30505
- if (!(window.navigator.userAgent.includes('Chrome') && window.location.href.includes('localhost'))) {
30506
- var client = startWebSocketConnection(updateNotifications, updateAllNotificationsList, _reConnectSocket, updateUserStatusFromWebSocket, {
30507
- onOpen: function onOpen() {
30508
- reconnectingRef.current = false;
30509
- },
30510
- onClose: function onClose() {
30511
- reconnectingRef.current = false;
30512
- }
30513
- });
30514
- if (client) {
30515
- socketClientRef.current = client;
30516
- var pingIntervalInSec = coreAppConfig.nchanPingIntervalInSec || 30;
30517
- setPingInterval(setInterval(function () {
30518
- if (client.readyState === WebSocket.OPEN) {
30519
- client.send('_ping_');
30520
- }
30521
- }, pingIntervalInSec * 1000));
30522
- setSocketClient(client);
30530
+ var client = startWebSocketConnection(updateNotifications, updateAllNotificationsList, _reConnectSocket, updateUserStatusFromWebSocket, {
30531
+ onOpen: function onOpen() {
30532
+ reconnectingRef.current = false;
30533
+ },
30534
+ onClose: function onClose() {
30535
+ reconnectingRef.current = false;
30523
30536
  }
30537
+ });
30538
+ if (client) {
30539
+ socketClientRef.current = client;
30540
+ var pingIntervalInSec = coreAppConfig.nchanPingIntervalInSec || 30;
30541
+ setPingInterval(setInterval(function () {
30542
+ if (client.readyState === WebSocket.OPEN) {
30543
+ client.send('_ping_');
30544
+ }
30545
+ }, pingIntervalInSec * 1000));
30546
+ setSocketClient(client);
30524
30547
  }
30525
30548
  }
30526
30549
  var loadUserStatus = /*#__PURE__*/function () {
@@ -30598,11 +30621,11 @@ var AppBar = function AppBar(_ref) {
30598
30621
  _context5.p = 10;
30599
30622
  _t7 = _context5.v;
30600
30623
  console.error('Failed to load user status:', _t7);
30601
- if (_t7.message && _t7.message.includes('available statuses')) {
30602
- showError('Failed to fetch available statuses.');
30603
- } else {
30604
- showError('Failed to fetch user status.');
30605
- }
30624
+ // if (error.message && error.message.includes('available statuses')) {
30625
+ // showError('Failed to fetch available statuses.')
30626
+ // } else {
30627
+ // showError('Failed to fetch user status.')
30628
+ // }
30606
30629
  case 11:
30607
30630
  return _context5.a(2);
30608
30631
  }
@@ -30684,7 +30707,9 @@ var AppBar = function AppBar(_ref) {
30684
30707
  userInteractionIntervalMs: userInteractionIntervalMs,
30685
30708
  userKey: userKey
30686
30709
  });
30710
+ heartbeatStopRef.current = stopCoordinator;
30687
30711
  return function () {
30712
+ heartbeatStopRef.current = null;
30688
30713
  interactionEvents.forEach(function (event) {
30689
30714
  document.removeEventListener(event, updateLastInteractionTime);
30690
30715
  });