Permission Delegation support #1315
Conversation
| "account_page_asset_table_no_lptoken": "No LP Tokens found", | ||
| "account_page_asset_table_no_mpt": "No MPTs found", | ||
| "account_page_asset_table_no_nft": "No NFTs found", | ||
| "account_page_permission_delegation": "Permission delegation", |
|
|
||
| // Don't render the section if there are no delegations and we're done loading | ||
| if (!isLoading && delegates.length === 0) { | ||
| return null |
There was a problem hiding this comment.
If we return null, the component isn't rendered? Do we test that?
There was a problem hiding this comment.
Correct. There is a test in place for this case.
| <div className="asset-section-header"> | ||
| <h3 className="account-asset-title"> | ||
| {t('account_page_permission_delegation')} | ||
| </h3> | ||
| <button | ||
| type="button" | ||
| className="asset-section-toggle" | ||
| onClick={() => setIsOpen((s) => !s)} | ||
| aria-expanded={isOpen} | ||
| aria-label="Toggle permission delegation" | ||
| > | ||
| <ArrowIcon | ||
| className={`asset-section-arrow ${isOpen ? 'open' : ''}`} | ||
| /> | ||
| </button> | ||
| </div> |
There was a problem hiding this comment.
Do we use the same style and HTML code for Account Properties?
There was a problem hiding this comment.
Yes there are shared components. I made a CollapsibleSection component that is now shared between Account Properties (AccountSummary) and PermissionDelegation:
src/containers/shared/components/CollapsibleSection/index.tsx
src/containers/shared/components/CollapsibleSection/styles.scss
| {delegates.length === 0 ? ( | ||
| <EmptyMessageTableRow colSpan={3}> | ||
| {t('account_page_permission_delegation_no_delegations')} | ||
| </EmptyMessageTableRow> | ||
| ) : ( |
There was a problem hiding this comment.
Is this unnecessary since we don't show the component when delegates is empty.
There was a problem hiding this comment.
Yes. Removed this section which is now reflected in the latest commits
| "account_page_permission_delegation_column_granted_to": "Granted To", | ||
| "account_page_permission_delegation_column_status": "Status", | ||
| "account_page_permission_delegation_status_active": "Active", | ||
| "account_page_permission_delegation_status_expired": "Expired", |
There was a problem hiding this comment.
It's stale code from a previous change. Updated the translations pages so that only account_page_permission_delegation is added:
public/locales/ca-CA/translations.json
public/locales/en-US/translations.json
public/locales/es-ES/translations.json
public/locales/fr-FR/translations.json
public/locales/ja-JP/translations.json
public/locales/ko-KR/translations.json
public/locales/my-MM/translations.json
| </th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> |
There was a problem hiding this comment.
What if we have 100 permissions, do we just show a giant and long table? Do we ask the design about this?
There was a problem hiding this comment.
Yes the plan is to show a large table. This section (along with the others) can be minimized
| </td> | ||
| <td> | ||
| {t( | ||
| 'account_page_permission_delegation_status_active', |
There was a problem hiding this comment.
Is the status always Active? If yes, we don't need this column?
| .account-asset-table table { | ||
| min-width: 0; | ||
| } |
There was a problem hiding this comment.
Is it a good idea to just reuse this without any renaming? This table isn't an asset table. I would rather create new CSS rule. Do we have share table CSS or component in explorer that we can reuse?
| from AccountAsset via the shared .account-asset / .asset-section-header / | ||
| .account-asset-table classes. */ | ||
|
|
||
| .permission-delegation .permission-delegation-table-wrapper { |
There was a problem hiding this comment.
Is it good UX to have a table span the full width of the screen when it only contains three columns? Bringing this up for consideration—could we instead use a layout similar to the Account Properties or Signers sections, like those shown here: https://livenet.xrpl.org/accounts/rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De
There was a problem hiding this comment.
Yes and good idea. Implemented this in src/containers/Accounts/PermissionDelegation/styles.scss. I replaced the table with a delegate-list.
| default: () => <div data-testid="account-asset">Account Asset</div>, | ||
| })) | ||
|
|
||
| jest.mock('../PermissionDelegation', () => ({ |
There was a problem hiding this comment.
Why do we need this if we aren't verify anything in this test file?
There was a problem hiding this comment.
The mock is needed for isolation, not verification. I am mocking ../PermissionDelegation so rendering <Accounts> does not pull in the actual PermissionDelegation since this is for a unit test on Accounts specifically
There was a problem hiding this comment.
Then, should we do something similar to other component and verify the content of in it('renders static parts', async () => {
|
Not sure if this is happening in another PR, but IMO the transaction page (maybe also the table detail section) should also show that the tx was sent by a delegate |
- Extract shared CollapsibleSection component used by PermissionDelegation, AccountAsset, and AccountSummary (removes 3 duplicate implementations) - Redesign PermissionDelegation as a card layout (address + permission chips) instead of a full-width table - Drop the always-"Active" Status column and unused EmptyMessageTableRow branch - Remove unused in-branch translation keys (permission_delegation column/ status/no_delegations, assets_available, other_data, not_available, percent_of_supply, currency_toggle_help)
CI fails to resolve react-router-dom from the new test file. Use MemoryRouter from react-router (the pattern used by QuickHarness) to avoid the resolution issue.
- Reorder padding/gap in delegate-item to satisfy stylelint - Wait for rendered state (not just mock call) in the empty and card-structure tests to avoid CI timing failures - Re-prettier AccountAsset styles.scss
Restore assets_available, other_data, not_available, percent_of_supply, and currency_toggle_help at their original positions. These were added earlier in this branch and should be preserved even if not yet wired up.
| default: () => <div data-testid="account-asset">Account Asset</div>, | ||
| })) | ||
|
|
||
| jest.mock('../PermissionDelegation', () => ({ |
There was a problem hiding this comment.
Then, should we do something similar to other component and verify the content of in it('renders static parts', async () => {
| "account_page_asset_table_no_lptoken": "No LP Tokens found", | ||
| "account_page_asset_table_no_mpt": "No MPTs found", | ||
| "account_page_asset_table_no_nft": "No NFTs found", | ||
| "account_page_permission_delegation": "Permission Delegation", |
There was a problem hiding this comment.
Can you update the screenshots in the PR description?
High Level Overview of Change
This PR includes a permission delegation section in the account account page.
Context of Change
The new permission delegation section appears between account properties and assets held in the account page. If the account does not have any permission delegations associated with it, then the section will now appear
Type of Change
Codebase Modernization
Before / After
Example of the account page before any permission delegations (or if the account does not have any permission delegations associated with it):

Screenshots for both desktop and mobile after the permission delegation changes are made:


Test Plan
There are tests that cover this change: