dce-reactkit 3.9.4 → 3.9.6
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 +133 -22
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/AppWrapper.d.ts +12 -4
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/esm/index.js +133 -23
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/AppWrapper.d.ts +12 -4
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/index.d.ts +33 -1
- package/package.json +1 -1
- package/src/components/AppWrapper.tsx +87 -47
- package/src/components/CheckboxButton.tsx +21 -3
- package/src/components/LogReviewer.tsx +17 -4
- package/src/index.ts +2 -0
- package/src/server/initLogCollection.ts +5 -0
- package/src/server/initServer.ts +11 -5
package/dist/cjs/index.js
CHANGED
|
@@ -1088,6 +1088,87 @@ const confirm = (title, text, opts) => __awaiter(void 0, void 0, void 0, functio
|
|
|
1088
1088
|
/*----------------------------------------*/
|
|
1089
1089
|
// Stored copies of setters
|
|
1090
1090
|
let setPromptInfo;
|
|
1091
|
+
// Function to call when prompt is closed
|
|
1092
|
+
let onPromptClosed;
|
|
1093
|
+
/**
|
|
1094
|
+
* Show a prompt modal asking the user for input
|
|
1095
|
+
* @author Yuen Ler Chow
|
|
1096
|
+
* @param title the title text to display at the top of the prompt
|
|
1097
|
+
* @param [opts={}] additional options for the prompt dialog
|
|
1098
|
+
* @param [opts.textAboveInputField] the text to display in the prompt
|
|
1099
|
+
* @param [opts.defaultText] the default text for the input field
|
|
1100
|
+
* @param [opts.placeholder] the placeholder text for the input field
|
|
1101
|
+
* @param [opts.confirmButtonText=Okay] the text of the confirm button
|
|
1102
|
+
* @param [opts.confirmButtonVariant=Variant.Dark] the variant of the confirm button
|
|
1103
|
+
* @param [opts.cancelButtonText=Cancel] the text of the cancel button
|
|
1104
|
+
* @param [opts.cancelButtonVariant=Variant.Secondary] the variant of the cancel button
|
|
1105
|
+
* @param [opts.minNumChars] the minimum number of characters required for
|
|
1106
|
+
* the input to be valid
|
|
1107
|
+
* @param [opts.findValidationError] a function that takes the input text and
|
|
1108
|
+
* returns an error message if the input is invalid, returns undefined if the
|
|
1109
|
+
* input is valid
|
|
1110
|
+
* @param [opts.ariaLabel] the aria label for the input field
|
|
1111
|
+
* @returns Promise that resolves with the input string or null if canceled
|
|
1112
|
+
*/
|
|
1113
|
+
const prompt = (title, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1114
|
+
var _a, _b;
|
|
1115
|
+
// Wait for helper to exist
|
|
1116
|
+
yield waitForHelper(() => {
|
|
1117
|
+
return !!setPromptInfo;
|
|
1118
|
+
});
|
|
1119
|
+
// Fallback if prompt is not available
|
|
1120
|
+
if (!setPromptInfo) {
|
|
1121
|
+
const resultPassesValidation = false;
|
|
1122
|
+
while (!resultPassesValidation) {
|
|
1123
|
+
// eslint-disable-next-line no-alert
|
|
1124
|
+
const result = window.prompt(`${title}\n\n${(_a = opts === null || opts === void 0 ? void 0 : opts.textAboveInputField) !== null && _a !== void 0 ? _a : ''}`, (_b = opts === null || opts === void 0 ? void 0 : opts.defaultText) !== null && _b !== void 0 ? _b : '');
|
|
1125
|
+
// Exit loop if user cancels
|
|
1126
|
+
if (result === null) {
|
|
1127
|
+
return null;
|
|
1128
|
+
}
|
|
1129
|
+
// Validate min num chars
|
|
1130
|
+
const minNumCharsValidationError = (((opts === null || opts === void 0 ? void 0 : opts.minNumChars) && result.length < opts.minNumChars)
|
|
1131
|
+
? `Please enter at least ${opts.minNumChars} characters.`
|
|
1132
|
+
: undefined);
|
|
1133
|
+
// Run custom validation
|
|
1134
|
+
const customValidationError = ((opts === null || opts === void 0 ? void 0 : opts.findValidationError)
|
|
1135
|
+
&& opts.findValidationError(result));
|
|
1136
|
+
// Show validation issue
|
|
1137
|
+
if (minNumCharsValidationError || customValidationError) {
|
|
1138
|
+
// Create error message
|
|
1139
|
+
const errorMessage = ([
|
|
1140
|
+
minNumCharsValidationError,
|
|
1141
|
+
customValidationError,
|
|
1142
|
+
]
|
|
1143
|
+
// Filter out undefined messages
|
|
1144
|
+
.filter((msg) => {
|
|
1145
|
+
return !!msg;
|
|
1146
|
+
})
|
|
1147
|
+
// Join messages with newlines
|
|
1148
|
+
.join('\n'));
|
|
1149
|
+
// Show alert
|
|
1150
|
+
alert('Invalid Input', errorMessage);
|
|
1151
|
+
}
|
|
1152
|
+
else {
|
|
1153
|
+
return result;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
// Return promise that resolves with result of prompt
|
|
1158
|
+
return new Promise((resolve) => {
|
|
1159
|
+
var _a;
|
|
1160
|
+
// Setup handler
|
|
1161
|
+
onPromptClosed = (result) => {
|
|
1162
|
+
resolve(result);
|
|
1163
|
+
};
|
|
1164
|
+
// Show the prompt
|
|
1165
|
+
setPromptInfo({
|
|
1166
|
+
title,
|
|
1167
|
+
currentInputFieldText: ((_a = opts === null || opts === void 0 ? void 0 : opts.defaultText) !== null && _a !== void 0 ? _a : ''),
|
|
1168
|
+
opts: (opts !== null && opts !== void 0 ? opts : {}),
|
|
1169
|
+
});
|
|
1170
|
+
});
|
|
1171
|
+
});
|
|
1091
1172
|
/*----------------------------------------*/
|
|
1092
1173
|
/* ------------- Fatal Error ------------ */
|
|
1093
1174
|
/*----------------------------------------*/
|
|
@@ -1104,14 +1185,14 @@ const fatalErrorHandlers = [];
|
|
|
1104
1185
|
* @param [errorTitle] title of the error box
|
|
1105
1186
|
*/
|
|
1106
1187
|
const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(void 0, void 0, void 0, function* () {
|
|
1107
|
-
var
|
|
1188
|
+
var _c, _d;
|
|
1108
1189
|
// Determine message and code
|
|
1109
1190
|
const message = (typeof error === 'string'
|
|
1110
1191
|
? error.trim()
|
|
1111
|
-
: String((
|
|
1192
|
+
: String((_c = error.message) !== null && _c !== void 0 ? _c : 'An unknown error occurred.'));
|
|
1112
1193
|
const code = (typeof error === 'string'
|
|
1113
1194
|
? ReactKitErrorCode$1.NoCode
|
|
1114
|
-
: String((
|
|
1195
|
+
: String((_d = error.code) !== null && _d !== void 0 ? _d : ReactKitErrorCode$1.NoCode));
|
|
1115
1196
|
// Call all fatal error listeners
|
|
1116
1197
|
try {
|
|
1117
1198
|
fatalErrorHandlers.forEach((handler) => {
|
|
@@ -1281,23 +1362,31 @@ const AppWrapper = (props) => {
|
|
|
1281
1362
|
// Run custom validation
|
|
1282
1363
|
const customValidationError = (promptInfo.opts.findValidationError
|
|
1283
1364
|
&& promptInfo.opts.findValidationError(promptInfo.currentInputFieldText));
|
|
1284
|
-
modal = (React__default["default"].createElement(Modal, { key: `prompt-${promptInfo.title}
|
|
1285
|
-
//
|
|
1365
|
+
modal = (React__default["default"].createElement(Modal, { key: `prompt-${promptInfo.title}`, title: promptInfo.title,
|
|
1366
|
+
// Don't show ok button if there is a validation error
|
|
1286
1367
|
type: ((customValidationError || minNumCharsValidationError)
|
|
1287
1368
|
? ModalType$1.Cancel
|
|
1288
1369
|
: ModalType$1.OkayCancel), okayLabel: promptInfo.opts.confirmButtonText, okayVariant: promptInfo.opts.confirmButtonVariant, cancelLabel: promptInfo.opts.cancelButtonText, cancelVariant: promptInfo.opts.cancelButtonVariant, onClose: (buttonType) => {
|
|
1289
|
-
|
|
1370
|
+
// Get result
|
|
1371
|
+
const result = (buttonType === ModalButtonType$1.Okay
|
|
1290
1372
|
? promptInfo.currentInputFieldText
|
|
1291
1373
|
: null);
|
|
1374
|
+
// Close prompt
|
|
1292
1375
|
setPromptInfo(undefined);
|
|
1376
|
+
// Call handler
|
|
1377
|
+
if (onPromptClosed) {
|
|
1378
|
+
onPromptClosed(result);
|
|
1379
|
+
}
|
|
1293
1380
|
}, onTopOfOtherModals: true, dontAllowBackdropExit: true },
|
|
1294
|
-
React__default["default"].createElement("div",
|
|
1295
|
-
React__default["default"].createElement("
|
|
1296
|
-
React__default["default"].createElement("input", { type: "text", placeholder: promptInfo.opts.placeholder, value: promptInfo.currentInputFieldText, onChange: (e) => {
|
|
1381
|
+
React__default["default"].createElement("div", null,
|
|
1382
|
+
promptInfo.opts.textAboveInputField && (React__default["default"].createElement("div", null, promptInfo.opts.textAboveInputField)),
|
|
1383
|
+
React__default["default"].createElement("input", { type: "text", className: "form-control", "aria-label": promptInfo.opts.ariaLabel, placeholder: promptInfo.opts.placeholder, value: promptInfo.currentInputFieldText, onChange: (e) => {
|
|
1297
1384
|
return setPromptInfo(Object.assign(Object.assign({}, promptInfo), { currentInputFieldText: e.target.value }));
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
|
|
1385
|
+
},
|
|
1386
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
1387
|
+
autoFocus: true }),
|
|
1388
|
+
minNumCharsValidationError && (React__default["default"].createElement("div", { className: "text-danger fw-bold mt-2" }, minNumCharsValidationError)),
|
|
1389
|
+
customValidationError && (React__default["default"].createElement("div", { className: "text-danger fw-bold mt-2" }, customValidationError)))));
|
|
1301
1390
|
}
|
|
1302
1391
|
/* ------ Custom Modal Portals ------ */
|
|
1303
1392
|
// Custom modal portals
|
|
@@ -3831,10 +3920,21 @@ const LogReviewer = (props) => {
|
|
|
3831
3920
|
// Destructure
|
|
3832
3921
|
const { year, month } = toLoad[i];
|
|
3833
3922
|
// Load
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3923
|
+
let logs = [];
|
|
3924
|
+
let pageNumber = 1;
|
|
3925
|
+
let hasAnotherPage = true;
|
|
3926
|
+
while (hasAnotherPage) {
|
|
3927
|
+
const response = yield visitServerEndpoint({
|
|
3928
|
+
path: `${LOG_REVIEW_ROUTE_PATH_PREFIX}/years/${year}/months/${month}`,
|
|
3929
|
+
method: 'GET',
|
|
3930
|
+
params: {
|
|
3931
|
+
pageNumber,
|
|
3932
|
+
},
|
|
3933
|
+
});
|
|
3934
|
+
logs = logs.concat(response.items);
|
|
3935
|
+
hasAnotherPage = response.hasAnotherPage;
|
|
3936
|
+
pageNumber += 1;
|
|
3937
|
+
}
|
|
3838
3938
|
// Add to map
|
|
3839
3939
|
if (!logMap[year]) {
|
|
3840
3940
|
logMap[year] = {};
|
|
@@ -14094,22 +14194,27 @@ const initServer = (opts) => {
|
|
|
14094
14194
|
paramTypes: {
|
|
14095
14195
|
year: ParamType$1.Int,
|
|
14096
14196
|
month: ParamType$1.Int,
|
|
14197
|
+
pageNumber: ParamType$1.Int,
|
|
14097
14198
|
},
|
|
14098
14199
|
handler: ({ params }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14099
14200
|
// Get user info
|
|
14100
|
-
const { year, month, userId, isAdmin, } = params;
|
|
14201
|
+
const { year, month, pageNumber, userId, isAdmin, } = params;
|
|
14101
14202
|
// Validate user
|
|
14102
14203
|
const canReview = yield canReviewLogs(userId, isAdmin);
|
|
14103
14204
|
if (!canReview) {
|
|
14104
14205
|
throw new ErrorWithCode('You cannot access this resource because you do not have the appropriate permissions.', ReactKitErrorCode$1.NotAllowedToReviewLogs);
|
|
14105
14206
|
}
|
|
14106
14207
|
// Query for logs
|
|
14107
|
-
const
|
|
14108
|
-
|
|
14109
|
-
|
|
14208
|
+
const response = yield _logCollection.findPaged({
|
|
14209
|
+
query: {
|
|
14210
|
+
year,
|
|
14211
|
+
month,
|
|
14212
|
+
},
|
|
14213
|
+
perPage: 1000,
|
|
14214
|
+
pageNumber,
|
|
14110
14215
|
});
|
|
14111
|
-
// Return
|
|
14112
|
-
return
|
|
14216
|
+
// Return response
|
|
14217
|
+
return response;
|
|
14113
14218
|
}),
|
|
14114
14219
|
}));
|
|
14115
14220
|
};
|
|
@@ -15340,6 +15445,11 @@ const initLogCollection = (Collection) => {
|
|
|
15340
15445
|
'context',
|
|
15341
15446
|
'subcontext',
|
|
15342
15447
|
'tags',
|
|
15448
|
+
'year',
|
|
15449
|
+
'month',
|
|
15450
|
+
'day',
|
|
15451
|
+
'hour',
|
|
15452
|
+
'type',
|
|
15343
15453
|
],
|
|
15344
15454
|
});
|
|
15345
15455
|
};
|
|
@@ -16361,6 +16471,7 @@ exports.padDecimalZeros = padDecimalZeros;
|
|
|
16361
16471
|
exports.padZerosLeft = padZerosLeft;
|
|
16362
16472
|
exports.parallelLimit = parallelLimit;
|
|
16363
16473
|
exports.prefixWithAOrAn = prefixWithAOrAn;
|
|
16474
|
+
exports.prompt = prompt;
|
|
16364
16475
|
exports.roundToNumDecimals = roundToNumDecimals;
|
|
16365
16476
|
exports.setClientEventMetadataPopulator = setClientEventMetadataPopulator;
|
|
16366
16477
|
exports.showFatalError = showFatalError;
|