dce-reactkit 3.6.3 → 3.6.4

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/cjs/index.js CHANGED
@@ -670,38 +670,6 @@ var LogLevel;
670
670
  })(LogLevel || (LogLevel = {}));
671
671
  var LogLevel$1 = LogLevel;
672
672
 
673
- /*------------------------------------------------------------------------*/
674
- /* --------------------------- Static Helpers --------------------------- */
675
- /*------------------------------------------------------------------------*/
676
- // Timestamp after initialization when helpers should be available
677
- const timestampWhenHelpersShouldBeAvailable$1 = Date.now() + 2000;
678
- /**
679
- * Wait for a little while for a helper to exist
680
- * @author Gabe Abrams
681
- * @param checkForHelper a function that returns true if the helper exists
682
- * @returns true if the helper exists, false if the process timed out
683
- */
684
- const waitForHelper$1 = (checkForHelper) => __awaiter(void 0, void 0, void 0, function* () {
685
- // Wait for helper to exist
686
- while (!checkForHelper()) {
687
- // Check if we should stop waiting
688
- if (Date.now() > timestampWhenHelpersShouldBeAvailable$1) {
689
- // Stop waiting
690
- return false;
691
- }
692
- // Wait a little while
693
- yield waitMs(10);
694
- }
695
- // Helper exists
696
- return true;
697
- });
698
- /*------------------------------------------------------------------------*/
699
- /* Listener */
700
- /*------------------------------------------------------------------------*/
701
- // Handler for session expiry
702
- let sessionExpiryHandler;
703
- // Keep track of whether or not session expiry has already been handled
704
- let sessionAlreadyExpired = false;
705
673
  /*------------------------------------------------------------------------*/
706
674
  /* Stub Logic */
707
675
  /*------------------------------------------------------------------------*/
