Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature/dapp reusable action forms and progress #2921

Conversation

weilbith
Copy link
Contributor

@weilbith weilbith commented Aug 31, 2021

Fixes #2890
Based on #2920

Short description
TBD

Definition of Done

  • Steps to manually test the change have been documented
  • Acceptance criteria are met
  • Change has been manually tested by the reviewer (dApp)

Steps to manually test the change (dApp)

@weilbith weilbith requested a review from taleldayekh August 31, 2021 13:35
@codecov
Copy link

codecov bot commented Aug 31, 2021

Codecov Report

Merging #2921 (08a8487) into master (d0a25b0) will decrease coverage by 0.69%.
The diff coverage is 91.66%.

❗ Current head 08a8487 differs from pull request most recent head 96ca37f. Consider uploading reports for the commit 96ca37f to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2921      +/-   ##
==========================================
- Coverage   93.67%   92.98%   -0.70%     
==========================================
  Files         116      203      +87     
  Lines        6406     8168    +1762     
  Branches     1157     1361     +204     
==========================================
+ Hits         6001     7595    +1594     
- Misses        350      478     +128     
- Partials       55       95      +40     
Flag Coverage Δ
dapp 87.24% <91.66%> (+6.62%) ⬆️
dapp.unit 87.24% <91.66%> (+6.62%) ⬆️
sdk 95.71% <ø> (-0.02%) ⬇️
sdk.e2e 72.67% <ø> (-0.17%) ⬇️
sdk.integration 79.76% <ø> (ø)
sdk.unit 49.15% <ø> (ø)

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

Impacted Files Coverage Δ
raiden-dapp/src/model/types.ts 100.00% <ø> (ø)
...n-dapp/src/components/transfer/TransferHeaders.vue 94.73% <75.00%> (ø)
raiden-dapp/src/mixins/action-mixin.ts 78.94% <78.94%> (ø)
raiden-dapp/src/components/ActionProgressCard.vue 88.88% <88.88%> (ø)
...dapp/src/components/channels/ChannelOpenAction.vue 94.44% <94.44%> (ø)
raiden-dapp/src/views/OpenChannelRoute.vue 95.83% <95.00%> (ø)
...dapp/src/components/channels/ChannelActionForm.vue 100.00% <100.00%> (ø)
...p/src/components/channels/ChannelDepositAction.vue 100.00% <100.00%> (ø)
...p/src/components/channels/ChannelDepositDialog.vue 100.00% <100.00%> (ø)
...en-dapp/src/components/channels/ChannelDialogs.vue 100.00% <100.00%> (ø)
... and 91 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0a25b0...96ca37f. Read the comment docs.

@weilbith weilbith force-pushed the feature/dapp-reusable-action-forms-and-progress branch from 7223a54 to 82862ff Compare September 1, 2021 08:47
@weilbith
Copy link
Contributor Author

weilbith commented Sep 1, 2021

Alright. Talel and I did a "pair-programming-review" together yesterday. The review comments above are in fact mine as I found out that the linter did not detect those unused code snippets (part of older implementation approach versions).
Talel did agree with the general new concept of the actions I have introduced. The actual review and approval is outstanding. He might wanna check for example the new translations.
Today he is traveling for work and can't do it. But as he approved the general approach, I can continue with my work for #2882 using this PR.

@taleldayekh taleldayekh self-requested a review September 2, 2021 14:33
Copy link
Contributor

@taleldayekh taleldayekh left a comment

Choose a reason for hiding this comment

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

Your walkthrough the other day gave me a good understanding of the changes. I skimmed through it now and could not find anything apparent that seemed out of order.

Some nit-picks about spelling but no big deal, but you should address the ones in the locales the others you can decide yourself.

Thank you! 👍🏼

This component is meant to be the unified effort of displaying the
progress of an action to the user. Actions are understood as time
consuming processes where the user has to wait for it to complete.
Examples are opening a channel or withdrawing from the UDC.
So far this is implemented everywhere multiple times over and over again
with different feature sets and slightly different visuals. This
component should unify them and replace them on a long term.

The action progress card is just for the visualization, not the action
itself. The progress consists of a overall state and the state of
multiple steps that are within this action. The overall state can be in
progress, completed or failed (with a respective error). Each step can
be pending, active, completed or failed. Steps have a title and
a description with user instructions (e.g. to confirm a blockchain
transaction). An example for steps are the opening of a channel with
a final deposit, where it firsts opens the channel, then does a token
transfer and then deposit to the channel. This component does include no
own logic to interpret data on a higher level or controls how the steps
are changing their state.

The usage of this component will follow soon in the next commits.
@weilbith
Copy link
Contributor Author

weilbith commented Sep 8, 2021

I now first rebased this on master after #2920 got merged and resolved the conflicts. I'll now push fixup commits to address the review feedback so it is easier to see that I solved them.

@weilbith weilbith force-pushed the feature/dapp-reusable-action-forms-and-progress branch from 7990240 to 4119851 Compare September 8, 2021 12:14
@weilbith
Copy link
Contributor Author

weilbith commented Sep 8, 2021

