-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix(web): not throw a query if the new reviewers are the same as before #1318
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes in this pull request involve modifications across several files related to request management in a web application. Key updates include enhancements to the test suite for handling notifications during request operations, the introduction of update functionality for requests, and the removal of outdated update capabilities from other components. This restructuring aims to improve the clarity of test outputs and streamline the request management process, while maintaining existing functionalities for creating and managing requests and comments. Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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 (
|
✅ Deploy Preview for reearth-cms ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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: 1
🧹 Outside diff range and nitpick comments (5)
web/src/components/organisms/Project/Request/RequestDetails/index.tsx (1)
19-19
: LGTM! Clean separation of request update functionalityThe restructuring of hooks improves code organization by moving request update functionality to a dedicated hook, which aligns with the single responsibility principle.
Also applies to: 22-22
web/src/components/molecules/Request/Details/SidebarWrapper.tsx (1)
57-59
: Consider optimizing the array comparison logicWhile the current implementation works, it could be more efficient. The spread operator and JSON.stringify create unnecessary copies and overhead.
Consider this more efficient approach:
- const isEqual = - JSON.stringify([...defaultValue].sort()) === JSON.stringify([...selectedReviewers].sort()); + const isEqual = + defaultValue?.length === selectedReviewers.length && + new Set([...defaultValue, ...selectedReviewers]).size === defaultValue?.length;This approach:
- Avoids sorting operations
- Reduces memory allocations
- Handles null/undefined cases better
web/src/components/organisms/Project/Content/ContentDetails/hooks.ts (3)
Line range hint
32-92
: Consider enhancing type safety for state managementThe state management implementation could benefit from stricter typing:
- Consider using discriminated unions for state management
- Add explicit return type for the custom hook
Example implementation:
type ContentDetailsHookReturn = { loadingReference: boolean; linkedItemsModalList: FormItem[]; // ... other return types }; export default (): ContentDetailsHookReturn => { // ... existing implementation };
Line range hint
279-307
: Enhance error handling in item update logicThe error handling in
handleItemUpdate
andhandleMetaItemUpdate
could be improved:
- Add specific error messages based on error types
- Consider adding version conflict detection
- Implement retry logic for transient failures
Example implementation:
const handleItemUpdate = useCallback( async ({ itemId, fields }: { itemId: string; fields: ItemField[] }) => { try { const item = await updateItem({ variables: { itemId: itemId, fields: fields as ItemFieldInput[], version: currentItem?.version ?? "", }, }); if (item.errors) { const isVersionConflict = item.errors.some(e => e.message.includes('version')); if (isVersionConflict) { Notification.error({ message: t("Version conflict detected. Please refresh and try again.") }); return; } Notification.error({ message: t("Failed to update item: ") + item.errors[0].message }); return; } if (!item.data?.updateItem) { Notification.error({ message: t("No data returned from update operation.") }); return; } Notification.success({ message: t("Successfully updated Item!") }); } catch (error) { console.error('Update failed:', error); Notification.error({ message: t("An unexpected error occurred while updating the item.") }); } }, [updateItem, currentItem?.version, t], );
Line range hint
514-558
: Consider restructuring hook return value for better maintainabilityThe hook returns a large number of values and handlers. Consider:
- Splitting into smaller, focused hooks
- Grouping related values and handlers into logical objects
Example implementation:
// Split into smaller hooks const useItemManagement = () => { // Item-related state and handlers return { itemLoading, currentItem, handleItemCreate, handleItemUpdate, // ... }; }; const useRequestManagement = () => { // Request-related state and handlers return { requests, requestModalShown, handleRequestCreate, // ... }; }; // Main hook export default () => { const itemManagement = useItemManagement(); const requestManagement = useRequestManagement(); return { ...itemManagement, ...requestManagement, // ... other values }; };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
web/e2e/project/request.spec.ts
(0 hunks)web/src/components/molecules/Request/Details/SidebarWrapper.tsx
(2 hunks)web/src/components/organisms/Project/Content/ContentDetails/hooks.ts
(1 hunks)web/src/components/organisms/Project/Request/RequestDetails/hooks.ts
(4 hunks)web/src/components/organisms/Project/Request/RequestDetails/index.tsx
(2 hunks)
💤 Files with no reviewable changes (1)
- web/e2e/project/request.spec.ts
🔇 Additional comments (8)
web/src/components/organisms/Project/Request/RequestDetails/index.tsx (2)
34-34
: LGTM! Proper removal of update-related functionality from content hooks
The simplified destructuring from useContentHooks reflects the proper removal of request update responsibilities from content-related hooks.
Line range hint 51-51
: LGTM! Consistent prop passing for loading state
The loading state is correctly passed down to the molecule component, maintaining proper state management.
web/src/components/molecules/Request/Details/SidebarWrapper.tsx (1)
82-82
: LGTM: Proper dependency inclusion
The addition of defaultValue
to the dependency array is correct and necessary as it's used within the callback.
web/src/components/organisms/Project/Request/RequestDetails/hooks.ts (4)
6-6
: LGTM: Clean type import addition
The RequestUpdatePayload type import is appropriately placed alongside related types.
Line range hint 9-18
: LGTM: Consistent hook import structure
The useUpdateRequestMutation hook is properly grouped with other mutation hooks, maintaining consistent import organization.
101-102
: LGTM: Clean mutation hook implementation
The mutation hook is properly implemented with loading state extraction following React hooks best practices.
256-260
: LGTM: Consistent return object structure
The new properties are properly added to the return object, maintaining consistent ordering with other similar entries.
web/src/components/organisms/Project/Content/ContentDetails/hooks.ts (1)
13-13
: LGTM: Import changes align with functionality move
The simplified import of request types aligns with moving request update functionality to the RequestDetails component.
Overview
This PR fixes to not throw a query if the new reviewers are the same as before.
What I've done
Summary by CodeRabbit
Release Notes
New Features
Improvements
Bug Fixes
Documentation