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

Stage 2 experiment: Show Language Guide Before Solution #2574

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

andy1li
Copy link
Member

@andy1li andy1li commented Jan 22, 2025

Checklist:

  • I've thoroughly self-reviewed my changes
  • I've added tests for my changes, unless they affect admin-only areas (or are otherwise not worth testing)
  • I've verified any visual changes using Percy (add a commit with [percy] in the message to trigger)

Summary by CodeRabbit

  • New Features

    • Added a feature flag to conditionally display the language guide before the solution.
    • Introduced a new method to determine user access to the language guide based on roles and feature flags.
  • Improvements

    • Enhanced the organization of template logic for better clarity and user experience.
    • Streamlined rendering of the solution with improved visibility controls based on user context.

@andy1li andy1li self-assigned this Jan 22, 2025
Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Walkthrough

This pull request introduces changes to the implementation of the solution and language guide display in the course stage tutorial card. The modifications involve adding a feature flag service to conditionally render the language guide before the solution based on user roles and specific flag settings. The changes enhance the component's flexibility by allowing different visibility rules for instructional content.

Changes

File Change Summary
app/components/course-page/course-stage-step/.../implement-solution-step.hbs Restructured template to conditionally display language guide and solution with new headers and BlurredOverlay component.
app/components/course-page/course-stage-step/.../implement-solution-step.ts Added FeatureFlagsService dependency and new computed property canSeeLanguageGuideBeforeSolution.
app/services/feature-flags.ts Introduced new getter method canSeeLanguageGuideBeforeSolutionForStage2 to check feature flag and user role.

Sequence Diagram

sequenceDiagram
    participant User
    participant Component
    participant FeatureFlagsService
    
    User->>Component: Loads tutorial stage
    Component->>FeatureFlagsService: Check language guide visibility
    FeatureFlagsService-->>Component: Return visibility status
    alt Language guide can be shown
        Component->>User: Display Language Guide
    end
    alt Solution is available
        Component->>User: Display Solution with Blurred Overlay
    end
Loading

Possibly related PRs

Poem

🐰 A rabbit's tale of code so bright,
Feature flags dancing left and right,
Solutions blurred, then clear as day,
Guides that show the learning way,
Complexity tamed with magical might! 🔧


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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

github-actions bot commented Jan 22, 2025

Test Results

  1 files  ±0    1 suites  ±0   6m 7s ⏱️ +5s
595 tests ±0  554 ✅ ±0  41 💤 ±0  0 ❌ ±0 
610 runs  ±0  569 ✅ ±0  41 💤 ±0  0 ❌ ±0 

Results for commit ae4202a. ± Comparison against base commit 144db8d.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files

📢 Thoughts on this report? Let us know!

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a4b3bac and 00bd72e.

📒 Files selected for processing (3)
  • app/components/course-page/course-stage-step/second-stage-tutorial-card/implement-solution-step.hbs (1 hunks)
  • app/components/course-page/course-stage-step/second-stage-tutorial-card/implement-solution-step.ts (2 hunks)
  • app/services/feature-flags.ts (1 hunks)
🔇 Additional comments (4)
app/components/course-page/course-stage-step/second-stage-tutorial-card/implement-solution-step.ts (2)

5-5: LGTM! Service injection follows standard patterns.

The import and service injection are implemented correctly following Ember.js conventions.

Also applies to: 7-7, 22-22


25-27: Add tests for the new feature flag functionality.

The new computed property canSeeLanguageGuideBeforeSolution lacks test coverage. Since this controls a key feature of showing/hiding the language guide, it should be tested.

Consider adding tests for:

  • Staff user can see guide before solution
  • Non-staff user with feature flag can see guide before solution
  • Non-staff user without feature flag cannot see guide before solution
app/services/feature-flags.ts (1)

21-23: LGTM! Feature flag implementation follows established patterns.

The new getter follows the service's existing patterns and properly handles type safety.

Add tests for the new feature flag.

Please add test coverage for this new feature flag getter to ensure it behaves correctly for:

  • Staff users
  • Users with the test feature flag
  • Users without the feature flag

Verify feature flag naming convention.

The feature flag name can-see-language-guide-before-solution-for-stage-2 is quite long. Let's verify if it follows the project's naming convention.

✅ Verification successful

Feature flag name follows established convention

The feature flag name can-see-language-guide-before-solution-for-stage-2 perfectly matches the existing pattern used in the codebase, following the same structure as can-see-split-up-git-commands-for-stage-1.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other feature flag names to compare naming patterns
rg "getFeatureFlagValue\(['\"].*['\"]\)" --type ts

Length of output: 387

app/components/course-page/course-stage-step/second-stage-tutorial-card/implement-solution-step.hbs (1)

14-28: LGTM! Clear conditional structure for language guide.

The template logic for displaying the language guide is clear and well-structured.

@andy1li andy1li force-pushed the stage-2-experiments branch from 6dee3bd to ae4202a Compare January 22, 2025 15:50
@andy1li andy1li enabled auto-merge January 22, 2025 15:52
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

♻️ Duplicate comments (1)
app/components/course-page/course-stage-step/second-stage-tutorial-card/implement-solution-step.hbs (1)

25-132: 🛠️ Refactor suggestion

Extract duplicated solution display logic into a separate component.

The significant code duplication between the two solution display blocks should be eliminated as previously suggested.

🧹 Nitpick comments (1)
app/components/course-page/course-stage-step/second-stage-tutorial-card/implement-solution-step.hbs (1)

34-44: Improve TypeScript type narrowing for solution property.

The extra if this.solution check is a workaround for TypeScript type narrowing. Consider a more elegant solution:

  1. Use a computed property to handle the type narrowing:
get changedFilesWithSolution() {
  return this.solution?.changedFiles ?? [];
}
  1. Update the template:
-{{#each this.solution.changedFiles as |changedFile|}}
-  {{! Extra if condition convinces typescript that solution isn't null }}
-  {{#if this.solution}}
+{{#each this.changedFilesWithSolution as |changedFile|}}
    <FileDiffCard
      @filename={{changedFile.filename}}
      @code={{changedFile.diff}}
      @language={{this.solution.language.slug}}
      data-test-file-diff-card
    />
-  {{/if}}
{{/each}}

Also applies to: 83-93

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6dee3bd and ae4202a.

📒 Files selected for processing (1)
  • app/components/course-page/course-stage-step/second-stage-tutorial-card/implement-solution-step.hbs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (1)
app/components/course-page/course-stage-step/second-stage-tutorial-card/implement-solution-step.hbs (1)

14-23: LGTM! Clean implementation of the language guide section.

The markup is well-structured and follows the project's conventions with proper test attributes.

Comment on lines +69 to +70
<button class="absolute inset-0" type="button" {{on "click" this.handleRevealSolutionButtonClick}} data-test-solution-blurred-overlay>
</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve accessibility of the solution reveal button.

The button element lacks proper accessibility attributes:

  • Missing aria-label
  • Missing role attribute
  • Empty button content

Apply this diff to improve accessibility:

-<button class="absolute inset-0" type="button" {{on "click" this.handleRevealSolutionButtonClick}} data-test-solution-blurred-overlay>
+<button 
+  class="absolute inset-0" 
+  type="button" 
+  aria-label="Reveal solution"
+  role="button"
+  {{on "click" this.handleRevealSolutionButtonClick}} 
+  data-test-solution-blurred-overlay
+>
+  <span class="sr-only">Reveal solution</span>
</button>

Also applies to: 128-129

@andy1li andy1li merged commit 25ce92d into main Jan 22, 2025
4 of 5 checks passed
@andy1li andy1li deleted the stage-2-experiments branch January 22, 2025 15:53
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.

2 participants