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

517 add a switch to createhintpage #518

Merged
merged 3 commits into from
Jan 23, 2025

Conversation

MandeepPaul
Copy link
Collaborator

Describe your changes

  • Added switch to enable hint icon
  • Updated modal and migration

Issue number

#517

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.

Preview

Screenshot 2025-01-22 101045

Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Walkthrough

This pull request introduces a new feature to manage hint icon visibility across the application. The changes span multiple files in the backend and frontend, adding a boolean column isHintIconVisible to the hints table, updating the Hint model, and implementing a toggle switch in the user interface to control hint icon display. The modifications include database migration, model updates, and frontend component enhancements to provide more granular control over hint presentation.

Changes

File Change Summary
backend/migrations/0006-1.0-hint.js Added isHintIconVisible column, modified action and tooltipPlacement to ENUM types
backend/src/models/Hint.js Added isHintIconVisible property with default true
backend/src/test/e2e/hint.test.mjs Updated response structure for GET /api/hint/all_hints
backend/src/test/mocks/hint.mock.js Added isHintIconVisible to hint object
frontend/src/components/HintPageComponents/HintLeftContent/HintLeftContent.css Added .switch-style CSS class
frontend/src/components/HintPageComponents/HintLeftContent/HintLeftContent.jsx Integrated Switch component for hint icon visibility
frontend/src/scenes/hints/CreateHintPage.jsx Added state and props for managing hint icon visibility

Sequence Diagram

sequenceDiagram
    participant User
    participant CreateHintPage
    participant HintLeftContent
    participant Backend

    User->>CreateHintPage: Toggle hint icon visibility
    CreateHintPage->>HintLeftContent: Pass visibility state
    HintLeftContent->>User: Update Switch component
    CreateHintPage->>Backend: Save hint with visibility setting
    Backend-->>CreateHintPage: Confirm save
Loading

Possibly related PRs

Suggested Labels

enhancement, design

Suggested Reviewers

  • erenfn
  • swoopertr
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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

🧹 Nitpick comments (4)
frontend/src/components/HintPageComponents/HintLeftContent/HintLeftContent.jsx (1)

189-202: Let's make this switch accessible! ♿

The switch component needs accessibility improvements and more specific styling.

Apply this diff:

-          <div className="switch-style">
+          <div className="hint-icon-switch-container">
             <Switch
               id="switch"
               name="target"
+              aria-label="Toggle hint icon visibility"
               onChange={(e) => {
                 handleHintIcon(e);
                 handleChange(e);
               }}
-              value={isHintIconVisible}
+              checked={isHintIconVisible}
             />
-            <span style={{ fontSize: 'var(--font-regular)' }}>
+            <label htmlFor="switch" className="hint-icon-switch-label">
               Enable hint icon
-            </span>
+            </label>
           </div>
frontend/src/scenes/hints/CreateHintPage.jsx (1)

178-179: Yo, let's make these props more fire! 🚀

The prop name enableHintIcon could be more descriptive since it's a setter function.

Consider renaming for better clarity:

-          enableHintIcon={setHintIconVisible}
+          onHintIconVisibilityChange={setHintIconVisible}
backend/src/test/e2e/hint.test.mjs (1)

480-480: Yo dawg, we need more test coverage! 🧪

While the isHintIconVisible field is correctly added to the expected keys, we should add specific test cases for this new field.

Consider adding these test cases:

  1. Verify default value when creating a new hint
  2. Verify the value is preserved after editing
  3. Verify the value is correctly returned in single hint retrieval
frontend/src/components/HintPageComponents/HintLeftContent/HintLeftContent.css (1)

25-30: These styles are fresh, but we can make 'em fresher! 💅

The .switch-style class looks good, but we can improve maintainability.

Consider these enhancements:

 .switch-style {
-  margin-top: 2rem;
+  margin-top: var(--spacing-lg, 2rem);
   display: flex;
   align-items: center;
-  gap: 10px;
+  gap: var(--spacing-sm, 10px);
 }

This change makes the spacing consistent with your design system variables.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5d9cce0 and 671dca4.

📒 Files selected for processing (7)
  • backend/migrations/0006-1.0-hint.js (1 hunks)
  • backend/src/models/Hint.js (1 hunks)
  • backend/src/test/e2e/hint.test.mjs (1 hunks)
  • backend/src/test/mocks/hint.mock.js (1 hunks)
  • frontend/src/components/HintPageComponents/HintLeftContent/HintLeftContent.css (1 hunks)
  • frontend/src/components/HintPageComponents/HintLeftContent/HintLeftContent.jsx (4 hunks)
  • frontend/src/scenes/hints/CreateHintPage.jsx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (22.x)
🔇 Additional comments (4)
backend/src/test/mocks/hint.mock.js (1)

10-10: Yo, this mock's looking fresh! 🔥

The new isHintIconVisible property with default value true aligns perfectly with the model changes.

frontend/src/components/HintPageComponents/HintLeftContent/HintLeftContent.jsx (1)

22-23: Props looking clean! 🧼

The new props isHintIconVisible and enableHintIcon are well-named and their purpose is clear.

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

55-55: Yo, the state management is on point! 🔥

The initialization of isHintIconVisible with a default value of true and the use of nullish coalescing operator for handling the fetched value is clean and robust.

Also applies to: 81-81


105-105: Straight fire! The save logic is tight! 🎯

The isHintIconVisible property is properly included in the hintData object for persistence.

@MandeepPaul MandeepPaul requested a review from erenfn January 23, 2025 16:57
@gorkem-bwl
Copy link
Contributor

Looks good.

@erenfn erenfn merged commit fbe3bd6 into develop Jan 23, 2025
2 checks passed
@MandeepPaul MandeepPaul deleted the 517-add-a-switch-to-createhintpage branch January 24, 2025 13:35
@coderabbitai coderabbitai bot mentioned this pull request Jan 27, 2025
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