-
Notifications
You must be signed in to change notification settings - Fork 588
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
update exec options text #5075
update exec options text #5075
Conversation
WalkthroughThe changes introduce a new functional component Changes
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
b2f9f64
to
119c5a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
app/packages/operators/src/SplitButton.tsx (1)
140-145
: Consider adding TypeScript types for the option properties.While the implementation is correct, adding explicit TypeScript interfaces for the option properties would improve type safety and documentation.
interface SplitButtonOption { id: string; label: string; choiceLabel?: string; tag?: string; selected?: boolean; disabled?: boolean; description?: string; onSelect: () => void; }app/packages/operators/src/state.ts (1)
273-273
: Improve clarity of scheduled execution description.The description "Run this operation on your compute cluster" might be too generic. Consider providing more context about the implications of scheduled execution.
- description: "Run this operation on your compute cluster", + description: "Run this operation asynchronously on your compute cluster for better resource management",
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
app/packages/operators/src/SplitButton.tsx
(3 hunks)app/packages/operators/src/state.ts
(4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/operators/src/SplitButton.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/state.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.
📓 Learnings (1)
app/packages/operators/src/state.ts (1)
Learnt from: swheaton
PR: voxel51/fiftyone#5036
File: app/packages/operators/src/state.ts:329-330
Timestamp: 2024-11-04T17:01:09.830Z
Learning: In `app/packages/operators/src/state.ts`, within the `useOperatorPromptSubmitOptions` function, the variable `allowImmediateExecution` is correctly used and should not be replaced with `executionOptions.allowImmediateExecution`.
🔇 Additional comments (2)
app/packages/operators/src/SplitButton.tsx (1)
17-17
: LGTM: Import statement is correctly placed and necessary.
The useTheme import is required for accessing theme properties in the new PrimaryWithTag component.
app/packages/operators/src/state.ts (1)
253-256
: 🛠️ Refactor suggestion
Consider clarifying the purpose of the "FOR TESTING" tag.
The addition of a static "FOR TESTING" tag to immediate execution options might be misleading or confusing to users. Consider:
- Making this tag configurable based on the execution context
- Adding documentation to explain when and why this tag appears
- tag: "FOR TESTING",
+ tag: executionOptions.immediateExecutionTag || "FOR TESTING",
function PrimaryWithTag({ label, tag }) { | ||
const theme = useTheme(); | ||
const tagEl = tag ? ( | ||
<span | ||
style={{ | ||
fontSize: "11px", | ||
color: theme.custom.primarySoft, | ||
marginLeft: "5px", | ||
}} | ||
> | ||
{tag} | ||
</span> | ||
) : null; | ||
return ( | ||
<div style={{ display: "flex", alignItems: "center" }}> | ||
{label} | ||
{tagEl} | ||
</div> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Several improvements needed for the PrimaryWithTag component.
While the component works, there are several areas for improvement:
- Missing TypeScript types
- Hardcoded style values
- Inline styles could be better organized
- Performance optimization opportunity
Here's a suggested refactor:
+ interface PrimaryWithTagProps {
+ label: string;
+ tag?: string;
+ }
- function PrimaryWithTag({ label, tag }) {
+ const PrimaryWithTag = React.memo(({ label, tag }: PrimaryWithTagProps) => {
const theme = useTheme();
const tagEl = tag ? (
<span
sx={{
- fontSize: "11px",
+ fontSize: theme.typography.pxToRem(11),
color: theme.custom.primarySoft,
- marginLeft: "5px",
+ marginLeft: theme.spacing(0.625),
}}
>
{tag}
</span>
) : null;
return (
- <div style={{ display: "flex", alignItems: "center" }}>
+ <Box sx={{ display: "flex", alignItems: "center" }}>
{label}
{tagEl}
- </div>
+ </Box>
);
- }
+ });
Key improvements:
- Added TypeScript interface for props
- Used theme spacing and typography utilities
- Replaced inline styles with MUI's sx prop
- Memoized component for better performance
- Used MUI's Box component instead of div
Committable suggestion skipped: line range outside the PR's diff.
// sort options so that the default is always the first in the list | ||
options.sort((a, b) => { | ||
if (a.default) return -1; | ||
if (b.default) return 1; | ||
return 0; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review the sorting implementation for options array.
The current sorting implementation has a few potential issues:
- It modifies the original array (sort is in-place)
- The comparison function might not be stable across browsers
- The logic doesn't handle undefined/null default properties
Consider this safer implementation:
- options.sort((a, b) => {
- if (a.default) return -1;
- if (b.default) return 1;
- return 0;
- });
+ const sortedOptions = [...options].sort((a, b) => {
+ const aDefault = Boolean(a?.default);
+ const bDefault = Boolean(b?.default);
+ if (aDefault === bDefault) return 0;
+ return aDefault ? -1 : 1;
+ });
+ options.length = 0;
+ options.push(...sortedOptions);
📝 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.
// sort options so that the default is always the first in the list | |
options.sort((a, b) => { | |
if (a.default) return -1; | |
if (b.default) return 1; | |
return 0; | |
}); | |
// sort options so that the default is always the first in the list | |
const sortedOptions = [...options].sort((a, b) => { | |
const aDefault = Boolean(a?.default); | |
const bDefault = Boolean(b?.default); | |
if (aDefault === bDefault) return 0; | |
return aDefault ? -1 : 1; | |
}); | |
options.length = 0; | |
options.push(...sortedOptions); |
Summary by CodeRabbit
New Features
PrimaryWithTag
component in theSplitButton
, allowing options to display a label with an optional tag for better visual representation.Improvements