-
Notifications
You must be signed in to change notification settings - Fork 3.2k
chore: code refactor #5952
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
chore: code refactor #5952
Conversation
WalkthroughThis pull request introduces a new React functional component named Changes
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
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
CodeRabbit Configuration File (
|
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: 3
🧹 Outside diff range and nitpick comments (3)
web/ce/components/de-dupe/de-dupe-button.tsx (1)
3-4: Remove unnecessary commentThe comment "// local components" appears to be unnecessary as there are no local component imports.
-// local componentsweb/core/components/inbox/modals/create-modal/create-root.tsx (1)
213-218: LGTM! Clean implementation of the duplicate detection button.The component usage is well-structured with proper prop passing and conditional rendering. Consider extracting the label text to a constant or i18n file for better maintainability.
+const getDuplicateLabel = (count: number) => `${count} duplicate issue${count > 1 ? "s" : ""} found!`; <DeDupeButtonRoot workspaceSlug={workspaceSlug} isDuplicateModalOpen={isDuplicateModalOpen} - label={`${duplicateIssues.length} duplicate issue${duplicateIssues.length > 1 ? "s" : ""} found!`} + label={getDuplicateLabel(duplicateIssues.length)} handleOnClick={() => handleDuplicateIssueModal(!isDuplicateModalOpen)} />web/core/components/issues/issue-modal/form.tsx (1)
Line range hint
141-182: Enhance form submission error handling and user feedbackThe form submission logic could be improved in several areas:
- Error handling should provide user feedback instead of just console logging
- Editor readiness message could be more user-friendly
- Form reset logic could be more selective based on isCreateMoreToggleEnabled
Consider applying these improvements:
const handleFormSubmit = async (formData: Partial<TIssue>, is_draft_issue = false) => { // Check if the editor is ready to discard if (!editorRef.current?.isEditorReadyToDiscard()) { setToast({ type: TOAST_TYPE.ERROR, title: "Error!", - message: "Editor is not ready to discard changes.", + message: "Please wait for the editor to finish processing your changes before submitting.", }); return; } // ... existing validation code ... await onSubmit(submitData, is_draft_issue) .then(() => { setGptAssistantModal(false); + // Preserve specific fields when create more is enabled + const fieldsToPreserve = isCreateMoreToggleEnabled + ? { + project_id: getValues<"project_id">("project_id"), + type_id: getValues<"type_id">("type_id"), + label_ids: getValues<"label_ids">("label_ids"), + } + : {}; reset({ ...defaultValues, - ...(isCreateMoreToggleEnabled ? { ...data } : {}), - project_id: getValues<"project_id">("project_id"), - type_id: getValues<"type_id">("type_id"), + ...fieldsToPreserve, description_html: data?.description_html ?? "<p></p>", }); editorRef?.current?.clearEditor(); }) .catch((error) => { - console.error(error); + setToast({ + type: TOAST_TYPE.ERROR, + title: "Error submitting form", + message: error?.message || "An unexpected error occurred. Please try again.", + }); }); };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
web/ce/components/de-dupe/de-dupe-button.tsx(1 hunks)web/ce/components/de-dupe/index.ts(1 hunks)web/core/components/inbox/modals/create-modal/create-root.tsx(2 hunks)web/core/components/issues/issue-modal/form.tsx(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- web/ce/components/de-dupe/index.ts
🧰 Additional context used
🪛 GitHub Check: lint-web
web/ce/components/de-dupe/de-dupe-button.tsx
[warning] 13-13:
'workspaceSlug' is assigned a value but never used
[warning] 13-13:
'isDuplicateModalOpen' is assigned a value but never used
[warning] 13-13:
'label' is assigned a value but never used
[warning] 13-13:
'handleOnClick' is assigned a value but never used
🔇 Additional comments (4)
web/ce/components/de-dupe/de-dupe-button.tsx (1)
5-10: LGTM! Well-structured type definition
The type definition is clear, well-structured, and follows TypeScript best practices.
web/core/components/inbox/modals/create-modal/create-root.tsx (1)
25-26: LGTM! Clean organization of deduplication-related imports.
The new imports are well-organized in a dedicated deduplication module, improving code modularity.
web/core/components/issues/issue-modal/form.tsx (2)
34-34: LGTM: Clean import of de-duplication components
The import statement is well-structured and correctly imports both required components from the web components directory.
353-358: LGTM: Clean integration of DeDupeButtonRoot
The component is well-integrated with:
- Proper prop passing
- Dynamic label generation
- Conditional rendering based on duplicate issues
- Correct event handling for modal toggle
| export const DeDupeButtonRoot: FC<TDeDupeButtonRoot> = (props) => { | ||
| const { workspaceSlug, isDuplicateModalOpen, label, handleOnClick } = props; | ||
| return <></>; | ||
| }; |
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.
Component implementation is incomplete
The component currently returns an empty fragment and doesn't utilize any of its props. Based on the PR objectives and AI summary, this component is meant to replace an existing implementation for handling duplicate issues, but the functionality is missing.
Consider implementing:
- A button UI element using the
labelprop - Click handler integration with
handleOnClick - Modal state handling with
isDuplicateModalOpen
Here's a suggested implementation:
export const DeDupeButtonRoot: FC<TDeDupeButtonRoot> = (props) => {
const { workspaceSlug, isDuplicateModalOpen, label, handleOnClick } = props;
- return <></>;
+ return (
+ <button
+ type="button"
+ className="w-full text-custom-text-200 hover:text-custom-text-100"
+ onClick={handleOnClick}
+ >
+ {label}
+ </button>
+ );
};📝 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.
| export const DeDupeButtonRoot: FC<TDeDupeButtonRoot> = (props) => { | |
| const { workspaceSlug, isDuplicateModalOpen, label, handleOnClick } = props; | |
| return <></>; | |
| }; | |
| export const DeDupeButtonRoot: FC<TDeDupeButtonRoot> = (props) => { | |
| const { workspaceSlug, isDuplicateModalOpen, label, handleOnClick } = props; | |
| return ( | |
| <button | |
| type="button" | |
| className="w-full text-custom-text-200 hover:text-custom-text-100" | |
| onClick={handleOnClick} | |
| > | |
| {label} | |
| </button> | |
| ); | |
| }; |
🧰 Tools
🪛 GitHub Check: lint-web
[warning] 13-13:
'workspaceSlug' is assigned a value but never used
[warning] 13-13:
'isDuplicateModalOpen' is assigned a value but never used
[warning] 13-13:
'label' is assigned a value but never used
[warning] 13-13:
'handleOnClick' is assigned a value but never used
💡 Codebase verification
Component integration needs to be updated
The component is actively used in two locations with consistent prop usage:
web/core/components/inbox/modals/create-modal/create-root.tsxweb/core/components/issues/issue-modal/form.tsx
Both files import and use DeDupeButtonRoot with the same props that are being removed in the empty implementation (workspaceSlug, isDuplicateModalOpen, label, handleOnClick). This will cause runtime errors.
🔗 Analysis chain
Verify component integration
Let's verify how this component is integrated in the mentioned files to ensure proper implementation.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check how DeDupeButtonRoot is used in the codebase
# Check component imports and usage
echo "Checking DeDupeButtonRoot usage:"
rg -A 5 "DeDupeButtonRoot" "web/core/components/inbox/modals/create-modal/create-root.tsx" "web/core/components/issues/issue-modal/form.tsx"
# Check if there are any remnants of the old implementation
echo -e "\nChecking for old implementation:"
rg "DeDupeIssueButtonLabel"
Length of output: 3270
🧰 Tools
🪛 GitHub Check: lint-web
[warning] 13-13:
'workspaceSlug' is assigned a value but never used
[warning] 13-13:
'isDuplicateModalOpen' is assigned a value but never used
[warning] 13-13:
'label' is assigned a value but never used
[warning] 13-13:
'handleOnClick' is assigned a value but never used
| // services | ||
| import { DeDupeIssueButtonLabel, DuplicateModalRoot } from "@/plane-web/components/de-dupe"; | ||
| import { DeDupeButtonRoot, DuplicateModalRoot } from "@/plane-web/components/de-dupe"; | ||
| import { useDebouncedDuplicateIssues } from "@/plane-web/hooks/use-debounced-duplicate-issues"; |
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.
💡 Codebase verification
Debounce implementation is missing in the duplicate issues hook
The current implementation of useDebouncedDuplicateIssues in web/ce/hooks/use-debounced-duplicate-issues.tsx is incomplete. Despite its name suggesting debounced functionality:
- It doesn't use the
useDebouncehook that exists inweb/core/hooks/use-debounce.tsx - It returns an empty array without any actual duplicate detection logic
- No debounce timing is configured
This needs to be addressed to:
- Implement proper debounce using the existing
useDebouncehook - Add the actual duplicate detection logic
- Configure appropriate debounce timing (other components use 500-1500ms)
🔗 Analysis chain
Verify the debounce timing for duplicate detection.
The code uses useDebouncedDuplicateIssues hook for duplicate detection. Let's verify its implementation to ensure optimal performance.
Also applies to: 213-218
Let me gather more information about the debounce implementation.
Let me try searching in a different location since the previous path wasn't found.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check the implementation of useDebouncedDuplicateIssues hook
# Expected: Find the debounce timing configuration and any rate limiting
# Search for the hook implementation
ast-grep --pattern 'export const useDebouncedDuplicateIssues = $_'
# Search for debounce timing configuration
rg -A 5 'useDebouncedDuplicateIssues'
Length of output: 7051
Script:
#!/bin/bash
# Search for the actual implementation file and any debounce logic
rg -g '*.ts*' -A 10 'useDebouncedDuplicateIssues.*=' web/plane-web/hooks/
# Check for any debounce utility or hook being used
rg -g '*.ts*' 'useDebounce|debounce' web/plane-web/hooks/
Length of output: 257
Script:
#!/bin/bash
# Search for the actual implementation in the web directory
rg -g '*.ts*' -A 10 'useDebouncedDuplicateIssues.*=' web/
# Check for any debounce utility or hook being used
rg -g '*.ts*' 'useDebounce|debounce' web/
# Find the correct path for the hook implementation
fd -e tsx -e ts use-debounced-duplicate-issues
Length of output: 8345
Summary
This PR includes code refactoring for de dupe.
Summary by CodeRabbit
New Features
DeDupeButtonRootcomponent for handling duplicate issues.Improvements
Refactor
DeDupeButtonRootcomponent across relevant modules.de-dupe-buttonmodule for easier access.