@copart/ops-tool-kit 1.8.1-alpha.4 → 1.8.1-alpha.6

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.
@@ -33,7 +33,7 @@ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
33
33
  var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
34
34
 
35
35
  const name$f = "@copart/ops-tool-kit";
36
- const version$5 = "1.8.1-alpha.4";
36
+ const version$5 = "1.8.1-alpha.6";
37
37
  const main$1 = "dist/ops-tool-kit.js";
38
38
  const style = "dist/ops-tool-kit.css";
39
39
  const files = [
@@ -35524,10 +35524,10 @@ function filterOutNotificationForOtherAppsFirebase(notifications) {
35524
35524
  }
35525
35525
 
35526
35526
  function filterOutNotificationForOtherApps(notifications) {
35527
- var currentApp = window.location.pathname === '/' ? 'home' : window.location.pathname.split('/')[1];
35527
+ var currentApp = window.location.pathname === '/' ? 'home' : window.location.pathname;
35528
35528
  var tilesConfig = storage$1.getLocalItem('opsportal-core:config').tiles || [];
35529
35529
  var tile = tilesConfig.find(function (item) {
35530
- return item.path === "/".concat(currentApp);
35530
+ return item.path === currentApp;
35531
35531
  }) || {};
35532
35532
  return notifications.filter(function (notification) {
35533
35533
  var targetApps = pathOr$1(null, ['targetAudience', 'targetApplications'])(notification);
@@ -36700,6 +36700,12 @@ var AppBar$1 = function AppBar(props) {
36700
36700
  return width > 760 ? '40vw' : width > 500 ? '70vw' : '80vw';
36701
36701
  };
36702
36702
 
36703
+ var closeSidebar = function closeSidebar(e) {
36704
+ if (e.target.className.includes("sideBarWrapper")) {
36705
+ setNotificationsVisible(false);
36706
+ }
36707
+ };
36708
+
36703
36709
  return React__default["default"].createElement("div", {
36704
36710
  "data-e2e": "cc-AppBar",
36705
36711
  className: "utilities_ops-app-frame_AppBarComponent_AppBar--root"
@@ -36805,7 +36811,8 @@ var AppBar$1 = function AppBar(props) {
36805
36811
  backgroundColor: 'white'
36806
36812
  }
36807
36813
  })), notificationsVisible && React__default["default"].createElement("div", {
36808
- className: "utilities_ops-app-frame_AppBarComponent_AppBar--sideBarWrapper"
36814
+ className: "utilities_ops-app-frame_AppBarComponent_AppBar--sideBarWrapper",
36815
+ onClick: closeSidebar
36809
36816
  }, React__default["default"].createElement("div", {
36810
36817
  className: "utilities_ops-app-frame_AppBarComponent_AppBar--innerNotificationDiv",
36811
36818
  style: {
@@ -42039,7 +42046,8 @@ var generateQuery = function generateQuery(yardNumber, email) {
42039
42046
  var EndDateTs = moment(new Date()).local().format("YYYY-MM-DDTHH:mm:ss[Z]");
42040
42047
  var startDateTsUTC = moment.utc(new Date()).add(1, 'days').format("YYYY-MM-DDTHH:mm:ss[Z]");
42041
42048
  var EndDateTsUTC = moment.utc(new Date()).format("YYYY-MM-DDTHH:mm:ss[Z]");
42042
- return "fq=(facilities:".concat(yardNumber, " OR user_details:\"").concat(email, "\")&fq=((start_date_timezone:\"UTC\" AND end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTsUTC, "] AND end_date_ts_utc:[").concat(EndDateTsUTC, " TO *]) OR (!start_date_timezone:\"UTC\" AND !end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTs, "] AND end_date_ts_utc:[").concat(EndDateTs, " TO *]) OR (!start_date_timezone:\"UTC\" AND end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTs, "] AND end_date_ts_utc:[").concat(EndDateTsUTC, " TO *]))&fq=(operating_country_a3_code:\"USA\")&fq=status:A&rows=10000&q=*:*");
42049
+ var countryCode = storage$1.getSessionItem('dashboard', 'selectedCountryA3code');
42050
+ return "fq=(facilities:".concat(yardNumber, " OR user_details:\"").concat(email, "\" OR group_user_details:\"").concat(email, "\")&fq=((start_date_timezone:\"UTC\" AND end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTsUTC, "] AND end_date_ts_utc:[").concat(EndDateTsUTC, " TO *]) OR (!start_date_timezone:\"UTC\" AND !end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTs, "] AND end_date_ts_utc:[").concat(EndDateTs, " TO *]) OR (!start_date_timezone:\"UTC\" AND end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTs, "] AND end_date_ts_utc:[").concat(EndDateTsUTC, " TO *]))&fq=(operating_country_a3_code:\"").concat(countryCode, "\")&fq=status:A&rows=10000&q=*:*");
42043
42051
  };
