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

410 dialog reset #429

Merged
merged 10 commits into from
Dec 28, 2024
Merged

410 dialog reset #429

merged 10 commits into from
Dec 28, 2024

Conversation

DeboraSerra
Copy link
Contributor

@DeboraSerra DeboraSerra commented Dec 24, 2024

Describe your changes

Briefly describe the changes you made and their purpose.

Issue number

Mention the issue number(s) this PR addresses (e.g., #123).

Please ensure all items are checked off before requesting a review:

  • I deployed the code locally.
  • I have performed a self-review of my code.
  • I have included the issue # in the PR.
  • I have labelled the PR correctly.
  • The issue I am working on is assigned to me.
  • I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • I made sure font sizes, color choices etc are all referenced from the theme.
  • My PR is granular and targeted to one specific feature.
  • I took a screenshot or a video and attached to this PR if there is a UI change.

Copy link
Contributor

coderabbitai bot commented Dec 24, 2024

Walkthrough

The pull request introduces several modifications across multiple frontend components, primarily focusing on state management enhancements. A new resetState prop is added to the RichTextEditor component, altering how it handles state upon destruction. Additionally, various components such as CreatePopupPage, BannerDefaultPage, and others receive the setIsEdit prop, facilitating improved state management for edit functionality. The changes also include prop type validations and refactoring for better code organization, enhancing overall maintainability.

Changes

File Change Summary
frontend/src/components/RichTextEditor/RichTextEditor.jsx - Added resetState prop to component
- Updated propTypes to include resetState as a function
frontend/src/scenes/popup/CreatePopupPage.jsx - Reorganized imports
- Added prop type validation
- Introduced resetState function
- Updated component signature to include setIsEdit
frontend/src/scenes/banner/BannerDefaultPage.jsx - Added setIsEdit prop to BannerPage component
frontend/src/scenes/banner/CreateBannerPage.jsx - Updated BannerPage signature to include setIsEdit prop
frontend/src/scenes/hints/CreateHintPage.jsx - Updated HintPage signature to include setIsEdit prop
frontend/src/scenes/hints/HintDefaultPage.jsx - Added setIsEdit prop to CreateHintPage component
frontend/src/scenes/links/LinksDefaultPage.jsx - Added setIsEdit prop to NewLinksPopup and DefaultPageTemplate components
frontend/src/scenes/links/NewLinksPopup.jsx - Updated NewLinksPopup signature to include setIsEdit prop
- Updated propTypes to include setIsEdit
frontend/src/scenes/popup/PopupDefaultPage.jsx - Added setIsEdit prop to CreatePopupPage component
frontend/src/scenes/popup/PopupPageComponents/PopupContent/PopupContent.jsx - Reorganized import statements for PropTypes
- Reformatted propTypes declaration
frontend/src/services/popupServices.js - Removed console logging from addPopup function
frontend/src/templates/DefaultPageTemplate/DefaultPageTemplate.jsx - Added state reset lines in handleClosePopup function
frontend/src/templates/GuideTemplate/GuideTemplate.jsx - Updated signature to include setIsEdit prop

Possibly Related PRs

  • popup-design #290: The changes in the RichTextEditor component are related as they both involve modifications to the handling of props and state management within the editor context.
  • Fullname refactor #313: This PR is related because it also involves changes to the RichTextEditor component, specifically in how props are managed and utilized.
  • 375 add url to banner and popup #382: The addition of the actionUrl prop in the Banner and Popup components connects with the changes in the CreatePopupPage and CreateBannerPage, which also involve managing URLs and state.
  • fix/#367-improved dialog styles on text-editor popup #425: The updates to the dialog styles in the RichTextEditor component are relevant as they enhance the user interface, similar to the changes made in the main PR regarding the RichTextEditor.
  • Blocked aria-hidden on an element because its descendant retained focus. #422 #427: The changes to the Dialog component's behavior in relation to aria-hidden are relevant as they improve accessibility, which is a consideration in the main PR's updates to the RichTextEditor.
  • updated dashboard buttons link #433: The modifications to the dashboard buttons and their links are related as they involve navigation and state management, similar to the changes made in the main PR regarding the RichTextEditor.

Suggested Labels

enhancement

Suggested Reviewers

  • erenfn

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af83188 and 6163206.

📒 Files selected for processing (8)
  • backend/src/test/unit/controllers/popup.test.js (0 hunks)
  • frontend/src/components/RichTextEditor/RichTextEditor.jsx (3 hunks)
  • frontend/src/scenes/banner/BannerDefaultPage.jsx (1 hunks)
  • frontend/src/scenes/banner/CreateBannerPage.jsx (2 hunks)
  • frontend/src/scenes/hints/CreateHintPage.jsx (2 hunks)
  • frontend/src/scenes/hints/HintDefaultPage.jsx (1 hunks)
  • frontend/src/scenes/popup/PopupDefaultPage.jsx (1 hunks)
  • frontend/src/templates/GuideTemplate/GuideTemplate.jsx (3 hunks)
💤 Files with no reviewable changes (1)
  • backend/src/test/unit/controllers/popup.test.js
🚧 Files skipped from review as they are similar to previous changes (7)
  • frontend/src/scenes/hints/HintDefaultPage.jsx
  • frontend/src/scenes/banner/BannerDefaultPage.jsx
  • frontend/src/components/RichTextEditor/RichTextEditor.jsx
  • frontend/src/scenes/hints/CreateHintPage.jsx
  • frontend/src/scenes/popup/PopupDefaultPage.jsx
  • frontend/src/scenes/banner/CreateBannerPage.jsx
  • frontend/src/templates/GuideTemplate/GuideTemplate.jsx

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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

🧹 Nitpick comments (5)
frontend/src/scenes/popup/CreatePopupPage.jsx (4)

1-11: Ensure consistent import ordering and remove unused imports
Your arms are not weak here, but to keep the import section from getting spaghetti messy, consider grouping external libraries before local imports. Double-check if every import is truly needed to avoid intangible clutter in your code.


18-23: Add inline documentation for new props
Knees weak? Not at all if you add short doc comments for new props (autoOpen, isEdit, etc.). This helps future readers avoid that sweaty confusion and clarifies each prop’s usage.


35-39: Use a colour constants file
We see repeated colour values. Store these in a constants or theme file, so your sweater doesn't get stained with repeated hex codes that might result in accidental mismatches.


149-153: Refine success messaging
The toast messages describing new or edited popups are good. Consider adding key details (like the popup title) to avoid confusion in large flows. Avoid letting important info slip onto the floor.

frontend/src/components/RichTextEditor/RichTextEditor.jsx (1)

21-21: Consider default resetState
If resetState is not supplied, you might end up with heavier arms if an error is thrown. A default no-op function could prevent any accidental references causing code vomit.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 370bf11 and 4e18a4f.

📒 Files selected for processing (2)
  • frontend/src/components/RichTextEditor/RichTextEditor.jsx (3 hunks)
  • frontend/src/scenes/popup/CreatePopupPage.jsx (5 hunks)
🔇 Additional comments (7)
frontend/src/scenes/popup/CreatePopupPage.jsx (5)

27-28: Confirm "autoOpen" usage
Double-check that "autoOpen" remains relevant once the dialog is triggered. It's definitely not mom’s spaghetti, but ensuring it’s used consistently will prevent unexpected popups.


54-68: Keep the resetState function maintainable
The single function approach is neat. Like dropping a single verse to reset the vibe, it’s straightforward and keeps logic centralized. Ensure it's well-documented so future expansions don't become mom’s spaghetti.


104-120: Graceful error handling
You handle unsuccessful fetch gracefully by calling emitToastError. Ensure messages provide clarity on next steps. This way, you won't find vomit on your code sweater if issues arise.


164-176: Solid structure for splitted left, right, and appearance
Segmenting the UI with dedicated components keeps your arms steady and your code easy to read. Watch for too much vertical nesting and use early returns or sub-components for clarity.

Also applies to: 178-193, 195-206, 208-214, 218-224


231-236: Well-defined prop types
Prop validation is on point. No sign of that mom’s spaghetti here! Keep it up to reduce run-time bugs early.

frontend/src/components/RichTextEditor/RichTextEditor.jsx (2)

48-48: Avoid forcing a full reset
Calling resetState() on onDestroy is convenient, but consider if partial resets are sometimes needed. This one-liner approach might be too sweeping, like wiping your entire sweater unnecessarily.


101-101: Prop type matches function usage
Ensure resetState is consistently invoked as a function. If you pass anything else, you might get spaghetti in your console. The type definition is correct—kudos!

@DeboraSerra DeboraSerra requested a review from erenfn December 24, 2024 17:23
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: 1

🧹 Nitpick comments (3)
frontend/src/scenes/links/LinksDefaultPage.jsx (1)

28-28: Prop ensures cohesive editing flows
Your spaghetti code fear can rest easy—this prop glues the edit mode logic together nicely. By passing setIsEdit to NewLinksPopup, you keep the parent-child communication solid, letting the child announce edits clearly.

If your code evolves further, consider a context-based approach for even more streamlined state sharing.

frontend/src/templates/GuideTemplate/GuideTemplate.jsx (1)

18-18: Prop default is helpful, but document it
Including setIsEdit = () => null, is as smooth as a fresh verse. However, mention it in GuideTemplate.propTypes to maintain clarity. This ensures that future devs fully comprehend your code’s lyrical structure.

Here's a potential snippet:

 GuideTemplate.propTypes = {
   title: PropTypes.string,
   ...
+  setIsEdit: PropTypes.func,
 };
frontend/src/scenes/banner/CreateBannerPage.jsx (1)

86-86: Ensure clarity for future maintainers.
Explicitly passing setIsEdit into GuideTemplate is consistent, but adding a brief inline comment might help emphasize how and why it's utilized.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b434726 and 0aff4c1.

📒 Files selected for processing (12)
  • frontend/src/scenes/banner/BannerDefaultPage.jsx (1 hunks)
  • frontend/src/scenes/banner/CreateBannerPage.jsx (2 hunks)
  • frontend/src/scenes/hints/CreateHintPage.jsx (2 hunks)
  • frontend/src/scenes/hints/HintDefaultPage.jsx (1 hunks)
  • frontend/src/scenes/links/LinksDefaultPage.jsx (1 hunks)
  • frontend/src/scenes/links/NewLinksPopup.jsx (2 hunks)
  • frontend/src/scenes/popup/CreatePopupPage.jsx (4 hunks)
  • frontend/src/scenes/popup/PopupDefaultPage.jsx (1 hunks)
  • frontend/src/scenes/popup/PopupPageComponents/PopupContent/PopupContent.jsx (3 hunks)
  • frontend/src/services/popupServices.js (0 hunks)
  • frontend/src/templates/DefaultPageTemplate/DefaultPageTemplate.jsx (1 hunks)
  • frontend/src/templates/GuideTemplate/GuideTemplate.jsx (2 hunks)
💤 Files with no reviewable changes (1)
  • frontend/src/services/popupServices.js
✅ Files skipped from review due to trivial changes (1)
  • frontend/src/scenes/popup/PopupPageComponents/PopupContent/PopupContent.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/scenes/popup/CreatePopupPage.jsx
🔇 Additional comments (9)
frontend/src/scenes/popup/PopupDefaultPage.jsx (1)

34-34: Slick addition of the setter prop
Sweaty palms aside, passing setIsEdit down here is a straightforward solution for controlling the parent’s edit state. This ensures that child components can reset or toggle the editing mode. Nicely done—just like a well-timed mic drop.

frontend/src/scenes/banner/BannerDefaultPage.jsx (1)

33-33: Consistent state management approach
Knees weak, arms heavy, but your approach remains steady—aligning with the pattern used in other components. Passing down setIsEdit here fosters a unified technique for toggling edit mode across the application.

frontend/src/templates/GuideTemplate/GuideTemplate.jsx (1)

69-69: Good call on resetting isEdit
When the “Cancel” button is clicked, calling setIsEdit(false) is the perfect outro, ensuring no leftover changes linger like stale spaghetti. This tidy close fosters a seamless user experience.

frontend/src/scenes/banner/CreateBannerPage.jsx (1)

15-15: Looks good for improved state control.
This newly introduced setIsEdit prop aligns with your approach across other components.

frontend/src/templates/DefaultPageTemplate/DefaultPageTemplate.jsx (1)

57-58: Wise choice to reset the edit and item ID.
Clearing the states on close ensures no leftover data when reopening the popup. Confirm this doesn't remove partial edits inadvertently.

frontend/src/scenes/links/NewLinksPopup.jsx (2)

32-32: Introduction of setIsEdit prop is consistent.
Integrates well with the broader edit-state changes. No concerns here.


164-164: Validate final usage.
Ensure that any callers of setIsEdit handle its possible side effects, such as resetting other states and dependencies.

frontend/src/scenes/hints/CreateHintPage.jsx (2)

13-13: Prop setIsEdit nicely matches the editing pattern.
This addition seamlessly standardizes the approach used in other files.


125-125: Prop passing for maintainable design.
Forwarding setIsEdit from this level to the template fosters cohesion across the codebase. Looks solid.

Copy link
Collaborator

@erenfn erenfn left a comment

Choose a reason for hiding this comment

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

  • I click edit
    image
  • I click save
  • I click edit again

image

@swoopertr
Copy link
Contributor

I see only hint section has error. Others are fine

@erenfn erenfn merged commit 4e020ed into develop Dec 28, 2024
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 30, 2025
9 tasks
@coderabbitai coderabbitai bot mentioned this pull request Mar 3, 2025
9 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