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

Remove double modal #468

Closed
wants to merge 11 commits into from
Closed

Conversation

tvolk131
Copy link
Member

@tvolk131 tvolk131 commented Aug 5, 2024

Requires #455

When connecting to a new federation, show a loading spinner on the "Add Federation" button rather than showing a second modal with a loading spinner on top of the first modal

Summary by CodeRabbit

  • New Features

    • Introduced a tabbed interface for selecting currency units (msats, sats, btc), enhancing user experience.
    • Added loading and error handling components for improved feedback during data fetching.
    • Launched the FederationsTable for managing deposits and withdrawals, enhancing usability.
    • Implemented the ConnectFederation component to facilitate federation connections with a user-friendly modal interface.
    • Introduced WalletCard for managing cryptocurrency wallet operations, including deposits and withdrawals.
  • Bug Fixes

    • Refined error messaging display for clarity during user interactions.
  • Documentation

    • Updated language files with new keys for wallet and federation functionalities to improve user interface clarity.
  • Chores

    • Organized component structure for better clarity and modularity.
  • Style

    • Enhanced visual feedback and interactivity of components.

@tvolk131 tvolk131 requested review from a team as code owners August 5, 2024 21:55
Copy link
Contributor

coderabbitai bot commented Aug 5, 2024

Walkthrough

Walkthrough

The updates to the application significantly enhance the user interface and functionality of wallet and federation management components. Key improvements include a streamlined tabbed interface for currency unit selection, enhanced error handling with dedicated components, and the introduction of new features for managing deposits and withdrawals. Collectively, these changes improve usability, maintainability, and user experience, making interactions more intuitive and efficient.

Changes

