Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MergeDups] Enable word/sense protection bypass #3445

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
167527b
[MergeDups] Enable protection override
imnasnainaec Nov 12, 2024
7185f48
Reset hasProtected when new words loaded
imnasnainaec Nov 13, 2024
e21032c
Add reducer test cases for protect override
imnasnainaec Nov 13, 2024
04400e2
Add project setting for overriding protected words/senses
imnasnainaec Nov 13, 2024
9abdab1
Add pop-up confirmation for overriding protected senses
imnasnainaec Nov 14, 2024
b4d139b
Merge branch 'master' into merge-unprotect
imnasnainaec Nov 14, 2024
cfdf244
Merge branch 'master' into merge-unprotect
imnasnainaec Dec 13, 2024
c5e9cc6
Extract protect-reason text functions
imnasnainaec Dec 13, 2024
72aad50
Unify sense refs and protection override
imnasnainaec Dec 16, 2024
d232d4b
Fix test
imnasnainaec Dec 16, 2024
0d0ebc9
Merge branch 'master' into merge-unprotect
imnasnainaec Jan 8, 2025
4a6445e
Merge branch 'master' into merge-unprotect
imnasnainaec Jan 8, 2025
0cbc9da
Remove redundant consts
imnasnainaec Jan 8, 2025
ef4fafb
Merge branch 'master' into merge-unprotect
imnasnainaec Jan 14, 2025
aa35ddf
Merge branch 'master' into merge-unprotect
imnasnainaec Jan 14, 2025
93118c0
Warn when displacing protected sidebar sense
imnasnainaec Jan 14, 2025
79654b5
Fix non-top sidebar sense bug
imnasnainaec Jan 14, 2025
3f7c4d5
Merge branch 'master' into merge-unprotect
imnasnainaec Jan 14, 2025
a75c25f
Merge branch 'master' into merge-unprotect
imnasnainaec Jan 15, 2025
0c40e4b
Merge branch 'master' into merge-unprotect
imnasnainaec Jan 15, 2025
a065f51
Show protected word warning, even with multiple senses
imnasnainaec Jan 30, 2025
ec426b1
Add toasts to explain illegal drops
imnasnainaec Jan 30, 2025
77aafaa
Merge branch 'master' into merge-unprotect
imnasnainaec Jan 30, 2025
70a80a7
Remove useless ?; Prefer undefined to null
imnasnainaec Jan 30, 2025
0a5f55b
Split off pr #3560
imnasnainaec Jan 31, 2025
e8941de
Merge branch 'master' into merge-unprotect
imnasnainaec Jan 31, 2025
e8a7e33
Merge branch 'master' into merge-unprotect
imnasnainaec Feb 7, 2025
47eb91d
Merge branch 'master' into merge-unprotect
imnasnainaec Feb 12, 2025
1c6be91
Localize bypass checkbox text
imnasnainaec Feb 12, 2025
36c6204
Update User Guide
imnasnainaec Feb 12, 2025
be25106
Merge branch 'master' into merge-unprotect
imnasnainaec Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into merge-unprotect
imnasnainaec committed Jan 14, 2025
commit ef4fafbe2e81d0b92da0312b37e9084a4a24a88d
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ export function DropWordCardHeader(
const tooltipTexts = [t("mergeDups.helpText.protectedWord")];
const reasons = words[props.wordId]?.protectReasons;
if (reasons?.length) {
tooltipTexts.push(protectReasonsText(t, reasons, []));
tooltipTexts.push(protectReasonsText(t, { word: reasons }));
}
tooltipTexts.push(t("mergeDups.helpText.protectedWordInfo"));

Original file line number Diff line number Diff line change
@@ -73,9 +73,12 @@ export default function MergeDragDrop(): ReactElement {
const wordReasons = isOnlySenseInProtectedWord
? (srcWord.protectReasons ?? [])
: undefined;
const senseReasons = src.protectReasons;
protectReason = t("mergeDups.helpText.protectedOverrideWarning", {
val: protectReasonsText(t, wordReasons, senseReasons, false),
val: protectReasonsText(
t,
{ sense: src.protectReasons, word: wordReasons },
false
),
});
}

Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ export default function SenseCardContent(
const tooltipTexts = [t("mergeDups.helpText.protectedSense")];
const reasons = sense.protectReasons;
if (reasons?.length) {
tooltipTexts.push(protectReasonsText(t, [], reasons));
tooltipTexts.push(protectReasonsText(t, { sense: reasons }));
}
tooltipTexts.push(t("mergeDups.helpText.protectedSenseInfo"));

30 changes: 14 additions & 16 deletions src/goals/MergeDuplicates/MergeDupsStep/protectReasonUtils.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import { TFunction } from "i18next";
import { type TFunction } from "i18next";

import { ProtectReason, ReasonType } from "api/models";
import { type ProtectReason, ReasonType } from "api/models";

const sep = "; ";

interface WordSenseReasons {
sense?: ProtectReason[];
word?: ProtectReason[];
}

export function protectReasonsText(
t: TFunction<"translation", undefined>,
wordReasons: ProtectReason[] = [],
senseReasons: ProtectReason[] = [],
t: TFunction,
reasons: WordSenseReasons,
defaultPreface = true
): string {
const wordTexts = wordReasons.map((r) => wordReasonText(t, r));
const senseTexts = senseReasons.map((r) => senseReasonText(t, r));
const val = [...wordTexts, ...senseTexts].join(sep);
const wordTexts = reasons.word?.map((r) => wordReasonText(t, r));
const senseTexts = reasons.sense?.map((r) => senseReasonText(t, r));
const val = [...(wordTexts ?? []), ...(senseTexts ?? [])].join(sep);
return defaultPreface ? t("mergeDups.helpText.protectedData", { val }) : val;
}

/** Cases match Backend/Helper/LiftHelper.cs > GetProtectedReasons(LiftSense sense) */
function senseReasonText(
t: TFunction<"translation", undefined>,
reason: ProtectReason
): string {
function senseReasonText(t: TFunction, reason: ProtectReason): string {
switch (reason.type) {
case ReasonType.Annotations:
return t("mergeDups.protectReason.annotations");
@@ -76,10 +77,7 @@ function senseReasonText(
}

/** Cases match Backend/Helper/LiftHelper.cs > GetProtectedReasons(LiftEntry entry) */
function wordReasonText(
t: TFunction<"translation", undefined>,
reason: ProtectReason
): string {
function wordReasonText(t: TFunction, reason: ProtectReason): string {
switch (reason.type) {
case ReasonType.Annotations:
return t("mergeDups.protectReason.annotations");
You are viewing a condensed version of this merge commit. You can view the full changes here.