diff --git a/lib/oli_web/components/common.ex b/lib/oli_web/components/common.ex index b538e32496a..680d071a520 100644 --- a/lib/oli_web/components/common.ex +++ b/lib/oli_web/components/common.ex @@ -1063,4 +1063,30 @@ defmodule OliWeb.Components.Common do """ end + + attr :on_toggle, :string, required: true + attr :label, :string, default: nil + attr :name, :string, default: nil + attr :checked, :boolean, default: false + attr :phx_target, :any, default: nil + attr :rest, :global, include: ~w(class disabled role) + + def toggle_switch(assigns) do + ~H""" +
+
+ +
+
+ """ + end end diff --git a/lib/oli_web/live/collaboration_live/collab_space_config_view.ex b/lib/oli_web/live/collaboration_live/collab_space_config_view.ex index abd1a35492c..f91c12b8909 100644 --- a/lib/oli_web/live/collaboration_live/collab_space_config_view.ex +++ b/lib/oli_web/live/collaboration_live/collab_space_config_view.ex @@ -1,4 +1,5 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do + alias Oli.Rendering.Group use OliWeb, :live_view alias Oli.Authoring.Course @@ -9,6 +10,7 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do alias Oli.Resources.Collaboration.CollabSpaceConfig alias Oli.Delivery.Sections.SectionResource alias OliWeb.CollaborationLive.CollabSpaceView + alias OliWeb.Common.Properties.{Group} alias Phoenix.PubSub alias OliWeb.Components.Modal alias Phoenix.LiveView.JS @@ -79,7 +81,134 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do )} end + def render(%{is_overview_render: true} = assigns) do + ~H""" + <.notes_modals form={@form} /> + + +
+
+ Enable Notes for all pages in the course + <.toggle_switch + class="ml-4" + role="collab_space_toggle_all_pages" + checked={@collab_space_pages_count > 0} + on_toggle={ + if @collab_space_pages_count > 0 do + Modal.show_modal("disable_collab_space_modal") + else + Modal.show_modal("enable_collab_space_modal") + end + } + /> +
+
+ <%= ~s{#{if @pages_count == @collab_space_pages_count, do: "All"} #{@collab_space_pages_count} #{Gettext.ngettext(OliWeb.Gettext, "page currently has", "pages currently have", @collab_space_pages_count)}} %> Notes enabled. +
+
+
+ +
+
+ Enable Course Discussions + <.toggle_switch + class="ml-4" + checked={@collab_space_status == :enabled} + on_toggle="toggle_discussions" + /> +
+ + <.form id="collab_space_config_form" class="w-full" for={@form} phx-change="save"> + <.inputs_for :let={cs} field={@form[:collab_space_config]}> + <.input type="hidden" field={cs[:status]} /> + + <.input type="hidden" field={cs[:threaded]} /> + <.input type="hidden" field={cs[:show_full_history]} /> + <.input type="hidden" field={cs[:participation_min_replies]} value={0} /> + <.input type="hidden" field={cs[:participation_min_posts]} value={0} /> + + <.input + type="checkbox" + field={cs[:auto_accept]} + class="disabled:bg-primary-200 disabled:hover:bg-primary-200 dark:disabled:bg-primary-800 dark:disabled:hover:bg-primary-800" + label="Allow posts to be visible without approval" + disabled={@collab_space_status == :disabled} + /> + <.input + type="checkbox" + field={cs[:anonymous_posting]} + class="disabled:bg-primary-200 disabled:hover:bg-primary-200 dark:disabled:bg-primary-800 dark:disabled:hover:bg-primary-800" + label="Allow anonymous posts" + disabled={@collab_space_status == :disabled} + /> + + +
+
+ """ + end + + # page-level notes configuration def render(assigns) do + ~H""" + <.notes_modals form={@form} /> + +
+
+
+ <%= unless @is_overview_render do %> +

Notes

+ <% end %> +
+ + <%= humanize(@collab_space_status) %> + +
+
+ +
+ <.action_buttons status={@collab_space_status} /> +
+
+ <%= if @collab_space_status == :enabled do %> + + <% end %> +
+ """ + end + + attr(:status, :atom) + + def action_buttons(%{status: :disabled} = assigns) do + ~H""" + + """ + end + + def action_buttons(%{status: :enabled} = assigns) do + ~H""" + + + """ + end + + def action_buttons(assigns) do + ~H""" + + + """ + end + + attr :form, :map, required: true + + def notes_modals(assigns) do ~H""" Are you sure you want to enable - collaboration spaces for all pages in the course? + Notes for all pages in the course?
The following configuration will be bulk-applied to all pages: <.form class="w-full" for={@form} phx-submit="enable_all_page_collab_spaces"> <.collab_space_form_content form={@form} /> @@ -109,88 +238,10 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do } > Are you sure you want to disable - collaboration spaces for all pages in the course? + Notes for all pages in the course? <:confirm>OK <:cancel>Cancel
- -
-
-
Student Course Portal Collaborative Space
-
-
- <%= unless @is_overview_render do %> -