Alright. I addressed all review comments. As they were all about spelling, I'm rushing a little and squash the fixup commits already.

@weilbith weilbith force-pushed the feature/dapp-reusable-action-forms-and-progress branch from 426f3f9 to 0b6673b Compare September 8, 2021 12:24
@weilbith
Copy link
Contributor Author

weilbith commented Sep 8, 2021

Ah, some feedback here was actually about changes in the predecessor PR. Thereby the fixup commits do not work. I need to combine them into a new standalone commit.

@weilbith weilbith force-pushed the feature/dapp-reusable-action-forms-and-progress branch from 0b6673b to 4ef80de Compare September 8, 2021 12:30
@weilbith
Copy link
Contributor Author

weilbith commented Sep 8, 2021

I suffer from the TypeScript update...

The action progress card unifies the display of an action to the user.
The now newly added action mixin is the abstract class for all action
implementations. This means these components are not actually displaying
anything, but control the action (steps) and use the progress card to
visualize it. The first here added action which is using this setup is
the channel deposit action. It is a very simple one and consists of
a single step only.

The mixin controls the higher level action state, and the orchestration
of the control flow including the state reset and all computed
properties. The parts which are individual by the actions like the
steps are then customized by the components using the mixin.

The mixin includes a minimal visual part which allows to either use the
plain action progress card or put it into a dialog pop-up. This is
helpful as in many places we trigger actions with a button and then want
to visualize the progress independently from the existing layout (e.g.
open channel view).
In case of such a dialog it re-implements the already known feature to
automatically close the dialog (with the progress) when the action has
succeeded. The delay to do so can be customized. In case of a failure,
the user is responsible to close the dialog himself.

This also finally brings in the feature to block the user from closing
the action dialog, while the action has not yet completed

The mixin allows to display a slot component instead of the progress
while the action is not in progress. When the action gets triggered,
slot gets hidden if the progress is not showing in a dialog on top of
it.

Unfortunately Vue does not support single-file-components with
a template for mixins. This requires to use a pure render function to
provide the features of the slot and dialog handling.
This is the second action implementation. It re-uses the introduced
action mixin. It is more complex than the first action to do
a channel deposit as it consists of up to three steps depending on the
inputs.

This required some changes to the raiden service function to execute the
actual channel opening. The SDK accepts a event handler function as
parameter. So far this got abstracted away with a (stupid) generic
function which counts the events as steps. This got removed, allowing
the channel open action to directly update the actions progress steps up
on the emitted events by the SDK.
This component is meant to be used for handling the parameters of
a channel related action (e.g. opening a channel). It consists of the
three values that relate to channel actions which are the token
(address), the partner (address) and the token amount (e.g. to deposit).
Each value can be either just be displayed or is allowed to be edited by
the user. Values can be also completely hidden if they are clear for the
context (e.g. acting on a selected channel). Inputs can be restricted
according to special scenarios (e.g. exclude channel partners when
opening a new channel).

The form component finally provides a single component which is
responsible to fetch token information and monitor them. Before (or
actually still is yet) this was done everywhere we needed it. As this is
an asynchronous process, this was causing a lot of issues in some
components. Now they must only handle the addresses as strings and the
form will do the work.

The form will be bound to a specific action to execute. It also allows
to customize some labeling for the specific action and some other visual
adoptions. Of course it only allows to execute the action if all form
values are valid. This does not apply for fixed values that are not
editable. They are provided by the parent component and expected to be
correct. This might be spot to improve at a later point (especially if
the values come from URL parameters).

The component emits events according to the outcome of the executed
action.

Note that for the moment the token value of the form is not editable and always
fixed. This is because we don't have yet a token input component. Only the big
component for the select token route. This might be added at a later point.
The channel deposit dialog could be finally drastically simplified by
using the new channel deposit action and the channel action form. It
basically just puts everything into a dialog and reacts to a completed
deposit. This also reflects in the heavily simplified unit tests, as the
tests of the action and form component test all the functionality at
a single place.

This commit includes the changes to adapt the dialog usage everywhere.
This includes a lot of simplifications as the new unified component do
the heavy lifting and the using/parent components must just use them in
their templates with the correct properties.

Also the end-to-end tests got marginally adopted to some new `data-cy`
components and the handling of token amount input without a default zero
value.
Also here we now use the new (fancy) action architecture, heavily
simplifying the route component itself by using the channel action and
form components.

This includes improvements/refactoring of the unit tests for the route
component.
@weilbith
Copy link
Contributor Author

weilbith commented Sep 8, 2021

Alright. TypeScript issues fixed and CI is fine. So I squash the fixup commits. No CHANGELOG entry required.

@weilbith weilbith force-pushed the feature/dapp-reusable-action-forms-and-progress branch from 08a8487 to 96ca37f Compare September 8, 2021 14:06
@weilbith weilbith merged commit 556686f into raiden-network:master Sep 8, 2021
@weilbith weilbith deleted the feature/dapp-reusable-action-forms-and-progress branch September 8, 2021 14:22
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dApp - make open channel and deposit to channel re-usable
2 participants