Skip to content

Extract a reusable "Voting Power Preview" component for governance proposal forms #367

Description

@thegreatfeez

Frontend — Modal

Summary

The AddOwner, RemoveOwner, and weight-change proposal forms each need to show a before/after voting-power preview, and left unchecked each one will grow its own slightly different copy of that logic. This issue consolidates that into a single shared component so all three forms present the same preview consistently and any future fix or styling change only has to happen once.

Background

By the time this issue is picked up, the AddOwner, RemoveOwner, and "Propose Weight Change" forms in CreateProposalModal.tsx and OwnersPage.tsx each independently compute and render a "what will total weight and quorum look like after this proposal executes" preview, using the weight-percentage formatting helpers in soroban.ts. Each form's preview shows slightly different specifics (AddOwner shows a fixed +1 weight increase, RemoveOwner shows a decrease and a possible quorum-break warning, weight-change shows an owner's before/after share), but the underlying shape — a labeled before value, an after value, and a percentage — is the same across all three.

What Needs to Be Done

  1. Create a new component (for example, frontend/src/components/VotingPowerPreview.tsx) that takes a before weight, an after weight, a total weight, and renders a consistent "before → after" summary with percentage shares, using the existing weight-percentage formatting helpers.
  2. Support an optional warning state (a boolean plus a message) so the RemoveOwner form's quorum-break warning can use the same component instead of a separate ad hoc warning block.
  3. Replace the bespoke preview markup in the AddOwner, RemoveOwner, and weight-change forms with this shared component, keeping each form's specific data-fetching logic in place — only the rendering is consolidated.
  4. Confirm visually (or with a snapshot test) that each form's preview looks the same as it did before the refactor, since this issue is not meant to change behavior, only reduce duplication.

Acceptance Criteria

  • A single VotingPowerPreview component exists and is used by all three governance proposal forms that need a weight preview.
  • The component supports an optional warning state for the RemoveOwner form's quorum-break case.
  • No duplicated before/after weight-percentage rendering logic remains across the three forms.
  • Each form's preview renders the same information it did before this refactor.

Files to Look At

  • frontend/src/components/CreateProposalModal.tsx — AddOwner and RemoveOwner forms with their own preview logic to consolidate
  • frontend/src/pages/OwnersPage.tsx — weight-change proposal form with its own preview logic to consolidate
  • frontend/src/lib/soroban.ts — shared weight-percentage formatting helpers the new component should build on

Difficulty: Medium

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions