From 33de9f3a7a283558e1843f51fa038e62009104b6 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 11 Jul 2023 21:54:36 +0100 Subject: [PATCH] Feature: Moving project solutions to Hotwire final tweaks Because: * A few final touches before we start rolling this out to users. This commit: * Move the add solution button hook outside of the current users solution conditional - this is needed for the button to display correctly when the user deletes their solution after refreshing the page. * Change "Add submission" button text to "Add solution" - to fit the solutions title. * Add a hidden class to the drop down so it does not flash visible for a brief moment during re-render --- .../project_submissions/item_component.html.erb | 2 +- .../lessons/v2_project_submissions/_add_button.html.erb | 2 +- app/views/lessons/v2_project_submissions/_form.html.erb | 4 ++-- app/views/lessons/v2_project_submissions/index.html.erb | 9 +++++---- .../v2_lesson_project_submissions/add_submission_spec.rb | 2 +- .../delete_submission_spec.rb | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/components/project_submissions/item_component.html.erb b/app/components/project_submissions/item_component.html.erb index a3ff6d2f9d..0f743e737a 100644 --- a/app/components/project_submissions/item_component.html.erb +++ b/app/components/project_submissions/item_component.html.erb @@ -24,7 +24,7 @@ data-transition-leave="transition ease-in duration-75" data-transition-leave-start="transform opacity-100 scale-100" data-transition-leave-end="transform opacity-10 scale-95" - class="absolute right-0 z-10 mt-2 w-32 origin-top-right rounded-md bg-white dark:bg-gray-700 py-2 shadow-lg ring-1 ring-gray-900/5 dark:ring-gray-300/5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="options-menu-0-button" tabindex="-1"> + class="hidden absolute right-0 z-10 mt-2 w-32 origin-top-right rounded-md bg-white dark:bg-gray-700 py-2 shadow-lg ring-1 ring-gray-900/5 dark:ring-gray-300/5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="options-menu-0-button" tabindex="-1"> <% if project_submission.user == current_user %> <%= link_to edit_lesson_v2_project_submission_path(project_submission.lesson, project_submission), class: 'text-gray-700 dark:text-gray-300 group flex items-center px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-600 hover:text-gray-900 dark:hover:text-gray-200', role: 'menuitem', tabindex: '-1', data: { turbo_frame: 'modal', test_id: 'edit-submission', action: 'click->visibility#off'} do %> diff --git a/app/views/lessons/v2_project_submissions/_add_button.html.erb b/app/views/lessons/v2_project_submissions/_add_button.html.erb index c7d173b900..3fd9e8b82a 100644 --- a/app/views/lessons/v2_project_submissions/_add_button.html.erb +++ b/app/views/lessons/v2_project_submissions/_add_button.html.erb @@ -1,3 +1,3 @@ <%= link_to new_lesson_v2_project_submission_path(@lesson), class: 'button button--primary', data: { turbo_frame: 'modal', test_id: 'add_submission_btn' } do %> - Add submission + Add solution <% end %> diff --git a/app/views/lessons/v2_project_submissions/_form.html.erb b/app/views/lessons/v2_project_submissions/_form.html.erb index 9afc48d7a3..9ba6537784 100644 --- a/app/views/lessons/v2_project_submissions/_form.html.erb +++ b/app/views/lessons/v2_project_submissions/_form.html.erb @@ -25,7 +25,7 @@
<%= form.label :is_public_true, 'Public to other learners', class: 'dark:text-gray-200' %> -

Anyone can see this project in the submissions list.

+

Anyone can see this project in the solutions list.

@@ -35,7 +35,7 @@
<%= form.label :is_public_false, 'Private to you' %> -

Only you can see this project in the submissions list.

+

Only you can see this project in the solutions list.

diff --git a/app/views/lessons/v2_project_submissions/index.html.erb b/app/views/lessons/v2_project_submissions/index.html.erb index 042c0b8609..ee12d2904c 100644 --- a/app/views/lessons/v2_project_submissions/index.html.erb +++ b/app/views/lessons/v2_project_submissions/index.html.erb @@ -18,11 +18,12 @@ <%= @lesson.course.title %> : (<%= @lesson.title %>) - <% if @current_user_submission.nil? %> -
+ +
+ <% if @current_user_submission.nil? %> <%= render 'lessons/v2_project_submissions/add_button', lesson: @lesson %> -
- <% end %> + <% end %> +
<%= turbo_frame_tag 'submissions-list', data: { test_id: 'submissions-list', controller: 'sort' } do %> diff --git a/spec/system/v2_lesson_project_submissions/add_submission_spec.rb b/spec/system/v2_lesson_project_submissions/add_submission_spec.rb index e519ac3ab2..6c4b212948 100644 --- a/spec/system/v2_lesson_project_submissions/add_submission_spec.rb +++ b/spec/system/v2_lesson_project_submissions/add_submission_spec.rb @@ -41,7 +41,7 @@ expect(page).to have_content(user.username) end - expect(page).not_to have_content('Add submission') + expect(page).not_to have_content('Add solution') using_session('another_user') do sign_in(another_user) diff --git a/spec/system/v2_lesson_project_submissions/delete_submission_spec.rb b/spec/system/v2_lesson_project_submissions/delete_submission_spec.rb index cda5a00004..a6aca82b29 100644 --- a/spec/system/v2_lesson_project_submissions/delete_submission_spec.rb +++ b/spec/system/v2_lesson_project_submissions/delete_submission_spec.rb @@ -31,7 +31,7 @@ end end - expect(page).to have_content('Add submission') + expect(page).to have_content('Add solution') within(:test_id, 'submissions-list') do expect(page).not_to have_content(user.username)