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

Channels modal #97

Merged
merged 1 commit into from
May 29, 2024
Merged

Channels modal #97

merged 1 commit into from
May 29, 2024

Conversation

mvpoyatt
Copy link
Collaborator

@mvpoyatt mvpoyatt commented Apr 24, 2024

This is basic functionality to show only UCs by default on the Channels page, make other channels searchable by ID and make it possible to navigate to a specific channel by including it as a url param.

Still needs more functionality in the new modal and styling work, as well as coordination with product to figure out how to show DApp specific data. Merging incrementally so PRs don't get too big.

This will also require new ENV variable:
REGISTRY_URL='https://raw.githubusercontent.com/polymerdao/polymer-registry/staging/dist/output.json'

Summary by CodeRabbit

  • New Features

    • Introduced detailed channel information view, including channel ID, state, port IDs, and connection hops.
    • Added search functionality for channels by ID.
    • Enhanced error handling and modal behavior.
    • Added new columns 'Source' and 'Dest' to display chain information.
  • Improvements

    • Updated UI elements for channel search.
    • Improved display formatting for port IDs and counterparty port columns.
    • Enhanced state representation with new stateToString function.
    • Updated table components to include row details using the new ChannelDetails component.
  • Bug Fixes

    • Improved error logging to include specific channel IDs during errors.
    • Enhanced error handling in search and modal components.
  • Style

    • Adjusted styling classes for margin in various components.
    • Removed transition effects from packet details for a static display.
  • Refactor

    • Renamed and refactored variable names for clarity and consistency.
    • Updated import paths for better organization.
  • Chores

    • Added rule to ignore local log files in the repository.

Copy link

coderabbitai bot commented Apr 24, 2024

Warning

Review Failed

The pull request is closed.

Walkthrough

The recent update introduces several new features and enhancements across multiple components. Key changes include adding search functionality for channels, improving error handling, and renaming variables for clarity. The ChannelDetails component has been introduced for detailed channel information, while the StateCell component now includes conditional styling. Additionally, various helper functions were refactored and logging was enhanced for better error tracking.

Changes

File(s) Change Summary
.gitignore Added a rule to ignore local log files.
app/(routes)/channels/channel-details.tsx Introduced ChannelDetails component for rendering channel information.
app/(routes)/channels/page.tsx Renamed variables, added search functionality, enhanced error handling, and updated UI elements.
app/(routes)/clients/page.tsx Renamed variables related to clients for clarity.
app/(routes)/packets/packet-details.tsx Removed transition effects from a div element.
app/(routes)/packets/page.tsx Updated state variable names and imports for consistency.
app/api/channels/helpers.ts Refactored channel-related functions, added new helper functions, and improved logging.
app/api/channels/route.ts Renamed getChannels to getUniversalChannels and improved error logging.
app/api/packets/helpers.ts Swapped implementations of getPacket and getRecentPackets functions.
app/components/ibc-table.tsx Updated imports and adjusted styling classes.
app/utils/types/channel.ts Introduced stateToString function for converting state enum values to strings.
app/components/format-strings.tsx Added formatPortId and formatConnectionHops functions for formatting.
app/components/state-cell.tsx Added conditional background color setting based on the state.

Poem

In the code where channels flow,
A search now helps the details show.
With states that change from open to closed,
And logs that catch what once was lost.
A bunny's touch, so light and swift,
Brings clarity, a coder's gift.
🐇✨


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 Configration 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.

@mvpoyatt mvpoyatt marked this pull request as draft April 26, 2024 17:27
@mvpoyatt mvpoyatt marked this pull request as ready for review May 28, 2024 19:32
@mvpoyatt mvpoyatt requested review from Inkvi and dshiell May 28, 2024 19:32
Copy link

@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: 3

Outside diff range and nitpick comments (10)
app/(routes)/packets/packet-details.tsx (5)

Line range hint 169-169: Use strict equality checks.

- if (hex[0] != '0' || hex[1] != 'x') {
+ if (hex[0] !== '0' || hex[1] !== 'x') {

Line range hint 174-174: Prefer template literals for string concatenation.

- hex = '0x' + hex;
+ hex = `0x${hex}`;

Also applies to: 179-179


Line range hint 168-168: Avoid reassigning function parameters.

Consider using a new variable instead of modifying the function parameter hex.

Also applies to: 172-172, 174-174


Line range hint 170-170: Avoid declaring variables that are only assigned once.

- let split = hex.split('.');
+ const split = hex.split('.');

Line range hint 69-69: Ensure JSX elements without children are self-closing.

- <div>
+ <div />

Apply this change to all applicable elements.

Also applies to: 71-71, 72-72, 73-73, 88-88, 90-90, 91-91, 92-92, 158-158

app/components/ibc-table.tsx (5)

Line range hint 115-115: Ensure JSX elements without children are self-closing.

- <div>
+ <div />

Apply this change to all applicable elements.

Also applies to: 155-155


Line range hint 159-170: Ensure accessibility by pairing mouse events with keyboard events.

Consider adding onKeyUp, onKeyDown, or onKeyPress events to complement the onClick events for accessibility.


Line range hint 234-234: Specify explicit types instead of using any.

Consider defining a more specific type for the column and table parameters in the ColumnFilter function.


Line range hint 202-205: Provide an explicit type prop for button elements.

- <button
+ <button type="button"

Apply this change to all applicable button elements.

Also applies to: 208-211, 217-220, 223-226


Line range hint 286-286: Prefer template literals for string concatenation.

- classes += ' max-w-32';
+ classes += ` max-w-32`;

Apply this change to all applicable string concatenations.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 0631d74 and 0013e74.
Files selected for processing (8)
  • app/(routes)/channels/channel-details.tsx (1 hunks)
  • app/(routes)/channels/page.tsx (3 hunks)
  • app/(routes)/packets/packet-details.tsx (1 hunks)
  • app/(routes)/packets/page.tsx (5 hunks)
  • app/api/channels/helpers.ts (4 hunks)
  • app/components/format-strings.tsx (2 hunks)
  • app/components/ibc-table.tsx (4 hunks)
  • app/components/state-cell.tsx (1 hunks)
Files not reviewed due to errors (3)
  • app/api/channels/helpers.ts (no review received)
  • app/(routes)/channels/page.tsx (no review received)
  • app/(routes)/packets/page.tsx (no review received)
Additional Context Used
Biome (69)
app/(routes)/channels/channel-details.tsx (2)

58-58: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


1-2: Some named imports are only used as types.

app/(routes)/channels/page.tsx (6)

90-90: The computed expression can be simplified without the use of a string literal.


91-91: The computed expression can be simplified without the use of a string literal.


3-13: Some named imports are only used as types.


14-15: Some named imports are only used as types.


217-220: Provide an explicit type prop for the button element.


224-224: Provide an explicit type prop for the button element.

app/(routes)/packets/packet-details.tsx (19)

69-69: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


71-71: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


72-72: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


73-73: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


88-88: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


90-90: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


91-91: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


92-92: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


158-158: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


169-169: Use !== instead of !=.
!= is only allowed when comparing against null


169-169: Use !== instead of !=.
!= is only allowed when comparing against null


174-174: Template literals are preferred over string concatenation.


179-179: Template literals are preferred over string concatenation.


1-2: Some named imports are only used as types.


2-3: Some named imports are only used as types.


168-168: Reassigning a function parameter is confusing.


172-172: Reassigning a function parameter is confusing.


174-174: Reassigning a function parameter is confusing.


170-170: This let declares a variable that is only assigned once.

app/(routes)/packets/page.tsx (14)

82-86: This else clause can be omitted because previous branches break early.


84-86: This else clause can be omitted because previous branches break early.


131-131: The computed expression can be simplified without the use of a string literal.


132-132: The computed expression can be simplified without the use of a string literal.


133-133: The computed expression can be simplified without the use of a string literal.


135-135: The computed expression can be simplified without the use of a string literal.


136-136: The computed expression can be simplified without the use of a string literal.


137-137: The computed expression can be simplified without the use of a string literal.


138-138: The computed expression can be simplified without the use of a string literal.


139-139: The computed expression can be simplified without the use of a string literal.


3-13: Some named imports are only used as types.


15-16: All these imports are only used as types.


261-264: Provide an explicit type prop for the button element.


268-268: Provide an explicit type prop for the button element.

app/api/channels/helpers.ts (7)

37-37: Template literals are preferred over string concatenation.


55-55: Forbidden non-null assertion.


76-76: This type annotation is trivially inferred from its initialization.


122-122: Forbidden non-null assertion.


124-124: Template literals are preferred over string concatenation.


130-130: Template literals are preferred over string concatenation.


1-1: Some named imports are only used as types.

app/components/format-strings.tsx (3)

1-1: A Node.js builtin module should be imported with the node: protocol.


6-6: Template literals are preferred over string concatenation.


18-18: Template literals are preferred over string concatenation.

app/components/ibc-table.tsx (18)

115-115: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


155-155: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


159-170: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.


234-234: Unexpected any. Specify a different type.


234-234: Unexpected any. Specify a different type.


234-234: Unexpected any. Specify a different type.


254-291: This else clause can be omitted because previous branches break early.


286-286: Template literals are preferred over string concatenation.


289-291: This else clause can be omitted because previous branches break early.


1-5: Some named imports are only used as types.


9-10: All these imports are only used as types.


10-11: All these imports are only used as types.


11-12: All these imports are only used as types.


12-13: All these imports are only used as types.


202-205: Provide an explicit type prop for the button element.


208-211: Provide an explicit type prop for the button element.


217-220: Provide an explicit type prop for the button element.


223-226: Provide an explicit type prop for the button element.

Additional comments not posted (4)
app/components/state-cell.tsx (1)

6-6: LGTM! The conditional rendering of the background color based on the state is implemented correctly.

app/components/format-strings.tsx (2)

16-25: LGTM! The function correctly formats the port ID by shortening it.


27-38: LGTM! The function correctly formats connection hops into a comma-separated string.

app/(routes)/channels/channel-details.tsx (1)

4-53: LGTM! The ChannelDetails component correctly handles URL updates and conditional rendering based on the provided channel.

@@ -1,3 +1,4 @@
import { connect } from 'http2';
Copy link

Choose a reason for hiding this comment

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

Consider using the node: protocol when importing Node.js built-in modules for clarity and to avoid potential issues with package resolution.

- import { connect } from 'http2';
+ import { connect } from 'node:http2';

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.

Suggested change
import { connect } from 'http2';
import { connect } from 'node:http2';


export function formatPortId(portId: string) {
if (!portId) return null;
const shortened = portId.slice(0, 18) + '...' + portId.slice(-5);
Copy link

Choose a reason for hiding this comment

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

Use template literals for better readability and performance in string operations.

- const shortened =  portId.slice(0, 18) + '...' + portId.slice(-5);
+ const shortened = `${portId.slice(0, 18)}...${portId.slice(-5)}`;

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.

Suggested change
const shortened = portId.slice(0, 18) + '...' + portId.slice(-5);
const shortened = `${portId.slice(0, 18)}...${portId.slice(-5)}`;

function Divider () {
return (
<div className="flex flex-row justify-center my-0.5">
<div className="h-0 mb-[0.5px] mt-[1.5px] w-[calc(100%-0.5rem)] border-b border-fg-dark/30"></div>
Copy link

Choose a reason for hiding this comment

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

Consider using self-closing tags for JSX elements without children for cleaner code.

- <div className="h-0 mb-[0.5px] mt-[1.5px] w-[calc(100%-0.5rem)] border-b border-fg-dark/30"></div>
+ <div className="h-0 mb-[0.5px] mt-[1.5px] w-[calc(100%-0.5rem)] border-b border-fg-dark/30" />

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.

Suggested change
<div className="h-0 mb-[0.5px] mt-[1.5px] w-[calc(100%-0.5rem)] border-b border-fg-dark/30"></div>
<div className="h-0 mb-[0.5px] mt-[1.5px] w-[calc(100%-0.5rem)] border-b border-fg-dark/30" />

Copy link
Member

@dshiell dshiell left a comment

Choose a reason for hiding this comment

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

lets get it tested in staging

@mvpoyatt mvpoyatt merged commit 01e602b into main May 29, 2024
2 checks passed
@mvpoyatt mvpoyatt deleted the channels-modal branch May 29, 2024 20:07
@coderabbitai coderabbitai bot mentioned this pull request Nov 13, 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