-
Notifications
You must be signed in to change notification settings - Fork 408
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: improve disable condition and tooltip tile on TxSummary
buttons
#1969
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9bd716c
fix: improve disable condition and tooltip message on ExecuteTxButton
DiogoSoaress 0751ab1
improve disable condition and tooltip message for RejectTxButton and …
DiogoSoaress a9da970
use hook instead of getter
DiogoSoaress ad5c0de
improve tx pending message
DiogoSoaress 183e252
extract get tootip title to an util
DiogoSoaress 850ab75
improve type and remove leftover code
DiogoSoaress 9f8f7fd
improve SDK not initialized tooltip message
DiogoSoaress 9985ca4
remove tx is pending tooltip
DiogoSoaress File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,38 @@ | ||||
import { getTxButtonTooltip } from '../utils' | ||||
|
||||
describe('transactions utils', () => { | ||||
describe('getTooltipTitle', () => { | ||||
const disabledPropsBase = { isPending: false, hasSafeSDK: true } | ||||
|
||||
it('should return the enabledTitle if no disabled conditions', () => { | ||||
const enabledTitle = 'Execute' | ||||
|
||||
expect(getTxButtonTooltip(enabledTitle, disabledPropsBase)).toBe('Execute') | ||||
expect(true).toBe(true) | ||||
}) | ||||
|
||||
it('should return the not isNext message', () => { | ||||
const enabledTitle = 'Confirm' | ||||
const nonce = 2 | ||||
const disabledProps = { ...disabledPropsBase, isNext: false, nonce } | ||||
|
||||
expect(getTxButtonTooltip(enabledTitle, disabledProps)).toBe('Transaction 2 must be executed first') | ||||
}) | ||||
|
||||
it('should return the "is tx pending" message', () => { | ||||
const enabledTitle = 'Execute' | ||||
const disabledProps = { ...disabledPropsBase, isPending: true } | ||||
|
||||
expect(getTxButtonTooltip(enabledTitle, disabledProps)).toBe('Pending transaction must first succeed') | ||||
expect(true).toBe(true) | ||||
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.
Suggested change
|
||||
}) | ||||
|
||||
it('should return the Safe SDK not initialized message', () => { | ||||
const enabledTitle = 'Execute' | ||||
const disabledProps = { ...disabledPropsBase, hasSafeSDK: false } | ||||
|
||||
expect(getTxButtonTooltip(enabledTitle, disabledProps)).toBe('Waiting for the SDK to initialize') | ||||
expect(true).toBe(true) | ||||
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.
Suggested change
|
||||
}) | ||||
}) | ||||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
type DisabledPropsType = | ||
| { | ||
isNext: false | ||
nonce: number | ||
isPending: boolean | ||
hasSafeSDK: boolean | ||
} | ||
| { | ||
isNext?: boolean | ||
nonce?: number | ||
isPending: boolean | ||
hasSafeSDK: boolean | ||
} | ||
|
||
type EnabledTitleType = 'Execute' | 'Replace' | 'Confirm' | ||
|
||
export const getTxButtonTooltip = (enabledTitle: EnabledTitleType, disabledProps: DisabledPropsType) => { | ||
const { isPending, hasSafeSDK, isNext, nonce } = disabledProps | ||
|
||
return isNext === false | ||
? `Transaction ${nonce} must be executed first` | ||
: isPending | ||
? 'Pending transaction must first succeed' | ||
: !hasSafeSDK | ||
? 'Waiting for the SDK to initialize' | ||
: enabledTitle | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.