From f697edfa101db0b5beba88076dd755f5811249a6 Mon Sep 17 00:00:00 2001 From: Jeremy Walker Date: Tue, 1 Oct 2024 08:49:52 +0100 Subject: [PATCH] Post merge tweaks (#7081) * Start work on begging modal * Add modal, adjust things, add props (#7080) * Add modal, adjust things, add props * Add success modal * Progress further * Add success + cancel flow * Change success button close flow * Fix path and improve tests --------- Co-authored-by: Jeremy Walker * A few minor post-merge tweaks * Remove default export of DonationStep * Remove duplicate from dashboard, add modal to track-show * Fix `mentor_finished_discussion_test` --------- Co-authored-by: Aron Demeter <66035744+dem4ron@users.noreply.github.com> Co-authored-by: dem4ron --- app/helpers/react_components/modals/beg_modal.rb | 11 +++++------ .../finish-mentor-discussion-modal/DonationStep.tsx | 2 -- app/views/dashboard/show.html.haml | 3 +-- app/views/tracks/show.html.haml | 2 ++ .../flows/student/mentor_finished_discussion_test.rb | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/helpers/react_components/modals/beg_modal.rb b/app/helpers/react_components/modals/beg_modal.rb index e09db01d80..3e455c9051 100644 --- a/app/helpers/react_components/modals/beg_modal.rb +++ b/app/helpers/react_components/modals/beg_modal.rb @@ -15,18 +15,19 @@ def to_s links: { settings: Exercism::Routes.donations_settings_url, success: Exercism::Routes.dashboard_url, - hide_introducer: Exercism::Routes.hide_api_settings_introducer_path(slug) + hide_introducer: Exercism::Routes.hide_api_settings_introducer_path(INTRODUCER_SLUG) } }) end + private memoize def show_modal? return false if current_user.current_subscription return false if current_user.donated_in_last_35_days? return false unless current_user.solutions.count >= 5 - dismissal = current_user.dismissed_introducers.find_by(slug:) + dismissal = current_user.dismissed_introducers.find_by(slug: INTRODUCER_SLUG) return true unless dismissal if dismissal.created_at < 1.month.ago @@ -40,10 +41,8 @@ def show_modal? memoize def previous_donor = current_user.total_donated_in_dollars.positive? - private - def slug - "beg-modal" - end + INTRODUCER_SLUG = "beg-modal".freeze + private_constant :INTRODUCER_SLUG end end end diff --git a/app/javascript/components/modals/student/finish-mentor-discussion-modal/DonationStep.tsx b/app/javascript/components/modals/student/finish-mentor-discussion-modal/DonationStep.tsx index e259c188c9..85de359b8d 100644 --- a/app/javascript/components/modals/student/finish-mentor-discussion-modal/DonationStep.tsx +++ b/app/javascript/components/modals/student/finish-mentor-discussion-modal/DonationStep.tsx @@ -94,5 +94,3 @@ export function DonationStep({ ) } - -export default DonationStep diff --git a/app/views/dashboard/show.html.haml b/app/views/dashboard/show.html.haml index 4d7b2343e5..983d51bb24 100644 --- a/app/views/dashboard/show.html.haml +++ b/app/views/dashboard/show.html.haml @@ -1,9 +1,8 @@ - require_stylesheet "track" -= render ReactComponents::Modals::BegModal.new - #page-dashboard = render ReactComponents::Modals::WelcomeModal.new + = render ReactComponents::Modals::BegModal.new .summary-bar .lg-container.container diff --git a/app/views/tracks/show.html.haml b/app/views/tracks/show.html.haml index 4e00d670fe..e24d7f7ce4 100644 --- a/app/views/tracks/show.html.haml +++ b/app/views/tracks/show.html.haml @@ -4,6 +4,8 @@ #page-track-show = render ViewComponents::Track::Header.new(@track, :overview) = render ReactComponents::Modals::TrackWelcomeModal.new(@track) + = render ReactComponents::Modals::BegModal.new + = render "tracks/show/summary_article", track: @track, user_track: @user_track, exercise_statuses: @exercise_statuses, recent_solutions: @recent_solutions, sample_learnt_concepts: @sample_learnt_concepts, sample_mastered_concepts: @sample_mastered_concepts, last_8_weeks_counts: @last_8_weeks_counts, forum_threads: @forum_threads, docs: @docs = render "tracks/show/mentoring_article", track: @track, user_track: @user_track = render "tracks/show/updates_article", track: @track, updates: @updates diff --git a/test/system/flows/student/mentor_finished_discussion_test.rb b/test/system/flows/student/mentor_finished_discussion_test.rb index 5f281ceaf3..ad709a605a 100644 --- a/test/system/flows/student/mentor_finished_discussion_test.rb +++ b/test/system/flows/student/mentor_finished_discussion_test.rb @@ -47,8 +47,8 @@ class MentorFinishedDiscussionTest < ApplicationSystemTestCase assert_css ".m-confirm-finish-student-mentor-discussion" within(".m-confirm-finish-student-mentor-discussion") { click_on "Review and end discussion" } click_on "It was good!" - fill_in "Leave #{discussion.mentor.handle} a testimonial (optional)", - with: "I am very satisfied with this mentor. He was amazing." + find("#testimonial").set("I am very satisfied with this mentor. He was amazing.") + click_on "Finish" click_on "Continue without donating"