dce-reactkit 3.6.2 → 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.
@@ -60,6 +60,6 @@ export declare const addFatalErrorHandler: (handler: () => void) => void;
60
60
  * Show the "session expired" message
61
61
  * @author Gabe Abrams
62
62
  */
63
- export declare const showSessionExpiredMessage: () => void;
63
+ export declare const showSessionExpiredMessage: () => Promise<void>;
64
64
  declare const AppWrapper: React.FC<Props>;
65
65
  export default AppWrapper;
@@ -1,9 +1,3 @@
1
- /**
2
- * Set the session expiry handler
3
- * @author Gabe Abrams
4
- * @param handler new handler to use when session expires
5
- */
6
- export declare const setSessionExpiryHandler: (handler: () => void) => void;
7
1
  /**
8
2
  * Add a stub response
9
3
  * @author Gabe Abrams
package/dist/esm/index.js CHANGED
@@ -644,8 +644,6 @@ var LogLevel;
644
644
  })(LogLevel || (LogLevel = {}));
645
645
  var LogLevel$1 = LogLevel;
646
646
 
647
- // Keep track of whether or not session expiry has already been handled
648
- let sessionAlreadyExpired = false;
649
647
  /*------------------------------------------------------------------------*/
650
648
  /* Stub Logic */
651
649
  /*------------------------------------------------------------------------*/
@@ -728,20 +726,7 @@ const visitServerEndpoint = (opts) => __awaiter(void 0, void 0, void 0, function
728
726
  if (!response.body.success) {
729
727
  // Session expired
730
728
  if (response.body.code === ReactKitErrorCode$1.SessionExpired) {
731
- // Skip notice if session was already expired
732
- if (sessionAlreadyExpired) {
733
- // Never return (browser is already reloading)
734
- yield new Promise(() => {
735
- // Promise that never returns
736
- });
737
- }
738
- sessionAlreadyExpired = true;
739
- // Show session expiration message
740
- {
741
- // Fallback to alert
742
- // eslint-disable-next-line no-alert
743
- alert('Your session has expired. Please start over.');
744
- }
729
+ showSessionExpiredMessage();
745
730
  // Never return (don't continue execution)
746
731
  yield new Promise(() => {
747
732
  // Promise that never returns
@@ -869,7 +854,7 @@ let onAlertClosed;
869
854
  * @param title the title text to display at the top of the alert
870
855
  * @param text the text to display in the alert
871
856
  */
872
- const alert$1 = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
857
+ const alert = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
873
858
  // Wait for helper to exist
874
859
  yield waitForHelper(() => {
875
860
  return !!setAlertInfo;
@@ -990,7 +975,7 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(vo
990
975
  });
991
976
  // Handle case where app hasn't loaded
992
977
  if (!setFatalErrorMessage || !setFatalErrorCode) {
993
- alert$1(errorTitle, `${message} (code: ${code}). Please contact support.`);
978
+ alert(errorTitle, `${message} (code: ${code}). Please contact support.`);
994
979
  return;
995
980
  }
996
981
  // Use setters
@@ -1005,6 +990,28 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(vo
1005
990
  const addFatalErrorHandler = (handler) => {
1006
991
  fatalErrorHandlers.push(handler);
1007
992
  };
993
+ /*----------------------------------------*/
994
+ /* ----------- Session Expired ---------- */
995
+ /*----------------------------------------*/
996
+ // Stored copies of setters
997
+ let setSessionHasExpired;
998
+ /**
999
+ * Show the "session expired" message
1000
+ * @author Gabe Abrams
1001
+ */
1002
+ const showSessionExpiredMessage = () => __awaiter(void 0, void 0, void 0, function* () {
1003
+ // Wait for helper to exist
1004
+ yield waitForHelper(() => {
1005
+ return !!setSessionHasExpired;
1006
+ });
1007
+ // Show session expired message
1008
+ if (setSessionHasExpired) {
1009
+ setSessionHasExpired(true);
1010
+ }
1011
+ else {
1012
+ showFatalError('Your session has expired. Please start over.', 'Session Expired');
1013
+ }
1014
+ });
1008
1015
  /*------------------------------------------------------------------------*/
1009
1016
  /* -------------------------------- Style ------------------------------- */
1010
1017
  /*------------------------------------------------------------------------*/
@@ -1057,6 +1064,7 @@ const AppWrapper = (props) => {
1057
1064
  setConfirmInfo = setConfirmInfoInner;
1058
1065
  // Session expired
1059
1066
  const [sessionHasExpired, setSessionHasExpiredInner,] = useState(false);
1067
+ setSessionHasExpired = setSessionHasExpiredInner;
1060
1068
  /*------------------------------------------------------------------------*/
1061
1069
  /* ------------------------------- Render ------------------------------- */
1062
1070
  /*------------------------------------------------------------------------*/
@@ -2083,7 +2091,7 @@ const CopiableBox = (props) => {
2083
2091
  yield navigator.clipboard.writeText(text);
2084
2092
  }
2085
2093
  catch (err) {
2086
- return alert$1('Unable to copy', 'Oops! We couldn\'t copy that to the clipboard. Please copy the text manually.');
2094
+ return alert('Unable to copy', 'Oops! We couldn\'t copy that to the clipboard. Please copy the text manually.');
2087
2095
  }
2088
2096
  // Show copied notice
2089
2097
  dispatch({
@@ -2672,7 +2680,7 @@ const IntelliTable = (props) => {
2672
2680
  return !isSelected;
2673
2681
  }));
2674
2682
  if (noColumnsSelected) {
2675
- return alert$1('Choose at least one column', 'To continue, you have to choose at least one column to show');
2683
+ return alert('Choose at least one column', 'To continue, you have to choose at least one column to show');
2676
2684
  }
2677
2685
  dispatch({
2678
2686
  type: ActionType$6.ToggleColVisCusModalVisibility,
@@ -3684,7 +3692,7 @@ const LogReviewer = (props) => {
3684
3692
  || (year === dateFilterState.startDate.year
3685
3693
  && month === dateFilterState.startDate.month
3686
3694
  && day < dateFilterState.startDate.day)) {
3687
- return alert$1('Invalid Start Date', 'The start date cannot be before the end date.');
3695
+ return alert('Invalid Start Date', 'The start date cannot be before the end date.');
3688
3696
  }
3689
3697
  dateFilterState.endDate = { month, day, year };
3690
3698
  handleDateRangeUpdated(dateFilterState);
@@ -40181,7 +40189,7 @@ const AddOrEditDBEntry = (props) => {
40181
40189
  React__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* () {
40182
40190
  // Show validation errors
40183
40191
  if (validationError && validationError.length > 0) {
40184
- return alert$1('Please fix the following error', validationError);
40192
+ return alert('Please fix the following error', validationError);
40185
40193
  }
40186
40194
  // Run the included validator if it exists
40187
40195
  if (validateEntry) {
@@ -40189,7 +40197,7 @@ const AddOrEditDBEntry = (props) => {
40189
40197
  yield validateEntry(entry);
40190
40198
  }
40191
40199
  catch (error) {
40192
- return alert$1('Please fix the following error', String(error));
40200
+ return alert('Please fix the following error', String(error));
40193
40201
  }
40194
40202
  }
40195
40203
  save();
@@ -43072,5 +43080,5 @@ var DayOfWeek;
43072
43080
  })(DayOfWeek || (DayOfWeek = {}));
43073
43081
  var DayOfWeek$1 = DayOfWeek;
43074
43082
 
43075
- export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert$1 as alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
43083
+ export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
43076
43084
  //# sourceMappingURL=index.js.map