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

additional panel meta (is_new, beta, category) #5038

Merged
merged 6 commits into from
Nov 4, 2024
Merged

Conversation

ritch
Copy link
Contributor

@ritch ritch commented Nov 4, 2024

Here's an example using all of the new settings in python and JS:

class CounterExample(foo.Panel):
    @property
    def config(self):
        return foo.PanelConfig(
            name="example_counter",
            label="Examples: Counter",
            category=foo.Categories.ANALYZE, # new
            is_new=foo.is_new("2024-11-01"), # new
            beta=True # new,
            priority=52000 # new
        )
registerComponent({
  name: "Embeddings",
  label: "Embeddings",
  component: Embeddings,
  type: PluginComponentType.Panel,
  activator: () => true,
  Icon: WorkspacesIcon,
  panelOptions: {
    TabIndicator: EmbeddingsTabIndicator,
    priority: BUILT_IN_PANEL_PRIORITY_CONST,
    category: Categories.Curate, // new
    isNew: true, // new
    beta: true, // new
    priority: 51001 // existing
  },
});

New information is displayed only in the AddPanel* component.

image image

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a categorization system for panels, allowing users to easily identify and organize panels by their respective categories.
    • Added visual indicators for "NEW" and "BETA" features in the UI, enhancing user awareness of recent additions and experimental features.
  • Improvements

    • Enhanced the AddPanelButton and AddPanelItem components for better usability and organization.
    • Improved panel registration capabilities with new metadata options, including priority and categorization.
  • Bug Fixes

    • Minor adjustments to ensure consistent behavior across components.

@ritch ritch requested a review from imanjra November 4, 2024 19:06
Copy link
Contributor

coderabbitai bot commented Nov 4, 2024

Walkthrough

The changes in this pull request involve modifications to various components and files within the application, primarily focusing on the addition of categorization properties and enhancements to panel registration. Key updates include the introduction of a category property for several components, new utility functions for handling categories, and adjustments to the rendering logic of UI components to support these categories. Overall, the changes aim to improve the organization and management of components within the application.

Changes

File Path Change Summary
app/packages/core/src/plugins/histograms.tsx Added import for Categories and set category: Categories.Curate in panelOptions for the Histograms component.
app/packages/embeddings/src/index.ts Added import for Categories and set category: Categories.Curate in panelOptions for a component.
app/packages/operators/src/Panel/register.tsx Added properties beta, category, isNew, and priority to panelOptions in registerPanel.
app/packages/operators/src/built-in-operators.ts Added new properties to resolveInput in RegisterPanel class: help_markdown, category, beta, is_new, and priority.
app/packages/plugins/src/index.ts Introduced new type CategoryID, enum Categories, and functions getCategoryLabel and getCategoryForPanel. Updated PanelOptions type to include category, beta, and isNew.
app/packages/spaces/src/components/AddPanelButton.tsx Added imports for categorization functions and created categorizedPanels object. Introduced PanelCategories and PanelCategory components for rendering categorized panels.
app/packages/spaces/src/components/AddPanelItem.tsx Added props showBeta and showNew to AddPanelItemProps for conditional rendering of indicators.
app/packages/spaces/src/components/PanelIcon.tsx Added import for Box and modified rendering to wrap PanelTabIcon in a Box.
app/packages/spaces/src/components/PanelTab.tsx Introduced PanelTabMeta component for displaying "NEW" and "BETA" indicators based on panel?.panelOptions.
app/packages/spaces/src/types.ts Added optional properties showBeta and showNew to AddPanelItemProps.
fiftyone/operators/init.py Added imports for is_new function and Categories.
fiftyone/operators/categories.py Introduced new enum class Categories with members: IMPORT, CURATE, ANALYZE, CUSTOM.
fiftyone/operators/operations.py Updated register_panel method to include category, beta, is_new, and priority parameters.
fiftyone/operators/panel.py Added parameters beta, is_new, category, and priority to PanelConfig constructor. Updated to_json and on_startup methods to include these parameters.
fiftyone/operators/utils.py Introduced a new function is_new to determine if a feature is considered "new" based on its release date.

Possibly related PRs

Suggested labels

feature, plugins

Suggested reviewers

  • imanjra
  • brimoor

🐰 In the garden where changes bloom,
New categories chase away the gloom.
With panels now neatly aligned,
A curated world, beautifully designed.
Hop along, let’s celebrate,
For better organization awaits! 🌼


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.

@ritch ritch requested a review from brimoor November 4, 2024 19:06
@ritch ritch changed the title [wip] additional panel meta (is_new, beta, category) additional panel meta (is_new, beta, category) Nov 4, 2024
Copy link
Contributor

@minhtuev minhtuev left a comment

Choose a reason for hiding this comment

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

Thanks Ritchie, meta info look good for me, not sure how to determine priority value thoug.

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

🧹 Outside diff range and nitpick comments (16)
fiftyone/operators/categories.py (1)

4-8: Add documentation and type hints to improve API usability.

The Categories enum is well-structured, but could benefit from additional documentation and type safety.

Consider applying these improvements:

+from enum import Enum, unique
+from typing import Literal
 
-
-
+CategoryType = Literal["import", "curate", "analyze", "custom"]
+
+@unique
 class Categories(Enum):
+    """Categorization options for panels.
+
+    Attributes:
+        IMPORT: Panels related to data import functionality
+        CURATE: Panels for data curation and management
+        ANALYZE: Panels for data analysis and visualization
+        CUSTOM: Custom or user-defined panels
+    """
     IMPORT = "import"
     CURATE = "curate"
     ANALYZE = "analyze"
     CUSTOM = "custom"
+
+    @classmethod
+    def to_value(cls, category: "Categories") -> CategoryType:
+        """Convert enum member to its string value."""
+        return category.value
fiftyone/operators/__init__.py (1)

20-22: LGTM! Consider adding docstring for new imports.

The new imports align well with the PR objectives of adding metadata attributes for panels. The imports are correctly placed and follow the existing style.

Consider adding a brief docstring above these imports to document their purpose:

 from .utils import ProgressHandler, is_new
 from .panel import Panel, PanelConfig
+# Categories enum provides panel categorization options
 from .categories import Categories
🧰 Tools
🪛 Ruff

20-20: .utils.ProgressHandler imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


20-20: .utils.is_new imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


21-21: .panel.Panel imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


21-21: .panel.PanelConfig imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


22-22: .categories.Categories imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

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

The isNew and beta properties should be added to the panel configuration

Based on the codebase analysis, these properties are part of the standard panel configuration as seen in the PanelOptions type definition in plugins/src/index.ts and their usage in operators/src/Panel/register.tsx. They are required metadata properties that help users identify new and beta features.

 panelOptions: {
   TabIndicator: EmbeddingsTabIndicator,
   priority: BUILT_IN_PANEL_PRIORITY_CONST,
   category: Categories.Curate,
+  isNew: false,
+  beta: false,
 },
🔗 Analysis chain

Line range hint 10-22: Consider adding isNew and beta metadata properties.

According to the PR objectives, this change introduces three new panel metadata attributes: is_new, beta, and category. While the category property has been correctly implemented, the other two properties are missing from this panel's configuration.

Let's verify if other panels are using these properties:

Consider adding the missing properties if they apply to this panel:

 panelOptions: {
   TabIndicator: EmbeddingsTabIndicator,
   priority: BUILT_IN_PANEL_PRIORITY_CONST,
   category: Categories.Curate,
+  isNew: false, // or true if this is a new panel
+  beta: false, // or true if this is in beta
 },

Let me gather more information about the panel registration pattern and metadata properties.


Let me try a different search pattern to find panel registrations.


Let me check the content of these specific files to understand how these properties are used.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if any other panels are using isNew or beta properties
# Expected: Find other panel configurations using these properties for consistency

# Search for panel registrations with isNew or beta
rg -A 10 'panelOptions.*\{' | rg -B 10 '(isNew|beta)'

Length of output: 1086


Script:

#!/bin/bash
# Search for all panel registrations to understand the pattern
rg -B 2 -A 10 'registerComponent\(\{.*type:\s*PluginComponentType\.Panel'

Length of output: 75


Script:

#!/bin/bash
# Search for panel registrations with a more flexible pattern
rg -B 2 -A 10 'registerComponent.*Panel'

# Also search specifically for the pattern of setting these properties
rg -l 'isNew:|beta:' app/packages/

Length of output: 159


Script:

#!/bin/bash
# Check the content of the files that contain these properties
cat app/packages/plugins/src/index.ts
cat app/packages/operators/src/Panel/register.tsx

Length of output: 15792

app/packages/spaces/src/components/PanelIcon.tsx (1)

14-21: Consider using MUI theme spacing and flexible dimensions

While the implementation works, there are some improvements that could make it more maintainable and consistent with MUI best practices:

  1. Use MUI's spacing theme values instead of hard-coded rem units
  2. Consider making dimensions more flexible or theme-based
  3. Consider using Stack or Grid for layout instead of manual margins

Here's a suggested improvement:

-    <Box sx={{ mr: "0.75rem", width: "1rem", height: "1.5rem" }}>
-      <PanelTabIcon
-        style={{
-          width: "1rem",
-          height: "1rem",
-        }}
-      />
-    </Box>
+    <Box
+      sx={(theme) => ({
+        mr: theme.spacing(1),
+        display: 'flex',
+        alignItems: 'center',
+        width: theme.spacing(2),
+        height: theme.spacing(3)
+      })}
+    >
+      <PanelTabIcon
+        sx={(theme) => ({
+          width: theme.spacing(2),
+          height: theme.spacing(2)
+        })}
+      />
+    </Box>

This change:

  • Uses MUI's theme spacing for consistent spacing across the app
  • Makes dimensions theme-dependent for better maintainability
  • Uses proper flex layout for alignment
app/packages/operators/src/Panel/register.tsx (1)

28-31: Consider adding TypeScript type definitions for the new properties.

The new metadata properties look good and align with the PR objectives. However, to improve type safety and maintainability, consider defining TypeScript interfaces for these properties:

interface PanelMetadata {
  beta?: boolean;
  category?: string;
  isNew?: boolean;
  priority?: number;
}

interface PanelParams extends PanelMetadata {
  // ... existing params
}

This will provide better type checking and IDE support.

app/packages/spaces/src/types.ts (1)

17-18: LGTM! Consider adding JSDoc comments.

The new optional boolean properties follow TypeScript naming conventions and align with their UI rendering purpose.