@@ -784,24 +752,7 @@ const visitServerEndpoint = (opts) => __awaiter(void 0, void 0, void 0, function
784
752
  if (!response.body.success) {
785
753
  // Session expired
786
754
  if (response.body.code === ReactKitErrorCode$1.SessionExpired) {
787
- // Skip notice if session was already expired
788
- if (sessionAlreadyExpired) {
789
- // Never return (browser is already reloading)
790
- yield new Promise(() => {
791
- // Promise that never returns
792
- });
793
- }
794
- sessionAlreadyExpired = true;
795
- // Wait for helper to exist
796
- yield waitForHelper$1(() => {
797
- return !!sessionExpiryHandler;
798
- });
799
- // Show session expiration message
800
- {
801
- // Fallback to alert
802
- // eslint-disable-next-line no-alert
803
- alert('Your session has expired. Please start over.');
804
- }
755
+ showSessionExpiredMessage();
805
756
  // Never return (don't continue execution)
806
757
  yield new Promise(() => {
807
758
  // Promise that never returns
@@ -929,7 +880,7 @@ let onAlertClosed;
929
880
  * @param title the title text to display at the top of the alert
930
881
  * @param text the text to display in the alert
931
882
  */
932
- const alert$1 = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
883
+ const alert = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
933
884
  // Wait for helper to exist
934
885
  yield waitForHelper(() => {
935
886
  return !!setAlertInfo;
@@ -1050,7 +1001,7 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(vo
1050
1001
  });
1051
1002
  // Handle case where app hasn't loaded
1052
1003
  if (!setFatalErrorMessage || !setFatalErrorCode) {
1053
- alert$1(errorTitle, `${message} (code: ${code}). Please contact support.`);
1004
+ alert(errorTitle, `${message} (code: ${code}). Please contact support.`);
1054
1005
  return;
1055
1006
  }
1056
1007
  // Use setters
@@ -1065,6 +1016,28 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(vo
1065
1016
  const addFatalErrorHandler = (handler) => {
1066
1017
  fatalErrorHandlers.push(handler);
1067
1018
  };
1019
+ /*----------------------------------------*/
1020
+ /* ----------- Session Expired ---------- */
1021
+ /*----------------------------------------*/
1022
+ // Stored copies of setters
1023
+ let setSessionHasExpired;
1024
+ /**
1025
+ * Show the "session expired" message
1026
+ * @author Gabe Abrams
1027
+ */
1028
+ const showSessionExpiredMessage = () => __awaiter(void 0, void 0, void 0, function* () {
1029
+ // Wait for helper to exist
1030
+ yield waitForHelper(() => {
1031
+ return !!setSessionHasExpired;
1032
+ });
1033
+ // Show session expired message
1034
+ if (setSessionHasExpired) {
1035
+ setSessionHasExpired(true);
1036
+ }
1037
+ else {
1038
+ showFatalError('Your session has expired. Please start over.', 'Session Expired');
1039
+ }
1040
+ });
1068
1041
  /*------------------------------------------------------------------------*/
1069
1042
  /* -------------------------------- Style ------------------------------- */
1070
1043
  /*------------------------------------------------------------------------*/
@@ -1117,6 +1090,7 @@ const AppWrapper = (props) => {
1117
1090
  setConfirmInfo = setConfirmInfoInner;
1118
1091
  // Session expired
1119
1092
  const [sessionHasExpired, setSessionHasExpiredInner,] = React.useState(false);
1093
+ setSessionHasExpired = setSessionHasExpiredInner;
1120
1094
  /*------------------------------------------------------------------------*/
1121
1095
  /* ------------------------------- Render ------------------------------- */
1122
1096
  /*------------------------------------------------------------------------*/
@@ -2143,7 +2117,7 @@ const CopiableBox = (props) => {
2143
2117
  yield navigator.clipboard.writeText(text);
2144
2118
  }
2145
2119
  catch (err) {
2146
- return alert$1('Unable to copy', 'Oops! We couldn\'t copy that to the clipboard. Please copy the text manually.');
2120
+ return alert('Unable to copy', 'Oops! We couldn\'t copy that to the clipboard. Please copy the text manually.');
2147
2121
  }
2148
2122
  // Show copied notice
2149
2123
  dispatch({
@@ -2732,7 +2706,7 @@ const IntelliTable = (props) => {
2732
2706
  return !isSelected;
2733
2707
  }));
2734
2708
  if (noColumnsSelected) {
2735
- return alert$1('Choose at least one column', 'To continue, you have to choose at least one column to show');
2709
+ return alert('Choose at least one column', 'To continue, you have to choose at least one column to show');
2736
2710
  }
2737
2711
  dispatch({
2738
2712
  type: ActionType$6.ToggleColVisCusModalVisibility,
@@ -3744,7 +3718,7 @@ const LogReviewer = (props) => {
3744
3718
  || (year === dateFilterState.startDate.year
3745
3719
  && month === dateFilterState.startDate.month
3746
3720
  && day < dateFilterState.startDate.day)) {
3747
- return alert$1('Invalid Start Date', 'The start date cannot be before the end date.');
3721
+ return alert('Invalid Start Date', 'The start date cannot be before the end date.');
3748
3722
  }
3749
3723
  dateFilterState.endDate = { month, day, year };
3750
3724
  handleDateRangeUpdated(dateFilterState);
@@ -40241,7 +40215,7 @@ const AddOrEditDBEntry = (props) => {
40241
40215
  React__default["default"].createElement("button", { type: "button", id: "AddOrEditDBEntry-save-changes-button", className: "btn btn-primary btn-lg me-1", "aria-label": "Save changes", onClick: () => __awaiter(void 0, void 0, void 0, function* () {
40242
40216
  // Show validation errors
40243
40217
  if (validationError && validationError.length > 0) {
40244
- return alert$1('Please fix the following error', validationError);
40218
+ return alert('Please fix the following error', validationError);
40245
40219
  }
40246
40220
  // Run the included validator if it exists
40247
40221
  if (validateEntry) {
@@ -40249,7 +40223,7 @@ const AddOrEditDBEntry = (props) => {
40249
40223
  yield validateEntry(entry);
40250
40224
  }
40251
40225
  catch (error) {
40252
- return alert$1('Please fix the following error', String(error));
40226
+ return alert('Please fix the following error', String(error));
40253
40227
  }
40254
40228
  }
40255
40229
  save();
@@ -43174,7 +43148,7 @@ exports.Variant = Variant$1;
43174
43148
  exports.abbreviate = abbreviate;
43175
43149
  exports.addDBEditorEndpoints = addDBEditorEndpoints;
43176
43150
  exports.addFatalErrorHandler = addFatalErrorHandler;
43177
- exports.alert = alert$1;
43151
+ exports.alert = alert;
43178
43152
  exports.avg = avg;
43179
43153
  exports.canReviewLogs = canReviewLogs;
43180
43154
  exports.ceilToNumDecimals = ceilToNumDecimals;