dce-reactkit 4.2.0-beta-select-admin-check.2 → 4.2.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.
@@ -20,6 +20,7 @@ type Props = {
20
20
  numMonthsToShow?: number;
21
21
  dontAllowPast?: boolean;
22
22
  dontAllowFuture?: boolean;
23
+ isDisabled?: boolean;
23
24
  };
24
25
  declare const SimpleDateChooser: React.FC<Props>;
25
26
  export default SimpleDateChooser;
@@ -15,6 +15,7 @@ type Props = {
15
15
  */
16
16
  onChange: (hour: number, minute: number) => void;
17
17
  intervalMin?: number;
18
+ isDisabled?: boolean;
18
19
  };
19
20
  declare const SimpleTimeChooser: React.FC<Props>;
20
21
  export default SimpleTimeChooser;
@@ -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
@@ -2789,7 +2789,7 @@ const SimpleDateChooser = (props) => {
2789
2789
  /* -------------------------------- Setup ------------------------------- */
2790
2790
  /*------------------------------------------------------------------------*/
2791
2791
  /* -------------- Props ------------- */
2792
- const { ariaLabel, name, dontAllowPast, dontAllowFuture, numMonthsToShow, onChange, month, day, year, } = props;
2792
+ const { ariaLabel, name, dontAllowPast, dontAllowFuture, numMonthsToShow, onChange, month, day, year, isDisabled = false, } = props;
2793
2793
  // Get choices
2794
2794
  const choices = getChoices({
2795
2795
  numMonthsToShow,
@@ -2874,11 +2874,11 @@ const SimpleDateChooser = (props) => {
2874
2874
  const choice = choices[e.target.selectedIndex];
2875
2875
  // Change day, month, and year
2876
2876
  onChange(choice.month, choice.days[0], choice.year);
2877
- } }, monthOptions),
2877
+ }, disabled: isDisabled }, monthOptions),
2878
2878
  React__default.createElement("select", { "aria-label": `day for ${ariaLabel}`, className: "custom-select form-select d-inline-block", style: { width: 'auto' }, id: `SimpleDateChooser-${name}-day`, value: day, onChange: (e) => {
2879
2879
  // Only change the day
2880
2880
  onChange(month, Number.parseInt(e.target.value, 10), year);
2881
- } }, dayOptions)));
2881
+ }, disabled: isDisabled }, dayOptions)));
2882
2882
  }
2883
2883
  /* --------- DateOutOfRange --------- */
2884
2884
  if (view === View.InvalidDate) {
@@ -2936,7 +2936,7 @@ const SimpleTimeChooser = (props) => {
2936
2936
  /* -------------------------------- Setup ------------------------------- */
2937
2937
  /*------------------------------------------------------------------------*/
2938
2938
  /* -------------- Props ------------- */
2939
- const { ariaLabel, name, hour, minute, onChange, } = props;
2939
+ const { ariaLabel, name, hour, minute, onChange, isDisabled = false, } = props;
2940
2940
  let { intervalMin = DEFAULT_INTERVAL, } = props;
2941
2941
  // Use default interval if not supported
2942
2942
  if (!ALLOWED_INTERVALS.includes(intervalMin)) {
@@ -3015,7 +3015,7 @@ const SimpleTimeChooser = (props) => {
3015
3015
  const timeInfo = convertMinSinceMidnightToHoursAndMin(newTime);
3016
3016
  // Notify parent
3017
3017
  onChange(timeInfo.hours, timeInfo.minutes);
3018
- } }, timeOptions)));
3018
+ }, disabled: isDisabled }, timeOptions)));
3019
3019
  };
3020
3020
 
3021
3021
  /**
@@ -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 = {}));
@@ -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