Consider adding JSDoc comments to improve documentation:

 export type AddPanelItemProps = {
   node: SpaceNode;
   name: SpaceNodeType;
   label: string;
   Icon?: React.ComponentType;
   onClick?: () => void;
   spaceId: string;
+  /** Whether to show a beta indicator for this panel item */
   showBeta?: boolean;
+  /** Whether to show a new feature indicator for this panel item */
   showNew?: boolean;
 };
app/packages/spaces/src/components/AddPanelItem.tsx (1)

55-65: Consider refactoring badge styling for better maintainability.

The badge implementation could be improved by:

  1. Extracting duplicate styles into a reusable component
  2. Using the sx prop instead of inline styles
  3. Using theme spacing values instead of magic numbers

Consider this refactor:

+ const BadgeText = ({ children }) => (
+   <Typography
+     component="span"
+     variant="caption"
+     sx={{
+       color: theme.primary.main,
+       ml: 1,
+     }}
+   >
+     {children}
+   </Typography>
+ );

  {showNew && (
-   <span
-     style={{
-       color: theme.primary.main,
-       fontSize: "11px",
-       marginLeft: "6px",
-     }}
-   >
-     NEW
-   </span>
+   <BadgeText>NEW</BadgeText>
  )}
fiftyone/operators/utils.py (1)

75-106: Consider timezone handling and input validation improvements

The function implementation looks good overall, but here are some suggested improvements:

 def is_new(release_date, days=30):
     """
     Determines if a feature is considered "new" based on its release date.
 
     A feature is considered new if its release date is within the specified number of days.
 
     Args:
         release_date (str or datetime): The release date of the feature.
             - If a string, it should be in the format "%Y-%m-%d" (e.g., "2024-11-09").
             - If a datetime object, it will be used directly without conversion.
         days (int, optional): The number of days within which the feature is considered new.
             Defaults to 30.
 
     Returns:
         bool: True if the release date is within the specified number of days, False otherwise.
     
     Raises:
+        ValueError: If release_date is invalid or days is not a positive integer.
     """
+    if not isinstance(days, int) or days <= 0:
+        raise ValueError("days must be a positive integer")
+
     if isinstance(release_date, str):
+        try:
             release_date = datetime.strptime(release_date, "%Y-%m-%d")
+        except ValueError:
+            raise ValueError("release_date string must be in format YYYY-MM-DD")
     elif not isinstance(release_date, datetime):
         raise ValueError("release_date must be a string or datetime object")
 
-    return (datetime.now() - release_date).days <= days
+    # Cache datetime.now() to ensure consistent results
+    current_time = datetime.now()
+    return (current_time - release_date).days <= days

Consider these additional improvements:

  1. Add timezone awareness if needed in the future
  2. Cache datetime.now() at the module level if this function is called frequently
fiftyone/operators/panel.py (1)

37-38: Enhance parameter documentation.

The docstring should include all new parameters and their types:

  • Add documentation for beta and is_new parameters
  • Specify the full type for category (e.g., foo.Categories.ANALYZE as shown in PR description)
     Args:
         name: the name of the panel
         label: the display name for the panel
+        beta (False): whether the panel is in beta
+        is_new (False): whether the panel should be marked as new
-        category (Category): the category id of the panel
+        category (foo.Categories): the category of the panel (e.g., foo.Categories.ANALYZE)
         priority (None): the priority of the panel for sorting in the UI
app/packages/plugins/src/index.ts (2)

300-307: LGTM! Consider adding JSDoc comments.

The type and enum definitions are well-structured and consistent. Consider adding JSDoc comments to document the purpose and usage of each category.

+/**
+ * Represents the available categories for panels
+ */
 type CategoryID = "import" | "curate" | "analyze" | "custom";

+/**
+ * Enum providing string representations of panel categories
+ */
 export enum Categories {
   Import = "import",
   Curate = "curate",
   Analyze = "analyze",
   Custom = "custom",
 }

309-324: LGTM! Consider enhancing type safety.

The utility functions are well-implemented. Consider using the Categories enum values instead of string literals in getCategoryLabel for better type safety and maintainability.

 export function getCategoryLabel(category: CategoryID): string {
   switch (category) {
-    case "import":
+    case Categories.Import:
       return "Import";
-    case "curate":
+    case Categories.Curate:
       return "Curate";
-    case "analyze":
+    case Categories.Analyze:
       return "Analyze";
-    case "custom":
+    case Categories.Custom:
       return "Custom";
   }
 }
fiftyone/operators/operations.py (2)

Line range hint 305-326: Consider reordering parameters for better readability

The new parameters (category, beta, is_new, priority) should be grouped with related parameters. Consider this ordering:

  1. Essential parameters first (name, label)
  2. Display-related parameters (help_markdown, icon, light_icon, dark_icon)
  3. Feature flags (beta, is_new)
  4. Behavioral parameters (category, priority, surfaces, reload_on_navigation, allow_duplicates)
  5. Event handlers (all on_* parameters)

345-347: Enhance documentation with examples

The documentation for new parameters is clear, but would benefit from examples showing common use cases, especially for:

  • Different category values
  • When to use beta vs is_new flags
  • How priority affects panel ordering

Also applies to: 372-372

app/packages/spaces/src/components/AddPanelButton.tsx (3)

51-61: Handle undefined categories when categorizing panels

In the categorizedPanels reducer, getCategoryForPanel(panel) may return undefined. To prevent runtime errors or unexpected behavior, consider handling cases where the category is undefined.

Suggested change:

 const category = getCategoryForPanel(panel) || 'uncategorized';

65-67: Avoid hardcoding category names in sortedCategories

The sortedCategories array uses hardcoded category names. For better scalability and maintainability, derive the category names dynamically from categorizedPanels.

Suggested change:

-const sortedCategories = ["import", "curate", "analyze", "custom"]
-  .map((cat) => categorizedPanels[cat])
-  .filter((c) => c);
+const sortedCategories = Object.values(categorizedPanels);

113-119: Add TypeScript types to PanelCategories component

The PanelCategories component lacks explicit prop types. Adding TypeScript type annotations enhances type safety and clarity.

Suggested change:

+import { ReactNode } from 'react';
+
 function PanelCategories({ children }: { children: ReactNode }) {
   return (
     <Grid container gap={1} sx={{ p: 2 }}>
       {children}
     </Grid>
   );
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f13a397 and 29fedc0.

📒 Files selected for processing (15)
  • app/packages/core/src/plugins/histograms.tsx (2 hunks)
  • app/packages/embeddings/src/index.ts (2 hunks)
  • app/packages/operators/src/Panel/register.tsx (1 hunks)
  • app/packages/operators/src/built-in-operators.ts (2 hunks)
  • app/packages/plugins/src/index.ts (2 hunks)
  • app/packages/spaces/src/components/AddPanelButton.tsx (5 hunks)
  • app/packages/spaces/src/components/AddPanelItem.tsx (2 hunks)
  • app/packages/spaces/src/components/PanelIcon.tsx (2 hunks)
  • app/packages/spaces/src/components/PanelTab.tsx (3 hunks)
  • app/packages/spaces/src/types.ts (1 hunks)
  • fiftyone/operators/__init__.py (1 hunks)
  • fiftyone/operators/categories.py (1 hunks)
  • fiftyone/operators/operations.py (6 hunks)
  • fiftyone/operators/panel.py (4 hunks)
  • fiftyone/operators/utils.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
app/packages/core/src/plugins/histograms.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/embeddings/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.

app/packages/operators/src/Panel/register.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/operators/src/built-in-operators.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/plugins/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.

app/packages/spaces/src/components/AddPanelButton.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/spaces/src/components/AddPanelItem.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/spaces/src/components/PanelIcon.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/spaces/src/components/PanelTab.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/spaces/src/types.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.

🪛 Ruff
fiftyone/operators/__init__.py

20-20: .utils.ProgressHandler imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


20-20: .utils.is_new imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


21-21: .panel.Panel imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


21-21: .panel.PanelConfig imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


22-22: .categories.Categories imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

fiftyone/operators/utils.py

72-72: Redefinition of unused datetime from line 9

Remove definition: datetime

(F811)


72-72: datetime.timedelta imported but unused

Remove unused import: datetime.timedelta

(F401)

🔇 Additional comments (21)
fiftyone/operators/categories.py (1)

1-3: LGTM!

The import statement and spacing follow PEP 8 guidelines.

fiftyone/operators/__init__.py (1)

20-22: Verify the implementation of new features.

Let's verify the implementation of the new features and their usage in panel configurations.

✅ Verification successful

Let me gather more information about the Categories implementation since it wasn't found in the first search.


New features are properly implemented and used across the codebase

The verification shows:

  • Categories enum is properly implemented in categories.py with four categories: IMPORT, CURATE, ANALYZE, and CUSTOM
  • is_new utility function is well-implemented in utils.py with comprehensive documentation and proper datetime handling
  • Both features are actively used in the codebase:
    • Categories are used in panel configurations across multiple packages
    • The is_new function is used as a parameter in panel configurations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of new features

# Check Categories enum implementation
echo "Checking Categories enum implementation..."
ast-grep --pattern 'class Categories:
  $$$
'

# Check is_new function implementation
echo "Checking is_new function implementation..."
ast-grep --pattern 'def is_new($$$):
  $$$
'

# Check usage in panel configurations
echo "Checking usage in panel configurations..."
rg -A 5 'PanelConfig.*category.*=.*Categories\.' 
rg -A 5 'is_new\('

Length of output: 4200


Script:

#!/bin/bash
# Search for Categories in different possible locations
echo "Searching for Categories implementation..."
rg -A 10 "class Categories"

echo "Searching for Categories enum usage..."
rg "Categories\." -A 2

Length of output: 2300

🧰 Tools
🪛 Ruff

20-20: .utils.ProgressHandler imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


20-20: .utils.is_new imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


21-21: .panel.Panel imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


21-21: .panel.PanelConfig imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


22-22: .categories.Categories imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

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

1-5: LGTM! Clean and well-structured imports.

The import statement follows TypeScript best practices with proper destructuring and organization.

app/packages/spaces/src/components/PanelIcon.tsx (1)

5-5: LGTM: Import statement follows conventions

The import of Box from @mui/material is properly placed and follows standard conventions.

app/packages/spaces/src/components/AddPanelItem.tsx (3)

8-8: LGTM! Props and imports are well-structured.

The new props and imports follow TypeScript/React best practices.

Also applies to: 16-17


19-19: LGTM! Theme hook is properly implemented.

The useTheme hook is correctly used to access theme values.


66-76: Apply the same badge styling refactor here.

The BETA badge has identical styling concerns as the NEW badge.

app/packages/core/src/plugins/histograms.tsx (3)

3-7: LGTM! Import changes are well-structured

The addition of Categories import is properly grouped with related imports from @fiftyone/plugins.


114-116: 🛠️ Refactor suggestion

Consider implementing additional panel metadata

The PR objectives mention support for is_new and beta flags, but these aren't implemented here. Consider adding these properties to maintain consistency with the PR's goals:

 panelOptions: {
   priority: BUILT_IN_PANEL_PRIORITY_CONST,
   category: Categories.Curate,
+  isNew: false, // or date-based check
+  beta: false, // if applicable
 },

Likely invalid or redundant comment.


115-115: Verify if 'Curate' is the appropriate category for Histograms

Histograms are typically used for data analysis and visualization. Consider if Categories.Analyze might be more appropriate than Categories.Curate for this component's primary use case.

✅ Verification successful

Let me gather more context about the categories and histogram usage.


Based on the code analysis, I can now provide a definitive response about the categorization of the Histograms panel.

The 'Curate' category is appropriate for the Histograms panel

The Histograms panel is correctly categorized under Categories.Curate because:

  1. It's used alongside other data curation tools, as evidenced by the embeddings plugin also using the same category
  2. The implementation shows it's primarily used for:
    • Field selection and data filtering
    • Understanding data distributions for curation decisions
    • Interactive data exploration and selection

The panel serves as a data curation tool by helping users understand and filter their dataset's distributions, which aligns with the curation workflow rather than pure analysis.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other histogram-related components and their categories
rg -A 5 "Categories\.(Analyze|Curate)" --type ts

Length of output: 383


Script:

#!/bin/bash
# Search for Categories enum definition and usage
ast-grep --pattern 'enum Categories {
  $$$
}'

