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

Mattupham/fe 726 porfolio v3 alloyed convert button deposit withdraw dropdown #3841

Conversation

mattupham
Copy link
Contributor

@mattupham mattupham commented Sep 12, 2024

What is the purpose of the change:

  • updates to asset row for alloyed assets

Linear Task

https://linear.app/osmosis/issue/FE-726/porfolio-v3-alloyed-convert-button-deposit-withdraw-dropdown
https://linear.app/osmosis/issue/FE-1061/portfolio-v3-portfolioalloyed-feature-flag

Brief Changelog

  • add alloyed assets feature flag
  • add convert button
  • add dropdown with trade, earn, withdraw, deposit
  • i18n

Testing and Verifying

Screenshot 2024-09-11 at 6 31 48 PM Screenshot 2024-09-11 at 6 31 31 PM Screenshot 2024-09-11 at 5 55 13 PM

Copy link

vercel bot commented Sep 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
osmosis-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2024 5:58am
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Visit Preview Sep 20, 2024 5:58am
osmosis-frontend-dev ⬜️ Ignored (Inspect) Visit Preview Sep 20, 2024 5:58am
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) Sep 20, 2024 5:58am
osmosis-testnet ⬜️ Ignored (Inspect) Visit Preview Sep 20, 2024 5:58am

Copy link
Contributor

coderabbitai bot commented Sep 12, 2024

Walkthrough

The pull request introduces enhancements to the AssetBalancesTable and AssetActionsCell components by implementing a dropdown menu for asset actions and adding new props for asset conversion logic. The AssetActionsCell now conditionally renders action buttons, including a conversion option, based on user interaction. Additionally, a new AssetActionsDropdown component encapsulates the dropdown functionality, improving modularity. A feature flag for "alloyedAssets" is also added to the feature flag system, enhancing control over application features.

Changes

Files Change Summary
packages/web/components/table/asset-balances.tsx Added new imports for dropdown functionality, defined Action type, and introduced getActionOptions and handleSelectAction functions. Modified AssetActionsCell to use a dropdown for actions and created AssetActionsDropdown component.
packages/web/hooks/use-feature-flags.ts Added "alloyedAssets" feature flag to AvailableFlags type and initialized it in defaultFlags.

Possibly related PRs


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 15a2ac9 and c7b99cc.

Files selected for processing (1)
  • packages/web/components/table/asset-balances.tsx (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/web/components/table/asset-balances.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0cd41ed and c31dcac.

Files ignored due to path filters (1)
  • packages/web/localizations/en.json is excluded by !**/*.json
Files selected for processing (1)
  • packages/web/components/table/asset-balances.tsx (4 hunks)
Additional comments not posted (2)
packages/web/components/table/asset-balances.tsx (2)

509-510: Enhancements to AssetActionsCell component look good!

The changes in the AssetActionsCell component enhance its functionality to handle asset conversion scenarios. The new props coinMinimalDenom and variantGroupKey are used to determine if conversion is needed. The rendering logic is updated to conditionally display the "Convert" button when conversion is necessary, and the deposit and withdraw buttons are shown only when conversion is not needed.

These changes improve the component's behavior and provide a better user experience by showing relevant actions based on the asset's conversion state.

Also applies to: 518-519, 525-530, 547-595


627-663: New AssetActionsDropdown component looks great!

The introduction of the AssetActionsDropdown component is a positive addition to the codebase. It encapsulates the dropdown functionality for asset actions, making it a reusable and modular component.

The component receives actionOptions and onSelectAction as props, allowing flexibility in defining the available actions and handling the selection of an action. It utilizes the Popover component to implement the dropdown behavior and renders the action options as buttons within the dropdown.

The component is well-structured, properly implemented, and integrates seamlessly with the existing code. It improves the overall organization and maintainability of the asset actions functionality.

packages/web/components/table/asset-balances.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1775cf3 and 09af7ab.

Files ignored due to path filters (2)
  • packages/web/localizations/en.json is excluded by !**/*.json
  • packages/web/public/icons/sprite.svg is excluded by !**/*.svg, !**/*.svg
Files selected for processing (1)
  • packages/web/components/table/asset-balances.tsx (6 hunks)
Additional comments not posted (5)
packages/web/components/table/asset-balances.tsx (5)

159-160: See the previous comment about removing console log statements.


511-512: LGTM!

The code changes are approved. The new props coinMinimalDenom and variantGroupKey are added to the AssetActionsCell component to determine if asset conversion is necessary.


515-523: LGTM!

The code changes are approved. The needsConversion variable is correctly introduced to check if coinMinimalDenom differs from variantGroupKey. The showConvertButton variable is correctly introduced to conditionally show the convert button based on the alloyedAssets feature flag and needsConversion state.


524-563: LGTM!

The code changes are approved. The getActionOptions function is correctly introduced to return an array of action options based on the showConvertButton state. The handleSelectAction function is correctly introduced to handle the routing logic when an action is selected from the dropdown.


640-701: LGTM!

The code changes are approved. The new AssetActionsDropdown component is correctly introduced to encapsulate the dropdown functionality for action options. The dropdown is correctly populated with action options that are conditionally displayed based on the user's context. The dropdown correctly integrates with the routing logic to navigate to the appropriate pages when actions are selected. The component enhances the modularity of the code and improves the organization of action-related UI elements.

packages/web/components/table/asset-balances.tsx Outdated Show resolved Hide resolved
packages/web/components/table/asset-balances.tsx Outdated Show resolved Hide resolved
@mattupham mattupham changed the title [draft] Mattupham/fe 726 porfolio v3 alloyed convert button deposit withdraw dropdown Mattupham/fe 726 porfolio v3 alloyed convert button deposit withdraw dropdown Sep 12, 2024
@mattupham mattupham requested a review from a team September 12, 2024 01:42
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
// TODO - open conversion modal once clicked
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will plug in the modal in the next PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is behind a flag right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah! calculated here - const showConvertButton = featureFlags.alloyedAssets && needsConversion;

Copy link
Collaborator

@MaxMillington MaxMillington left a comment

Choose a reason for hiding this comment

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

Make to to have QA take a look

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 05faa68 and 15a2ac9.

Files selected for processing (1)
  • packages/web/components/table/asset-balances.tsx (6 hunks)

Comment on lines 509 to 520
const handleSelectAction = (
action: string,
coinDenom: string,
router: NextRouter,
bridgeAsset: ({
anyDenom,
direction,
}: {
anyDenom: string | undefined;
direction: "deposit" | "withdraw" | undefined;
}) => void
) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Specify the action parameter type in handleSelectAction.

The action parameter is currently typed as string. To enhance type safety and prevent potential bugs from invalid action keys, consider typing it as the Action type defined earlier.

Apply this diff to update the parameter type:

 const handleSelectAction = (
-  action: string,
+  action: Action,
   coinDenom: string,
   router: NextRouter,
   bridgeAsset: ({
     anyDenom,
     direction,
   }: {
     anyDenom: string | undefined;
     direction: "deposit" | "withdraw" | undefined;
   }) => void
 ) => {

This ensures that only valid actions of type Action are passed to the function, improving code robustness.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleSelectAction = (
action: string,
coinDenom: string,
router: NextRouter,
bridgeAsset: ({
anyDenom,
direction,
}: {
anyDenom: string | undefined;
direction: "deposit" | "withdraw" | undefined;
}) => void
) => {
const handleSelectAction = (
action: Action,
coinDenom: string,
router: NextRouter,
bridgeAsset: ({
anyDenom,
direction,
}: {
anyDenom: string | undefined;
direction: "deposit" | "withdraw" | undefined;
}) => void
) => {

@mattupham mattupham merged commit 6db052a into stage Sep 20, 2024
33 checks passed
@mattupham mattupham deleted the mattupham/fe-726-porfolio-v3-alloyed-convert-button-deposit-withdraw-dropdown branch September 20, 2024 06:06
mattupham added a commit that referenced this pull request Sep 25, 2024
* Amplitude: prevent outlier value usd logs (#3825)

* prevent outlier value usd logs

* usd const

* forgot one

* format

* Mattupham/fe 726 porfolio v3 alloyed convert button deposit withdraw dropdown (#3841)

* Add convert button

* Add convert button

* Clean up

* Handle feature via flag

* Update icons

* Clean up

* Clean up

* i18n

* Extract functionality

* Extract type

* Clean up comments

* Refactor icon

* Clean up styles

* Update types

* fix: amino signing for withdraw position message (#3852)

* add favorites to portfolio (#3853)

* Update sprite

* Clean up

* Update to useUserWatchlist

---------

Co-authored-by: Jon Ator <[email protected]>
Co-authored-by: Matt Upham <[email protected]>
Co-authored-by: PaddyMc <[email protected]>
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.

2 participants