Files Change Summary
apps/gateway-ui/src/App.tsx Enhanced App component with a tabbed interface for currency unit selection, improved state management, and refactored error/loading handling. Introduced FederationsTable for managing deposit and withdrawal actions.
apps/gateway-ui/src/components/Error.tsx, apps/gateway-ui/src/components/ErrorMessage.tsx Introduced Error and ErrorMessage components for better error display, utilizing Chakra UI and internationalization.
apps/gateway-ui/src/components/FederationCard.tsx, apps/gateway-ui/src/components/wallet/WalletCard.tsx Added WalletCard to manage wallet operations, integrating deposit and withdrawal functionalities, and visual enhancements.
apps/gateway-ui/src/components/Loading.tsx Created a Loading component for displaying an indeterminate loading state.
apps/gateway-ui/src/components/federations/* Introduced several new components (ConnectFederation, FederationsTable, ViewConfigModal) for federation management, enhancing user interaction and data presentation.
packages/utils/src/format.tsx, packages/utils/src/index.tsx Enhanced utility functions by adding new parameters for formatting values and generating node URLs based on network types.
apps/gateway-ui/src/languages/en.json, apps/guardian-ui/src/languages/en.json Expanded localization strings for wallet and federation features; modified session shutdown guidance text.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1fed174 and 9ac38f4.

Files selected for processing (1)
  • apps/gateway-ui/src/components/federations/ConnectFederation.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/gateway-ui/src/components/federations/ConnectFederation.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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@@ -151,15 +108,15 @@ export const ConnectFederation = React.memo(function ConnectFederation({
/>
<Button
borderRadius='8px'
maxW='210px'
Copy link
Member Author

Choose a reason for hiding this comment

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

Note for reviewers: We're removing this so that the loadingText below isn't cut off

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: 6

@@ -158,7 +158,7 @@
"current-session": "Current Session",
"session-to-shutdown": "Session to Shutdown at",
"confirm-shutdown": "Confirm Shutdown",
"session-to-shutdown-helper": "Enter the session height at which you want to shutdown your guardian node."
"session-to-shutdown-helper": "."
Copy link
Contributor

Choose a reason for hiding this comment

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

Retain the descriptive text for clarity.

The change to "session-to-shutdown-helper" from a descriptive message to a single period removes valuable guidance for users. This could negatively impact user experience by leaving them without context or instructions regarding the session shutdown process. Consider retaining the original descriptive text.

- "session-to-shutdown-helper": "."
+ "session-to-shutdown-helper": "Enter the session height at which you want to shutdown your guardian node."
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
"session-to-shutdown-helper": "."
"session-to-shutdown-helper": "Enter the session height at which you want to shutdown your guardian node."

Comment on lines +1 to +30
import React from 'react';
import { Flex, Heading, Text, useTheme } from '@chakra-ui/react';
import { useTranslation } from '@fedimint/utils';

interface ErrorProps {
error: string;
}

export const Error: React.FC<ErrorProps> = ({ error }) => {
const { t } = useTranslation();
const theme = useTheme();

return (
<Flex
direction='column'
align='center'
width='100%'
paddingTop='10vh'
paddingX='4'
textAlign='center'
>
<Heading size='lg' marginBottom='4' color={theme.colors.red[500]}>
{t('common.error')}
</Heading>
<Text fontSize='md' color={theme.colors.gray[700]}>
{error}
</Text>
</Flex>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename the Error component to avoid shadowing the global Error object.

The component name Error shadows the global Error object, which can lead to confusion and potential issues. Consider renaming the component to ErrorMessage.

- export const Error: React.FC<ErrorProps> = ({ error }) => {
+ export const ErrorMessage: React.FC<ErrorProps> = ({ error }) => {
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
import React from 'react';
import { Flex, Heading, Text, useTheme } from '@chakra-ui/react';
import { useTranslation } from '@fedimint/utils';
interface ErrorProps {
error: string;
}
export const Error: React.FC<ErrorProps> = ({ error }) => {
const { t } = useTranslation();
const theme = useTheme();
return (
<Flex
direction='column'
align='center'
width='100%'
paddingTop='10vh'
paddingX='4'
textAlign='center'
>
<Heading size='lg' marginBottom='4' color={theme.colors.red[500]}>
{t('common.error')}
</Heading>
<Text fontSize='md' color={theme.colors.gray[700]}>
{error}
</Text>
</Flex>
);
};
import React from 'react';
import { Flex, Heading, Text, useTheme } from '@chakra-ui/react';
import { useTranslation } from '@fedimint/utils';
interface ErrorProps {
error: string;
}
export const ErrorMessage: React.FC<ErrorProps> = ({ error }) => {
const { t } = useTranslation();
const theme = useTheme();
return (
<Flex
direction='column'
align='center'
width='100%'
paddingTop='10vh'
paddingX='4'
textAlign='center'
>
<Heading size='lg' marginBottom='4' color={theme.colors.red[500]}>
{t('common.error')}
</Heading>
<Text fontSize='md' color={theme.colors.gray[700]}>
{error}
</Text>
</Flex>
);
};
Tools
Biome

[error] 9-9: Do not shadow the global "Error" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

Comment on lines +17 to +19
import { FederationsTable } from './components/federations/FederationsTable';
import { Loading } from './components/Loading';
import { Error } from './components/Error';
Copy link
Contributor

Choose a reason for hiding this comment

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

Shadowing global "Error" property.

Consider renaming the Error component to avoid shadowing the global Error property.

- import { Error } from './components/Error';
+ import { ErrorComponent } from './components/Error';
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
import { FederationsTable } from './components/federations/FederationsTable';
import { Loading } from './components/Loading';
import { Error } from './components/Error';
import { FederationsTable } from './components/federations/FederationsTable';
import { Loading } from './components/Loading';
import { ErrorComponent } from './components/Error';
Tools
Biome

[error] 19-19: Do not shadow the global "Error" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

[network]
);

const url = useMemo(() => getAddressUrl(address), [address, getAddressUrl]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused URL variable.

The url variable is assigned a value but never used. Consider removing it if not needed.

Tools
GitHub Check: Lint

[warning] 93-93:
'url' is assigned a value but never used

Comment on lines +74 to +91
const getAddressUrl = useCallback(
(address: string): URL => {
const baseAddress = address.split(':')[1]?.split('?')[0] || '';
switch (network) {
case Network.Signet:
return new URL(`https://mutinynet.com/address/${baseAddress}`);
case Network.Testnet:
return new URL(
`https://mempool.space/testnet/address/${baseAddress}`
);
case Network.Bitcoin:
case Network.Regtest:
default:
return new URL(`https://mempool.space/address/${baseAddress}`);
}
},
[network]
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Get address URL logic.

The getAddressUrl function is correctly implemented but contains redundant case clauses.

- case Network.Bitcoin:
- case Network.Regtest:
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 getAddressUrl = useCallback(
(address: string): URL => {
const baseAddress = address.split(':')[1]?.split('?')[0] || '';
switch (network) {
case Network.Signet:
return new URL(`https://mutinynet.com/address/${baseAddress}`);
case Network.Testnet:
return new URL(
`https://mempool.space/testnet/address/${baseAddress}`
);
case Network.Bitcoin:
case Network.Regtest:
default:
return new URL(`https://mempool.space/address/${baseAddress}`);
}
},
[network]
);
const getAddressUrl = useCallback(
(address: string): URL => {
const baseAddress = address.split(':')[1]?.split('?')[0] || '';
switch (network) {
case Network.Signet:
return new URL(`https://mutinynet.com/address/${baseAddress}`);
case Network.Testnet:
return new URL(
`https://mempool.space/testnet/address/${baseAddress}`
);
default:
return new URL(`https://mempool.space/address/${baseAddress}`);
}
},
[network]
);
Tools
Biome

[error] 84-84: Useless case clause.

because the default clause is present:

Unsafe fix: Remove the useless case.

(lint/complexity/noUselessSwitchCase)


[error] 85-85: Useless case clause.

because the default clause is present:

Unsafe fix: Remove the useless case.

(lint/complexity/noUselessSwitchCase)

Comment on lines 1 to 15
import React, { useState, FC } from 'react';
import {
Box,
Button,
Heading,
Stack,
Text,
useTheme,
Flex,
Textarea,
Modal,
ModalBody,
ModalOverlay,
ModalContent,
CircularProgressLabel,
CircularProgress,
ModalCloseButton,
} from '@chakra-ui/react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unused imports.

The following imports are unused and should be removed: FC, Flex, CircularProgressLabel, CircularProgress.

- import React, { useState, FC } from 'react';
+ import React, { useState } from 'react';
- import { Flex, CircularProgressLabel, CircularProgress } from '@chakra-ui/react';
+ import { CircularProgressLabel, CircularProgress } from '@chakra-ui/react';

Committable suggestion was skipped due to low confidence.

Tools
GitHub Check: Lint

[warning] 1-1:
'FC' is defined but never used


[warning] 9-9:
'Flex' is defined but never used


[warning] 15-15:
'CircularProgressLabel' is defined but never used


[warning] 16-16:
'CircularProgress' is defined but never used

@tvolk131
Copy link
Member Author

tvolk131 commented Aug 6, 2024

Closing in favor of #470 since it's not stacked on another PR

@tvolk131 tvolk131 closed this Aug 6, 2024
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