42044
42052
 
42045
42053
  var generateTargets = function generateTargets(notification) {
@@ -42085,7 +42093,7 @@ function fetchG2Notifications(updateNotifications, updateAllNotificationsList) {
42085
42093
  var headers = {
42086
42094
  collection: "notifications",
42087
42095
  serviceName: "notification",
42088
- Country: "USA"
42096
+ Country: storage$1.getSessionItem('dashboard', 'selectedCountryA3code')
42089
42097
  };
42090
42098
  fetcher.get("".concat(endpoints.getG2NotificationsSolr, "?").concat(query), {
42091
42099
  headers: headers
@@ -42105,10 +42113,10 @@ function fetchG2Notifications(updateNotifications, updateAllNotificationsList) {
42105
42113
  notification.sourcePlatform = notification.source_platform;
42106
42114
  notification.timeZoneType = notification.timezone_type;
42107
42115
  notification.targetAudience = {
42108
- targetApplications: [{
42116
+ targetApplications: notification.applications ? [{
42109
42117
  platform: notification.source_platform,
42110
42118
  applications: notification.applications
42111
- }],
42119
+ }] : null,
42112
42120
  targets: _toConsumableArray(generateTargets(notification))
42113
42121
  };
42114
42122
  return notification;
@@ -49919,6 +49927,88 @@ var getFireBaseNotifications = function getFireBaseNotifications(updateNotificat
49919
49927
  attachHandlers(updateNotifications);
49920
49928
  };
49921
49929
 
49930
+ var allAreTruthy = all$1(equals$1(true));
49931
+ var yardNumberAllowed = function yardNumberAllowed(yardNumber, tile) {
49932
+ var _tile$yardRules, _tile$yardRules$allow, _tile$yardRules2, _tile$yardRules3;
49933
+
49934
+ // Pass if yardNumber is specifically allowed or if it is not specifically denied.
49935
+ return ((_tile$yardRules = tile.yardRules) === null || _tile$yardRules === void 0 ? void 0 : (_tile$yardRules$allow = _tile$yardRules.allow) === null || _tile$yardRules$allow === void 0 ? void 0 : _tile$yardRules$allow.length) ? includes$1(yardNumber, (_tile$yardRules2 = tile.yardRules) === null || _tile$yardRules2 === void 0 ? void 0 : _tile$yardRules2.allow) : !includes$1(yardNumber, (_tile$yardRules3 = tile.yardRules) === null || _tile$yardRules3 === void 0 ? void 0 : _tile$yardRules3.deny);
49936
+ };
49937
+ var securityLevelAllowed = function securityLevelAllowed(securityLevel, tile) {
49938
+ var _tile$securityLevelRu, _tile$securityLevelRu2;
49939
+
49940
+ // Pass if securityLevel is not in not array or if greater than the lessThan array.
49941
+ return !includes$1(securityLevel, (_tile$securityLevelRu = tile.securityLevelRules) === null || _tile$securityLevelRu === void 0 ? void 0 : _tile$securityLevelRu.not) && ((_tile$securityLevelRu2 = tile.securityLevelRules) === null || _tile$securityLevelRu2 === void 0 ? void 0 : _tile$securityLevelRu2.lessThan) > Number(securityLevel);
49942
+ };
49943
+ var emailAddressAllowed = function emailAddressAllowed(emailAddress, tile) {
49944
+ var _tile$userRules, _tile$userRules2;
49945
+
49946
+ // Pass if no emails specified or if email is in allow array.
49947
+ return isEmpty$2((_tile$userRules = tile.userRules) === null || _tile$userRules === void 0 ? void 0 : _tile$userRules.allow) || includes$1(emailAddress, (_tile$userRules2 = tile.userRules) === null || _tile$userRules2 === void 0 ? void 0 : _tile$userRules2.allow);
49948
+ }; // permissionIds are for selected role only
49949
+
49950
+ var appFunctionIdAllowed = function appFunctionIdAllowed() {
49951
+ var coreAppPermissions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
49952
+ var tile = arguments.length > 1 ? arguments[1] : undefined;
49953
+ var id = tile.appFunctionId;
49954
+
49955
+ if (!id) {
49956
+ return true; // not defined in config so just allow the tile to be viewed for now
49957
+ }
49958
+ /* else if (['view_miorg', 'view_mitime', 'view_midriverpay'].includes(id)) {
49959
+ // special case for miorg/mitime to check all permissions
49960
+ return includes(id, allPermissionIds)
49961
+ } else {
49962
+ return includes(id, permissionIds)
49963
+ } */
49964
+ // Check appfunction in opsportal-core permissions
49965
+ else {
49966
+ return !isEmpty$2(coreAppPermissions) && !isNil$1(coreAppPermissions.find(function (permission) {
49967
+ return permission.name === id;
49968
+ }));
49969
+ }
49970
+ };
49971
+ var stackIsAllowed = function stackIsAllowed(stack) {
49972
+ return stack ? stack === global.STACK : true;
49973
+ }; // require cas access is a configurable flag per tile
49974
+ // while hasAccess is defined at the user level determined by me service
49975
+
49976
+ var casAccessAllowed = function casAccessAllowed(hasCasAccess) {
49977
+ var requireCasAccess = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
49978
+ // this is just a check for usres who are currently logged in
49979
+ if (isNil$1(hasCasAccess)) return true;
49980
+ return requireCasAccess === false || requireCasAccess && hasCasAccess;
49981
+ };
49982
+
49983
+ var getUserData = function getUserData() {
49984
+ return {
49985
+ activeYardNumber: storage$1.activeYardNumber,
49986
+ securityLevel: storage$1.userSecurityLevel,
49987
+ emailAddress: storage$1.userEmail,
49988
+ permissionIds: storage$1.permissionIds,
49989
+ allPermissionIds: storage$1.allPermissionIds,
49990
+ hasCasAccess: storage$1.hasCasAccess,
49991
+ coreAppPermissions: storage$1.coreAppPermissions
49992
+ };
49993
+ };
49994
+
49995
+ var userHasAccess = function userHasAccess(tile) {
49996
+ var user = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getUserData();
49997
+ return allAreTruthy([stackIsAllowed(tile.stack), yardNumberAllowed(user.activeYardNumber, tile), securityLevelAllowed(user.securityLevel, tile), emailAddressAllowed(user.emailAddress, tile), appFunctionIdAllowed(user.coreAppPermissions, tile), casAccessAllowed(user.hasCasAccess, tile.requireCasAccess)]);
49998
+ };
49999
+
50000
+ var accessHelpers = /*#__PURE__*/Object.freeze({
50001
+ __proto__: null,
50002
+ yardNumberAllowed: yardNumberAllowed,
50003
+ securityLevelAllowed: securityLevelAllowed,
50004
+ emailAddressAllowed: emailAddressAllowed,
50005
+ appFunctionIdAllowed: appFunctionIdAllowed,
50006
+ stackIsAllowed: stackIsAllowed,
50007
+ casAccessAllowed: casAccessAllowed,
50008
+ userHasAccess: userHasAccess,
50009
+ 'default': userHasAccess
50010
+ });
50011
+
49922
50012
  var css_248z$2 = ".utilities_ops-app-frame_AppBar_AppBar--AppBar {\n background: var(--primaryBlue);\n background: var(--primaryBlue);\n color: var(--white);\n color: var(--white);\n height: 64px;\n width: 100vw;\n padding: 0 20px;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n}\n\n.__AppBar-item.__AppBar-phoneUnvailable > div, .__AppBar-item.__AppBar-phoneAvailable > div {\n margin-bottom: 2px;\n}\n\nbutton[name='Clear Cookies'] {\n font-size: 12px;\n opacity: 0.5;\n text-transform: uppercase;\n color: #f00;\n font-weight: 700;\n}\n\n.utilities_ops-app-frame_AppBar_AppBar--left {\n display: flex;\n align-items: center;\n}\n\n.utilities_ops-app-frame_AppBar_AppBar--right {\n display: flex;\n align-items: center;\n}\n";
49923
50013
  styleInject(css_248z$2);
49924
50014
 
@@ -49969,7 +50059,8 @@ var AppBar = function AppBar(_ref) {
49969
50059
  setAppBarMounted = _ref.setAppBarMounted,
49970
50060
  onSettingsSaved = _ref.onSettingsSaved,
49971
50061
  showTitle = _ref.showTitle,
49972
- title = _ref.title;
50062
+ title = _ref.title,
50063
+ pathname = _ref.pathname;
49973
50064
  SETTINGS_ITEMS[0].name = storage$1.userName; // Escape hatch for forceUpdate function
49974
50065
 
49975
50066
  var _useReducer = React.useReducer(function (x) {
@@ -50139,8 +50230,16 @@ var AppBar = function AppBar(_ref) {
50139
50230
  setNotifications([]);
50140
50231
  setListOfAllNotifications([]);
50141
50232
  socketClient && socketClient.close();
50233
+ var currentTile = coreAppConfig.tiles.find(function (tile) {
50234
+ return tile.path === window.location.pathname;
50235
+ });
50236
+ var tileConfigAccess = true;
50237
+
50238
+ if (currentTile) {
50239
+ tileConfigAccess = userHasAccess(currentTile);
50240
+ }
50142
50241
 
50143
- if (history.location.pathname !== '/logout') {
50242
+ if (history.location.pathname !== '/logout' && tileConfigAccess) {
50144
50243
  if (notificationsSource.includes('Nchan')) {
50145
50244
  fetchG2Notifications(updateNotifications, updateAllNotificationsList);
50146
50245
  setSocketClient(startWebSocketConnection(updateNotifications, updateAllNotificationsList));
@@ -50151,7 +50250,7 @@ var AppBar = function AppBar(_ref) {
50151
50250
  setFirebaseinitialized(true);
50152
50251
  }
50153
50252
  }
50154
- }, [selectedYard]);
50253
+ }, [selectedYard, pathname]);
50155
50254
  React.useEffect(function () {
50156
50255
  var interval = setInterval(function () {
50157
50256
  if (listOfAllNotifications.length) {
@@ -50230,88 +50329,6 @@ AppBar.defaultProps = {
50230
50329
  searchBarProps: {}
50231
50330
  };
50232
50331
 
50233
- var allAreTruthy = all$1(equals$1(true));
50234
- var yardNumberAllowed = function yardNumberAllowed(yardNumber, tile) {
50235
- var _tile$yardRules, _tile$yardRules$allow, _tile$yardRules2, _tile$yardRules3;
50236
-
50237
- // Pass if yardNumber is specifically allowed or if it is not specifically denied.
50238
- return ((_tile$yardRules = tile.yardRules) === null || _tile$yardRules === void 0 ? void 0 : (_tile$yardRules$allow = _tile$yardRules.allow) === null || _tile$yardRules$allow === void 0 ? void 0 : _tile$yardRules$allow.length) ? includes$1(yardNumber, (_tile$yardRules2 = tile.yardRules) === null || _tile$yardRules2 === void 0 ? void 0 : _tile$yardRules2.allow) : !includes$1(yardNumber, (_tile$yardRules3 = tile.yardRules) === null || _tile$yardRules3 === void 0 ? void 0 : _tile$yardRules3.deny);
50239
- };
50240
- var securityLevelAllowed = function securityLevelAllowed(securityLevel, tile) {
50241
- var _tile$securityLevelRu, _tile$securityLevelRu2;
50242
-
50243
- // Pass if securityLevel is not in not array or if greater than the lessThan array.
50244
- return !includes$1(securityLevel, (_tile$securityLevelRu = tile.securityLevelRules) === null || _tile$securityLevelRu === void 0 ? void 0 : _tile$securityLevelRu.not) && ((_tile$securityLevelRu2 = tile.securityLevelRules) === null || _tile$securityLevelRu2 === void 0 ? void 0 : _tile$securityLevelRu2.lessThan) > Number(securityLevel);
50245
- };
50246
- var emailAddressAllowed = function emailAddressAllowed(emailAddress, tile) {
50247
- var _tile$userRules, _tile$userRules2;
50248
-
50249
- // Pass if no emails specified or if email is in allow array.
50250
- return isEmpty$2((_tile$userRules = tile.userRules) === null || _tile$userRules === void 0 ? void 0 : _tile$userRules.allow) || includes$1(emailAddress, (_tile$userRules2 = tile.userRules) === null || _tile$userRules2 === void 0 ? void 0 : _tile$userRules2.allow);
50251
- }; // permissionIds are for selected role only
50252
-
50253
- var appFunctionIdAllowed = function appFunctionIdAllowed() {
50254
- var coreAppPermissions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
50255
- var tile = arguments.length > 1 ? arguments[1] : undefined;
50256
- var id = tile.appFunctionId;
50257
-
50258
- if (!id) {
50259
- return true; // not defined in config so just allow the tile to be viewed for now
50260
- }
50261
- /* else if (['view_miorg', 'view_mitime', 'view_midriverpay'].includes(id)) {
50262
- // special case for miorg/mitime to check all permissions
50263
- return includes(id, allPermissionIds)
50264
- } else {
50265
- return includes(id, permissionIds)
50266
- } */
50267
- // Check appfunction in opsportal-core permissions
50268
- else {
50269
- return !isEmpty$2(coreAppPermissions) && !isNil$1(coreAppPermissions.find(function (permission) {
50270
- return permission.name === id;
50271
- }));
50272
- }
50273
- };
50274
- var stackIsAllowed = function stackIsAllowed(stack) {
50275
- return stack ? stack === global.STACK : true;
50276
- }; // require cas access is a configurable flag per tile
50277
- // while hasAccess is defined at the user level determined by me service
50278
-
50279
- var casAccessAllowed = function casAccessAllowed(hasCasAccess) {
50280
- var requireCasAccess = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
50281
- // this is just a check for usres who are currently logged in
50282
- if (isNil$1(hasCasAccess)) return true;
50283
- return requireCasAccess === false || requireCasAccess && hasCasAccess;
50284
- };
50285
-
50286
- var getUserData = function getUserData() {
50287
- return {
50288
- activeYardNumber: storage$1.activeYardNumber,
50289
- securityLevel: storage$1.userSecurityLevel,
50290
- emailAddress: storage$1.userEmail,
50291
- permissionIds: storage$1.permissionIds,
50292
- allPermissionIds: storage$1.allPermissionIds,
50293
- hasCasAccess: storage$1.hasCasAccess,
50294
- coreAppPermissions: storage$1.coreAppPermissions
50295
- };
50296
- };
50297
-
50298
- var userHasAccess = function userHasAccess(tile) {
50299
- var user = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getUserData();
50300
- return allAreTruthy([stackIsAllowed(tile.stack), yardNumberAllowed(user.activeYardNumber, tile), securityLevelAllowed(user.securityLevel, tile), emailAddressAllowed(user.emailAddress, tile), appFunctionIdAllowed(user.coreAppPermissions, tile), casAccessAllowed(user.hasCasAccess, tile.requireCasAccess)]);
50301
- };
50302
-
50303
- var accessHelpers = /*#__PURE__*/Object.freeze({
50304
- __proto__: null,
50305
- yardNumberAllowed: yardNumberAllowed,
50306
- securityLevelAllowed: securityLevelAllowed,
50307
- emailAddressAllowed: emailAddressAllowed,
50308
- appFunctionIdAllowed: appFunctionIdAllowed,
50309
- stackIsAllowed: stackIsAllowed,
50310
- casAccessAllowed: casAccessAllowed,
50311
- userHasAccess: userHasAccess,
50312
- 'default': userHasAccess
50313
- });
50314
-
50315
50332
  var css_248z$1 = ".utilities_ops-app-frame_AuthGuard_header--header {\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n}";
50316
50333
  styleInject(css_248z$1);
50317
50334
 
@@ -50555,7 +50572,8 @@ var AppFrame = function AppFrame(props) {
50555
50572
  return location.reload();
50556
50573
  },
50557
50574
  showTitle: props.showTitle || true,
50558
- title: props.appTitle
50575
+ title: props.appTitle,
50576
+ pathname: props.location.pathname
50559
50577
  })), React__default["default"].createElement(Breadcrumbs, {
50560
50578
  history: props.history,
50561
50579
  pathname: window.location.pathname