# Search for histogram-related code and documentation
rg -i "histogram" -A 5 --type ts

Length of output: 36765

app/packages/spaces/src/components/PanelTab.tsx (1)

4-4: LGTM!

The Grid import is appropriately grouped with other Material-UI components.

fiftyone/operators/panel.py (4)

46-55: LGTM! Constructor parameters are well-structured.

The new parameters are added with appropriate default values and maintain a logical order.


70-73: LGTM! Instance variables are properly initialized.

The new attributes are correctly assigned from constructor parameters.


132-135: LGTM! Panel registration correctly includes new metadata.

The panel configuration dictionary properly includes all new attributes: category, beta, is_new, and priority.


Line range hint 81-92: Verify category string conversion compatibility.

The category is converted to string using str(self.category). Let's verify this works correctly with the expected foo.Categories enum.

✅ Verification successful

Let me gather more information about the Categories enum and its usage.


Category string conversion is safe and compatible

The str(self.category) conversion is correct and compatible with the codebase because:

  • The Categories enum is properly defined with string values in fiftyone/operators/categories.py
  • All enum values (IMPORT, CURATE, ANALYZE, CUSTOM) are already strings
  • String conversion of these enum values will return their defined string values ("import", "curate", "analyze", "custom")
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how categories are used across the codebase

# Test 1: Find category enum definition
echo "Looking for Categories enum definition..."
rg -p "class.*Categories.*\(.*Enum.*\)"

# Test 2: Find category usage in panel configurations
echo "Looking for category usage in panel configurations..."
rg "category.*=.*Categories\." -A 2

Length of output: 525


Script:

#!/bin/bash
# Check Categories enum definition and values
echo "=== Categories enum definition ==="
cat fiftyone/operators/categories.py

# Find all imports of Categories
echo -e "\n=== Categories imports ==="
rg "from.*categories.*import.*Categories"

# Find all direct usage of Categories enum
echo -e "\n=== Categories enum usage ==="
rg "Categories\.[A-Z_]+" -B 1 -A 1

Length of output: 1513

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

326-330: LGTM! Type definition is clear and focused.

The Category type effectively pairs the category ID with its display label.

fiftyone/operators/operations.py (1)

12-12: LGTM: Clean import addition

The relative import of Categories is properly placed and follows the project's import conventions.

app/packages/operators/src/built-in-operators.ts (2)

1000-1003: LGTM! New panel metadata fields are well-implemented.

The new input fields for panel metadata (help_markdown, category, beta, is_new) are correctly implemented using appropriate types and default values. The implementation aligns with the PR objectives to enhance panel configuration.


1013-1013: LGTM! Priority field addition.

The priority field is correctly implemented as an integer input, which will allow for customizable panel ordering.

app/packages/spaces/src/components/AddPanelButton.tsx (2)

1-7: Potential theme inconsistencies between component libraries

The code imports useTheme from @fiftyone/components and uses Typography and Grid from @mui/material. Ensure that the theme object provided by useTheme is compatible with Material-UI components to prevent styling inconsistencies.


35-35: Corrected missing return statement in useMemo

The addition of the return statement in the nodeTypes computation ensures that the array of node types is correctly returned. This fix prevents nodeTypes from being undefined.

Comment on lines +58 to +61
<PanelTabMeta
showBeta={panel?.panelOptions?.beta}
showNew={panel?.panelOptions?.isNew}
/>
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

Add TypeScript types and consider layout stability

