dce-reactkit 4.2.0-beta-select-admin-check.1 → 4.2.0

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.
@@ -2,5 +2,5 @@
2
2
  * Route for checking if the current user is a select admin
3
3
  * @author Gabe Abrams
4
4
  */
5
- declare const SELECT_ADMIN_CHECK_ROUTE: string;
5
+ declare const SELECT_ADMIN_CHECK_ROUTE = "/api/admin/select/is-select-admin";
6
6
  export default SELECT_ADMIN_CHECK_ROUTE;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Checks if the current user is a select admin
3
+ * @author Gardenia Liu
4
+ * @returns true if the user is a select admin, false otherwise
5
+ */
6
+ declare const isSelectAdmin: () => Promise<boolean>;
7
+ export default isSelectAdmin;
@@ -81,6 +81,7 @@ import shuffleArray from './helpers/shuffleArray';
81
81
  import getWordCount from './helpers/getWordCount';
82
82
  import cloneDeep from './helpers/cloneDeep';
83
83
  import getTimestampFromTimeInfoInET from './helpers/getTimestampFromTimeInfoInET';
84
+ import isSelectAdmin from './helpers/isSelectAdmin';
84
85
  import ParamType from './types/ParamType';
85
86
  import ModalButtonType from './types/ModalButtonType';
86
87
  import ModalSize from './types/ModalSize';
@@ -106,4 +107,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
106
107
  import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
107
108
  import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
108
109
  import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
109
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, SimpleTimeChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, LOG_REVIEW_GET_LOGS_ROUTE, SELECT_ADMIN_CHECK_ROUTE, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, ParamType, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, IntelliTableColumn, DropdownItemType, LogReviewerFilterState, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, };
110
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, SimpleTimeChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, LOG_REVIEW_GET_LOGS_ROUTE, SELECT_ADMIN_CHECK_ROUTE, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, isSelectAdmin, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, ParamType, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, IntelliTableColumn, DropdownItemType, LogReviewerFilterState, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, };
@@ -22,6 +22,8 @@ declare enum LogAction {
22
22
  Resume = "Resume",
23
23
  Jump = "Jump",
24
24
  Post = "Post",
25
+ Like = "Like",
26
+ Dislike = "Dislike",
25
27
  Unknown = "Unknown"
26
28
  }
27
29
  export default LogAction;
package/dist/esm/index.js CHANGED
@@ -3848,6 +3848,10 @@ var LogAction;
3848
3848
  LogAction["Jump"] = "Jump";
3849
3849
  // Post a submission/message/etc. into the target
3850
3850
  LogAction["Post"] = "Post";
3851
+ // Like something
3852
+ LogAction["Like"] = "Like";
3853
+ // Dislike something
3854
+ LogAction["Dislike"] = "Dislike";
3851
3855
  // Unknown action
3852
3856
  LogAction["Unknown"] = "Unknown";
3853
3857
  })(LogAction || (LogAction = {}));
@@ -15330,7 +15334,7 @@ const LOG_REVIEW_STATUS_ROUTE = `${ROUTE_PATH_PREFIX}/logs/access_allowed`;
15330
15334
  * Route for checking if the current user is a select admin
15331
15335
  * @author Gabe Abrams
15332
15336
  */
15333
- const SELECT_ADMIN_CHECK_ROUTE = `${ROUTE_PATH_PREFIX}/select-admin/is-select-admin`;
15337
+ const SELECT_ADMIN_CHECK_ROUTE = '/api/admin/select/is-select-admin';
15334
15338
 
15335
15339
  // True if user is on mobile or tablet
15336
15340
  let cachedResult = undefined;
@@ -16395,6 +16399,42 @@ const getTimestampFromTimeInfoInET = (opts) => {
16395
16399
  return timestamp;
16396
16400
  };
16397
16401
 
16402
+ /*------------------------------------------------------------------------*/
16403
+ /* ------------------------------- Caching ------------------------------ */
16404
+ /*------------------------------------------------------------------------*/
16405
+ // If true, user is a select admin
16406
+ let cachedUserIsSelectAdmin;
16407
+ /*------------------------------------------------------------------------*/
16408
+ /* -------------------------------- Main -------------------------------- */
16409
+ /*------------------------------------------------------------------------*/
16410
+ /**
16411
+ * Checks if the current user is a select admin
16412
+ * @author Gardenia Liu
16413
+ * @returns true if the user is a select admin, false otherwise
16414
+ */
16415
+ const isSelectAdmin = () => __awaiter(void 0, void 0, void 0, function* () {
16416
+ // Use cached version if we have one
16417
+ if (cachedUserIsSelectAdmin !== undefined) {
16418
+ return cachedUserIsSelectAdmin;
16419
+ }
16420
+ // Check if the user is a select admin
16421
+ try {
16422
+ const userIsSelectAdmin = yield visitServerEndpoint({
16423
+ path: SELECT_ADMIN_CHECK_ROUTE,
16424
+ method: 'GET',
16425
+ });
16426
+ // Cache the result
16427
+ cachedUserIsSelectAdmin = !!userIsSelectAdmin;
16428
+ // Return the result
16429
+ return userIsSelectAdmin;
16430
+ }
16431
+ catch (err) {
16432
+ // Error means the user isn't a select admin
16433
+ cachedUserIsSelectAdmin = false;
16434
+ return false;
16435
+ }
16436
+ });
16437
+
16398
16438
  /**
16399
16439
  * Days of the week
16400
16440
  * @author Gabe Abrams
@@ -16411,5 +16451,5 @@ var DayOfWeek;
16411
16451
  })(DayOfWeek || (DayOfWeek = {}));
16412
16452
  var DayOfWeek$1 = DayOfWeek;
16413
16453
 
16414
- export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, Dropdown, DropdownItemType$1 as DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogLevel$1 as LogLevel, 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, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SELECT_ADMIN_CHECK_ROUTE, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, cloneDeep, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getTimestampFromTimeInfoInET, getWordCount, idify, initClient, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
16454
+ export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, Dropdown, DropdownItemType$1 as DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogLevel$1 as LogLevel, 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, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SELECT_ADMIN_CHECK_ROUTE, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, cloneDeep, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getTimestampFromTimeInfoInET, getWordCount, idify, initClient, isMobileOrTablet, isSelectAdmin, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
16415
16455
  //# sourceMappingURL=index.js.map