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

Fix return to index page #4478

Merged
merged 1 commit into from
Jun 11, 2024
Merged

Fix return to index page #4478

merged 1 commit into from
Jun 11, 2024

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Jun 11, 2024

What changes are proposed in this pull request?

Ensures the next page entry is requested when updating the App page

How is this patch tested? If it is not, please explain why.

e2e spec

Release Notes

  • Fixed returning to the index page in the App, e.g. with session.dataset = None

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • New Features

    • Added a PagePom class and PageAsserter class to improve page-related functionality and assertions.
    • Introduced a new test file for index page functionality, including dataset-related tests.
  • Enhancements

    • Updated DatasetSelector component to include a new cy prop for better dataset identification.
    • Improved rendering logic in IndexPage and DatasetPage for more consistent behavior.
  • Bug Fixes

    • Adjusted useStateUpdate function to ensure actions are performed only when readyStateRef.current is valid.

@benjaminpkane benjaminpkane requested a review from a team June 11, 2024 14:32
@benjaminpkane benjaminpkane self-assigned this Jun 11, 2024
Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Walkthrough

The recent updates span multiple files, enhancing functionality and usability. Key changes include the introduction of new props and CSS styling, improved conditional rendering, and added test logic for end-to-end testing. Additionally, a new Page Object Model (POM) class was created to streamline page-related operations and assertions in tests.

Changes

Files/Paths Change Summaries
app/.../Renderer.tsx Modified the router.get() function call to include a true argument.
app/.../DatasetSelector.tsx Added a new prop cy with the value "dataset" to the Selector component.
app/.../IndexPage.tsx Imported index.module.css and added a div with class style.page and data-cy attribute.
app/.../DatasetPage.tsx Reorganized the conditional rendering structure for consistency based on isEmpty state.
app/.../RouterContext.ts Updated get method to take a boolean parameter next and handle it accordingly.
app/.../useStateUpdate.ts Added a conditional block to check readyStateRef.current before performing actions.
e2e-pw/.../page.ts Introduced PagePom and PageAsserter classes for page functionality and assertions.
e2e-pw/.../index-page.spec.ts Added test logic for index page functionality, including dataset loading and path navigation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI as User Interface
    participant Router as RouterContext
    participant Backend as Backend Service

    User->>UI: Interacts with Dataset Selector
    UI->>Router: Calls get(true)
    Router->>Backend: Fetches data with next=true
    Backend-->>Router: Returns data
    Router-->>UI: Provides fetched data
    UI-->>User: Displays updated data
Loading

Poem

In the code where logic flows,
A rabbit hops, as knowledge grows.
Props and styles, they intertwine,
To make the app's design divine.
Tests ensure all paths align,
Hopping forward, all is fine. 🐇✨


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.

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

Outside diff range and nitpick comments (1)
app/packages/app/src/components/DatasetSelector.tsx (1)

Line range hint 11-11: Add a href attribute to improve accessibility.

- <a className={className} title={value}>
+ <a className={className} title={value} href={`#dataset-${value}`}>
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a78d4e6 and a719c91.

Files selected for processing (8)
  • app/packages/app/src/Renderer.tsx (1 hunks)
  • app/packages/app/src/components/DatasetSelector.tsx (1 hunks)
  • app/packages/app/src/pages/IndexPage.tsx (2 hunks)
  • app/packages/app/src/pages/datasets/DatasetPage.tsx (1 hunks)
  • app/packages/app/src/routing/RouterContext.ts (2 hunks)
  • app/packages/app/src/useEvents/useStateUpdate.ts (1 hunks)
  • e2e-pw/src/oss/poms/page.ts (1 hunks)
  • e2e-pw/src/oss/specs/regression-tests/index-page.spec.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • app/packages/app/src/Renderer.tsx
  • app/packages/app/src/useEvents/useStateUpdate.ts
Additional context used
Path-based instructions (6)
app/packages/app/src/components/DatasetSelector.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

e2e-pw/src/oss/specs/regression-tests/index-page.spec.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/app/src/pages/IndexPage.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

e2e-pw/src/oss/poms/page.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/app/src/pages/datasets/DatasetPage.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/app/src/routing/RouterContext.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

Biome
app/packages/app/src/components/DatasetSelector.tsx

[error] 11-11: Provide a href attribute for the a element. (lint/a11y/useValidAnchor)

An anchor element should always have a href
Check this thorough explanation to better understand the context.

app/packages/app/src/routing/RouterContext.ts

[error] 88-88: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 156-156: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

Additional comments not posted (7)
app/packages/app/src/components/DatasetSelector.tsx (1)

25-25: LGTM! Adding the cy attribute enhances testability.

e2e-pw/src/oss/specs/regression-tests/index-page.spec.ts (2)

7-12: Well-structured test setup using page object model.


24-36: Thorough and clear assertions for navigation functionality.

app/packages/app/src/pages/IndexPage.tsx (1)

8-8: Good use of CSS modules for styling consistency and maintainability.

Also applies to: 32-36

e2e-pw/src/oss/poms/page.ts (1)

5-65: Well-implemented page object model and assertions for robust e2e testing.

app/packages/app/src/pages/datasets/DatasetPage.tsx (1)

115-124: The changes to wrap the conditional rendering with a styled div enhance maintainability and testability. Ensure that the added div does not introduce any layout or styling issues.

app/packages/app/src/routing/RouterContext.ts (1)

Line range hint 57-139: The update to the get method to accept a boolean parameter enhances flexibility in routing. Ensure that this change is well-documented and does not affect existing routing logic adversely.

Verification successful

The search results indicate that the get method is used in various contexts throughout the codebase. However, the specific get method from RouterContext.ts is only referenced within that file. This suggests that the changes to the get method in RouterContext.ts are isolated and do not impact other parts of the codebase.

  • The get method in RouterContext.ts is defined with a default parameter next = false.
  • The search results show that the get method is called within RouterContext.ts with the next parameter.

Given this context, it appears that the changes to the get method are self-contained and should not break existing routing logic.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the updated `get` method does not break existing routing logic.

# Test: Search for usages of the `get` method to ensure they pass the correct parameters.
rg --type ts 'get(' src/

Length of output: 85



Script:

#!/bin/bash
# Description: Verify that the updated `get` method does not break existing routing logic.

# Test: Search for usages of the `get` method to ensure they pass the correct parameters.
rg --type ts 'get\(' src/

Length of output: 72



Script:

#!/bin/bash
# Description: Verify that the updated `get` method does not break existing routing logic.

# Step 1: Locate all TypeScript files.
fd --type f --extension ts > ts_files.txt

# Step 2: Search for usages of the `get` method in the located TypeScript files.
xargs rg 'get\(' < ts_files.txt

Length of output: 72958

Copy link
Contributor

@imanjra imanjra left a comment

Choose a reason for hiding this comment

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

Tested locally. Works great 🚀

Copy link
Contributor

@sashankaryal sashankaryal left a comment

Choose a reason for hiding this comment

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

image

@benjaminpkane benjaminpkane merged commit 1df67c2 into develop Jun 11, 2024
16 checks passed
@benjaminpkane benjaminpkane deleted the bugfix/session-none branch June 11, 2024 16:49
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.

3 participants