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

feat: homepage actions and federation selector #527

Merged
merged 11 commits into from
Sep 20, 2024

Conversation

Kodylow
Copy link
Member

@Kodylow Kodylow commented Sep 18, 2024

Took another pass at improving the home page, it's much better now with a nice selector

image

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a dynamic navigation header with service selection capabilities.
    • Added modals for connecting, editing, and removing services, enhancing user interaction.
    • Implemented a responsive service table for better service management.
    • Added a component for displaying messages when no services are connected.
  • Improvements

    • Enhanced localization support with new language entries for modals and UI elements.
    • Improved error handling and user feedback in service connection processes.
  • Refactor

    • Streamlined component structure for better maintainability and readability.

@Kodylow Kodylow requested a review from a team as a code owner September 18, 2024 20:28
Copy link

vercel bot commented Sep 18, 2024

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

Name Status Preview Comments Updated (UTC)
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2024 1:22am

Copy link
Contributor

coderabbitai bot commented Sep 18, 2024

Walkthrough

Walkthrough

This pull request introduces several new components and modifies existing ones within the application, focusing on service management and user interface enhancements. Key additions include the Header, Logo, ServiceMenu, and various modal components for connecting, editing, and removing services. The application context is also updated to handle new actions related to guardians and gateways, while localization files are enhanced to support multiple languages. Overall, the changes aim to improve the structure and functionality of the service management features.

Changes

Files Change Summary
apps/router/src/components/{Header, Logo, ServiceMenu}.tsx Introduced new components for navigation and service selection, enhancing UI and responsiveness.
apps/router/src/components/Wrapper.tsx Removed headerProps from WrapperProps, simplifying the interface by directly rendering the Header.
apps/router/src/context/AppContext.tsx Added new action types and updated the reducer to manage UPDATE_GUARDIAN and UPDATE_GATEWAY actions.
apps/router/src/home/{ConnectServiceModal, EditServiceModal, RemoveServiceModal, ServiceTable, NoConnectedServices}.tsx Added and modified modal components for connecting, editing, and removing services, improving user interaction.
apps/router/src/home/utils.ts Introduced utility functions for service validation and classification.
apps/router/src/hooks/index.tsx Added a custom hook useActiveService to manage active service identifiers based on the current route.
apps/router/src/index.tsx Restructured component hierarchy for better clarity and context management.
apps/router/src/languages/{en, de, es, fr, hu, it, ja, ko, pt, ru, zh}.json Enhanced localization files with new keys for modals and service management.
apps/router/src/types/index.tsx Defined new types and interfaces for service configurations.
apps/router/tsconfig.json Updated TypeScript configuration to include local components.
packages/ui/src/{Header, index}.tsx Removed Header component and updated exports to reference components from the router application.
packages/ui/tsconfig.json Expanded TypeScript compilation scope to include components from the router application.

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 a122f4e and 86ae01f.

Files selected for processing (4)
  • apps/router/src/home/EditServiceModal.tsx (1 hunks)
  • apps/router/src/home/RemoveServiceModal.tsx (1 hunks)
  • apps/router/src/index.tsx (3 hunks)
  • apps/router/src/languages/en.json (2 hunks)
Files skipped from review as they are similar to previous changes (4)
  • apps/router/src/home/EditServiceModal.tsx
  • apps/router/src/home/RemoveServiceModal.tsx
  • apps/router/src/index.tsx
  • apps/router/src/languages/en.json

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 1ba5f8c and a122f4e.

Files selected for processing (31)
  • apps/router/src/components/Header.tsx (1 hunks)
  • apps/router/src/components/Logo.tsx (1 hunks)
  • apps/router/src/components/ServiceMenu.tsx (1 hunks)
  • apps/router/src/components/Wrapper.tsx (2 hunks)
  • apps/router/src/context/AppContext.tsx (3 hunks)
  • apps/router/src/home/ConnectServiceModal.tsx (3 hunks)
  • apps/router/src/home/EditServiceModal.tsx (1 hunks)
  • apps/router/src/home/HomePage.tsx (1 hunks)
  • apps/router/src/home/NoConnectedServices.tsx (1 hunks)
  • apps/router/src/home/RemoveServiceModal.tsx (1 hunks)
  • apps/router/src/home/ServiceTable.tsx (1 hunks)
  • apps/router/src/home/utils.ts (1 hunks)
  • apps/router/src/hooks/index.tsx (1 hunks)
  • apps/router/src/index.tsx (3 hunks)
  • apps/router/src/languages/ca.json (2 hunks)
  • apps/router/src/languages/de.json (2 hunks)
  • apps/router/src/languages/en.json (2 hunks)
  • apps/router/src/languages/es.json (2 hunks)
  • apps/router/src/languages/fr.json (2 hunks)
  • apps/router/src/languages/hu.json (2 hunks)
  • apps/router/src/languages/it.json (2 hunks)
  • apps/router/src/languages/ja.json (2 hunks)
  • apps/router/src/languages/ko.json (2 hunks)
  • apps/router/src/languages/pt.json (2 hunks)
  • apps/router/src/languages/ru.json (2 hunks)
  • apps/router/src/languages/zh.json (2 hunks)
  • apps/router/src/types/index.tsx (1 hunks)
  • apps/router/tsconfig.json (1 hunks)
  • packages/ui/src/Header.tsx (0 hunks)
  • packages/ui/src/index.tsx (1 hunks)
  • packages/ui/tsconfig.json (1 hunks)
Files not reviewed due to content moderation or server errors (1)
  • apps/router/src/components/Wrapper.tsx
Files not reviewed due to no reviewable changes (1)
  • packages/ui/src/Header.tsx
Additional comments not posted (59)
apps/router/tsconfig.json (1)

7-7: LGTM!

The change to include the src/components/Header.tsx file in the TypeScript compilation is valid and suggests a shift towards a more localized component structure.

packages/ui/tsconfig.json (1)

4-8: LGTM!

The changes to include additional components from the router application look good. This should enhance the integration between the UI package and the router components.

apps/router/src/hooks/index.tsx (1)

3-12: LGTM!

The custom hook useActiveService correctly extracts and returns the service-related identifiers from the current URL path. The implementation is clean and provides useful typed properties for consuming components.

packages/ui/src/index.tsx (2)

10-10: Verify the impact of changing the source of the Wrapper export.

Ensure that the Wrapper component from the new location ('../../../apps/router/src/components/Wrapper') is fully compatible with the previous implementation and does not introduce any unexpected behavior or dependencies.

Also, consider using a more maintainable import path (e.g., an absolute path or a path alias) to avoid long relative paths that could break if the directory structure changes.


13-13: Verify the impact of changing the source of the Header export.

Ensure that the Header component from the new location ('../../../apps/router/src/components/Header') is fully compatible with the previous implementation and does not introduce any unexpected behavior or dependencies.

Also, consider using a more maintainable import path (e.g., an absolute path or a path alias) to avoid long relative paths that could break if the directory structure changes.

apps/router/src/home/utils.ts (2)

3-11: LGTM!

The function logic is correct, and the implementation is efficient.


13-17: LGTM!

The function logic is correct, and the implementation is accurate.

apps/router/src/home/RemoveServiceModal.tsx (1)

1-72: LGTM!

The RemoveServiceModal component is implemented correctly and follows best practices. The component correctly handles the modal visibility, dispatches the appropriate action based on the service type, and uses internationalization for the modal content.

apps/router/src/home/NoConnectedServices.tsx (1)

1-56: LGTM!

The NoConnectedServices component is well-structured, informative, and provides clear explanations of the service types in a Fedimint federation. The use of Chakra UI for layout and styling is appropriate, and the link to the Fedimint GitHub repository is helpful for users who want to learn more about setting up services.

apps/router/src/index.tsx (3)

17-17: LGTM!

The import statement for the Wrapper component is necessary and correct.


26-46: LGTM!

The repositioning of the Wrapper component to wrap only the Routes component improves the clarity of the component structure. It is now evident that the Wrapper is specifically for layout purposes around the routing logic.


60-62: LGTM!

The AppContextProvider directly wrapping the App component ensures that the context is available throughout the entire application. This change simplifies the component tree and may improve performance or readability.

apps/router/src/components/ServiceMenu.tsx (1)

1-87: The ServiceMenu component looks good!

The component is well-structured, modular, and provides a good user experience. It uses appropriate libraries and hooks, and is typed using TypeScript. No major issues identified.

apps/router/src/home/HomePage.tsx (3)

1-23: LGTM!

The import refactoring and state management changes look good. They improve the component's structure and introduce a more dynamic interaction model for managing services.


24-53: LGTM!

The rendering logic changes look good. The simplified layout, modular components, and abstracted handling of no connected services improve the component's readability and maintainability.


56-74: LGTM!

The conditional rendering of modal components based on state variables looks good. It ensures a more responsive user interface.

apps/router/src/home/ConnectServiceModal.tsx (1)

38-75: LGTM!

The changes to the handleSubmit function improve the validation and categorization of the service URL. The error handling provides clearer feedback to the user. The logic and implementation look good.

apps/router/src/context/AppContext.tsx (3)

55-56: LGTM!

The new action types are valid and follow the existing naming convention.


81-94: LGTM!

The new action structures are correctly typed and match the expected payload for updating a guardian or gateway.


140-155: LGTM!

The reducer correctly handles the new actions by updating the corresponding state with the provided payload while maintaining immutability.

apps/router/src/components/Logo.tsx (1)

1-42: LGTM!

The Logo component looks good. The structure is clear, the SVG paths are valid, and the responsive behavior is implemented correctly using Chakra UI.

apps/router/src/languages/zh.json (3)

30-30: LGTM!

The added key-value pair for "view" is syntactically correct and the Chinese translation aligns with the existing terminology.


497-502: Looks good!

The added "connect-service-modal" object provides clear labels and instructions in Chinese for connecting to Fedimint services. The translations are syntactically correct and align well with their corresponding English keys.


503-506: Looks good!

The added "remove-service-modal" object provides a clear title and confirmation prompt in Chinese for deleting a service. The translations are syntactically correct and align well with their corresponding English keys.

apps/router/src/languages/ko.json (2)

29-30: LGTM!


496-506: Looks good!

apps/router/src/languages/ja.json (2)

29-30: LGTM!


496-506: LGTM!

apps/router/src/languages/en.json (3)

28-28: LGTM!


190-196: Looks good!


197-200: LGTM!

apps/router/src/languages/pt.json (3)

29-30: LGTM!


496-502: Looks good!


503-506: LGTM!

apps/router/src/languages/hu.json (3)

29-30: LGTM!

The new key-value pairs for "ecash" and "view" translations have been added correctly.


496-502: LGTM!

The new "connect-service-modal" section and its translations have been added correctly.


503-506: LGTM!

The new "remove-service-modal" section and its translations have been added correctly.

apps/router/src/languages/ru.json (3)

30-30: LGTM!


497-502: LGTM!


503-506: LGTM!

apps/router/src/languages/es.json (2)

497-502: LGTM!


503-506: LGTM!

apps/router/src/languages/it.json (2)

29-30: LGTM!

The additions are syntactically correct and the translations seem appropriate.


496-506: LGTM!

The additions provide clear labels and helper text for connecting and removing services. This improves the user experience by offering more comprehensive service management options. The translations are appropriate as well.

apps/router/src/languages/fr.json (4)

29-30: LGTM!


496-497: LGTM!


498-502: LGTM!


503-506: LGTM!

apps/router/src/languages/ca.json (2)

29-30: LGTM!


496-506: Looks good!

apps/router/src/languages/de.json (2)

496-502: LGTM!


503-506: LGTM!

apps/router/src/components/Header.tsx (4)

1-6: LGTM!

The imports are relevant and necessary for the component's functionality.


8-8: LGTM!

The component is correctly declared as a named export and memoized using React.memo for performance optimization.


9-13: LGTM!

The component correctly uses hooks to access necessary data from the application context and implements the logic to determine the availability of services.


15-31: LGTM!

The rendering logic and structure of the component are implemented correctly. The responsive styling of the Flex container and the conditional rendering of the ServiceMenu component based on the availability of services are good practices. The necessary data is passed as props to the ServiceMenu component.

apps/router/src/home/ServiceTable.tsx (1)

35-107: LGTM!

The ServiceTable component is well-structured and follows best practices. It correctly handles the service type prop to display the appropriate heading and labels. The edit, delete, and view functionality is properly implemented using the provided prop functions and the Link component from react-router-dom.

apps/router/src/types/index.tsx (2)

1-1: LGTM!

The ServiceType union type is correctly defined and restricts the allowed values to the specified strings.


3-7: LGTM!

The ServiceConfig interface is correctly defined and provides a standardized structure for service configurations.

Comment on lines +81 to +92
} catch (error) {
toast({
title: 'Error updating service',
description:
error instanceof Error
? error.message
: 'An unknown error occurred',
status: 'error',
duration: 5000,
isClosable: true,
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Improve error handling.

The error handling could be improved by providing more specific error messages based on the type of error that occurred. For example, if the error is due to an invalid URL, the error message could be more informative.

Copy link
Member

@tvolk131 tvolk131 left a comment

Choose a reason for hiding this comment

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

Just one small thing, otherwise LGTM and works on my machine!


i18nProvider(languages);

// ... existing imports ...
Copy link
Member

Choose a reason for hiding this comment

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

AI leftovers? 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

oh lol haha yup fixing

Copy link
Member

@tvolk131 tvolk131 left a comment

Choose a reason for hiding this comment

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

Send it! 🚀

@tvolk131 tvolk131 merged commit ab03dd9 into fedimint:master Sep 20, 2024
3 checks passed
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