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

fix: improve disable condition and tooltip tile on TxSummary buttons #1969

Merged
merged 8 commits into from
May 12, 2023

Conversation

DiogoSoaress
Copy link
Member

@DiogoSoaress DiogoSoaress commented May 9, 2023

What it solves

Resolves #1932

How this PR fixes it

Includes the coreSDK initialization in the condition to disable the <TxSummary> buttons (ExecuteTxButton, RejectTxButton and SignTxbutton)
Improve tooltip description as per the disable condition

How to test it

Not next tx

  1. Go to a Tx queue where a queued tx is fully signed but not the "Next" in the queue
  2. Observe the execution icons is disabled and show a tooltip "Transaction {nonce} must be executed first"

Transaction is pending execution

1. Go to a Tx queue and have 2 transactions ready to be executed
2. Execute the first one
3. Observe the execution icons in the second one is disabled and show a tooltip "Pending transaction must first succeed"

Safe SDK not initialized

  1. Go to a Tx queue where there is a tx queued in the "next" nonce
  2. Refresh the page
  3. Try to hover the Execute/Reject/Sign buttons immediately
  4. Observe they are disabled and show a tooltip 'Waiting for the SDK to initialize'

Screenshots

Screenshot 2023-05-09 at 18 13 36

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@github-actions
Copy link

github-actions bot commented May 9, 2023

Branch preview

✅ Deploy successful!

https://fix_disable_execute_button--walletweb.review-wallet-web.5afe.dev

@github-actions
Copy link

github-actions bot commented May 9, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Copy link
Member

@iamacook iamacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some comments to the ExecuteTxButton but they stand for each. I'd suggest consulting with design about this.

A simpler solution would be disabling the submit button in the transaction SignOrExecute modal when the SDK is initialising.

@@ -26,9 +27,19 @@ const ExecuteTxButton = ({
const txNonce = isMultisigExecutionInfo(txSummary.executionInfo) ? txSummary.executionInfo.nonce : undefined
const isPending = useIsPending(txSummary.id)
const { setSelectedTxId } = useContext(ReplaceTxHoverContext)
const safeSDK = getSafeSDK()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getSafeSDK will not react to changes in ExternalStore state. We should use the hook when accessing the value.


const tooltipTitle =
isDisabled && !isNext
? `Transaction ${safe.nonce} must be executed first`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to show this, maybe even the button at all.

isDisabled && !isNext
? `Transaction ${safe.nonce} must be executed first`
: isPending
? `There's a pending transaction`
Copy link
Member

@iamacook iamacook May 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be more descriptive here, e.g.

Suggested change
? `There's a pending transaction`
? `You cannot execute while a transaction is pending.`

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to juggle between a more complete description and a more succinct one given it's a tooltip. Said that are you still in favor of the longer one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared to the title on line 37, I think it needs more information. An alternative: "Pending transaction must first succeed".

: isPending
? `There's a pending transaction`
: !safeSDK
? 'Waiting for the SDK to initialize'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this - it's somewhat technical for the "standard" user. It shouldn't happen to too long either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DiogoSoaress
Copy link
Member Author

A simpler solution would be disabling the submit button in the transaction SignOrExecute modal when the SDK is initialising.

That is already too late, the error appears when loading the values in that modal. That's why I think we should prevent opening it.

@iamacook
Copy link
Member

iamacook commented May 10, 2023

That is already too late, the error appears when loading the values in that modal. That's why I think we should prevent opening it.

Could you suppress the error until the SDK has initialised/failed to initialise?

@DiogoSoaress
Copy link
Member Author

You could suppress the error until the SDK has initialised/failed to initialise.

The way we render ErrorMessage would delay any error until the SDK initialized/failed to initialize. But what I meant was that in order to display the tx data in the modal we rely on the SDK being initialized. See

const [safeTx, safeTxError] = useAsync<SafeTransaction>(() => {
return createExistingTx(chainId, safeAddress, txId)
}, [txId, safeAddress, chainId])
const text = canSign ? (canExecute ? SIGN_EXECUTE_TEXT : SIGN_TEXT) : EXECUTE_TEXT
return (
<SignOrExecuteForm
safeTx={safeTx}
txId={txId}
onSubmit={onSubmit}
isExecutable={canExecute}
onlyExecute={!canSign}
error={safeTxError}
>

const enabledTitle = 'Execute'

expect(getTxButtonTooltip(enabledTitle, disabledPropsBase)).toBe('Execute')
expect(true).toBe(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(true).toBe(true)

const disabledProps = { ...disabledPropsBase, isPending: true }

expect(getTxButtonTooltip(enabledTitle, disabledProps)).toBe('Pending transaction must first succeed')
expect(true).toBe(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(true).toBe(true)

const disabledProps = { ...disabledPropsBase, hasSafeSDK: false }

expect(getTxButtonTooltip(enabledTitle, disabledProps)).toBe('Waiting for the SDK to initialize')
expect(true).toBe(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(true).toBe(true)

@francovenica
Copy link
Contributor

Issue:
The tx, while is being executed, shows the "Pending tx must succeed first", giving the impression that the button will be available at some point, but actually that button should never be since the tx will go away after being executed.
Or we don't show nothing at all in the tx that is being currently executed
Or we show a "Tx in execution"

image

@DiogoSoaress
Copy link
Member Author

@usame-algan @francovenica What do you think of changing that tooltip to "Transaction in execution" ? dropping the "must execute first" that can be misleading.
Or, should we simply not show a tooltip when we have a pending tx?

@katspaugh
Copy link
Member

Can we please wrap this up? The amount of discussion and attention this fix receives starts to worry me.

@francovenica
Copy link
Contributor

francovenica commented May 12, 2023

I think not showing the tooltip in a executing tx is fine. The tx is supposed to disappear anyways after execution

@francovenica
Copy link
Contributor

I still see tooltips while the tx is executing, maybe because the status is not "pending" but "processing" or "relaying".

Still I don't think is that big of a deal. I think we can leave it this way until we get feedback about it.
image
image

@DiogoSoaress
Copy link
Member Author

I still see tooltips while the tx is executing

These tooltips ("Execute", "Replace", "Confirm") were already in place and were not affected by this bug fix/improvement.

@francovenica
Copy link
Contributor

Yes, I think we are done with this ticket. I'll pass it

@DiogoSoaress DiogoSoaress merged commit 08077c2 into dev May 12, 2023
@DiogoSoaress DiogoSoaress deleted the fix-disable-execute-button branch May 12, 2023 14:58
@github-actions github-actions bot locked and limited conversation to collaborators May 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transaction error when trying to execute too fast
5 participants