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

better icons support in operators #4373

Merged
merged 4 commits into from May 9, 2024
Merged

Conversation

imanjra
Copy link
Contributor

@imanjra imanjra commented May 8, 2024

What changes are proposed in this pull request?

  • Add IconButtonView
  • Add support for Python panel icon
  • Add support for using any mui by name

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

Using example panels and operators
image

Kapture.2024-05-08.at.13.38.17.mp4

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

    • Introduced IconButtonView class for rendering icon buttons based on schema configurations.
    • Added dark_icon and light_icon parameters to enhance icon display in different modes.
    • Updated PanelOperatorConfig class to include icon parameters for customization.
  • Enhancements

    • Improved icon handling and display flexibility in the application.
    • Enhanced registration functionalities for custom panel components with specific configurations.
  • Bug Fixes

    • Corrected parameter naming inconsistencies in the Button class for uniformity.
  • Refactor

    • Streamlined panel registration processes with the new registerPanel function.
  • Removals

    • Removed outdated constants to simplify configuration management.

@imanjra imanjra requested review from ritch and a team May 8, 2024 17:35
Copy link
Contributor

coderabbitai bot commented May 8, 2024

Walkthrough

This update introduces new components and updates existing ones across various packages to enhance icon handling and panel registration. Key additions include MuiIconFont and IconButtonView components, which integrate Material-UI icons and schema-based configurations. The update also streamlines panel registration with new parameters for icon variations and refines several type definitions.

Changes

Files Change Summary
.../MuiIconFont/index.tsx, .../components/index.ts Introduced MuiIconFont component and exported it for broader use.
.../SchemaIO/components/IconButtonView.tsx, .../SchemaIO/components/index.ts Added IconButtonView component and its export to handle icon buttons based on schema configurations.
.../operators/src/OperatorIcon.tsx, .../operators/src/Panel/register.tsx, .../operators/src/built-in-operators.ts, .../operators/src/types.ts Enhanced icon handling in operator components, introduced registerPanel function, and updated type definitions. Removed unused constants.
fiftyone/operators/operations.py, fiftyone/operators/panel.py, fiftyone/operators/types.py Updated register_panel function and PanelOperatorConfig class to support different icon modes. Introduced IconButtonView class in types.

🐰✨
In the code garden, fresh sprouts arise,
Icons bloom, and panels harmonize.
A rabbit hops along the digital rows,
Admiring the update's new composed prose.
Cheers to changes, big and small,
In our code world, standing tall! 🌼🌟


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ritch
Copy link
Contributor

ritch commented May 8, 2024

I think we need to be able to build these:

image

and these:

image

@imanjra
Copy link
Contributor Author

imanjra commented May 8, 2024

Sounds good. I will add another view ActionButtonView with these two variants.

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

Out of diff range and nitpick comments (3)
app/packages/components/src/components/MuiIconFont/index.tsx (1)

1-1: Ensure consistent import ordering.

Consider grouping and ordering imports to improve readability. Typically, external library imports (like @mui/material) should come before local imports.

fiftyone/operators/panel.py (2)

Line range hint 81-81: Unused variable panel_id.

The local variable panel_id is assigned but never used, which could be an oversight or redundant code.

-        panel_id = ctx.params.get("panel_id", None)

Line range hint 83-83: Unused variable state.

The local variable state is assigned but never used, indicating potential redundant code.

-        state = ctx.params.get("state", {})
Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between e52c5c1 and cebb04f.
Files ignored due to path filters (2)
  • app/packages/components/package.json is excluded by !**/*.json
  • app/yarn.lock is excluded by !**/*.lock, !**/*.lock
Files selected for processing (12)
  • app/packages/components/src/components/MuiIconFont/index.tsx (1 hunks)
  • app/packages/components/src/components/index.ts (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/IconButtonView.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/index.ts (1 hunks)
  • app/packages/operators/src/OperatorIcon.tsx (3 hunks)
  • app/packages/operators/src/Panel/register.tsx (1 hunks)
  • app/packages/operators/src/built-in-operators.ts (4 hunks)
  • app/packages/operators/src/constants.ts (1 hunks)
  • app/packages/operators/src/types.ts (1 hunks)
  • fiftyone/operators/operations.py (4 hunks)
  • fiftyone/operators/panel.py (3 hunks)
  • fiftyone/operators/types.py (2 hunks)
Files skipped from review due to trivial changes (3)
  • app/packages/components/src/components/index.ts
  • app/packages/core/src/plugins/SchemaIO/components/index.ts
  • app/packages/operators/src/constants.ts
Additional Context Used
Ruff (2)
fiftyone/operators/panel.py (2)

81-81: Local variable panel_id is assigned to but never used


83-83: Local variable state is assigned to but never used

Path-based Instructions (6)
app/packages/components/src/components/MuiIconFont/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/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/core/src/plugins/SchemaIO/components/IconButtonView.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/OperatorIcon.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/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.

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.

Additional comments not posted (10)
app/packages/components/src/components/MuiIconFont/index.tsx (3)

2-2: Verify the CSS import.


6-8: Component implementation looks clean and efficient.

The MuiIconFont component is well-implemented, using destructuring to separate the name prop from other iconProps, and correctly spreading iconProps into the Icon component.


11-13: Type definition for MuiIconFontProps is clear and appropriate.

The type extends IconProps and correctly requires a name string, which is essential for the component's functionality.

app/packages/operators/src/Panel/register.tsx (1)

12-21: Icon rendering logic is well-implemented.

The use of a functional component for the Icon prop in registerComponent is a good practice, allowing for dynamic rendering based on ctx.params.

app/packages/core/src/plugins/SchemaIO/components/IconButtonView.tsx (1)

8-26: Review the use of getComponentProps and usePanelEvent.

Ensure that getComponentProps and usePanelEvent are correctly implemented and used. These functions play a critical role in the component's functionality.

Verification successful

The verification process has confirmed the implementation and usage of both getComponentProps and usePanelEvent within the codebase:

  • getComponentProps is implemented in app/packages/core/src/plugins/SchemaIO/utils/index.ts.
  • usePanelEvent is implemented in app/packages/operators/src/usePanelEvent.ts and is correctly imported and used in IconButtonView.tsx as well as other components within the SchemaIO plugin.

Based on this information, the usage of these functions in the IconButtonView component aligns with their definitions and implementations in the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the implementation of `getComponentProps` and `usePanelEvent`.

# Test: Search for the implementation of these functions in the codebase.
rg --type ts "getComponentProps|usePanelEvent" "app/packages/core/src/plugins/SchemaIO/utils/"

Length of output: 195



Script:

#!/bin/bash
# Description: Search for the implementation of `usePanelEvent` across the entire codebase.

# Test: Use ripgrep to search for `usePanelEvent` in TypeScript files.
rg --type ts "usePanelEvent"

Length of output: 1400

app/packages/operators/src/OperatorIcon.tsx (1)

48-51: Good implementation of utility function isIconFont.

The isIconFont function is well-implemented with clear logic to determine if a path represents a font icon based on its format.

fiftyone/operators/panel.py (2)

Line range hint 16-45: Ensure proper initialization and serialization of PanelOperatorConfig.

The PanelOperatorConfig class is correctly initialized with new icon-related properties and properly serializes these properties in the to_json method.


69-71: Proper handling of icon properties in panel configuration.

The Panel class correctly uses the new icon properties (icon, dark_icon, light_icon) in its configuration logic.

fiftyone/operators/operations.py (1)

Line range hint 269-295: Updated register_panel method to support icons.

The register_panel method has been correctly updated to include parameters for icon, dark_icon, and light_icon, enhancing the flexibility and functionality of panel registration.

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

1137-1145: New IconButtonView class added.

The IconButtonView class is correctly defined and extends the Button class, adding specific functionality for icon buttons. The implementation follows good OOP practices.

allowDuplicates: ctx.params.allow_duplicates,
},
});
registerPanel(ctx);
Copy link
Contributor

@coderabbitai coderabbitai bot May 8, 2024

Choose a reason for hiding this comment

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

The use of registerPanel directly in the execute method of RegisterPanel class without any arguments seems incorrect. Typically, such functions require parameters to specify what is being registered.

- registerPanel(ctx);
+ registerPanel({
+   name: ctx.params.panel_name,
+   label: ctx.params.panel_label,
+   on_load: ctx.params.on_load,
+   on_change: ctx.params.on_change,
+   on_unload: ctx.params.on_unload,
+   allow_duplicates: ctx.params.allow_duplicates
+ });

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
registerPanel(ctx);
registerPanel({
name: ctx.params.panel_name,
label: ctx.params.panel_label,
on_load: ctx.params.on_load,
on_change: ctx.params.on_change,
on_unload: ctx.params.on_unload,
allow_duplicates: ctx.params.allow_duplicates
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The parameters are extracted and used in the registerPanel method itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

@imanjra, thank you for your patience. After reviewing the implementation of the registerPanel function, I can confirm that it indeed extracts and utilizes parameters from the ctx object internally. This means that your usage of registerPanel(ctx); in the execute method of the RegisterPanel class is correct as it passes the entire context which contains all necessary parameters.

I appreciate your clarification, and I'll remember this detail for future reviews.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the implementation of the `registerPanel` function in TypeScript files
rg "function registerPanel" --type ts

Length of output: 130



Script:

#!/bin/bash
# Fetch and display the content of register.tsx where registerPanel is defined
cat app/packages/operators/src/Panel/register.tsx

Length of output: 833


New Learnings Added
User: imanjra
PR: voxel51/fiftyone#4373
File: app/packages/operators/src/built-in-operators.ts:983-983
Timestamp: 2024-05-09T14:47:54.783Z
Learning: The `registerPanel` function in `app/packages/operators/src/Panel/register.tsx` extracts parameters from the `ctx` object internally and does not require explicit parameter passing when called.

Note: Learnings are effective only in the context of specific code segments. To apply general coding guidelines, please configure review instructions.

Comment on lines 1870 to 1891
class IconButtonView(Button):
"""Represents a button in a :class:`View`.

Examples::

import fiftyone.operators.types as types

iconButtonView = types.IconButtonView(
icon="waving_hand",
operator="print_stdout",
params={"msg": "Hi!"},
)

inputs = types.Object()
inputs.view("icon_btn", iconButtonView)

Args:
icon (None): a icon for the button. See https://marella.me/material-icons/demo/
"""

def __init__(self, **kwargs):
super().__init__(**kwargs)
Copy link
Contributor

@coderabbitai coderabbitai bot May 8, 2024

Choose a reason for hiding this comment

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

Consider adding validation for the icon parameter in IconButtonView.

  def __init__(self, **kwargs):
+     if 'icon' not in kwargs or not isinstance(kwargs['icon'], str):
+         raise ValueError("An 'icon' parameter of type str is required.")
      super().__init__(**kwargs)

This ensures that an icon is always provided and is of the correct type, preventing runtime errors.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
class IconButtonView(Button):
"""Represents a button in a :class:`View`.
Examples::
import fiftyone.operators.types as types
iconButtonView = types.IconButtonView(
icon="waving_hand",
operator="print_stdout",
params={"msg": "Hi!"},
)
inputs = types.Object()
inputs.view("icon_btn", iconButtonView)
Args:
icon (None): a icon for the button. See https://marella.me/material-icons/demo/
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
class IconButtonView(Button):
"""Represents a button in a :class:`View`.
Examples::
import fiftyone.operators.types as types
iconButtonView = types.IconButtonView(
icon="waving_hand",
operator="print_stdout",
params={"msg": "Hi!"},
)
inputs = types.Object()
inputs.view("icon_btn", iconButtonView)
Args:
icon (None): a icon for the button. See https://marella.me/material-icons/demo/
"""
def __init__(self, **kwargs):
if 'icon' not in kwargs or not isinstance(kwargs['icon'], str):
raise ValueError("An 'icon' parameter of type str is required.")
super().__init__(**kwargs)

Copy link
Contributor

@ritch ritch May 9, 2024

Choose a reason for hiding this comment

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

Seems like a good suggestion. Although I don't think we do that consistently throughout the type system.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ritch, you're absolutely right about the inconsistency in validation across the type system. It's often a balance between strict type checking and flexibility. However, for parameters like icon that are crucial for the functionality of components, ensuring the correct type can prevent potential runtime errors and enhance stability.

If you think it would be beneficial, I can help review other parts of the type system to identify where similar validations might be needed. This could be a step towards more robust and error-resistant code. Let me know how you'd like to proceed!

Comment on lines 5 to 26
export default function registerPanel(ctx) {
registerComponent({
type: PluginComponentType.Panel,
name: ctx.params.panel_name,
component: defineCustomPanel(ctx.params),
label: ctx.params.panel_label,
activator: () => true,
Icon: () => {
return (
<OperatorIcon
icon={ctx.params.icon || "extension"}
darkIcon={ctx.params.dark_icon}
lightIcon={ctx.params.light_icon}
iconProps={{ sx: { fontSize: 14, mr: "0.5rem" } }}
/>
);
},
panelOptions: {
allowDuplicates: ctx.params.allow_duplicates,
},
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The review comment about the lack of error handling in the registerPanel function is accurate. The function uses ctx.params multiple times without any checks or error handling mechanisms to ensure that the properties accessed on ctx.params are present and correctly structured. This could lead to runtime errors if ctx.params does not meet the expected structure or contains unexpected values.

To address this, it would be beneficial to implement error handling mechanisms such as:

  • Validating the structure and presence of necessary properties in ctx.params before they are used.
  • Providing default values or handling cases where expected properties are missing.

This will help prevent potential runtime errors and make the function more robust.

Analysis chain

Ensure proper error handling in registerPanel.

While the function implementation looks correct, it's crucial to ensure that error handling is in place for cases where ctx.params might not have the expected structure or values.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify error handling in the `registerPanel` function.

# Test: Search for error handling related to `ctx.params`.
rg --type ts "ctx.params" "app/packages/operators/src/Panel/register.tsx"

Length of output: 371

Comment on lines 15 to 65
return (
<IconButton
aria-label={icon}
{...getComponentProps(props, "button")}
onClick={() => {
handleClick(panelId, { params, operator, prompt });
}}
>
<MuiIconFont name={icon} {...getComponentProps(props, "icon")} />
</IconButton>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure accessibility standards are met.

Consider adding more descriptive aria-label for better accessibility. The current implementation uses the icon name, which might not be descriptive enough for screen readers.

-      aria-label={icon}
+      aria-label={`Button for ${icon}`}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
return (
<IconButton
aria-label={icon}
{...getComponentProps(props, "button")}
onClick={() => {
handleClick(panelId, { params, operator, prompt });
}}
>
<MuiIconFont name={icon} {...getComponentProps(props, "icon")} />
</IconButton>
);
return (
<IconButton
aria-label={`Button for ${icon}`}
{...getComponentProps(props, "button")}
onClick={() => {
handleClick(panelId, { params, operator, prompt });
}}
>
<MuiIconFont name={icon} {...getComponentProps(props, "icon")} />
</IconButton>
);

Comment on lines 20 to 32
if (isIconFont(iconPath)) {
return <MuiIconFont {...(iconProps as IconProps)} name={iconPath} />;
}

if (!iconPath || !canExecute) return Fallback ? <Fallback /> : null;
if (_builtIn) return <ImageIcon src={iconPath} />;
return <CustomOperatorIcon pluginName={pluginName} iconPath={iconPath} />;
return (
<CustomOperatorIcon
pluginName={pluginName}
iconPath={iconPath}
iconProps={iconProps as JSX.IntrinsicElements["img"]}
/>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor to improve readability and maintainability.

The conditional logic for rendering different types of icons can be simplified to improve readability and maintainability.

-  if (isIconFont(iconPath)) {
-    return <MuiIconFont {...(iconProps as IconProps)} name={iconPath} />;
-  }
-  if (!iconPath || !canExecute) return Fallback ? <Fallback /> : null;
-  if (_builtIn) return <ImageIcon src={iconPath} />;
-  return (
-    <CustomOperatorIcon
-      pluginName={pluginName}
-      iconPath={iconPath}
-      iconProps={iconProps as JSX.IntrinsicElements["img"]}
-    />
-  );
+  if (!iconPath || !canExecute) return Fallback ? <Fallback /> : null;
+  if (isIconFont(iconPath)) {
+    return <MuiIconFont {...(iconProps as IconProps)} name={iconPath} />;
+  } else if (_builtIn) {
+    return <ImageIcon src={iconPath} />;
+  } else {
+    return (
+      <CustomOperatorIcon
+        pluginName={pluginName}
+        iconPath={iconPath}
+        iconProps={iconProps as JSX.IntrinsicElements["img"]}
+      />
+    );
+  }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if (isIconFont(iconPath)) {
return <MuiIconFont {...(iconProps as IconProps)} name={iconPath} />;
}
if (!iconPath || !canExecute) return Fallback ? <Fallback /> : null;
if (_builtIn) return <ImageIcon src={iconPath} />;
return <CustomOperatorIcon pluginName={pluginName} iconPath={iconPath} />;
return (
<CustomOperatorIcon
pluginName={pluginName}
iconPath={iconPath}
iconProps={iconProps as JSX.IntrinsicElements["img"]}
/>
);
if (!iconPath || !canExecute) return Fallback ? <Fallback /> : null;
if (isIconFont(iconPath)) {
return <MuiIconFont {...(iconProps as IconProps)} name={iconPath} />;
} else if (_builtIn) {
return <ImageIcon src={iconPath} />;
} else {
return (
<CustomOperatorIcon
pluginName={pluginName}
iconPath={iconPath}
iconProps={iconProps as JSX.IntrinsicElements["img"]}
/>
);
}

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

Out of diff range and nitpick comments (1)
fiftyone/operators/panel.py (1)

Line range hint 81-83: Unused variables panel_id and state should be removed if they are not needed.

-        panel_id = ctx.params.get("panel_id", None)
-        state = ctx.params.get("state", {})
Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between e52c5c1 and f519710.
Files ignored due to path filters (2)
  • app/packages/components/package.json is excluded by !**/*.json
  • app/yarn.lock is excluded by !**/*.lock, !**/*.lock
Files selected for processing (12)
  • app/packages/components/src/components/MuiIconFont/index.tsx (1 hunks)
  • app/packages/components/src/components/index.ts (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/IconButtonView.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/index.ts (1 hunks)
  • app/packages/operators/src/OperatorIcon.tsx (3 hunks)
  • app/packages/operators/src/Panel/register.tsx (1 hunks)
  • app/packages/operators/src/built-in-operators.ts (4 hunks)
  • app/packages/operators/src/constants.ts (1 hunks)
  • app/packages/operators/src/types.ts (1 hunks)
  • fiftyone/operators/operations.py (4 hunks)
  • fiftyone/operators/panel.py (3 hunks)
  • fiftyone/operators/types.py (2 hunks)
Files skipped from review as they are similar to previous changes (11)
  • app/packages/components/src/components/MuiIconFont/index.tsx
  • app/packages/components/src/components/index.ts
  • app/packages/core/src/plugins/SchemaIO/components/IconButtonView.tsx
  • app/packages/core/src/plugins/SchemaIO/components/index.ts
  • app/packages/operators/src/OperatorIcon.tsx
  • app/packages/operators/src/Panel/register.tsx
  • app/packages/operators/src/built-in-operators.ts
  • app/packages/operators/src/constants.ts
  • app/packages/operators/src/types.ts
  • fiftyone/operators/operations.py
  • fiftyone/operators/types.py
Additional Context Used
Ruff (2)
fiftyone/operators/panel.py (2)

81-81: Local variable panel_id is assigned to but never used


83-83: Local variable state is assigned to but never used

Additional comments not posted (2)
fiftyone/operators/panel.py (2)

16-31: LGTM! The addition of icon parameters enhances the flexibility of panel configurations.


69-71: The addition of icon parameters in the panel configuration is consistent and well-implemented.

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

Out of diff range and nitpick comments (1)
fiftyone/operators/panel.py (1)

Line range hint 81-83: Consider removing the unused variables panel_id and state unless they are intended for future use.

-        panel_id = ctx.params.get("panel_id", None)
-        state = ctx.params.get("state", {})
Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between e52c5c1 and 65916ad.
Files ignored due to path filters (2)
  • app/packages/components/package.json is excluded by !**/*.json
  • app/yarn.lock is excluded by !**/*.lock, !**/*.lock
Files selected for processing (11)
  • app/packages/components/src/components/MuiIconFont/index.tsx (1 hunks)
  • app/packages/components/src/components/index.ts (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/IconButtonView.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/index.ts (1 hunks)
  • app/packages/operators/src/OperatorIcon.tsx (3 hunks)
  • app/packages/operators/src/Panel/register.tsx (1 hunks)
  • app/packages/operators/src/built-in-operators.ts (4 hunks)
  • app/packages/operators/src/types.ts (1 hunks)
  • fiftyone/operators/operations.py (4 hunks)
  • fiftyone/operators/panel.py (3 hunks)
  • fiftyone/operators/types.py (2 hunks)
Files skipped from review as they are similar to previous changes (10)
  • app/packages/components/src/components/MuiIconFont/index.tsx
  • app/packages/components/src/components/index.ts
  • app/packages/core/src/plugins/SchemaIO/components/IconButtonView.tsx
  • app/packages/core/src/plugins/SchemaIO/components/index.ts
  • app/packages/operators/src/OperatorIcon.tsx
  • app/packages/operators/src/Panel/register.tsx
  • app/packages/operators/src/built-in-operators.ts
  • app/packages/operators/src/types.ts
  • fiftyone/operators/operations.py
  • fiftyone/operators/types.py
Additional Context Used
Ruff (2)
fiftyone/operators/panel.py (2)

81-81: Local variable panel_id is assigned to but never used


83-83: Local variable state is assigned to but never used

Additional comments not posted (3)
fiftyone/operators/panel.py (3)

16-31: Constructor modifications correctly handle the new icon parameters.


44-45: The to_json method correctly serializes the new icon parameters.


69-71: The on_startup method correctly includes the new icon parameters in the panel configuration.

) : null;

const onClick = useCallback(() => {
handleClick(panelId, { params, operator, prompt });
Copy link
Contributor

Choose a reason for hiding this comment

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

🆒

)

inputs = types.Object()
inputs.view("icon_btn", iconButtonView)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add inputs.btn(name, icon="waving_hand", variant="round") since this is going to be such a typical use case. I'd like to keep first class usecases using the types.Object.util() methods (eg. .str(), .enum()).

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 65916ad and 5886ffd.
Files selected for processing (5)
  • app/packages/core/src/plugins/SchemaIO/components/IconButtonView.tsx (1 hunks)
  • app/packages/operators/src/OperatorIcon.tsx (3 hunks)
  • app/packages/operators/src/Panel/register.tsx (1 hunks)
  • app/packages/operators/src/built-in-operators.ts (4 hunks)
  • fiftyone/operators/types.py (3 hunks)
Files skipped from review as they are similar to previous changes (4)
  • app/packages/core/src/plugins/SchemaIO/components/IconButtonView.tsx
  • app/packages/operators/src/OperatorIcon.tsx
  • app/packages/operators/src/Panel/register.tsx
  • app/packages/operators/src/built-in-operators.ts
Additional comments not posted (1)
fiftyone/operators/types.py (1)

1912-1937: LGTM! The IconButtonView class is well-implemented with necessary validations.

Verification successful

The verification process has successfully confirmed that the IconButtonView class is being used correctly across the codebase. The specific instance where IconButtonView is created dynamically based on the presence of an icon parameter shows that the icon parameter is indeed being passed correctly, adhering to the class's requirement for this parameter to be a string.

  • The class definition in fiftyone/operators/types.py correctly enforces the presence and type of the icon parameter.
  • The example usage within the same file demonstrates the correct instantiation with the icon parameter.
  • The dynamic creation of IconButtonView based on the icon condition also correctly includes the icon parameter.

This thorough verification across different usages in the codebase confirms that the implementation and usage of IconButtonView adhere to the specified requirements.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all uses of `IconButtonView` to ensure they provide a valid `icon` parameter.

# Test: Search for the class usage. Expect: Only occurrences with a valid `icon` parameter.
rg --type python $'IconButtonView'

Length of output: 64



Script:

#!/bin/bash
# Description: Verify all uses of `IconButtonView` to ensure they provide a valid `icon` parameter.

# Test: Search for the class usage. Expect: Only occurrences with a valid `icon` parameter.
rg --type py $'IconButtonView'

Length of output: 224



Script:

#!/bin/bash
# Description: Extract the full context around the creation of `IconButtonView` instances to verify the correct usage of the `icon` parameter.

# Extract lines around the first occurrence outside the class definition.
rg --type py --context 5 $'btn = IconButtonView(' fiftyone/operators/types.py

Length of output: 171



Script:

#!/bin/bash
# Description: Extract the full context around the creation of `IconButtonView` instances to verify the correct usage of the `icon` parameter.

# Extract lines around the first occurrence outside the class definition.
rg --type py --context 5 $'btn = IconButtonView\\(' fiftyone/operators/types.py

Length of output: 400

@imanjra imanjra merged commit e3c972a into py-panels-develop May 9, 2024
6 checks passed
@imanjra imanjra deleted the feat/mui-icons branch May 9, 2024 15:30
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.

None yet

2 participants