-
Notifications
You must be signed in to change notification settings - Fork 18
Design preview for code example voting #2810
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
base: main
Are you sure you want to change the base?
Conversation
""" WalkthroughA feedback feature was introduced to the community solution card within the course page. The upvote and downvote buttons, previously located in the card header, have been removed from there and a new feedback section component has been added at the bottom of the card. This feedback section provides interactive upvote and downvote buttons, visually reflects user actions, and displays a temporary thank-you message upon voting. The new component handles vote state and UI transitions internally, utilizing tracked properties and animated feedback. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CommunitySolutionCard
participant FeedbackSection
User->>CommunitySolutionCard: Views solution card
CommunitySolutionCard->>FeedbackSection: Renders feedback section
User->>FeedbackSection: Clicks "Helpful" or "Not helpful"
FeedbackSection->>FeedbackSection: Updates vote state
FeedbackSection->>FeedbackSection: Shows "Thanks for your feedback!" (1.5s)
FeedbackSection-->>User: Visual feedback (button highlight, message)
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
eb19b4a
to
8a5f787
Compare
Test Results 1 files ±0 1 suites ±0 8m 19s ⏱️ -58s For more details on these errors, see this check. Results for commit c4f2f92. ± Comparison against base commit c9b1151. ♻️ This comment has been updated with latest results. |
❌ 3 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Bundle ReportChanges will increase total bundle size by 1.12kB (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: client-array-pushAssets Changed:
|
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: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
app/components/course-page/course-stage-step/community-solution-card/content.hbs
(1 hunks)app/components/course-page/course-stage-step/community-solution-card/feedback-section.hbs
(1 hunks)app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts
(1 hunks)app/components/course-page/course-stage-step/community-solution-card/header.hbs
(1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts
[warning] 23-24: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L23-L24
Added lines #L23 - L24 were not covered by tests
[warning] 26-26: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L26
Added line #L26 was not covered by tests
[warning] 29-31: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L29-L31
Added lines #L29 - L31 were not covered by tests
[warning] 38-39: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L38-L39
Added lines #L38 - L39 were not covered by tests
[warning] 41-41: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L41
Added line #L41 was not covered by tests
[warning] 44-46: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L44-L46
Added lines #L44 - L46 were not covered by tests
[warning] 50-52: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L50-L52
Added lines #L50 - L52 were not covered by tests
🔇 Additional comments (1)
app/components/course-page/course-stage-step/community-solution-card/feedback-section.hbs (1)
1-42
: Feedback section UI looks goodThe UI implementation for the feedback section is well designed with appropriate animations and visual state changes for different voting conditions.
{{/each}} | ||
|
||
<CoursePage::CourseStageStep::CommunitySolutionCard::FeedbackSection class="pt-6 pb-3" /> |
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.
🛠️ Refactor suggestion
The feedback section component is missing solution data
The feedback section component is added correctly, but it doesn't receive any data about the current solution. For the design preview this might be intentional, but for actual functionality, it should receive the solution data to record votes.
-<CoursePage::CourseStageStep::CommunitySolutionCard::FeedbackSection class="pt-6 pb-3" />
+<CoursePage::CourseStageStep::CommunitySolutionCard::FeedbackSection
+ @solution={{@solution}}
+ @metadata={{@metadataForUpvote}}
+ class="pt-6 pb-3"
+/>
📝 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.
<CoursePage::CourseStageStep::CommunitySolutionCard::FeedbackSection class="pt-6 pb-3" /> | |
<CoursePage::CourseStageStep::CommunitySolutionCard::FeedbackSection | |
@solution={{@solution}} | |
@metadata={{@metadataForUpvote}} | |
class="pt-6 pb-3" | |
/> |
{{! Remove, replace with buttons at the bottom of the card }} | ||
{{!-- {{#unless (eq @solution.user this.authenticator.currentUser)}} | ||
<CoursePage::CourseStageStep::CommunitySolutionCard::UpvoteButton @solution={{@solution}} @metadata={{@metadataForUpvote}} class="mr-2" /> | ||
<CoursePage::CourseStageStep::CommunitySolutionCard::DownvoteButton @solution={{@solution}} @metadata={{@metadataForDownvote}} /> | ||
<div class="w-px h-3 bg-gray-200 dark:bg-white/5 mx-2"></div> | ||
{{/unless}} | ||
{{/unless}} --}} |
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.
Missing user restriction in new feedback component
The commented-out code shows the previous implementation had a condition to only show vote buttons if the solution wasn't created by the current user. This same logic should be applied to the new feedback section component to maintain consistent behavior.
This restriction logic should either be:
- Implemented in the feedback-section component itself (by passing the current user)
- Added as a condition when rendering the component in content.hbs
// In content.hbs:
+{{#unless (eq @solution.user this.authenticator.currentUser)}}
<CoursePage::CourseStageStep::CommunitySolutionCard::FeedbackSection @solution={{@solution}} class="pt-6 pb-3" />
+{{/unless}}
📝 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.
{{! Remove, replace with buttons at the bottom of the card }} | |
{{!-- {{#unless (eq @solution.user this.authenticator.currentUser)}} | |
<CoursePage::CourseStageStep::CommunitySolutionCard::UpvoteButton @solution={{@solution}} @metadata={{@metadataForUpvote}} class="mr-2" /> | |
<CoursePage::CourseStageStep::CommunitySolutionCard::DownvoteButton @solution={{@solution}} @metadata={{@metadataForDownvote}} /> | |
<div class="w-px h-3 bg-gray-200 dark:bg-white/5 mx-2"></div> | |
{{/unless}} | |
{{/unless}} --}} | |
{{!-- Only show feedback section if the solution wasn't created by the current user --}} | |
{{#unless (eq @solution.user this.authenticator.currentUser)}} | |
<CoursePage::CourseStageStep::CommunitySolutionCard::FeedbackSection | |
@solution={{@solution}} | |
class="pt-6 pb-3" | |
/> | |
{{/unless}} |
export default class CommunitySolutionCardFeedbackSectionComponent extends Component<Signature> { | ||
transition = fade; | ||
|
||
@tracked tempHasVotedRecently = false; | ||
@tracked tempHasUpvoted = false; | ||
@tracked tempHasDownvoted = false; | ||
|
||
@action | ||
handleDownvoteButtonClick() { | ||
// No feedback if the user is "reversing" their vote | ||
if (this.tempHasDownvoted) { | ||
this.tempHasDownvoted = false; | ||
this.tempHasVotedRecently = false; | ||
|
||
return; | ||
} | ||
|
||
this.flashSuccessMessageTask.perform(); | ||
this.tempHasUpvoted = false; | ||
this.tempHasDownvoted = true; | ||
} | ||
|
||
@action | ||
handleUpvoteButtonClick() { | ||
// No feedback if the user is "reversing" their vote | ||
if (this.tempHasUpvoted) { | ||
this.tempHasUpvoted = false; | ||
this.tempHasVotedRecently = false; | ||
|
||
return; | ||
} | ||
|
||
this.flashSuccessMessageTask.perform(); | ||
this.tempHasDownvoted = false; | ||
this.tempHasUpvoted = true; | ||
} | ||
|
||
flashSuccessMessageTask = task({ keepLatest: true }, async () => { | ||
this.tempHasVotedRecently = true; | ||
await timeout(1500); | ||
this.tempHasVotedRecently = false; | ||
}); | ||
} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
'CoursePage::CourseStageStep::CommunitySolutionCard::FeedbackSection': typeof CommunitySolutionCardFeedbackSectionComponent; | ||
} | ||
} |
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.
🛠️ Refactor suggestion
Missing actual vote persistence functionality
The component currently only manages temporary visual state (note the temp
prefixes in variable names) but doesn't persist votes or make API calls. For a design preview this is fine, but for production functionality, it should:
- Accept @Solution as an argument to know which solution is being voted on
- Make API calls to record votes
- Handle loading and error states
Here's a suggested enhancement to the component interface:
interface Signature {
Element: HTMLDivElement;
+ Args: {
+ solution: SolutionModel;
+ metadata?: Record<string, unknown>;
+ };
}
Additionally, implement actual API calls in the handlers:
@action
async handleUpvoteButtonClick() {
// Existing logic for UI state...
try {
await this.args.solution.upvote(this.args.metadata);
// Success handling
} catch (error) {
// Error handling
this.tempHasUpvoted = false;
this.tempHasVotedRecently = false;
}
}
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 23-24: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L23-L24
Added lines #L23 - L24 were not covered by tests
[warning] 26-26: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L26
Added line #L26 was not covered by tests
[warning] 29-31: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L29-L31
Added lines #L29 - L31 were not covered by tests
[warning] 38-39: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L38-L39
Added lines #L38 - L39 were not covered by tests
[warning] 41-41: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L41
Added line #L41 was not covered by tests
[warning] 44-46: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L44-L46
Added lines #L44 - L46 were not covered by tests
[warning] 50-52: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L50-L52
Added lines #L50 - L52 were not covered by tests
@tracked tempHasVotedRecently = false; | ||
@tracked tempHasUpvoted = false; | ||
@tracked tempHasDownvoted = false; | ||
|
||
@action | ||
handleDownvoteButtonClick() { | ||
// No feedback if the user is "reversing" their vote | ||
if (this.tempHasDownvoted) { | ||
this.tempHasDownvoted = false; | ||
this.tempHasVotedRecently = false; | ||
|
||
return; | ||
} | ||
|
||
this.flashSuccessMessageTask.perform(); | ||
this.tempHasUpvoted = false; | ||
this.tempHasDownvoted = true; | ||
} | ||
|
||
@action | ||
handleUpvoteButtonClick() { | ||
// No feedback if the user is "reversing" their vote | ||
if (this.tempHasUpvoted) { | ||
this.tempHasUpvoted = false; | ||
this.tempHasVotedRecently = false; | ||
|
||
return; | ||
} | ||
|
||
this.flashSuccessMessageTask.perform(); | ||
this.tempHasDownvoted = false; | ||
this.tempHasUpvoted = true; | ||
} | ||
|
||
flashSuccessMessageTask = task({ keepLatest: true }, async () => { | ||
this.tempHasVotedRecently = true; | ||
await timeout(1500); | ||
this.tempHasVotedRecently = false; | ||
}); |
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.
💡 Verification agent
🧩 Analysis chain
Missing test coverage for component logic
The static analysis indicates that much of the component logic is not covered by tests. Consider adding tests for:
- The upvote/downvote toggle functionality
- The success message flash behavior
- Edge cases like multiple rapid clicks
You can verify the current test coverage with:
🏁 Script executed:
#!/bin/bash
# Check current test coverage for feedback-section component
find tests -type f -name "*feedback-section*" -o -name "*community-solution*" | xargs cat
Length of output: 16787
Add targeted tests for flash message and rapid-click behavior
While the existing acceptance tests cover the basic upvote/downvote toggling via UI, we still need to add focused tests for the component’s internal logic:
• Test the flashSuccessMessageTask
in isolation
– Verify that tempHasVotedRecently
flips to true
, then back to false
after the 1.5 s timeout (e.g. using await settled()
or ember-concurrency’s test helpers).
• Test rapid‐click edge cases
– Ensure that clicking upvote/downvote multiple times in quick succession doesn’t trigger extra flashes or leave the component in an inconsistent state.
• (If not already covered) Add a small unit/integration test for the toggle logic directly on the component, asserting initial state and flip behavior of tempHasUpvoted
/tempHasDownvoted
.
You can place these in a new integration test under:
tests/integration/components/course-page/course-stage-step/community-solution-card/feedback-section-test.js
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 23-24: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L23-L24
Added lines #L23 - L24 were not covered by tests
[warning] 26-26: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L26
Added line #L26 was not covered by tests
[warning] 29-31: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L29-L31
Added lines #L29 - L31 were not covered by tests
[warning] 38-39: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L38-L39
Added lines #L38 - L39 were not covered by tests
[warning] 41-41: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L41
Added line #L41 was not covered by tests
[warning] 44-46: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L44-L46
Added lines #L44 - L46 were not covered by tests
[warning] 50-52: app/components/course-page/course-stage-step/community-solution-card/feedback-section.ts#L50-L52
Added lines #L50 - L52 were not covered by tests
45399f4
to
1fd42e4
Compare
refactor(feedback): increase animation duration for voting feedback fix: improve feedback section text clarity and consistency feat: add tooltips to feedback buttons for clarity feat(tooltip): add delay to tooltips for improved usability
1fd42e4
to
c4f2f92
Compare
Summary by CodeRabbit