Collaborative Space Config

- <% end %> -
- - <%= humanize(@collab_space_status) %> - -
-
- -
- <.action_buttons status={@collab_space_status} /> -
-
- <%= if @collab_space_status == :enabled do %> - - <% end %> -
- -
-
- <%= ~s{#{if @pages_count == @collab_space_pages_count, do: "All"} #{@collab_space_pages_count} #{Gettext.ngettext(OliWeb.Gettext, "page currently has", "pages currently have", @collab_space_pages_count)}} %> Collaborative Spaces enabled -
- - -
-
- """ - end - - attr(:status, :atom) - - def action_buttons(%{status: :disabled} = assigns) do - ~H""" - - """ - end - - def action_buttons(%{status: :enabled} = assigns) do - ~H""" - - - """ - end - - def action_buttons(assigns) do - ~H""" - - """ end @@ -201,14 +252,10 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do <.inputs_for :let={cs} field={@form[:collab_space_config]}> <.input type="hidden" field={cs[:status]} /> -
- <.input - type="checkbox" - field={cs[:threaded]} - class="form-check-input" - label="Allow threading of posts with replies" - /> -
+ <.input type="hidden" field={cs[:threaded]} /> + <.input type="hidden" field={cs[:show_full_history]} /> + <.input type="hidden" field={cs[:participation_min_replies]} value={0} /> + <.input type="hidden" field={cs[:participation_min_posts]} value={0} />
<.input @@ -219,15 +266,6 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do />
-
- <.input - type="checkbox" - field={cs[:show_full_history]} - class="form-check-input" - label="Show full history" - /> -
-
<.input type="checkbox" @@ -236,29 +274,6 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do label="Allow anonymous posts" />
- -
Participation requirements -
-
- <.input - type="number" - min={0} - field={cs[:participation_min_replies]} - class="form-control" - label="Minimum replies" - /> -
- -
- <.input - type="number" - min={0} - field={cs[:participation_min_posts]} - class="form-control" - label="Minimum posts" - /> -
-
""" end @@ -298,6 +313,26 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do ) end + def handle_event("toggle_discussions", _params, socket) do + case socket.assigns.collab_space_status == :enabled do + true -> + upsert_collab_space( + socket.assigns.is_delivery, + "disabled", + Map.merge(from_struct(socket.assigns.collab_space_config), %{status: :disabled}), + socket + ) + + false -> + upsert_collab_space( + socket.assigns.is_delivery, + "enabled", + Map.merge(from_struct(socket.assigns.collab_space_config), %{status: :enabled}), + socket + ) + end + end + def handle_event("disable_all_page_collab_spaces", _params, socket) do if socket.assigns.is_delivery do Collaboration.disable_all_page_collab_spaces_for_section(socket.assigns.slug) @@ -380,7 +415,7 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do {:ok, section_resource} -> set_contains_discussions(section, section_resource) - socket = put_flash(socket, :info, "Collaborative space successfully #{action}.") + socket = put_flash(socket, :info, "Notes successfully #{action}.") collab_space_config = section_resource.collab_space_config PubSub.broadcast( @@ -398,7 +433,7 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do )} {:error, _} -> - socket = put_flash(socket, :error, "Collaborative space couldn't be #{action}.") + socket = put_flash(socket, :error, "Notes couldn't be #{action}.") {:noreply, socket} end end @@ -419,7 +454,7 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do page_resource: _page_resource, next_page_revision: next_page_revision }} -> - socket = put_flash(socket, :info, "Collaborative space successfully #{action}.") + socket = put_flash(socket, :info, "Notes successfully #{action}.") collab_space_config = next_page_revision.collab_space_config {:noreply, @@ -431,7 +466,7 @@ defmodule OliWeb.CollaborationLive.CollabSpaceConfigView do )} {:error, _} -> - socket = put_flash(socket, :error, "Collaborative space couldn't be #{action}.") + socket = put_flash(socket, :error, "Notes couldn't be #{action}.") {:noreply, socket} end end diff --git a/lib/oli_web/live/delivery/student/lesson/annotations.ex b/lib/oli_web/live/delivery/student/lesson/annotations.ex index 3c2d8498e57..4e7f2aab72b 100644 --- a/lib/oli_web/live/delivery/student/lesson/annotations.ex +++ b/lib/oli_web/live/delivery/student/lesson/annotations.ex @@ -8,6 +8,7 @@ defmodule OliWeb.Delivery.Student.Lesson.Annotations do alias OliWeb.Components.Modal attr :section_slug, :string, required: true + attr :collab_space_config, :map, required: true attr :create_new_annotation, :boolean, default: false attr :annotations, :any, required: true attr :current_user, Oli.Accounts.User, required: true @@ -44,6 +45,7 @@ defmodule OliWeb.Delivery.Student.Lesson.Annotations do current_user={@current_user} create_new_annotation={@create_new_annotation} selected_point={@selected_point} + collab_space_config={@collab_space_config} /> <% _ -> %> <.search_results @@ -63,6 +65,7 @@ defmodule OliWeb.Delivery.Student.Lesson.Annotations do attr :current_user, Oli.Accounts.User, required: true attr :selected_point, :any, required: true attr :active_tab, :atom, required: true + attr :collab_space_config, :map, required: true defp annotations(assigns) do ~H""" @@ -71,7 +74,10 @@ defmodule OliWeb.Delivery.Student.Lesson.Annotations do :if={@selected_point} class="my-2" active={@create_new_annotation} - disable_anonymous_option={@active_tab == :my_notes || is_guest(@current_user)} + disable_anonymous_option={ + @active_tab == :my_notes || is_guest(@current_user) || + !@collab_space_config.anonymous_posting + } save_label={if(@active_tab == :my_notes, do: "Save", else: "Post")} placeholder={ if(@active_tab == :my_notes, do: "Add a new note...", else: "Post a new note...") @@ -88,7 +94,10 @@ defmodule OliWeb.Delivery.Student.Lesson.Annotations do <.post post={annotation} current_user={@current_user} - disable_anonymous_option={@active_tab == :my_notes || is_guest(@current_user)} + disable_anonymous_option={ + @active_tab == :my_notes || is_guest(@current_user) || + !@collab_space_config.anonymous_posting + } /> <% end %> <% end %> diff --git a/lib/oli_web/live/delivery/student/lesson_live.ex b/lib/oli_web/live/delivery/student/lesson_live.ex index 4d9f37a25de..c9df5e8850f 100644 --- a/lib/oli_web/live/delivery/student/lesson_live.ex +++ b/lib/oli_web/live/delivery/student/lesson_live.ex @@ -297,7 +297,8 @@ defmodule OliWeb.Delivery.Student.LessonLive do annotated_resource_id: page_context.page.resource_id, annotated_block_id: selected_point, annotation_type: if(selected_point, do: :point, else: :none), - anonymous: params["anonymous"] == "true", + anonymous: + page_context.collab_space_config.anonymous_posting && params["anonymous"] == "true", visibility: visibility_for_active_tab(active_tab, is_instructor), content: %Collaboration.PostContent{message: value} } @@ -489,7 +490,8 @@ defmodule OliWeb.Delivery.Student.LessonLive do annotated_resource_id: page_context.page.resource_id, annotated_block_id: selected_point, annotation_type: if(selected_point, do: :point, else: :none), - anonymous: params["anonymous"] == "true", + anonymous: + page_context.collab_space_config.anonymous_posting && params["anonymous"] == "true", visibility: visibility_for_active_tab(active_tab, is_instructor), content: %Collaboration.PostContent{message: value}, parent_post_id: parent_post_id, @@ -675,6 +677,7 @@ defmodule OliWeb.Delivery.Student.LessonLive do <:sidebar> @project.slug} ) %> - -
- <%= live_render(@socket, OliWeb.CollaborationLive.CollabSpaceConfigView, - id: "project_collab_space_config", - session: %{ - "collab_space_config" => @collab_space_config, - "project_slug" => @project.slug, - "resource_slug" => @revision_slug, - "is_overview_render" => true - } - ) %> -
-
+ <%= live_render(@socket, OliWeb.CollaborationLive.CollabSpaceConfigView, + id: "project_collab_space_config", + session: %{ + "collab_space_config" => @collab_space_config, + "project_slug" => @project.slug, + "resource_slug" => @revision_slug, + "is_overview_render" => true + } + ) %> <% end %> - -
- <%= live_render(@socket, OliWeb.CollaborationLive.CollabSpaceConfigView, - id: "collab_space_config", - session: %{ - "collab_space_config" => @collab_space_config, - "section_slug" => @section.slug, - "resource_slug" => @resource_slug, - "is_overview_render" => true, - "is_delivery" => true - } - ) %> -
-
+ + <%= live_render(@socket, OliWeb.CollaborationLive.CollabSpaceConfigView, + id: "collab_space_config", + session: %{ + "collab_space_config" => @collab_space_config, + "section_slug" => @section.slug, + "resource_slug" => @resource_slug, + "is_overview_render" => true, + "is_delivery" => true + } + ) %> + get(live_view_author_edit(project.slug, page_revision.slug)) assert html_response(conn, 200) =~ - "

Collaborative Space Config

" - end - end - - describe "user can access when is logged in as a system admin" do - setup [:admin_conn, :create_project_and_section] - - test "returns the collab space view when accessing the instructor preview page view", %{ - conn: conn, - admin: admin, - section: section, - page_revision_cs: page_revision_cs - } do - conn = - conn - |> Pow.Plug.assign_current_user(admin, OliWeb.Pow.PowHelpers.get_pow_config(:author)) - |> get(live_view_instructor_preview(section.slug, page_revision_cs.slug)) - - assert html_response(conn, 200) =~ "

Page Discussion

" + "

Notes

" end end @@ -355,11 +337,10 @@ defmodule OliWeb.CollaborationLiveTest do } ) - assert has_element?(view, "h3", "Collaborative Space Config") + assert has_element?(view, "h3", "Notes") assert has_element?(view, "span", "Disabled") assert has_element?(view, "button[phx-click=\"enable\"", "Enable") refute has_element?(view, "button[phx-click=\"archive\"", "Archived") - refute has_element?(view, "#revision_collab_space_config_threaded") view |> element("button[phx-click=\"enable\"") @@ -392,7 +373,7 @@ defmodule OliWeb.CollaborationLiveTest do } ) - assert has_element?(view, "h3", "Collaborative Space Config") + assert has_element?(view, "h3", "Notes") assert has_element?(view, "span", "Enabled") assert has_element?(view, "button[phx-click=\"disable\"", "Disable") assert has_element?(view, "button[phx-click=\"archive\"", "Archive") @@ -437,15 +418,6 @@ defmodule OliWeb.CollaborationLiveTest do } ) - assert has_element?(view, "h3", "Collaborative Space Config") - assert has_element?(view, "span", "Enabled") - - assert view - |> element( - "#collab_space_config_form #section_resource_collab_space_config_0_threaded" - ) - |> render() =~ "checked" - assert view |> element( "#collab_space_config_form #section_resource_collab_space_config_0_auto_accept" @@ -453,134 +425,10 @@ defmodule OliWeb.CollaborationLiveTest do |> render() =~ "checked" assert view - |> element( - "#collab_space_config_form #section_resource_collab_space_config_0_show_full_history" - ) - |> render() =~ "checked" - - assert view - |> element( - "#collab_space_config_form #section_resource_collab_space_config_0_anonymous_posting" - ) - |> render() =~ "checked" - - assert view - |> element( - "#collab_space_config_form #section_resource_collab_space_config_0_participation_min_replies" - ) - |> render() =~ "0" - - assert view - |> element( - "#collab_space_config_form #section_resource_collab_space_config_0_participation_min_posts" - ) - |> render() =~ "0" - end - - test "changes the collab space config attrs correctly", %{ - conn: conn, - instructor: instructor, - section: section, - page_revision_cs: page_revision_cs - } do - {:ok, view, _html} = - live_isolated( - conn, - CollabSpaceConfigView, - session: %{ - "current_user_id" => instructor.id, - "collab_space_config" => page_revision_cs.collab_space_config, - "section_slug" => section.slug, - "is_delivery" => true, - "resource_slug" => page_revision_cs.slug - } - ) - - view - |> element("form[phx-submit=\"save\"") - |> render_submit(%{ - section_resource: %{ - collab_space_config: %{ - threaded: false, - auto_accept: false, - participation_min_replies: 2, - anonymous_posting: false - } - } - }) - - refute view - |> element( - "#collab_space_config_form #section_resource_collab_space_config_0_threaded" - ) - |> render() =~ "checked" - - refute view - |> element( - "#collab_space_config_form #section_resource_collab_space_config_0_auto_accept" - ) - |> render() =~ "checked" - - refute view |> element( "#collab_space_config_form #section_resource_collab_space_config_0_anonymous_posting" ) |> render() =~ "checked" - - assert view - |> element( - "#collab_space_config_form #section_resource_collab_space_config_0_participation_min_replies" - ) - |> render() =~ "2" - - assert_receive { - :updated_collab_space_config, - %CollabSpaceConfig{ - threaded: false, - auto_accept: false, - participation_min_replies: 2 - } - } - end - - test "handles error when changes to the collab space config attrs are wrong", %{ - conn: conn, - instructor: instructor, - section: section, - page_revision_cs: page_revision_cs - } do - {:ok, view, _html} = - live_isolated( - conn, - CollabSpaceConfigView, - session: %{ - "current_user_id" => instructor.id, - "collab_space_config" => page_revision_cs.collab_space_config, - "section_slug" => section.slug, - "is_delivery" => true, - "resource_slug" => page_revision_cs.slug - } - ) - - view - |> element("form[phx-submit=\"save\"") - |> render_submit(%{ - section_resource: %{collab_space_config: %{participation_min_replies: -1}} - }) - - refute view - |> element( - "#collab_space_config_form #section_resource_collab_space_config_0_participation_min_replies" - ) - |> render() =~ "-1" - - assert view - |> element( - "#collab_space_config_form #section_resource_collab_space_config_0_participation_min_replies" - ) - |> render() =~ "0" - - refute_receive {:updated_collab_space_config, _} end test "can enable Collab spaces for all pages in course", %{ @@ -603,8 +451,8 @@ defmodule OliWeb.CollaborationLiveTest do } ) - assert element(view, "h5[role='collab_space_page_summary']") - |> render() =~ "1 page currently has Collaborative Spaces enabled" + assert element(view, "div[role='collab_space_page_summary']") + |> render() =~ "1 page currently has Notes enabled" # can not trigger a JS command from a test to show the confirmation modal (hidden to the user), # so we directly submit the form in the modal @@ -623,15 +471,8 @@ defmodule OliWeb.CollaborationLiveTest do } }) - assert element(view, "h5[role='collab_space_page_summary']") - |> render() =~ "All 2 pages currently have Collaborative Spaces enabled" - - # enable all pages button is disabled - assert has_element?( - view, - "button[disabled=disabled]", - "Enable Collaboration Spaces for all pages in the course" - ) + assert element(view, "div[role='collab_space_page_summary']") + |> render() =~ "All 2 pages currently have Notes enabled" end test "can disable Collab spaces for all pages in course", %{ @@ -654,8 +495,8 @@ defmodule OliWeb.CollaborationLiveTest do } ) - assert element(view, "h5[role='collab_space_page_summary']") - |> render() =~ "1 page currently has Collaborative Spaces enabled" + assert element(view, "div[role='collab_space_page_summary']") + |> render() =~ "1 page currently has Notes enabled" # can not trigger a JS command from a test to show the confirmation modal (hidden to the user), # so we directly confirm the modal @@ -663,15 +504,8 @@ defmodule OliWeb.CollaborationLiveTest do |> element(~s{div[id="disable_collab_space_modal"] button}, "OK") |> render_click() - assert element(view, "h5[role='collab_space_page_summary']") - |> render() =~ "0 pages currently have Collaborative Spaces enabled" - - # disable all pages button is disabled - assert has_element?( - view, - "button[disabled=disabled]", - "Disable Collaboration Spaces for all pages in the course" - ) + assert element(view, "div[role='collab_space_page_summary']") + |> render() =~ "0 pages currently have Notes enabled" end end @@ -692,7 +526,7 @@ defmodule OliWeb.CollaborationLiveTest do } ) - assert has_element?(view, "h3", "Collaborative Space Config") + assert has_element?(view, "h3", "Notes") assert has_element?(view, "span", "Disabled") assert has_element?(view, "button[phx-click=\"enable\"", "Enable") refute has_element?(view, "button[phx-click=\"archive\"", "Archived") @@ -723,7 +557,7 @@ defmodule OliWeb.CollaborationLiveTest do } ) - assert has_element?(view, "h3", "Collaborative Space Config") + assert has_element?(view, "h3", "Notes") assert has_element?(view, "span", "Enabled") assert has_element?(view, "button[phx-click=\"disable\"", "Disable") assert has_element?(view, "button[phx-click=\"archive\"", "Archive") @@ -763,133 +597,20 @@ defmodule OliWeb.CollaborationLiveTest do } ) - assert has_element?(view, "h3", "Collaborative Space Config") + assert has_element?(view, "h3", "Notes") assert has_element?(view, "span", "Enabled") - assert view - |> element("#collab_space_config_form #revision_collab_space_config_0_threaded") - |> render() =~ "checked" - assert view |> element("#collab_space_config_form #revision_collab_space_config_0_auto_accept") |> render() =~ "checked" - assert view - |> element( - "#collab_space_config_form #revision_collab_space_config_0_show_full_history" - ) - |> render() =~ - "checked" - assert view |> element( "#collab_space_config_form #revision_collab_space_config_0_anonymous_posting" ) |> render() =~ "checked" - - assert view - |> element( - "#collab_space_config_form #revision_collab_space_config_0_participation_min_replies" - ) - |> render() =~ "0" - - assert view - |> element( - "#collab_space_config_form #revision_collab_space_config_0_participation_min_posts" - ) - |> render() =~ - "0" - end - - test "changes the collab space config attrs correctly", %{ - conn: conn, - author: author, - project: project, - page_revision_cs: page_revision_cs - } do - {:ok, view, _html} = - live_isolated( - conn, - CollabSpaceConfigView, - session: %{ - "current_author_id" => author.id, - "collab_space_config" => page_revision_cs.collab_space_config, - "project_slug" => project.slug, - "resource_slug" => page_revision_cs.slug - } - ) - - view - |> element("form[phx-submit=\"save\"") - |> render_submit(%{ - revision: %{ - collab_space_config: %{ - threaded: false, - auto_accept: false, - participation_min_replies: 2, - anonymous_posting: false - } - } - }) - - refute view - |> element("#collab_space_config_form #revision_collab_space_config_0_threaded") - |> render() =~ "checked" - - refute view - |> element("#collab_space_config_form #revision_collab_space_config_0_auto_accept") - |> render() =~ - "checked" - - refute view - |> element( - "#collab_space_config_form #revision_collab_space_config_0_anonymous_posting" - ) - |> render() =~ - "checked" - - assert view - |> element( - "#collab_space_config_form #revision_collab_space_config_0_participation_min_replies" - ) - |> render() =~ "2" - end - - test "handles error when changes to the collab space config attrs are wrong", %{ - conn: conn, - author: author, - project: project, - page_revision_cs: page_revision_cs - } do - {:ok, view, _html} = - live_isolated( - conn, - CollabSpaceConfigView, - session: %{ - "current_author_id" => author.id, - "collab_space_config" => page_revision_cs.collab_space_config, - "project_slug" => project.slug, - "resource_slug" => page_revision_cs.slug - } - ) - - view - |> element("form[phx-submit=\"save\"") - |> render_submit(%{revision: %{collab_space_config: %{participation_min_replies: -1}}}) - - refute view - |> element( - "#collab_space_config_form #revision_collab_space_config_0_participation_min_replies" - ) - |> render() =~ "-1" - - assert view - |> element( - "#collab_space_config_form #revision_collab_space_config_0_participation_min_replies" - ) - |> render() =~ "0" end test "can enable Collab spaces for all pages in course", %{ @@ -912,8 +633,8 @@ defmodule OliWeb.CollaborationLiveTest do } ) - assert element(view, "h5[role='collab_space_page_summary']") - |> render() =~ "1 page currently has Collaborative Spaces enabled" + assert element(view, "div[role='collab_space_page_summary']") + |> render() =~ "1 page currently has Notes enabled" # can not trigger a JS command from a test to show the confirmation modal (hidden to the user), # so we directly submit the form in the modal @@ -932,15 +653,8 @@ defmodule OliWeb.CollaborationLiveTest do } }) - assert element(view, "h5[role='collab_space_page_summary']") - |> render() =~ "All 2 pages currently have Collaborative Spaces enabled" - - # enable all pages button is disabled - assert has_element?( - view, - "button[disabled=disabled]", - "Enable Collaboration Spaces for all pages in the course" - ) + assert element(view, "div[role='collab_space_page_summary']") + |> render() =~ "All 2 pages currently have Notes enabled" end test "can disable Collab spaces for all pages in course", %{ @@ -963,8 +677,8 @@ defmodule OliWeb.CollaborationLiveTest do } ) - assert element(view, "h5[role='collab_space_page_summary']") - |> render() =~ "1 page currently has Collaborative Spaces enabled" + assert element(view, "div[role='collab_space_page_summary']") + |> render() =~ "1 page currently has Notes enabled." # can not trigger a JS command from a test to show the confirmation modal (hidden to the user), # so we directly confirm the modal @@ -972,15 +686,15 @@ defmodule OliWeb.CollaborationLiveTest do |> element(~s{div[id="disable_collab_space_modal"] button}, "OK") |> render_click() - assert element(view, "h5[role='collab_space_page_summary']") - |> render() =~ "0 pages currently have Collaborative Spaces enabled" + assert element(view, "div[role='collab_space_page_summary']") + |> render() =~ "0 pages currently have Notes enabled." # disable all pages button is disabled - assert has_element?( - view, - "button[disabled=disabled]", - "Disable Collaboration Spaces for all pages in the course" - ) + element( + view, + "div[role='collab_space_toggle_all_pages']" + ) + |> render() =~ "" end end diff --git a/test/oli_web/live/projects/overview_live_test.exs b/test/oli_web/live/projects/overview_live_test.exs index 3ed3251d119..4282a4a457d 100644 --- a/test/oli_web/live/projects/overview_live_test.exs +++ b/test/oli_web/live/projects/overview_live_test.exs @@ -33,7 +33,8 @@ defmodule OliWeb.Projects.OverviewLiveTest do assert has_element?(view, "h4", "Advanced Activities") assert has_element?(view, "h4", "Allow Duplication") assert has_element?(view, "h4", "Publishing Visibility") - assert has_element?(view, "h4", "Collaboration Space") + assert has_element?(view, "h4", "Notes") + assert has_element?(view, "h4", "Course Discussions") assert has_element?(view, "h4", "Transfer Payment Codes") assert has_element?(view, "h4", "Actions") @@ -170,7 +171,8 @@ defmodule OliWeb.Projects.OverviewLiveTest do assert has_element?(view, "h4", "Advanced Activities") assert has_element?(view, "h4", "Allow Duplication") assert has_element?(view, "h4", "Publishing Visibility") - assert has_element?(view, "h4", "Collaboration Space") + assert has_element?(view, "h4", "Notes") + assert has_element?(view, "h4", "Course Discussions") assert has_element?(view, "h4", "Actions") assert has_element?(view, "button", "Bulk Resource Attribute Edit")