The integration looks good, but there are a few improvements needed:

  1. TypeScript types are missing for the panelOptions properties
  2. Consider wrapping in an error boundary to prevent crashes
  3. Consider adding a fixed width container to prevent layout shifts

Apply this diff:

- showBeta={panel?.panelOptions?.beta}
- showNew={panel?.panelOptions?.isNew}
+ showBeta={Boolean(panel?.panelOptions?.beta)}
+ showNew={Boolean(panel?.panelOptions?.isNew)}

Also, update your types file to include:

interface PanelOptions {
  beta?: boolean;
  isNew?: boolean;
  // ... other existing properties
}

Comment on lines 93 to 114
function PanelTabMeta({ showBeta, showNew }) {
return (
<Grid container gap={1} sx={{ width: "auto", ml: "6px" }}>
{showNew && (
<Grid
item
style={{ color: "var(--fo-palette-primary-main)", fontSize: 11 }}
>
NEW
</Grid>
)}
{showBeta && (
<Grid
item
style={{ color: "var(--fo-palette-primary-main)", fontSize: 11 }}
>
BETA
</Grid>
)}
</Grid>
);
}
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

Improve component implementation with TypeScript and better styling

Several improvements are needed:

  1. Add TypeScript interface for props
  2. Extract duplicate styles
  3. Improve accessibility
  4. Use theme constants instead of hardcoded values

Apply these changes:

interface PanelTabMetaProps {
  showBeta?: boolean;
  showNew?: boolean;
}

const MetaLabel = styled(Grid)({
  color: 'var(--fo-palette-primary-main)',
  fontSize: 11,
  fontWeight: 'medium',
});

function PanelTabMeta({ showBeta, showNew }: PanelTabMetaProps) {
  return (
    <Grid 
      container 
      gap={1} 
      sx={{ width: "auto", ml: "6px" }}
      aria-label="Panel status indicators"
    >
      {showNew && (
        <MetaLabel item role="status">
          NEW
        </MetaLabel>
      )}
      {showBeta && (
        <MetaLabel item role="status">
          BETA
        </MetaLabel>
      )}
    </Grid>
  );
}

Comment on lines +72 to +73
from datetime import datetime, timedelta

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

Remove redundant imports

The datetime module is already imported on line 9, and timedelta is not used in the implementation.

-from datetime import datetime, timedelta
📝 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
from datetime import datetime, timedelta
🧰 Tools
🪛 Ruff

72-72: Redefinition of unused datetime from line 9

Remove definition: datetime

(F811)


72-72: datetime.timedelta imported but unused

Remove unused import: datetime.timedelta

(F401)

Comment on lines +365 to +379

/**
* The category of the plugin
*/
category: CategoryID;

/**
* Whether the plugin is in beta
*/
beta: boolean;

/**
* Whether the plugin is new
*/
isNew: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider making the category property optional.

The category property is currently required, which could break existing panel implementations. Since getCategoryForPanel provides a default value of "custom", consider making this property optional for better backward compatibility.

 type PanelOptions = {
   // ... existing properties ...

   /**
    * The category of the plugin
    */
-  category: CategoryID;
+  category?: CategoryID;

   /**
    * Whether the plugin is in beta
    */
   beta: boolean;

   /**
    * Whether the plugin is new
    */
   isNew: boolean;
 };
📝 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
/**
* The category of the plugin
*/
category: CategoryID;
/**
* Whether the plugin is in beta
*/
beta: boolean;
/**
* Whether the plugin is new
*/
isNew: boolean;
/**
* The category of the plugin
*/
category?: CategoryID;
/**
* Whether the plugin is in beta
*/
beta: boolean;
/**
* Whether the plugin is new
*/
isNew: boolean;

Comment on lines +378 to +380
"category": category.value if category is not None else None,
"beta": beta,
"is_new": is_new,
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

Add type validation for category parameter

The category value extraction could fail if an invalid type is passed. Consider adding type validation or using a safer conversion method.

