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.
package/dist/cjs/index.js CHANGED
@@ -2816,7 +2816,7 @@ const SimpleDateChooser = (props) => {
2816
2816
  /* -------------------------------- Setup ------------------------------- */
2817
2817
  /*------------------------------------------------------------------------*/
2818
2818
  /* -------------- Props ------------- */
2819
- const { ariaLabel, name, dontAllowPast, dontAllowFuture, numMonthsToShow, onChange, month, day, year, } = props;
2819
+ const { ariaLabel, name, dontAllowPast, dontAllowFuture, numMonthsToShow, onChange, month, day, year, isDisabled = false, } = props;
2820
2820
  // Get choices
2821
2821
  const choices = getChoices({
2822
2822
  numMonthsToShow,
@@ -2901,11 +2901,11 @@ const SimpleDateChooser = (props) => {
2901
2901
  const choice = choices[e.target.selectedIndex];
2902
2902
  // Change day, month, and year
2903
2903
  onChange(choice.month, choice.days[0], choice.year);
2904
- } }, monthOptions),
2904
+ }, disabled: isDisabled }, monthOptions),
2905
2905
  React__default["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) => {
2906
2906
  // Only change the day
2907
2907
  onChange(month, Number.parseInt(e.target.value, 10), year);
2908
- } }, dayOptions)));
2908
+ }, disabled: isDisabled }, dayOptions)));
2909
2909
  }
2910
2910
  /* --------- DateOutOfRange --------- */
2911
2911
  if (view === View.InvalidDate) {
@@ -2963,7 +2963,7 @@ const SimpleTimeChooser = (props) => {
2963
2963
  /* -------------------------------- Setup ------------------------------- */
2964
2964
  /*------------------------------------------------------------------------*/
2965
2965
  /* -------------- Props ------------- */
2966
- const { ariaLabel, name, hour, minute, onChange, } = props;
2966
+ const { ariaLabel, name, hour, minute, onChange, isDisabled = false, } = props;
2967
2967
  let { intervalMin = DEFAULT_INTERVAL, } = props;
2968
2968
  // Use default interval if not supported
2969
2969
  if (!ALLOWED_INTERVALS.includes(intervalMin)) {
@@ -3042,7 +3042,7 @@ const SimpleTimeChooser = (props) => {
3042
3042
  const timeInfo = convertMinSinceMidnightToHoursAndMin(newTime);
3043
3043
  // Notify parent
3044
3044
  onChange(timeInfo.hours, timeInfo.minutes);
3045
- } }, timeOptions)));
3045
+ }, disabled: isDisabled }, timeOptions)));
3046
3046
  };
3047
3047
 
3048
3048
  /**
@@ -3875,6 +3875,10 @@ var LogAction;
3875
3875
  LogAction["Jump"] = "Jump";
3876
3876
  // Post a submission/message/etc. into the target
3877
3877
  LogAction["Post"] = "Post";
3878
+ // Like something
3879
+ LogAction["Like"] = "Like";
3880
+ // Dislike something
3881
+ LogAction["Dislike"] = "Dislike";
3878
3882
  // Unknown action
3879
3883
  LogAction["Unknown"] = "Unknown";
3880
3884
  })(LogAction || (LogAction = {}));
@@ -16422,6 +16426,42 @@ const getTimestampFromTimeInfoInET = (opts) => {
16422
16426
  return timestamp;
16423
16427
  };
16424
16428
 
16429
+ /*------------------------------------------------------------------------*/
16430
+ /* ------------------------------- Caching ------------------------------ */
16431
+ /*------------------------------------------------------------------------*/
16432
+ // If true, user is a select admin
16433
+ let cachedUserIsSelectAdmin;
16434
+ /*------------------------------------------------------------------------*/
16435
+ /* -------------------------------- Main -------------------------------- */
16436
+ /*------------------------------------------------------------------------*/
16437
+ /**
16438
+ * Checks if the current user is a select admin
16439
+ * @author Gardenia Liu
16440
+ * @returns true if the user is a select admin, false otherwise
16441
+ */
16442
+ const isSelectAdmin = () => __awaiter(void 0, void 0, void 0, function* () {
16443
+ // Use cached version if we have one
16444
+ if (cachedUserIsSelectAdmin !== undefined) {
16445
+ return cachedUserIsSelectAdmin;
16446
+ }
16447
+ // Check if the user is a select admin
16448
+ try {
16449
+ const userIsSelectAdmin = yield visitServerEndpoint({
16450
+ path: SELECT_ADMIN_CHECK_ROUTE,
16451
+ method: 'GET',
16452
+ });
16453
+ // Cache the result
16454
+ cachedUserIsSelectAdmin = !!userIsSelectAdmin;
16455
+ // Return the result
16456
+ return userIsSelectAdmin;
16457
+ }
16458
+ catch (err) {
16459
+ // Error means the user isn't a select admin
16460
+ cachedUserIsSelectAdmin = false;
16461
+ return false;
16462
+ }
16463
+ });
16464
+
16425
16465
  /**
16426
16466
  * Days of the week
16427
16467
  * @author Gabe Abrams
@@ -16517,6 +16557,7 @@ exports.getWordCount = getWordCount;
16517
16557
  exports.idify = idify;
16518
16558
  exports.initClient = initClient;
16519
16559
  exports.isMobileOrTablet = isMobileOrTablet;
16560
+ exports.isSelectAdmin = isSelectAdmin;
16520
16561
  exports.leaveToURL = leaveToURL;
16521
16562
  exports.logClientEvent = logClientEvent;
16522
16563
  exports.makeLinksClickable = makeLinksClickable;