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: Issues with actions table pagination and refactor table component #3935

Merged
merged 4 commits into from
Jan 7, 2025

Conversation

mmioana
Copy link
Contributor

@mmioana mmioana commented Dec 13, 2024

Description

This PR started off by addressing the broken pagination shown on the tables from the Manage verified members and Manage tokens actions and ended with a big refactoring of the Table component for a better separation of concerns in the supported table features/layouts etc.

Testing

TODO: Unfortunately for a throughout testing we'll have to go thorough all the tables we have in our app.

However, before we do this, let's check the issues for the Manage verified members and Manage tokens actions were solved.

Manage tokens

  • Step 1. Let's start off with a fresh new dev env
  • Step 2. Run node scripts/create-data.js --timeout 100 --coloniesCount 12
  • Step 3. Create a Manage tokens action
  • Step 4. Copy the token addresses from the other colonies and add them to the table until there are more than 10
  • Step 5. Check the pagination is not shown.
  • Step 6. Check the mobile version of the table.
  • Step 7. Create the action and check the table on the completed page
Screen.Recording.2024-12-19.at.17.41.44.mov

Manage verified members

  • Step 1. Create a Manage verified members action
  • Step 2. Select Add members - this is needed only for having a higher number of rows in the table
  • Step 3. Add more than 10 users
  • Step 4. Check the pagination is not shown.
  • Step 5. Check the mobile version of the table.
  • Step 6. Create the action and check the table on the completed page
Screen.Recording.2024-12-19.at.17.44.14.mov

Important

Ok, now let's move to the remaining actions that include tables.
I will kindly ask you to check both desktop and mobile screen sizes.
Also for each action, please complete the action and check the table on the completed action sidebar

Advanced payments action

Screenshot 2024-12-19 at 17 45 26
Screenshot 2024-12-19 at 17 45 52

Split payment action

Screenshot 2024-12-19 at 17 47 58
Screenshot 2024-12-19 at 17 48 07

Staged payments action

First enable the extension here http://localhost:9091/planex/extensions/StagedExpenditure

Screenshot 2024-12-19 at 17 49 53
Screenshot 2024-12-19 at 17 49 57

Manage reputation

Screenshot 2024-12-19 at 17 56 15
Screenshot 2024-12-19 at 17 56 19

Manage permissions

Screenshot 2024-12-19 at 17 56 52
Screenshot 2024-12-19 at 17 56 56

Edit colony details - the social links table

Screenshot 2024-12-19 at 17 57 44
Screenshot 2024-12-19 at 17 57 50

Arbitrary transactions

In order to test with a locally deployed contract, please add at line 21 in src/components/v5/common/ActionSidebar/partials/forms/ArbitraryTxsForm/partials/AddTransactionModal/useGenerateABI.ts
return;
Screenshot 2024-12-20 at 09 31 51

Add a new transaction using the following values
Contract address: 0xeF841fe1611ce41bFCf0265097EFaf50486F5111
ABI/JSON:

[{"type":"constructor","payable":false,"inputs":[{"type":"string","name":"_name"},{"type":"string","name":"_symbol"},{"type":"uint8","name":"_decimals"}]},{"type":"event","anonymous":false,"name":"Approval","inputs":[{"type":"address","name":"src","indexed":true},{"type":"address","name":"guy","indexed":true},{"type":"uint256","name":"wad","indexed":false}]},{"type":"event","anonymous":false,"name":"Burn","inputs":[{"type":"address","name":"guy","indexed":true},{"type":"uint256","name":"wad","indexed":false}]},{"type":"event","anonymous":false,"name":"LogSetAuthority","inputs":[{"type":"address","name":"authority","indexed":true}]},{"type":"event","anonymous":false,"name":"LogSetOwner","inputs":[{"type":"address","name":"owner","indexed":true}]},{"type":"event","anonymous":false,"name":"MetaTransactionExecuted","inputs":[{"type":"address","name":"user","indexed":false},{"type":"address","name":"relayerAddress","indexed":false},{"type":"bytes","name":"functionSignature","indexed":false}]},{"type":"event","anonymous":false,"name":"Mint","inputs":[{"type":"address","name":"guy","indexed":true},{"type":"uint256","name":"wad","indexed":false}]},{"type":"event","anonymous":false,"name":"Transfer","inputs":[{"type":"address","name":"src","indexed":true},{"type":"address","name":"dst","indexed":true},{"type":"uint256","name":"wad","indexed":false}]},{"type":"function","name":"DOMAIN_SEPARATOR","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"bytes32"}]},{"type":"function","name":"PERMIT_TYPEHASH","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"bytes32"}]},{"type":"function","name":"allowance","constant":true,"stateMutability":"view","payable":false,"inputs":[{"type":"address","name":"src"},{"type":"address","name":"guy"}],"outputs":[{"type":"uint256"}]},{"type":"function","name":"approve","constant":false,"payable":false,"inputs":[{"type":"address","name":"guy"},{"type":"uint256","name":"wad"}],"outputs":[{"type":"bool"}]},{"type":"function","name":"authority","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"address"}]},{"type":"function","name":"balanceOf","constant":true,"stateMutability":"view","payable":false,"inputs":[{"type":"address","name":"src"}],"outputs":[{"type":"uint256"}]},{"type":"function","name":"burn","constant":false,"payable":false,"inputs":[{"type":"uint256","name":"wad"}],"outputs":[]},{"type":"function","name":"burn","constant":false,"payable":false,"inputs":[{"type":"address","name":"guy"},{"type":"uint256","name":"wad"}],"outputs":[]},{"type":"function","name":"decimals","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"uint8"}]},{"type":"function","name":"executeMetaTransaction","constant":false,"stateMutability":"payable","payable":true,"inputs":[{"type":"address","name":"_user"},{"type":"bytes","name":"_payload"},{"type":"bytes32","name":"_sigR"},{"type":"bytes32","name":"_sigS"},{"type":"uint8","name":"_sigV"}],"outputs":[{"type":"bytes"}]},{"type":"function","name":"getMetatransactionNonce","constant":true,"stateMutability":"view","payable":false,"inputs":[{"type":"address","name":"_user"}],"outputs":[{"type":"uint256","name":"nonce"}]},{"type":"function","name":"locked","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"bool"}]},{"type":"function","name":"mint","constant":false,"payable":false,"inputs":[{"type":"address","name":"guy"},{"type":"uint256","name":"wad"}],"outputs":[]},{"type":"function","name":"mint","constant":false,"payable":false,"inputs":[{"type":"uint256","name":"wad"}],"outputs":[]},{"type":"function","name":"name","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"string"}]},{"type":"function","name":"nonces","constant":true,"stateMutability":"view","payable":false,"inputs":[{"type":"address","name":"_user"}],"outputs":[{"type":"uint256","name":"nonce"}]},{"type":"function","name":"owner","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"address"}]},{"type":"function","name":"permit","constant":false,"payable":false,"inputs":[{"type":"address","name":"owner"},{"type":"address","name":"spender"},{"type":"uint256","name":"value"},{"type":"uint256","name":"deadline"},{"type":"uint8","name":"v"},{"type":"bytes32","name":"r"},{"type":"bytes32","name":"s"}],"outputs":[]},{"type":"function","name":"setAuthority","constant":false,"payable":false,"inputs":[{"type":"address","name":"authority_"}],"outputs":[]},{"type":"function","name":"setOwner","constant":false,"payable":false,"inputs":[{"type":"address","name":"owner_"}],"outputs":[]},{"type":"function","name":"symbol","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"string"}]},{"type":"function","name":"totalSupply","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"uint256"}]},{"type":"function","name":"transfer","constant":false,"payable":false,"inputs":[{"type":"address","name":"dst"},{"type":"uint256","name":"wad"}],"outputs":[{"type":"bool"}]},{"type":"function","name":"transferFrom","constant":false,"payable":false,"inputs":[{"type":"address","name":"src"},{"type":"address","name":"dst"},{"type":"uint256","name":"wad"}],"outputs":[{"type":"bool"}]},{"type":"function","name":"unlock","constant":false,"payable":false,"inputs":[],"outputs":[]},{"type":"function","name":"verify","constant":true,"stateMutability":"view","payable":false,"inputs":[{"type":"address","name":"_user"},{"type":"uint256","name":"_nonce"},{"type":"uint256","name":"_chainId"},{"type":"bytes","name":"_payload"},{"type":"bytes32","name":"_sigR"},{"type":"bytes32","name":"_sigS"},{"type":"uint8","name":"_sigV"}],"outputs":[{"type":"bool"}]}]

Screenshot 2024-12-20 at 09 31 38

And select any method - probably mint(uint256) it's the simplest
Enter a value for the method parameters, confirm the modal and check the table

Screenshot 2024-12-20 at 09 27 18
Screenshot 2024-12-20 at 09 27 21

Important

Now on to the other pages having tables.
I will kindly ask you to check both desktop and mobile screen sizes.

Dashboard

Go to http://localhost:9091/planex

Screenshot 2024-12-19 at 17 51 03

Activity

Go to http://localhost:9091/planex/activity

Screenshot 2024-12-19 at 17 51 14

Balances

Go to http://localhost:9091/planex/balances

Screenshot 2024-12-19 at 17 53 35

Incoming

Go to http://localhost:9091/planex/incoming

Screenshot 2024-12-19 at 17 53 41

Verified members

Go to http://localhost:9091/planex/verified

Screenshot 2024-12-19 at 17 54 54

Crypto to fiat

Go to http://localhost:9091/account/crypto-to-fiat
Given we don't actually have data to test the table, please add the following at line 47 in src/components/frame/v5/pages/UserCryptoToFiatPage/partials/FiatTransfersTable/FiatTransfersTable.tsx

const { /* sortedData, */ loading } = useFiatTransfersData(sorting);
const sortedData=[{id:"1",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"2",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"3",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"4",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"5",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"6",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"7",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"8",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"9",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"10",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"11",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"12",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}},{id:"13",amount:"10",currency:"EUR",state:"funds_received",createdAt:"2024-12-10",receipt:{url:"http://localhost:9091"}}];

