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

Admins can choose to disable toasts by default #4966

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

minhtuev
Copy link
Contributor

@minhtuev minhtuev commented Oct 22, 2024

What changes are proposed in this pull request?

Admins can choose to configure vars to disable toasts by default

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

  • Manual testing

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)

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

    • Enhanced control over the visibility of the Query Performance section based on new conditional logic.
    • Extended duration for the Query Performance toast notifications, now displaying for 50 seconds.
    • Conditional rendering of the Query Performance toast based on user preferences.
  • Documentation

    • Added clarifying comments to improve understanding of the new rendering conditions for administrators.

Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

The changes in this pull request involve modifications to the QueryPerformance component within the Options component in Options.tsx, where a comment was added to clarify that administrators can disable all Query Performance features. The conditional rendering logic was updated to check the value of fos.enableQueryPerformanceConfig, preventing the rendering of the component if this value is false. Additionally, the QueryPerformanceToast component in QueryPerformanceToast.tsx was updated to include a new condition based on useRecoilValue(fos.defaultQueryPerformanceConfig), allowing for conditional rendering of the toast.

Changes

File Path Change Summary
app/packages/core/src/components/Actions/Options.tsx Added comment about admin controls; modified conditional rendering logic for QueryPerformance based on fos.enableQueryPerformanceConfig.
app/packages/app/src/components/QueryPerformanceToast.tsx Added import for useRecoilValue; updated rendering logic to include condition based on fos.defaultQueryPerformanceConfig and added a comment for clarity.

Possibly related PRs

  • Added two env vars for enabling query performance #4917: This PR introduces environment variables for enabling query performance, which is directly related to the modifications in the Options.tsx component regarding the conditional rendering of the QueryPerformance section based on configuration values.
  • Lightning mode refactor and disable/enable qp mode toggle  #4928: This PR refactors the Options.tsx component to rename and restructure functionality related to performance modes, which aligns with the changes made in the main PR regarding the QueryPerformance component's rendering logic.
  • Toast component #4955: Although primarily focused on introducing a new Toast component, it includes a comment clarifying that admins can disable toasts, which relates to the changes in the main PR about disabling Query Performance features.
  • Toast component refactor #4957: This PR refactors the Toast component, which is relevant as the main PR discusses the conditional rendering of components, including toasts, based on configuration settings.

Suggested reviewers

  • ritch
  • benjaminpkane
  • imanjra
  • Br2850

🐰 In the meadow, changes bloom,
A logic shift dispels the gloom.
Query's path, now clearer seen,
With comments bright, like grass so green.
Hop along, let features play,
In Options' dance, they find their way! 🌼


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 194824c and 5add5f2.

📒 Files selected for processing (1)
  • app/packages/app/src/components/QueryPerformanceToast.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/packages/app/src/components/QueryPerformanceToast.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>, 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.

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.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3c388be and c17018f.

📒 Files selected for processing (2)
  • app/packages/app/src/components/QueryPerformanceToast.tsx (2 hunks)
  • app/packages/core/src/components/Actions/Options.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/packages/core/src/components/Actions/Options.tsx
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/app/src/components/QueryPerformanceToast.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.

🔇 Additional comments (2)
app/packages/app/src/components/QueryPerformanceToast.tsx (2)

9-9: ⚠️ Potential issue

Remove duplicate import of useRecoilValue.

The useRecoilValue is already included in the combined import statement.

Apply this diff to fix the duplicate import:

-import { atom, useRecoilState, useRecoilValue } from "recoil";
+import { atom, useRecoilState } from "recoil";
⛔ Skipped due to learnings
Learnt from: minhtuev
PR: voxel51/fiftyone#4957
File: app/packages/components/src/components/Toast/Toast.tsx:29-36
Timestamp: 2024-10-22T16:25:08.017Z
Learning: When reviewing React components in `app/packages/components/src/components/*`, verify component imports carefully before suggesting missing imports, especially when components are imported via destructuring from packages like `@mui/material`.

41-41: Verify consistent usage of defaultQueryPerformanceConfig.

Let's ensure this configuration is consistently applied across other components that might need similar admin control.

✅ Verification successful

Let me try different commands to gather the necessary information.


Let me try one more search with simpler commands to find any related configurations or usages.


The usage of defaultQueryPerformanceConfig is consistent and properly integrated

The verification shows that the query performance configuration is well-integrated across the codebase:

  • The config is properly defined in state/recoil/queryPerformance.ts with both defaultQueryPerformanceConfig and enableQueryPerformanceConfig selectors
  • It's consistently used in the toast component and actions options
  • The implementation follows a proper hierarchy where defaultQueryPerformanceConfig depends on enableQueryPerformanceConfig

The current implementation in QueryPerformanceToast.tsx correctly follows the established pattern of admin control for query performance features.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of defaultQueryPerformanceConfig
echo "Searching for other components using defaultQueryPerformanceConfig..."
rg "defaultQueryPerformanceConfig" --type ts --type tsx

# Search for similar toast components that might need admin control
echo "Searching for other toast components..."
rg "Toast" --type ts --type tsx -g "!test/*" -g "!*.test.*"

Length of output: 409


Script:

#!/bin/bash
# Search for defaultQueryPerformanceConfig usage
echo "Searching for defaultQueryPerformanceConfig..."
rg -t typescript -t javascriptreact -t typescriptreact "defaultQueryPerformanceConfig"

# Search for toast components
echo "Searching for toast components..."
rg -t typescript -t javascriptreact -t typescriptreact "Toast" -g "!test/*" -g "!*.test.*"

# Search for files with .tsx extension that might contain the config
echo "Searching for tsx files..."
fd -e tsx -x grep -l "defaultQueryPerformanceConfig" {}

Length of output: 608


Script:

#!/bin/bash
# Look at the content of QueryPerformanceToast.tsx
echo "Content of QueryPerformanceToast.tsx:"
cat ./app/packages/app/src/components/QueryPerformanceToast.tsx

# Search for any files containing "Performance" in their name
echo -e "\nSearching for Performance-related files:"
fd "Performance"

# Basic grep for config-related terms
echo -e "\nSearching for related config terms:"
grep -r "PerformanceConfig" .

Length of output: 4716

Comment on lines 40 to 42
// Admins can choose to disable toasts for each dataset
if (!shown || disabled || !useRecoilValue(fos.defaultQueryPerformanceConfig)) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider restructuring conditions for better readability.

While the implementation is correct, the conditions could be reorganized for better clarity and the comment could be more specific.

Consider applying this diff:

-  // Admins can choose to disable toasts for each dataset
-  if (!shown || disabled || !useRecoilValue(fos.defaultQueryPerformanceConfig)) {
+  // Check if query performance toasts are enabled in dataset config
+  const queryPerformanceEnabled = useRecoilValue(fos.defaultQueryPerformanceConfig);
+  if (!queryPerformanceEnabled || !shown || disabled) {
     return null;
   }

This restructuring:

  1. Separates the config check for better visibility
  2. Orders conditions from global (config) to local (component state)
  3. Makes the comment more specific about the configuration's purpose
📝 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
// Admins can choose to disable toasts for each dataset
if (!shown || disabled || !useRecoilValue(fos.defaultQueryPerformanceConfig)) {
return null;
// Check if query performance toasts are enabled in dataset config
const queryPerformanceEnabled = useRecoilValue(fos.defaultQueryPerformanceConfig);
if (!queryPerformanceEnabled || !shown || disabled) {
return null;

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.

1 participant