-
Notifications
You must be signed in to change notification settings - Fork 465
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
Fix: signer vs plural signers #4675
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import EthHashInfo from '@/components/common/EthHashInfo' | |
|
||
import commonCss from '@/components/tx-flow/common/styles.module.css' | ||
import { ChangeSignerSetupWarning } from '@/features/multichain/components/SignerSetupWarning/ChangeSignerSetupWarning' | ||
import { maybePlural } from '@/utils/formatters' | ||
|
||
export const ReviewRemoveOwner = ({ params }: { params: RemoveOwnerFlowProps }): ReactElement => { | ||
const addressBook = useAddressBook() | ||
|
@@ -55,7 +56,7 @@ export const ReviewRemoveOwner = ({ params }: { params: RemoveOwnerFlowProps }): | |
Any transaction requires the confirmation of: | ||
</Typography> | ||
<Typography> | ||
<b>{threshold}</b> out of <b>{newOwnerLength}</b> signers | ||
<b>{threshold}</b> out of <b>{newOwnerLength}</b> signer{maybePlural(newOwnerLength)} | ||
</Typography> | ||
</Box> | ||
<Divider className={commonCss.nestedDivider} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -331,7 +331,7 @@ exports[`SettingsChange should display the SettingsChange component with owner d | |
|
||
<b> | ||
1 | ||
signers | ||
signer | ||
</b> | ||
</p> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure the conditional for singular/plural form is accurate. Changing "signers" to "signer" might be incorrect if it's intended for a plural context. Verify the logic, handling both singular and plural cases to avoid linguistic errors. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { SettingsInfoType, type SettingsChange } from '@safe-global/safe-gateway | |
import { ChangeSignerSetupWarning } from '@/features/multichain/components/SignerSetupWarning/ChangeSignerSetupWarning' | ||
import { useContext } from 'react' | ||
import { SettingsChangeContext } from '@/components/tx-flow/flows/AddOwner/context' | ||
import { maybePlural } from '@/utils/formatters' | ||
|
||
export interface SettingsChangeProps extends NarrowConfirmationViewProps { | ||
txInfo: SettingsChange | ||
|
@@ -22,6 +23,7 @@ const SettingsChange: React.FC<SettingsChangeProps> = ({ txInfo: { settingsInfo | |
|
||
const shouldShowChangeSigner = 'owner' in settingsInfo || 'newOwner' in params | ||
const hasNewOwner = 'newOwner' in params | ||
const newSignersLength = safe.owners.length + ('removedOwner' in settingsInfo ? 0 : 1) | ||
|
||
return ( | ||
<> | ||
|
@@ -54,7 +56,9 @@ const SettingsChange: React.FC<SettingsChangeProps> = ({ txInfo: { settingsInfo | |
<Typography variant="body2">Any transaction requires the confirmation of:</Typography> | ||
<Typography> | ||
<b>{settingsInfo.threshold}</b> out of{' '} | ||
<b>{safe.owners.length + ('removedOwner' in settingsInfo ? 0 : 1)} signers</b> | ||
<b> | ||
{newSignersLength} signer{maybePlural(newSignersLength)} | ||
</b> | ||
</Typography> | ||
</Box> | ||
</> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const newSignersLength = safe.owners.length + ('removedOwner' in settingsInfo ? 0 : 1); Consider encapsulating the logic to determine the number of signers inside a function for clarity and reuse. This will simplify the component and improve code readability. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,7 +123,7 @@ exports[`ConfirmationView should display a confirmation screen for a SETTINGS_CH | |
|
||
<b> | ||
1 | ||
signers | ||
signer | ||
</b> | ||
</p> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that the change from "signers" to "signer" does not impact any logic that depends on the plurality of signers. Verify surrounding code for logic that might assume a list or count of signers, and adjust business logic if applicable. |
||
|
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.
Consider moving
maybePlural
logic out of template literal for clarity. Refactor to use a single function call within the component to determine singular or plural form, to enhance readability and maintainability.