Screenshot 2024-12-19 at 18 05 44
Screenshot 2024-12-19 at 18 05 49

That's hopefully all folks ✨ but please let your creativity loose when testing these changes 🦾

Diffs

Changes 🏗

  • Clearer structure of the Table component

Resolves #3404
Resolves #3467

@mmioana mmioana self-assigned this Dec 13, 2024
@mmioana mmioana force-pushed the fix/3404-broken-action-table-pagination branch 8 times, most recently from 53ad3b6 to 4dc09b0 Compare December 19, 2024 16:16
@mmioana mmioana marked this pull request as ready for review December 19, 2024 17:07
@mmioana mmioana requested a review from a team as a code owner December 19, 2024 17:07
@mmioana mmioana changed the title WIP: Fix issue and refactor table component Fix: issues with actions table pagination and refactor table component Dec 19, 2024
@mmioana mmioana changed the title Fix: issues with actions table pagination and refactor table component Fix: Issues with actions table pagination and refactor table component Dec 19, 2024
@mmioana mmioana force-pushed the fix/3404-broken-action-table-pagination branch from 4dc09b0 to 0f8a145 Compare December 20, 2024 08:37
Fix tables page size issue and refactor table component
@mmioana mmioana force-pushed the fix/3404-broken-action-table-pagination branch from 0f8a145 to db380ed Compare December 23, 2024 08:47
Copy link
Contributor

@davecreaser davecreaser left a comment

Choose a reason for hiding this comment

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

Hey @mmioana really great work on this one! I've half reviewed it, and I remember looking at it when it was in draft mode and you had some questions about it, so I roughly already know what the code is like. I'll do a full review soon, but wanted to first point out an issue that I'm seeing on mobile. It's a problem with the table overflowing the screen when I scroll down (making an advanced payment), it's easiest to just take a look at the video :)

Screen.Recording.2025-01-06.at.13.58.32.mov

On desktop everything is looking great though! 👏

Manage tokens:
manage_tokens_1
manage_tokens_2
manage_tokens_3

Manage verified members:
manage_verified_members_1
manage_verified_members_2
manage_verified_members_3

Advanced payment:
Screenshot 2025-01-06 at 13 57 41

@@ -23,13 +24,20 @@ const RecentActivityTable: FC<ColonyActionsTableProps> = ({
domainId: nativeDomainId,
});

const pageCount = Math.ceil(totalActions / (props.pageSize ?? 10));
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay this is such a small little tidy up thing, and it has no right to make me as happy as it does, but it's these tiny type of things that just add up over time to make a wayyyy more readable and clean codebase 🧹

Copy link
Contributor

@davecreaser davecreaser left a comment

Choose a reason for hiding this comment

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

Just finished reviewing the code. Looking really good, and I think it's a lot easier to read and simpler to use / reuse. It is still quite a complicated table but I think that's unavoidable at the moment! You've done a really nice job with it, wasn't a fun refactor I'm sure 👍

Still just keeping this review as request changes purely because of the errors I found while testing (in my last review) but code-wise it's all good. The comments I've made in the code are super minor. Nice one! 🎉

}}
layout={isMobile ? 'vertical' : 'horizontal'}
// sizeUnit={isMobile ? undefined : '%'}
// meatBallMenuSize={isMobile ? undefined : 10}
Copy link
Contributor

Choose a reason for hiding this comment

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

Leftover comments?

@@ -113,11 +129,11 @@ export const useArbitraryTxsTableColumns = ({
}
return <CellDescription data={data} />;
},
size: isMobile ? 100 : 67,
staticSize: isMobile ? '100px' : '67%',
}),
],
[columnHelper, isMobile, openTransactionModal, isError],
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably best to fix this dependency array warning while we're here! 😄

pageSize?: number; // Number of rows per page
canNextPage?: boolean; // Enable "next page"
canPreviousPage?: boolean; // Enable "previous page"
onPageChange?: (direction: PaginationDirection) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Being pedantic, but ideally onPageChange should also have a comment if all the other properties do 😆

export interface BaseTableProps<T> extends BaseTableOptions<T> {
table: Table<T>; // React Table instance
rows?: TableRowOptions<T>; // Row-specific options
moreActions?: MoreActionsOptions<T>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, a comment would be nice for moreActions just to keep it consistent

Fix: Virtualised row overflowing
Chore: Changes after review
@mmioana
Copy link
Contributor Author

mmioana commented Jan 6, 2025

@davecreaser I have fixed the bug with the overflowing rows, which was reproducible also on master. It was caused by the width setup for the td in VirtualisedRow once the number of payments was > 10.
Also took care of the other comments, if you'd like to have another look 🙌

davecreaser
davecreaser previously approved these changes Jan 6, 2025
Copy link
Contributor

@davecreaser davecreaser left a comment

Choose a reason for hiding this comment

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

Awesome, the issue is fixed! Thanks for the code changes too. 🎉

Screen.Recording.2025-01-06.at.16.54.35.mov

Copy link
Contributor

@bassgeta bassgeta left a comment

Choose a reason for hiding this comment

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

Sheeeeeeesh now this is a lot of changes, legit stuff 💪
Props for untangling all the props, it's a major step in the right direction, but sadly the lib itself isn't that JSX friendly, so we gotta rely on a ton of JSX in hooks, but hey, can't have everything 🤷

I love the overrides approach, and overall the table now seems more sane to use, even if it's still quite complicated due to all the different variations 🔥
I've tried the meatball menu actions too, but I'm not gonna drop 1 GB of videos onto this review :D

Manage tokens ✔️

image
image

On mobile ✔️
image
image

Advanced payments ✔️

WITH 400 ROWS 😎
image
image
image
image
(we really should fix this to not take ages to load :D )
image

Split payments ⚠️

image
image
image
image
On mobile, the total number overlaps the Total text

Manage reputation ✔️

This one doesn't even need to be a table, but we can might as well use the styles it provides 🤷
image
image
image
image

Manage permissions ✔️

image
image
image
image

Edit colony details ✔️

image
image
image
image

Manage verified members ✔️

image
image
image
image

From this point onwards I'll just drop some weird bits so I don't spam this too much

  1. I somehow got the recent activity table stuck in a weird state with pagination? But it seems like it may be just my local dev env crashing since the full activity table one didn't have multiple pages
    image

Fix: Update colSpan for split payments table
@mmioana
Copy link
Contributor Author

mmioana commented Jan 6, 2025

@bassgeta I fixed the Split payments footer text overlapping issue, but this was already present on master - wondering how many more there are 🫠

And regarding the pagination bug, I didn't manage to reproduce it

Copy link
Contributor

@bassgeta bassgeta left a comment

Choose a reason for hiding this comment

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

Other tables still looking good, seems like my bug was more due to my locally broken dev env (I've tried reproducing it since, and I wasn't able to)...
Anyhow, nice job fixing the colspan issue 😎
image

🚢

Copy link
Contributor

@davecreaser davecreaser left a comment

Choose a reason for hiding this comment

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

Still all looking good to me!

Split Payments table:
Screenshot 2025-01-07 at 12 05 01

And completed action:
Screenshot 2025-01-07 at 12 05 38

Note: the next button at the bottom has no padding, but that is an issue on master and not caused by this PR

Copy link
Contributor

@rumzledz rumzledz left a comment

Choose a reason for hiding this comment

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

Awesome awesome updates @mmioana ! 🙌

Screenshot 2025-01-07 at 21 57 01 Screenshot 2025-01-07 at 22 24 28 Screenshot 2025-01-07 at 22 26 37 Screenshot 2025-01-07 at 22 46 14 Screenshot 2025-01-07 at 22 55 38

Found some tiny UI issues here and there but Ioana will deal with them separately 🔧

Merge it!!!

merge

@mmioana mmioana merged commit 84a52d4 into master Jan 7, 2025
2 checks passed
@mmioana mmioana deleted the fix/3404-broken-action-table-pagination branch January 7, 2025 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants