Skip to content

Permission Delegation support #1315

Open
cybele-ripple wants to merge 8 commits intomainfrom
explorer-permission-delegation
Open

Permission Delegation support #1315
cybele-ripple wants to merge 8 commits intomainfrom
explorer-permission-delegation

Conversation

@cybele-ripple
Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Translation Updates
  • Release

Codebase Modernization

  • Updated files to React Hooks
  • Updated files to TypeScript

Before / After

Example of the account page before any permission delegations (or if the account does not have any permission delegations associated with it):
Screenshot 2026-04-17 at 11 47 42 AM

Screenshots for both desktop and mobile after the permission delegation changes are made:
Screenshot 2026-04-17 at 11 40 44 AM
Screenshot 2026-04-17 at 11 41 36 AM

Test Plan

There are tests that cover this change:

  • src/containers/Accounts/test/index.test.tsx
  • src/containers/Accounts/PermissionDelegation/test/PermissionDelegation.test.tsx

Comment thread public/locales/en-US/translations.json Outdated
"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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Permission Delegation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Resolved here


// Don't render the section if there are no delegations and we're done loading
if (!isLoading && delegates.length === 0) {
return null
Copy link
Copy Markdown
Contributor

@kuan121 kuan121 Apr 23, 2026

Choose a reason for hiding this comment

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

If we return null, the component isn't rendered? Do we test that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correct. There is a test in place for this case.

Comment on lines +51 to +66
<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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we use the same style and HTML code for Account Properties?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment on lines +92 to +96
{delegates.length === 0 ? (
<EmptyMessageTableRow colSpan={3}>
{t('account_page_permission_delegation_no_delegations')}
</EmptyMessageTableRow>
) : (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this unnecessary since we don't show the component when delegates is empty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. Removed this section which is now reflected in the latest commits

Comment thread public/locales/en-US/translations.json Outdated
"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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where is this used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

</th>
</tr>
</thead>
<tbody>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if we have 100 permissions, do we just show a giant and long table? Do we ask the design about this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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',
Copy link
Copy Markdown
Contributor

@kuan121 kuan121 Apr 23, 2026

Choose a reason for hiding this comment

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

Is the status always Active? If yes, we don't need this column?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This section is now removed

Comment on lines +12 to +14
.account-asset-table table {
min-width: 0;
}
Copy link
Copy Markdown
Contributor

@kuan121 kuan121 Apr 23, 2026

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I replaced the table with a custom card here. Custom CSS for this card is now here.

from AccountAsset via the shared .account-asset / .asset-section-header /
.account-asset-table classes. */

.permission-delegation .permission-delegation-table-wrapper {
Copy link
Copy Markdown
Contributor

@kuan121 kuan121 Apr 23, 2026

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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', () => ({
Copy link
Copy Markdown
Contributor

@kuan121 kuan121 Apr 23, 2026

Choose a reason for hiding this comment

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

Why do we need this if we aren't verify anything in this test file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then, should we do something similar to other component and verify the content of in it('renders static parts', async () => {

@mvadari
Copy link
Copy Markdown
Collaborator

mvadari commented Apr 23, 2026

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', () => ({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you update the screenshots in the PR description?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants