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

[CharInv] Consolidate find-and-replace pieces #2964

Merged
merged 9 commits into from
Mar 21, 2024

Conversation

imnasnainaec
Copy link
Collaborator

@imnasnainaec imnasnainaec commented Feb 21, 2024

Follows #2962 (see diff: loading-button...find-and-replace-reorg)
Precedes #2955


This change is Reviewable

@imnasnainaec imnasnainaec added frontend refactor maintenance Issue that makes it difficult to maintain the software or to upgrade installations post-release. Size: S Small sized issue goal: CharacterInventory labels Feb 21, 2024
@imnasnainaec imnasnainaec self-assigned this Feb 21, 2024
@imnasnainaec imnasnainaec marked this pull request as draft February 21, 2024 19:42
Copy link

codecov bot commented Feb 21, 2024

Codecov Report

Attention: Patch coverage is 9.09091% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 72.81%. Comparing base (73dd492) to head (b7de9d3).

Files Patch % Lines
...racterInventory/Redux/CharacterInventoryActions.ts 0.00% 10 Missing ⚠️
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     
Flag Coverage Δ
backend 82.90% <ø> (+0.20%) ⬆️
frontend 63.39% <9.09%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@imnasnainaec imnasnainaec changed the title [CharInv] Consolidate fand-and-replace pieces [CharInv] Consolidate find-and-replace pieces Feb 21, 2024
@imnasnainaec imnasnainaec marked this pull request as ready for review March 20, 2024 14:31
Copy link
Collaborator

@jmgrady jmgrady left a 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, textIds are indistinguishable from strings 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"
    );

Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a 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 the textId mapped to an empty string.

Unfortunately, textIds are indistinguishable from strings 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.

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.

Copy link
Collaborator

@jmgrady jmgrady left a 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @imnasnainaec)

@imnasnainaec imnasnainaec merged commit e79ca3a into master Mar 21, 2024
17 checks passed
@imnasnainaec imnasnainaec deleted the find-and-replace-reorg branch March 21, 2024 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend goal: CharacterInventory maintenance Issue that makes it difficult to maintain the software or to upgrade installations post-release. refactor Size: S Small sized issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants