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 modal linking #4618

Merged
merged 4 commits into from
Aug 7, 2024
Merged

Fix modal linking #4618

merged 4 commits into from
Aug 7, 2024

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Aug 5, 2024

What changes are proposed in this pull request?

Fixes sample id and group groupId direct linking in the App

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

New e2e spec

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

    • Improved handling of dataset navigation through dynamic query parameters, enhancing flexibility in dataset views.
    • Enhanced identification system by standardizing the use of id instead of sampleId across various functions.
  • Bug Fixes

    • Resolved issues with state management by updating how parameters are passed, improving overall application stability.
  • Documentation

    • Updated code structure for better readability and maintenance, including extracting inline logic into dedicated resolver functions.
  • Chores

    • Reorganized module exports for better clarity and functionality within the utilities package.

Copy link
Contributor

coderabbitai bot commented Aug 5, 2024

Warning

Rate limit exceeded

@benjaminpkane has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 46 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 3a72198 and f96164a.

Walkthrough

The recent changes enhance the modularity and flexibility of the application by updating various components to manage identifiers and state more effectively. Key modifications include renaming properties for consistency, reorganizing module exports, and introducing new resolver functions. These adjustments improve data handling across different contexts, ultimately streamlining the application's functionality and maintainability.

Changes

File Path Change Summary
app/packages/app/src/useEventSource.ts Renamed sampleId parameter to id, altering data retrieval context.
app/packages/app/src/useEvents/useStateUpdate.ts Removed sampleId, added id referencing state.modalSelector?.id; slice logic now depends on stateless variable.
app/packages/app/src/useEvents/utils.ts Extracted inline logic in processState to resolver functions, improving code readability and maintainability.
app/packages/app/src/useSetters/onSetDataset.ts Renamed sampleId to id in extra object, indicating a broader identification approach.
app/packages/utilities/src/index.ts Restructured exports; altered env function to guarantee VITE_NO_STATE is included in return value.
e2e-pw/src/oss/fixtures/loader.ts Updated OssLoader constructor to replace savedView with searchParams, enhancing dynamic dataset navigation handling.
e2e-pw/src/shared/abstract-loader.ts Changed savedView property to searchParams in WaitUntilGridVisibleOptions, allowing for more flexible grid visibility conditions.
e2e-pw/src/oss/specs/groups/*.spec.ts Replaced savedView with searchParams in multiple test cases, enhancing parameter handling for grid visibility checks.

Sequence Diagram(s)

sequenceDiagram
    participant A as User
    participant B as Modal
    participant C as DatasetManager
    participant D as Loader

    A->>B: Open Modal
    B->>C: Request Datasets
    C->>D: Load Datasets
    D-->>C: Return Datasets
    C-->>B: Provide Datasets
    B-->>A: Display Modal with Datasets
Loading

🐇 In the meadow where rabbits play,
We’ve spruced our code, hip-hip-hooray!
With IDs now fresh and clear,
Flexibility brings us cheer!
Through modules we hop, with grace and style,
Coding’s a joy, let’s code for a while! 🌸


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.

@benjaminpkane benjaminpkane added bug Bug fixes app Issues related to App features labels Aug 5, 2024
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, codebase verification and nitpick comments (1)
app/packages/utilities/src/index.ts (1)

699-699: Issue Found: Unreachable Code in env Function

The env function in app/packages/utilities/src/index.ts contains two return statements, making the second one unreachable. The current implementation will always return { VITE_NO_STATE: true }. The second return statement (return import.meta.env;) should be removed or the function logic should be corrected.

  • File: app/packages/utilities/src/index.ts
  • Lines: 699-699
  • Code:
    return { VITE_NO_STATE: true };
    return import.meta.env;

Please revise the function to ensure it returns the intended value.

Analysis chain

LGTM! Verify the behavior of the env function.

The changes to the env function are approved.

Ensure that the function behaves as expected with the new default value.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the behavior of the env function.

# Test: Search for the usage of env function. Expect: Correct behavior with new default value.
rg --type ts 'env\(\)'

Length of output: 1048


Script:

#!/bin/bash
# Description: Locate the implementation of the env function and inspect its code.

# Locate the implementation of the env function
rg --type ts 'function env' -A 10

Length of output: 35


Script:

#!/bin/bash
# Description: Locate the definition of the env function or variable.

# Search for the definition of `env` as a function, variable, or export
rg --type ts 'env\s*[:=]' -A 10

Length of output: 2200


Script:

#!/bin/bash
# Description: Inspect the full implementation of the env function in `app/packages/utilities/src/index.ts`.

# Display the full implementation of the env function
rg --type ts -A 20 'export const env' app/packages/utilities/src/index.ts

Length of output: 609

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1fcc7b7 and 9474525.

Files selected for processing (8)
  • app/packages/app/src/useEventSource.ts (1 hunks)
  • app/packages/app/src/useEvents/useStateUpdate.ts (1 hunks)
  • app/packages/app/src/useEvents/utils.ts (2 hunks)
  • app/packages/app/src/useSetters/onSetDataset.ts (1 hunks)
  • app/packages/utilities/src/index.ts (2 hunks)
  • e2e-pw/src/oss/fixtures/loader.ts (3 hunks)
  • e2e-pw/src/oss/specs/modal/linking.spec.ts (1 hunks)
  • e2e-pw/src/shared/abstract-loader.ts (1 hunks)
Additional context used
Path-based instructions (8)
e2e-pw/src/shared/abstract-loader.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/useEvents/useStateUpdate.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/useSetters/onSetDataset.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.

e2e-pw/src/oss/specs/modal/linking.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/useEventSource.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/useEvents/utils.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.

e2e-pw/src/oss/fixtures/loader.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/utilities/src/index.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.

Additional comments not posted (21)
e2e-pw/src/shared/abstract-loader.ts (1)

11-13: Ensure proper usage of URLSearchParams.

The change from savedView to searchParams enhances flexibility. Ensure that any usage of WaitUntilGridVisibleOptions correctly handles URLSearchParams.

Verification successful

Proper usage of URLSearchParams verified.

The searchParams property in the WaitUntilGridVisibleOptions type is correctly handled as an instance of URLSearchParams in the e2e-pw/src/oss/fixtures/loader.ts file.

  • searchParams is converted to a string and appended to a URL.
  • The get method is called on searchParams to retrieve parameter values.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify correct usage of the updated `WaitUntilGridVisibleOptions` type.

# Test: Search for the usage of `WaitUntilGridVisibleOptions`. Expect: Correct handling of `URLSearchParams`.
rg --type ts -A 5 $'WaitUntilGridVisibleOptions'

Length of output: 1415


Script:

#!/bin/bash
# Description: Verify proper handling of `searchParams` as `URLSearchParams` in `e2e-pw/src/oss/fixtures/loader.ts`.

# Test: Search for the usage of `searchParams` in `e2e-pw/src/oss/fixtures/loader.ts`.
rg --type ts 'searchParams' -A 10 e2e-pw/src/oss/fixtures/loader.ts

Length of output: 1217

app/packages/app/src/useEvents/useStateUpdate.ts (1)

32-33: Ensure consistency in identifier usage.

The change from sampleId to id and the conditional logic for slice enhances flexibility. Verify that all references to sampleId have been updated to id and that the conditional logic is correctly implemented.

app/packages/app/src/useSetters/onSetDataset.ts (1)

51-51: Ensure consistency in identifier usage.

The change from sampleId to id aims to streamline the identification process. Verify that all references to sampleId have been updated to id.

e2e-pw/src/oss/specs/modal/linking.spec.ts (4)

1-9: LGTM!

The test function extension to include a modal fixture is well-structured and follows best practices for Playwright testing.


16-39: LGTM!

The beforeAll hook correctly sets up the datasets and samples for the tests using fiftyoneLoader.


41-50: LGTM!

The sample linking test correctly verifies the functionality by waiting for the grid, checking the modal state, and verifying the sidebar entry.


52-61: LGTM!

The group linking test correctly verifies the functionality by waiting for the grid, checking the modal state, and verifying the sidebar entry.

app/packages/app/src/useEventSource.ts (1)

61-61: Verify the correctness of the parameter change.

The sample_id parameter now uses getParam("id") instead of getParam("sampleId"). Ensure that this change aligns with the intended functionality and that getParam("id") retrieves the correct value.

Verification successful

The change from getParam("sampleId") to getParam("id") is correct and aligns with the intended functionality.

The usage of getParam("id") is consistent with other parts of the codebase, confirming its validity.

  • app/packages/app/src/useEventSource.ts
  • app/packages/app/src/useEvents/utils.ts
  • app/packages/app/src/useEvents/useStateUpdate.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `getParam("id")` in the codebase.

# Test: Search for the usage of `getParam("id")`. Expect: Correct usage in relevant contexts.
rg --type js --type ts -A 5 $'getParam("id")'

Length of output: 46


Script:

#!/bin/bash
# Description: Verify the definition and usage of `getParam` in the codebase.

# Search for the definition of the `getParam` function.
rg 'function getParam' -A 5

# Search for all usages of the `getParam` function.
rg 'getParam(' -A 5

Length of output: 120


Script:

#!/bin/bash
# Description: Verify the definition and usage of `getParam` in the codebase.

# Search for the definition of the `getParam` function.
rg 'function getParam' -A 5

# Search for all usages of the `getParam` function.
rg 'getParam\(' -A 5

Length of output: 2496

app/packages/app/src/useEvents/utils.ts (8)

Line range hint 10-49:
LGTM!

The processState function is well-structured and the use of resolver functions enhances modularity and readability.


52-58: LGTM!

The resolveSelected function correctly handles the VITE_NO_STATE condition and returns a set of selected items.


60-69: LGTM!

The resolveSelectedLabels function correctly handles the VITE_NO_STATE condition and returns an array of selected labels.


71-79: LGTM!

The resolveFieldVisibility function correctly handles the VITE_NO_STATE condition and returns the field visibility state.


81-87: LGTM!

The resolveGroupSlice function correctly handles the VITE_NO_STATE condition and returns the group slice state.


89-106: LGTM!

The resolveModalSelector function correctly handles the VITE_NO_STATE condition and returns the modal selector state.


108-114: LGTM!

The resolveView function correctly handles the VITE_NO_STATE condition and returns the view state.


116-125: LGTM!

The resolveWorkspace function correctly handles the VITE_NO_STATE condition and returns the workspace state.

e2e-pw/src/oss/fixtures/loader.ts (4)

132-132: Ensure proper handling of dataset selection.

The method forceDatasetFromSelector correctly handles dataset selection.

Verify that this logic works as expected in all scenarios.


144-146: LGTM! Verify the URL construction logic.

The URL construction logic using searchParams is approved.

Ensure that the URL is constructed correctly in all scenarios.


156-161: Ensure proper validation of view parameter.

The validation logic for the view parameter is correct.

Verify that the view parameter is validated correctly in all scenarios.


124-126: LGTM! Verify the usage of new options.

The constructor changes are approved.

Ensure that the new options isEmptyDataset, searchParams, and withGrid are used correctly throughout the class.

app/packages/utilities/src/index.ts (1)

11-13: LGTM! Verify the exports.

The reorganization of exports is approved.

Ensure that the Resource and order modules are exported correctly.

Verification successful

Verified: The exports for Resource and order modules are correctly set up.

  • index.ts correctly exports from ./order and ./Resource.
  • Resource/index.ts correctly exports Resource and createResourceGroup.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the exports of Resource and order modules.

# Test: Search for the exports in the index.ts file. Expect: Correct export statements.
rg --type ts 'export.*from.*"./Resource"|export.*from.*"./order"'

Length of output: 308

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9474525 and 3a72198.

Files selected for processing (4)
  • e2e-pw/src/oss/specs/groups/dynamic-groups.spec.ts (2 hunks)
  • e2e-pw/src/oss/specs/groups/sparse-dynamic-groups.spec.ts (1 hunks)
  • e2e-pw/src/oss/specs/regression-tests/grid-page.spec.ts (1 hunks)
  • e2e-pw/src/oss/specs/smoke-tests/quickstart-groups-dynamic.spec.ts (1 hunks)
Additional context used
Path-based instructions (4)
e2e-pw/src/oss/specs/smoke-tests/quickstart-groups-dynamic.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.

e2e-pw/src/oss/specs/regression-tests/grid-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.

e2e-pw/src/oss/specs/groups/dynamic-groups.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.

e2e-pw/src/oss/specs/groups/sparse-dynamic-groups.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.

Additional comments not posted (5)
e2e-pw/src/oss/specs/smoke-tests/quickstart-groups-dynamic.spec.ts (1)

57-58: Enhanced parameter handling for waitUntilGridVisible.

The change from savedView to searchParams using URLSearchParams improves the flexibility and clarity of the parameters passed to waitUntilGridVisible. This structured approach is beneficial for future expansions.

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

72-73: Improved parameter handling for waitUntilGridVisible.

The change from savedView to searchParams using URLSearchParams enhances the flexibility and clarity of the parameters passed to waitUntilGridVisible. This structured approach is beneficial for future expansions.

e2e-pw/src/oss/specs/groups/dynamic-groups.spec.ts (2)

57-58: Enhanced parameter handling for waitUntilGridVisible.

The change from savedView to searchParams using URLSearchParams improves the flexibility and clarity of the parameters passed to waitUntilGridVisible. This structured approach is beneficial for future expansions.


77-78: Improved parameter handling for waitUntilGridVisible.

The change from savedView to searchParams using URLSearchParams enhances the flexibility and clarity of the parameters passed to waitUntilGridVisible. This structured approach is beneficial for future expansions.

e2e-pw/src/oss/specs/groups/sparse-dynamic-groups.spec.ts (1)

90-91: Verify the correctness of the new parameter usage.

The change from savedView: "group" to searchParams: new URLSearchParams({ view: "group" }) is intended to facilitate additional query parameters. Ensure that this new parameter is correctly handled by the waitUntilGridVisible function and that it does not break existing functionality.

Verification successful

Verify the correctness of the new parameter usage.

The change from savedView: "group" to searchParams: new URLSearchParams({ view: "group" }) is correctly handled by the waitUntilGridVisible function, as it processes searchParams within its options parameter.

  • e2e-pw/src/oss/fixtures/loader.ts: The waitUntilGridVisible function handles searchParams correctly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `waitUntilGridVisible` function correctly handles the `searchParams` parameter.

# Test: Search for the function definition and ensure it handles `searchParams`.
rg --type python -A 5 $'def waitUntilGridVisible'

Length of output: 81


Script:

#!/bin/bash
# Description: Verify that the `waitUntilGridVisible` function correctly handles the `searchParams` parameter.

# Test: Search for the function definition in TypeScript/JavaScript files and ensure it handles `searchParams`.
rg --type js -A 10 'function waitUntilGridVisible'

Length of output: 52


Script:

#!/bin/bash
# Description: Verify that the `waitUntilGridVisible` function correctly handles the `searchParams` parameter.

# Test: Search for the function definition in TypeScript/JavaScript files and ensure it handles `searchParams`.
rg --type-add 'ts:*.ts' --type-add 'js:*.js' -A 10 'function waitUntilGridVisible'
rg --type-add 'ts:*.ts' --type-add 'js:*.js' -A 10 'waitUntilGridVisible ='
rg --type-add 'ts:*.ts' --type-add 'js:*.js' -A 10 'waitUntilGridVisible:'

Length of output: 237


Script:

#!/bin/bash
# Description: Verify that the `waitUntilGridVisible` function correctly handles the `searchParams` parameter.

# Test: Search for any references to `waitUntilGridVisible` across all file types.
rg -A 10 'waitUntilGridVisible'

Length of output: 46068

@benjaminpkane benjaminpkane requested review from imanjra and a team August 6, 2024 22:46
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.

LGTM. From local testing, i noticed when going to a group modal URL, slice is added as param. However, it does not update when switching between the slice in UI. Is that intentional?

@benjaminpkane
Copy link
Contributor Author

LGTM. From local testing, i noticed when going to a group modal URL, slice is added as param. However, it does not update when switching between the slice in UI. Is that intentional?

It's an unfortunate side effect of the event source 🤦, will try to follow up

@benjaminpkane benjaminpkane merged commit fdd03b5 into release/v0.25.0 Aug 7, 2024
17 checks passed
@benjaminpkane benjaminpkane deleted the bugfix/modal-linking branch August 7, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Issues related to App features bug Bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants