-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
[CharInv] Consolidate find-and-replace pieces #2964
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2964 +/- ##
==========================================
+ Coverage 72.72% 72.81% +0.08%
==========================================
Files 266 264 -2
Lines 10209 10201 -8
Branches 1196 1196
==========================================
+ Hits 7425 7428 +3
+ Misses 2433 2425 -8
+ Partials 351 348 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 15 files at r1, 11 of 11 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @imnasnainaec)
src/components/Dialogs/CancelConfirmDialog.tsx
line 50 at r2 (raw file):
<DialogContent> <DialogContentText id="alert-dialog-description"> {props.text || t(props.textId ?? "")}
Previously, it was not possible to have a CancelConfirmDialog
with empty text - unless the textId
mapped to an empty string.
Unfortunately, textId
s are indistinguishable from string
s so we can't use the typeof
operator.
If the interface is changed to:
interface CancelConfirmDialogProps {
open: boolean;
text: string | ReactElement;
isLocalized?: boolean;
handleCancel: () => void;
handleConfirm: () => Promise<void> | void;
buttonIdCancel?: string;
buttonIdConfirm?: string;
}
then when isLocalized
is false
or undefined
, it is a TextId
. Making it optional means you only have to specify it in the one instance where a ReactElement
is provided.
Code quote:
{props.text || t(props.textId ?? "")}
src/goals/CharacterInventory/Redux/CharacterInventoryActions.ts
line 179 at r2 (raw file):
"g" ); for (const word of changedWords) {
Add a comment explaining what is going on here - that you're escaping special characters in the find string (and that a regular expression is required to replace all occurrences in the string).
(or something to that effect)
Suggestion:
const findRegExp = new RegExp(
findValue.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"),
"g"
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 13 of 20 files reviewed, 2 unresolved discussions (waiting on @imnasnainaec and @jmgrady)
src/components/Dialogs/CancelConfirmDialog.tsx
line 50 at r2 (raw file):
Previously, jmgrady (Jim Grady) wrote…
Previously, it was not possible to have a
CancelConfirmDialog
with empty text - unless thetextId
mapped to an empty string.Unfortunately,
textId
s are indistinguishable fromstring
s so we can't use thetypeof
operator.If the interface is changed to:
interface CancelConfirmDialogProps { open: boolean; text: string | ReactElement; isLocalized?: boolean; handleCancel: () => void; handleConfirm: () => Promise<void> | void; buttonIdCancel?: string; buttonIdConfirm?: string; }
then when
isLocalized
isfalse
orundefined
, it is aTextId
. Making it optional means you only have to specify it in the one instance where aReactElement
is provided.
Done.
src/goals/CharacterInventory/Redux/CharacterInventoryActions.ts
line 179 at r2 (raw file):
Previously, jmgrady (Jim Grady) wrote…
Add a comment explaining what is going on here - that you're escaping special characters in the find string (and that a regular expression is required to replace all occurrences in the string).
(or something to that effect)
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 7 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @imnasnainaec)
Follows #2962 (see diff: loading-button...find-and-replace-reorg)
Precedes #2955
This change is