summaryrefslogtreecommitdiff
path: root/web/source/settings/lib/query/admin/domain-permissions/import.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/source/settings/lib/query/admin/domain-permissions/import.ts')
-rw-r--r--web/source/settings/lib/query/admin/domain-permissions/import.ts38
1 files changed, 9 insertions, 29 deletions
diff --git a/web/source/settings/lib/query/admin/domain-permissions/import.ts b/web/source/settings/lib/query/admin/domain-permissions/import.ts
index cbcf44964..a83448a1f 100644
--- a/web/source/settings/lib/query/admin/domain-permissions/import.ts
+++ b/web/source/settings/lib/query/admin/domain-permissions/import.ts
@@ -40,39 +40,19 @@ function importEntriesProcessor(formData: ImportDomainPermsParams): (_entry: Dom
// Override each obfuscate entry if necessary.
if (formData.obfuscate !== undefined) {
- const obfuscateEntry = (entry: DomainPerm) => {
+ processingFuncs.push((entry: DomainPerm) => {
entry.obfuscate = formData.obfuscate;
- };
- processingFuncs.push(obfuscateEntry);
+ });
}
- // Check whether we need to append or replace
- // private_comment and public_comment.
+ // Check whether we need to replace
+ // private_comment and/or public_comment.
["private_comment","public_comment"].forEach((commentType) => {
- let text = formData.commentType?.trim();
- if (!text) {
- return;
- }
-
- switch(formData[`${commentType}_behavior`]) {
- case "append":
- const appendComment = (entry: DomainPerm) => {
- if (entry.commentType == undefined) {
- entry.commentType = text;
- } else {
- entry.commentType = [entry.commentType, text].join("\n");
- }
- };
-
- processingFuncs.push(appendComment);
- break;
- case "replace":
- const replaceComment = (entry: DomainPerm) => {
- entry.commentType = text;
- };
-
- processingFuncs.push(replaceComment);
- break;
+ if (formData[`replace_${commentType}`]) {
+ const text = formData[commentType]?.trim();
+ processingFuncs.push((entry: DomainPerm) => {
+ entry[commentType] = text;
+ });
}
});