-            "category": category.value if category is not None else None,
+            "category": category.value if isinstance(category, Categories) else None,

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +121 to +134
function PanelCategory({ label, children }) {
const theme = useTheme();
return (
<Grid item>
<Typography
variant="subtitle2"
sx={{ padding: "0 8px", color: theme.text.secondary }}
>
{label || "no category"}
</Typography>
{children}
</Grid>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add TypeScript types to PanelCategory component and correct theme usage

The PanelCategory component does not explicitly define its prop types, and theme.text.secondary is used instead of theme.palette.text.secondary. Define prop types and correct the theme property to ensure proper styling.

Suggested changes:

+import { ReactNode } from 'react';
+
+interface PanelCategoryProps {
+  label: string;
+  children: ReactNode;
+}
+
 function PanelCategory({ label, children }: PanelCategoryProps) {
   const theme = useTheme();
   return (
     <Grid item>
       <Typography
         variant="subtitle2"
-        sx={{ padding: "0 8px", color: theme.text.secondary }}
+        sx={{ padding: "0 8px", color: theme.palette.text.secondary }}
       >
         {label || "no category"}
       </Typography>
       {children}
     </Grid>
   );
 }
📝 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
function PanelCategory({ label, children }) {
const theme = useTheme();
return (
<Grid item>
<Typography
variant="subtitle2"
sx={{ padding: "0 8px", color: theme.text.secondary }}
>
{label || "no category"}
</Typography>
{children}
</Grid>
);
}
import { ReactNode } from 'react';
interface PanelCategoryProps {
label: string;
children: ReactNode;
}
function PanelCategory({ label, children }: PanelCategoryProps) {
const theme = useTheme();
return (
<Grid item>
<Typography
variant="subtitle2"
sx={{ padding: "0 8px", color: theme.palette.text.secondary }}
>
{label || "no category"}
</Typography>
{children}
</Grid>
);
}

@Br2850 Br2850 self-requested a review November 4, 2024 20:11
@@ -297,6 +297,37 @@ export enum PluginComponentType {
*/
}

type CategoryID = "import" | "curate" | "analyze" | "custom";
Copy link
Contributor

@Br2850 Br2850 Nov 4, 2024

Choose a reason for hiding this comment

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

Given that @brimoor this was your original vision for the categories of workflows with Assistant, do we want to simply just add all of these (Explore, Annotate, Evaluate, etc.) right now?

Not sure if this list is still the "right" list in terms of categorization, but food for thought @ritch

Screenshot 2024-11-04 at 3 13 35 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We've been discussing the list in a slack thread

>>> is_new("2024-11-09") # Using a string date and default days
True # if today's date is within 30 days after 2024-11-09

>>> is_new(datetime(2024, 11, 9), days=15) # Using a datetime object with 15-day threshold
Copy link
Contributor

Choose a reason for hiding this comment

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

That's cool, I like that we can manually define when NEW should disappear 🙌🏽

Copy link
Contributor

@Br2850 Br2850 left a comment

Choose a reason for hiding this comment

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

Looks great! 🎉 Similar sentiment to Minh' not sure how we would self define priority - maybe it should be a calculation of (new + category, etc.) but other than that this is super awesome!

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

🧹 Outside diff range and nitpick comments (3)
app/packages/spaces/src/components/AddPanelItem.tsx (1)

57-61: Consider using MUI's styling system.

Instead of inline styles, consider using MUI's styling system for consistency with the rest of the codebase.

-style={{
-  color: theme.custom.primarySoft,
-  fontSize: "11px",
-  marginLeft: "6px",
-}}
+sx={{
+  color: (theme) => theme.custom.primarySoft,
+  fontSize: "11px",
+  ml: "6px",
+}}

Also applies to: 68-72

app/packages/embeddings/src/EmptyEmbeddings.tsx (1)

40-44: LGTM! Consider using sx prop shorthand for margin.

The change from hardcoded color to theme.custom.primarySoft improves theme consistency.

Consider using the shorthand mb instead of marginBottom for better readability:

  sx={{
    fontSize: 64,
    color: theme.custom.primarySoft,
-   marginBottom: 2,
+   mb: 2,
  }}
app/packages/components/src/components/ThemeProvider/index.tsx (1)

98-98: Consider deduplicating redundant color values.

The primarySoft color value is identical to both primary.plainColor and lightning in the light theme. Consider using a CSS custom property or a shared constant to maintain consistency and reduce duplication.

- primarySoft: "hsl(25, 100%, 51%)",
+ primarySoft: `var(--fo-primary-color, hsl(25, 100%, 51%))`,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 29fedc0 and e906bd2.

📒 Files selected for processing (4)
  • app/packages/components/src/components/ThemeProvider/index.tsx (2 hunks)
  • app/packages/embeddings/src/EmptyEmbeddings.tsx (1 hunks)
  • app/packages/spaces/src/components/AddPanelItem.tsx (2 hunks)
  • app/packages/spaces/src/components/PanelTab.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
app/packages/components/src/components/ThemeProvider/index.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/embeddings/src/EmptyEmbeddings.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/spaces/src/components/AddPanelItem.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/spaces/src/components/PanelTab.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 (1)
app/packages/spaces/src/components/AddPanelItem.tsx (1)

8-8: LGTM: Clean import and prop additions.

The new props and import are properly typed and follow TypeScript best practices.

Also applies to: 16-17

Comment on lines +55 to +76
{showNew && (
<span
style={{
color: theme.custom.primarySoft,
fontSize: "11px",
marginLeft: "6px",
}}
>
NEW
</span>
)}
{showBeta && (
<span
style={{
color: theme.custom.primarySoft,
fontSize: "11px",
marginLeft: "6px",
}}
>
BETA
</span>
)}
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

Refactor duplicate label styling logic.

The NEW and BETA label implementations share identical styling logic, which violates the DRY principle.

Consider extracting the shared styling into a reusable component:

+const StatusLabel = ({ children }: { children: React.ReactNode }) => {
+  const theme = useTheme();
+  return (
+    <span
+      style={{
+        color: theme.custom.primarySoft,
+        fontSize: "11px",
+        marginLeft: "6px",
+      }}
+    >
+      {children}
+    </span>
+  );
+};

 // In the main component
-{showNew && (
-  <span
-    style={{
-      color: theme.custom.primarySoft,
-      fontSize: "11px",
-      marginLeft: "6px",
-    }}
-  >
-    NEW
-  </span>
-)}
-{showBeta && (
-  <span
-    style={{
-      color: theme.custom.primarySoft,
-      fontSize: "11px",
-      marginLeft: "6px",
-    }}
-  >
-    BETA
-  </span>
-)}
+{showNew && <StatusLabel>NEW</StatusLabel>}
+{showBeta && <StatusLabel>BETA</StatusLabel>}

Additionally, consider these accessibility improvements:

  1. Add appropriate ARIA labels
  2. Use semantic HTML elements

Consider enhancing accessibility:

 const StatusLabel = ({ children }: { children: React.ReactNode }) => {
   const theme = useTheme();
   return (
     <span
+      role="status"
+      aria-label={`${children.toString().toLowerCase()} feature`}
       style={{
         color: theme.custom.primarySoft,
         fontSize: "11px",
         marginLeft: "6px",
       }}
     >
       {children}
     </span>
   );
 };
📝 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
{showNew && (
<span
style={{
color: theme.custom.primarySoft,
fontSize: "11px",
marginLeft: "6px",
}}
>
NEW
</span>
)}
{showBeta && (
<span
style={{
color: theme.custom.primarySoft,
fontSize: "11px",
marginLeft: "6px",
}}
>
BETA
</span>
)}
const StatusLabel = ({ children }: { children: React.ReactNode }) => {
const theme = useTheme();
return (
<span
role="status"
aria-label={`${children.toString().toLowerCase()} feature`}
style={{
color: theme.custom.primarySoft,
fontSize: "11px",
marginLeft: "6px",
}}
>
{children}
</span>
);
};
{showNew && <StatusLabel>NEW</StatusLabel>}
{showBeta && <StatusLabel>BETA</StatusLabel>}

Comment on lines +93 to +120
function PanelTabMeta({ showBeta, showNew }) {
return (
<Grid container gap={1} sx={{ width: "auto", ml: "6px" }}>
{showNew && (
<Grid
item
style={{
color: "var(--fo-palette-custom-primarySoft)",
fontSize: 11,
}}
>
NEW
</Grid>
)}
{showBeta && (
<Grid
item
style={{
color: "var(--fo-palette-custom-primarySoft)",
fontSize: 11,
}}
>
BETA
</Grid>
)}
</Grid>
);
}
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

Improve PanelTabMeta component implementation

The component needs several improvements:

  1. Extract duplicated styles into a styled component
  2. Add accessibility attributes
  3. Consider using a more semantic HTML structure for status indicators

Apply this diff:

+const StatusIndicator = styled(Grid)({
+  color: "var(--fo-palette-custom-primarySoft)",
+  fontSize: 11,
+});

-function PanelTabMeta({ showBeta, showNew }) {
+function PanelTabMeta({ showBeta, showNew }: { showBeta?: boolean; showNew?: boolean }) {
   return (
     <Grid container gap={1} sx={{ width: "auto", ml: "6px" }}
+          role="group" 
+          aria-label="Panel status indicators"
     >
       {showNew && (
-        <Grid
-          item
-          style={{
-            color: "var(--fo-palette-custom-primarySoft)",
-            fontSize: 11,
-          }}
-        >
+        <StatusIndicator item component="span" role="status">
           NEW
-        </Grid>
+        </StatusIndicator>
       )}
       {showBeta && (
-        <Grid
-          item
-          style={{
-            color: "var(--fo-palette-custom-primarySoft)",
-            fontSize: 11,
-          }}
-        >
+        <StatusIndicator item component="span" role="status">
           BETA
-        </Grid>
+        </StatusIndicator>
       )}
     </Grid>
   );
 }
📝 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
function PanelTabMeta({ showBeta, showNew }) {
return (
<Grid container gap={1} sx={{ width: "auto", ml: "6px" }}>
{showNew && (
<Grid
item
style={{
color: "var(--fo-palette-custom-primarySoft)",
fontSize: 11,
}}
>
NEW
</Grid>
)}
{showBeta && (
<Grid
item
style={{
color: "var(--fo-palette-custom-primarySoft)",
fontSize: 11,
}}
>
BETA
</Grid>
)}
</Grid>
);
}
const StatusIndicator = styled(Grid)({
color: "var(--fo-palette-custom-primarySoft)",
fontSize: 11,
});
function PanelTabMeta({ showBeta, showNew }: { showBeta?: boolean; showNew?: boolean }) {
return (
<Grid container gap={1} sx={{ width: "auto", ml: "6px" }}
role="group"
aria-label="Panel status indicators"
>
{showNew && (
<StatusIndicator item component="span" role="status">
NEW
</StatusIndicator>
)}
{showBeta && (
<StatusIndicator item component="span" role="status">
BETA
</StatusIndicator>
)}
</Grid>
);
}

@@ -95,6 +95,7 @@ let theme = extendMuiTheme({
shadowDark: "hsl(200, 0%, 70%)",
lightning: "hsl(25, 100%, 51%)",
toastBackgroundColor: "#FFFFFF",
primarySoft: "hsl(25, 100%, 51%)",
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

Add TypeScript interface for custom colors.

The new primarySoft color property should be properly typed in the theme's TypeScript interface to maintain type safety.

Add this interface update at the top of the file:

declare module '@mui/material/styles' {
  interface CustomPaletteColor {
    primarySoft?: string;
  }
}

Also applies to: 181-181

@ritch ritch merged commit 86eeea0 into develop Nov 4, 2024
13 checks passed
@ritch ritch deleted the feat/panel-meta branch November 4, 2024 21:16
@coderabbitai coderabbitai bot mentioned this pull request Nov 5, 2024
24 tasks
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