+ """
+ 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
+ }
+ />
+
+ <%= 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
-
-
"
- 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")