fix: if pages and resources view is disabled, show all pages in studio (#30550)

In a previous PR #28686, the ability to see and enable/disable wiki and progress tabs was removed from studio along with the ability to re-order non-static tabs. The ability to toggle the Wiki tab was moved to the pages and resources section of the course authoring MFE. If that MFE is unavailable this means there is no way to show/hide the Wiki. This reverts some of the old changes if the pages and resources view is disabled.
This commit is contained in:
Kshitij Sobti
2022-06-28 16:19:32 +00:00
committed by GitHub
parent ffbac0dc94
commit 8169aa99da
7 changed files with 103 additions and 60 deletions

View File

@@ -43,15 +43,11 @@ class TabsAPITests(CourseTestCase):
)
# add a static tab to the course, for code coverage
# add 4 static tabs to the course, for code coverage
self.test_tabs = []
for i in range(1, 5):
tab = ItemFactory.create(
parent_location=self.course.location,
category="static_tab",
display_name=f"Static_{i}"
)
self.test_tabs.append(tab)
self.test_tab = ItemFactory.create(
parent_location=self.course.location,
category="static_tab",
display_name="Static_1",
)
self.reload_course()
def check_invalid_response(self, resp):
@@ -129,27 +125,6 @@ class TabsAPITests(CourseTestCase):
new_tab_ids = [tab.tab_id for tab in self.course.tabs]
assert new_tab_ids == reordered_tab_ids
def test_reorder_tabs_invalid_list(self):
"""
Test re-ordering of tabs with invalid tab list.
Not all tabs can be rearranged. Here we are trying to swap the first
two tabs, which is disallowed since the first tab is the "Course" tab
which is immovable.
"""
orig_tab_ids = [tab.tab_id for tab in self.course.tabs]
tab_ids = list(orig_tab_ids)
# reorder the first two tabs
tab_ids[0], tab_ids[1] = tab_ids[1], tab_ids[0]
# post the request
resp = self.make_reorder_tabs_request([{"tab_id": tab_id} for tab_id in tab_ids])
assert resp.status_code == 400
error = self.check_invalid_response(resp)
assert "error" in error
def test_reorder_tabs_invalid_tab_ids(self):
"""
Test re-ordering of tabs with invalid tab.

View File

@@ -13,7 +13,7 @@ from xmodule.modulestore.exceptions import ItemNotFoundError
from common.djangoapps.student.auth import has_studio_read_access, has_studio_write_access
from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, verify_course_exists, view_auth_classes
from ..serializers import CourseTabSerializer, CourseTabUpdateSerializer, TabIDLocatorSerializer
from ....views.tabs import edit_tab_handler, get_course_static_tabs, reorder_tabs_handler
from ....views.tabs import edit_tab_handler, get_course_tabs, reorder_tabs_handler
@view_auth_classes(is_authenticated=True)
@@ -34,7 +34,7 @@ class CourseTabListView(DeveloperErrorViewMixin, APIView):
@verify_course_exists()
def get(self, request: Request, course_id: str) -> Response:
"""
Get a list of all the static tabs in a course including hidden tabs.
Get a list of all the tabs in a course including hidden tabs.
**Example Request**
@@ -82,7 +82,7 @@ class CourseTabListView(DeveloperErrorViewMixin, APIView):
self.permission_denied(request)
course_module = modulestore().get_course(course_key)
tabs_to_render = get_course_static_tabs(course_module, request.user)
tabs_to_render = get_course_tabs(course_module, request.user)
return Response(CourseTabSerializer(tabs_to_render, many=True).data)