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 +46 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/SimpleDateChooser.d.ts +1 -0
- package/dist/cjs/types/components/SimpleTimeChooser.d.ts +1 -0
- package/dist/cjs/types/helpers/isSelectAdmin.d.ts +7 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/types/types/LogAction.d.ts +2 -0
- package/dist/esm/index.js +46 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/SimpleDateChooser.d.ts +1 -0
- package/dist/esm/types/components/SimpleTimeChooser.d.ts +1 -0
- package/dist/esm/types/helpers/isSelectAdmin.d.ts +7 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/types/types/LogAction.d.ts +2 -0
- package/dist/index.d.ts +12 -1
- package/package.json +1 -1
- package/src/components/SimpleDateChooser.tsx +5 -0
- package/src/components/SimpleTimeChooser.tsx +4 -0
- package/src/helpers/isSelectAdmin.ts +48 -0
- package/src/index.ts +2 -0
- package/src/types/LogAction.ts +4 -0
|
@@ -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, };
|
package/dist/index.d.ts
CHANGED
|
@@ -316,6 +316,7 @@ type Props$g = {
|
|
|
316
316
|
numMonthsToShow?: number;
|
|
317
317
|
dontAllowPast?: boolean;
|
|
318
318
|
dontAllowFuture?: boolean;
|
|
319
|
+
isDisabled?: boolean;
|
|
319
320
|
};
|
|
320
321
|
declare const SimpleDateChooser: React$1.FC<Props$g>;
|
|
321
322
|
|
|
@@ -336,6 +337,7 @@ type Props$f = {
|
|
|
336
337
|
*/
|
|
337
338
|
onChange: (hour: number, minute: number) => void;
|
|
338
339
|
intervalMin?: number;
|
|
340
|
+
isDisabled?: boolean;
|
|
339
341
|
};
|
|
340
342
|
declare const SimpleTimeChooser: React$1.FC<Props$f>;
|
|
341
343
|
|
|
@@ -1183,6 +1185,8 @@ declare enum LogAction {
|
|
|
1183
1185
|
Resume = "Resume",
|
|
1184
1186
|
Jump = "Jump",
|
|
1185
1187
|
Post = "Post",
|
|
1188
|
+
Like = "Like",
|
|
1189
|
+
Dislike = "Dislike",
|
|
1186
1190
|
Unknown = "Unknown"
|
|
1187
1191
|
}
|
|
1188
1192
|
|
|
@@ -1580,6 +1584,13 @@ declare const getTimestampFromTimeInfoInET: (opts: {
|
|
|
1580
1584
|
minute: number;
|
|
1581
1585
|
}) => number;
|
|
1582
1586
|
|
|
1587
|
+
/**
|
|
1588
|
+
* Checks if the current user is a select admin
|
|
1589
|
+
* @author Gardenia Liu
|
|
1590
|
+
* @returns true if the user is a select admin, false otherwise
|
|
1591
|
+
*/
|
|
1592
|
+
declare const isSelectAdmin: () => Promise<boolean>;
|
|
1593
|
+
|
|
1583
1594
|
/**
|
|
1584
1595
|
* Days of the week
|
|
1585
1596
|
* @author Gabe Abrams
|
|
@@ -1707,4 +1718,4 @@ type LogReviewerFilterState = {
|
|
|
1707
1718
|
advancedFilterState: AdvancedFilterState;
|
|
1708
1719
|
};
|
|
1709
1720
|
|
|
1710
|
-
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogLevel, LogMainInfo, LogMetadataType, LogReviewer, LogReviewerFilterState, LogSource, LogSourceSpecificInfo, LogType, LogTypeSpecificInfo, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SELECT_ADMIN_CHECK_ROUTE, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, 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 };
|
|
1721
|
+
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogLevel, LogMainInfo, LogMetadataType, LogReviewer, LogReviewerFilterState, LogSource, LogSourceSpecificInfo, LogType, LogTypeSpecificInfo, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SELECT_ADMIN_CHECK_ROUTE, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, 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 };
|
package/package.json
CHANGED
|
@@ -51,6 +51,8 @@ type Props = {
|
|
|
51
51
|
dontAllowPast?: boolean,
|
|
52
52
|
// If true, the user isn't allowed to select dates in the future
|
|
53
53
|
dontAllowFuture?: boolean,
|
|
54
|
+
// If true, the chooser is disabled
|
|
55
|
+
isDisabled?: boolean,
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
/*------------------------------------------------------------------------*/
|
|
@@ -291,6 +293,7 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
|
|
|
291
293
|
month,
|
|
292
294
|
day,
|
|
293
295
|
year,
|
|
296
|
+
isDisabled = false,
|
|
294
297
|
} = props;
|
|
295
298
|
|
|
296
299
|
// Get choices
|
|
@@ -435,6 +438,7 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
|
|
|
435
438
|
choice.year,
|
|
436
439
|
);
|
|
437
440
|
}}
|
|
441
|
+
disabled={isDisabled}
|
|
438
442
|
>
|
|
439
443
|
{monthOptions}
|
|
440
444
|
</select>
|
|
@@ -454,6 +458,7 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
|
|
|
454
458
|
year,
|
|
455
459
|
);
|
|
456
460
|
}}
|
|
461
|
+
disabled={isDisabled}
|
|
457
462
|
>
|
|
458
463
|
{dayOptions}
|
|
459
464
|
</select>
|
|
@@ -32,6 +32,8 @@ type Props = {
|
|
|
32
32
|
// Allowed options: 15, 30, 60, defaults to 15
|
|
33
33
|
// If an unsupported interval is passed in, it will default to 15
|
|
34
34
|
intervalMin?: number,
|
|
35
|
+
// If true, the chooser is disabled
|
|
36
|
+
isDisabled?: boolean,
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
/*------------------------------------------------------------------------*/
|
|
@@ -61,6 +63,7 @@ const SimpleTimeChooser: React.FC<Props> = (props) => {
|
|
|
61
63
|
hour,
|
|
62
64
|
minute,
|
|
63
65
|
onChange,
|
|
66
|
+
isDisabled = false,
|
|
64
67
|
} = props;
|
|
65
68
|
let {
|
|
66
69
|
intervalMin = DEFAULT_INTERVAL,
|
|
@@ -181,6 +184,7 @@ const SimpleTimeChooser: React.FC<Props> = (props) => {
|
|
|
181
184
|
// Notify parent
|
|
182
185
|
onChange(timeInfo.hours, timeInfo.minutes);
|
|
183
186
|
}}
|
|
187
|
+
disabled={isDisabled}
|
|
184
188
|
>
|
|
185
189
|
{timeOptions}
|
|
186
190
|
</select>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Import shared constants
|
|
2
|
+
import SELECT_ADMIN_CHECK_ROUTE from '../constants/SELECT_ADMIN_CHECK_ROUTE';
|
|
3
|
+
|
|
4
|
+
// Import shared helpers
|
|
5
|
+
import visitServerEndpoint from './visitServerEndpoint';
|
|
6
|
+
|
|
7
|
+
/*------------------------------------------------------------------------*/
|
|
8
|
+
/* ------------------------------- Caching ------------------------------ */
|
|
9
|
+
/*------------------------------------------------------------------------*/
|
|
10
|
+
|
|
11
|
+
// If true, user is a select admin
|
|
12
|
+
let cachedUserIsSelectAdmin: boolean | undefined;
|
|
13
|
+
|
|
14
|
+
/*------------------------------------------------------------------------*/
|
|
15
|
+
/* -------------------------------- Main -------------------------------- */
|
|
16
|
+
/*------------------------------------------------------------------------*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Checks if the current user is a select admin
|
|
20
|
+
* @author Gardenia Liu
|
|
21
|
+
* @returns true if the user is a select admin, false otherwise
|
|
22
|
+
*/
|
|
23
|
+
const isSelectAdmin = async (): Promise<boolean> => {
|
|
24
|
+
// Use cached version if we have one
|
|
25
|
+
if (cachedUserIsSelectAdmin !== undefined) {
|
|
26
|
+
return cachedUserIsSelectAdmin;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Check if the user is a select admin
|
|
30
|
+
try {
|
|
31
|
+
const userIsSelectAdmin: boolean = await visitServerEndpoint({
|
|
32
|
+
path: SELECT_ADMIN_CHECK_ROUTE,
|
|
33
|
+
method: 'GET',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Cache the result
|
|
37
|
+
cachedUserIsSelectAdmin = !!userIsSelectAdmin;
|
|
38
|
+
|
|
39
|
+
// Return the result
|
|
40
|
+
return userIsSelectAdmin;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
// Error means the user isn't a select admin
|
|
43
|
+
cachedUserIsSelectAdmin = false;
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default isSelectAdmin;
|
package/src/index.ts
CHANGED
|
@@ -97,6 +97,7 @@ import shuffleArray from './helpers/shuffleArray';
|
|
|
97
97
|
import getWordCount from './helpers/getWordCount';
|
|
98
98
|
import cloneDeep from './helpers/cloneDeep';
|
|
99
99
|
import getTimestampFromTimeInfoInET from './helpers/getTimestampFromTimeInfoInET';
|
|
100
|
+
import isSelectAdmin from './helpers/isSelectAdmin';
|
|
100
101
|
|
|
101
102
|
// Import types
|
|
102
103
|
import ParamType from './types/ParamType';
|
|
@@ -217,6 +218,7 @@ export {
|
|
|
217
218
|
getWordCount,
|
|
218
219
|
cloneDeep,
|
|
219
220
|
getTimestampFromTimeInfoInET,
|
|
221
|
+
isSelectAdmin,
|
|
220
222
|
// Client helpers
|
|
221
223
|
initClient,
|
|
222
224
|
visitServerEndpoint,
|
package/src/types/LogAction.ts
CHANGED