From c7e56c01471e82f7562a5caac823e84186398a48 Mon Sep 17 00:00:00 2001 From: Alex Velez Date: Thu, 7 Nov 2024 08:29:33 -0500 Subject: [PATCH] Remove LessonPageNames --- kolibri/plugins/coach/assets/src/app.js | 2 +- .../assets/src/composables/useLessons.js | 4 +- .../coach/assets/src/constants/index.js | 6 +-- .../assets/src/constants/lessonsConstants.js | 19 ---------- .../coachNotifications/gettersUtils.js | 2 +- .../src/modules/lessonResources/handlers.js | 22 +++++------ .../src/modules/lessonSummary/handlers.js | 4 +- .../assets/src/modules/lessonsRoot/actions.js | 2 +- .../coach/assets/src/modules/pluginModule.js | 7 ++-- .../coach/assets/src/routes/baseRoutes.js | 3 +- .../coach/assets/src/routes/lessonsRoutes.js | 37 +++++++++---------- .../src/views/common/ReportsControls.vue | 3 +- .../views/common/ReportsResourceHeader.vue | 4 +- .../src/views/home/HomePage/LessonsBlock.vue | 2 +- .../src/views/lessons/LessonCreationPage.vue | 4 +- .../lessons/LessonEditDetailsPage/index.vue | 2 +- .../LessonResourceSelectionPage.spec.js | 8 ++-- .../LessonResourceSelectionPage/index.vue | 25 ++++++------- .../index.vue | 2 +- .../views/lessons/LessonSummaryPage/index.vue | 5 +-- .../src/views/lessons/LessonsRootPage.vue | 6 +-- .../lessons/reports/LessonLearnerPage.vue | 2 +- 22 files changed, 73 insertions(+), 98 deletions(-) diff --git a/kolibri/plugins/coach/assets/src/app.js b/kolibri/plugins/coach/assets/src/app.js index b83f13a6fc..db93287ede 100644 --- a/kolibri/plugins/coach/assets/src/app.js +++ b/kolibri/plugins/coach/assets/src/app.js @@ -98,7 +98,7 @@ class CoachToolsModule extends KolibriApp { PageNames.EXAMS_ROOT, PageNames.LESSONS_ROOT, PageNames.LESSON_CREATION_ROOT, - PageNames.SUMMARY, + PageNames.LESSON_SUMMARY, PageNames.LESSON_EDIT_DETAILS, PageNames.SELECTION_ROOT, PageNames.SELECTION, diff --git a/kolibri/plugins/coach/assets/src/composables/useLessons.js b/kolibri/plugins/coach/assets/src/composables/useLessons.js index 93bd51e074..cfc2ead37a 100644 --- a/kolibri/plugins/coach/assets/src/composables/useLessons.js +++ b/kolibri/plugins/coach/assets/src/composables/useLessons.js @@ -1,7 +1,7 @@ import { ref } from 'kolibri.lib.vueCompositionApi'; import { LearnerGroupResource } from 'kolibri.resources'; import useUser from 'kolibri.coreVue.composables.useUser'; -import { LessonsPageNames } from '../constants/lessonsConstants'; +import { PageNames } from '../constants'; // Place outside the function to keep the state const lessonsAreLoading = ref(false); @@ -37,7 +37,7 @@ export function useLessons() { return Promise.all(loadRequirements).then( ([learnerGroups]) => { store.commit('lessonsRoot/SET_LEARNER_GROUPS', learnerGroups); - store.commit('SET_PAGE_NAME', LessonsPageNames.LESSONS_ROOT); + store.commit('SET_PAGE_NAME', PageNames.LESSONS_ROOT); setLessonsLoading(false); }, error => { diff --git a/kolibri/plugins/coach/assets/src/constants/index.js b/kolibri/plugins/coach/assets/src/constants/index.js index 476a293269..df98dd2560 100644 --- a/kolibri/plugins/coach/assets/src/constants/index.js +++ b/kolibri/plugins/coach/assets/src/constants/index.js @@ -1,5 +1,3 @@ -import { LessonsPageNames } from './lessonsConstants'; - export const PageNames = { HOME_PAGE: 'HomePage', // make sure this matches the Coach 'Home' page name REPORTS_PAGE: 'REPORTS_PAGE', @@ -94,8 +92,8 @@ export const ViewMoreButtonStates = { export const pageNameToModuleMap = { [PageNames.EXAM_REPORT_DETAIL]: 'examReportDetail', - [LessonsPageNames.LESSONS_ROOT]: 'lessonsRoot', - [LessonsPageNames.RESOURCE_USER_REPORT]: 'exerciseDetail', + [PageNames.LESSONS_ROOT]: 'lessonsRoot', + [PageNames.RESOURCE_USER_REPORT]: 'exerciseDetail', // Omitting modules for resource selection, exam creation, and preview to prevent // default module state resetting behavior. }; diff --git a/kolibri/plugins/coach/assets/src/constants/lessonsConstants.js b/kolibri/plugins/coach/assets/src/constants/lessonsConstants.js index 0767afe529..2a9dab0454 100644 --- a/kolibri/plugins/coach/assets/src/constants/lessonsConstants.js +++ b/kolibri/plugins/coach/assets/src/constants/lessonsConstants.js @@ -1,22 +1,3 @@ -export const LessonsPageNames = { - LESSON_CREATION_ROOT: 'LESSON_CREATION_ROOT', - LESSON_CREATION_ROOT_BETTER: 'LESSON_CREATION_ROOT_BETTER', - SUMMARY: 'LESSON_SUMMARY', - RESOURCE_USER_REPORT: 'RESOURCE_USER_REPORT', - RESOURCE_USER_REPORT_ROOT: 'RESOURCE_USER_REPORT_ROOT', - RESOURCE_CONTENT_PREVIEW: 'RESOURCE_CONTENT_PREVIEW', // exclusively a route name - SELECTION_ROOT: 'SELECTION_ROOT', - SELECTION: 'SELECTION', - SELECTION_SEARCH: 'SELECTION_SEARCH', - SELECTION_CONTENT_PREVIEW: 'SELECTION_CONTENT_PREVIEW', // exclusively a route name - CONTENT_PREVIEW: 'CONTENT_PREVIEW', - LESSON_SELECTION_BOOKMARKS: 'LESSON_SELECTION_BOOKMARKS', - LESSON_SELECTION_BOOKMARKS_MAIN: 'LESSON_SELECTION_BOOKMARKS_MAIN', - - LESSONS_ROOT: 'LESSONS_ROOT', - LESSONS_ROOT_BETTER: 'LESSONS_ROOT_BETTER', -}; - export const CollectionTypes = { LEARNERGROUP: 'learnergroup', ADHOCLEARNERSGROUP: 'adhoclearnersgroup', diff --git a/kolibri/plugins/coach/assets/src/modules/coachNotifications/gettersUtils.js b/kolibri/plugins/coach/assets/src/modules/coachNotifications/gettersUtils.js index f74710211d..9bf5860433 100644 --- a/kolibri/plugins/coach/assets/src/modules/coachNotifications/gettersUtils.js +++ b/kolibri/plugins/coach/assets/src/modules/coachNotifications/gettersUtils.js @@ -68,7 +68,7 @@ const pageNameToNotificationPropsMap = [ isMultiple: true, isWholeClass: true, }, - value: PageNames.SUMMARY, + value: PageNames.LESSON_SUMMARY, }, { key: { diff --git a/kolibri/plugins/coach/assets/src/modules/lessonResources/handlers.js b/kolibri/plugins/coach/assets/src/modules/lessonResources/handlers.js index 01cace93e8..3adef3c93d 100644 --- a/kolibri/plugins/coach/assets/src/modules/lessonResources/handlers.js +++ b/kolibri/plugins/coach/assets/src/modules/lessonResources/handlers.js @@ -8,7 +8,7 @@ import { ContentNodeKinds } from 'kolibri.coreVue.vuex.constants'; import chunk from 'lodash/chunk'; import useUser from 'kolibri.coreVue.composables.useUser'; import { get } from '@vueuse/core'; -import { LessonsPageNames } from '../../constants/lessonsConstants'; +import { PageNames } from '../../constants'; async function showResourceSelectionPage(store, params) { const { @@ -74,13 +74,13 @@ async function showResourceSelectionPage(store, params) { store.commit('lessonSummary/resources/SET_SEARCH_RESULTS', params.searchResults); } store.commit('SET_PAGE_NAME', pageName); - if (pageName === LessonsPageNames.SELECTION_SEARCH) { + if (pageName === PageNames.SELECTION_SEARCH) { store.commit('SET_TOOLBAR_ROUTE', { - name: LessonsPageNames.SELECTION_ROOT, + name: PageNames.SELECTION_ROOT, }); } else { store.commit('SET_TOOLBAR_ROUTE', { - name: LessonsPageNames.SUMMARY, + name: PageNames.LESSON_SUMMARY, }); } return setResourceCachePromise.then(() => { @@ -107,7 +107,7 @@ export function showLessonResourceSelectionRootPage(store, params) { classId: params.classId, lessonId: params.lessonId, contentList: channelContentList, - pageName: LessonsPageNames.SELECTION_ROOT, + pageName: PageNames.SELECTION_ROOT, descendantCounts, }); }, @@ -130,7 +130,7 @@ export function showLessonResourceSelectionTopicPage(store, params) { classId: params.classId, lessonId: params.lessonId, contentList: childNodes, - pageName: LessonsPageNames.SELECTION, + pageName: PageNames.SELECTION, descendantCounts, ancestors: [...topicNode.ancestors, topicNode], }); @@ -150,7 +150,7 @@ export function showLessonResourceBookmarks(store, params) { classId: params.classId, lessonId: params.lessonId, bookmarksList: childNodes, - pageName: LessonsPageNames.SELECTION, + pageName: PageNames.SELECTION, ancestors: [...topicNode.ancestors, topicNode], }); }); @@ -222,7 +222,7 @@ export async function showLessonSelectionContentPreview(store, params, query = { const { searchTerm, ...otherQueryParams } = query; if (searchTerm) { store.commit('SET_TOOLBAR_ROUTE', { - name: LessonsPageNames.SELECTION_SEARCH, + name: PageNames.SELECTION_SEARCH, params: { searchTerm, }, @@ -230,7 +230,7 @@ export async function showLessonSelectionContentPreview(store, params, query = { }); } else { store.commit('SET_TOOLBAR_ROUTE', { - name: LessonsPageNames.SELECTION, + name: PageNames.SELECTION, params: { topicId: contentNode.parent, }, @@ -273,7 +273,7 @@ function _prepLessonContentPreview(store, classId, lessonId, contentId) { }); } - store.commit('SET_PAGE_NAME', LessonsPageNames.CONTENT_PREVIEW); + store.commit('SET_PAGE_NAME', PageNames.CONTENT_PREVIEW); return contentNode; }, error => { @@ -298,7 +298,7 @@ export function showLessonResourceSearchPage(store, params, query = {}) { lessonId: params.lessonId, contentList: results.results, searchResults: results, - pageName: LessonsPageNames.SELECTION_SEARCH, + pageName: PageNames.SELECTION_SEARCH, }); }); }); diff --git a/kolibri/plugins/coach/assets/src/modules/lessonSummary/handlers.js b/kolibri/plugins/coach/assets/src/modules/lessonSummary/handlers.js index 007c774454..db27d9c755 100644 --- a/kolibri/plugins/coach/assets/src/modules/lessonSummary/handlers.js +++ b/kolibri/plugins/coach/assets/src/modules/lessonSummary/handlers.js @@ -1,7 +1,7 @@ import { LearnerGroupResource } from 'kolibri.resources'; import useUser from 'kolibri.coreVue.composables.useUser'; import { get } from '@vueuse/core'; -import { LessonsPageNames } from '../../constants/lessonsConstants'; +import { PageNames } from '../../constants'; export async function setLessonSummaryState(store, params) { const { classId, lessonId } = params; @@ -37,7 +37,7 @@ export async function setLessonSummaryState(store, params) { return store.dispatch('lessonSummary/getResourceCache', resourceIds).then(() => { store.commit('lessonSummary/SET_WORKING_RESOURCES', currentLesson.resources); store.commit('lessonSummary/SET_LEARNER_GROUPS', learnerGroups); - store.commit('SET_PAGE_NAME', LessonsPageNames.SUMMARY); + store.commit('SET_PAGE_NAME', PageNames.LESSON_SUMMARY); }); }) .catch(error => { diff --git a/kolibri/plugins/coach/assets/src/modules/lessonsRoot/actions.js b/kolibri/plugins/coach/assets/src/modules/lessonsRoot/actions.js index a9eb878aae..9c794758d4 100644 --- a/kolibri/plugins/coach/assets/src/modules/lessonsRoot/actions.js +++ b/kolibri/plugins/coach/assets/src/modules/lessonsRoot/actions.js @@ -69,7 +69,7 @@ export function createLesson(store, { classId, payload }) { // Update the class summary now that we have a new lesson in town! store.dispatch('classSummary/refreshClassSummary', null, { root: true }).then(() => { router.push({ - name: PageNames.SUMMARY, + name: PageNames.LESSON_SUMMARY, params: { classId, lessonId: newLesson.id, diff --git a/kolibri/plugins/coach/assets/src/modules/pluginModule.js b/kolibri/plugins/coach/assets/src/modules/pluginModule.js index f5eb7d34e7..9a3e9b09c6 100644 --- a/kolibri/plugins/coach/assets/src/modules/pluginModule.js +++ b/kolibri/plugins/coach/assets/src/modules/pluginModule.js @@ -2,8 +2,7 @@ import { ClassroomResource } from 'kolibri.resources'; import logger from 'kolibri.lib.logging'; import useUser from 'kolibri.coreVue.composables.useUser'; import { get } from '@vueuse/core'; -import { pageNameToModuleMap } from '../constants'; -import { LessonsPageNames } from '../constants/lessonsConstants'; +import { PageNames, pageNameToModuleMap } from '../constants'; import examReportDetail from './examReportDetail'; import exerciseDetail from './exerciseDetail'; import groups from './groups'; @@ -114,8 +113,8 @@ export default { resetModuleState(store, { toRoute, fromRoute }) { // If going from Lesson Summary to something other than Resource Selection, reset if ( - fromRoute.name === LessonsPageNames.SUMMARY && - ![LessonsPageNames.SELECTION_ROOT, LessonsPageNames.SUMMARY].includes(toRoute.name) + fromRoute.name === PageNames.LESSON_SUMMARY && + ![PageNames.SELECTION_ROOT, PageNames.LESSON_SUMMARY].includes(toRoute.name) ) { return store.dispatch('lessonSummary/resetLessonSummaryState'); } diff --git a/kolibri/plugins/coach/assets/src/routes/baseRoutes.js b/kolibri/plugins/coach/assets/src/routes/baseRoutes.js index 192e46e9e8..470084c112 100644 --- a/kolibri/plugins/coach/assets/src/routes/baseRoutes.js +++ b/kolibri/plugins/coach/assets/src/routes/baseRoutes.js @@ -1,10 +1,9 @@ import { PageNames } from '../constants'; -import { LessonsPageNames } from '../constants/lessonsConstants'; import routes from '.'; const baseRouteNames = { classHome: PageNames.HOME_PAGE, - lessons: LessonsPageNames.LESSONS_ROOT, + lessons: PageNames.LESSONS_ROOT, quizzes: PageNames.EXAMS_ROOT, learners: PageNames.LEARNERS_ROOT, groups: PageNames.GROUPS_ROOT, diff --git a/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js b/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js index 6107f6eddc..387e579c63 100644 --- a/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js +++ b/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js @@ -9,7 +9,6 @@ import { showLessonResourceBookmarksMain, } from '../modules/lessonResources/handlers'; import { showLessonSummaryPage } from '../modules/lessonSummary/handlers'; -import { LessonsPageNames } from '../constants/lessonsConstants'; import { PageNames } from '../constants'; import { useLessons } from '../composables/useLessons'; @@ -75,11 +74,11 @@ function defaultHandler() { export default [ { - name: LessonsPageNames.LESSONS_ROOT, + name: PageNames.LESSONS_ROOT, path: path(OPTIONAL_CLASS, ALL_LESSONS), component: LessonsRootPage, handler(toRoute, fromRoute, next) { - if (classIdParamRequiredGuard(toRoute, LessonsPageNames.LESSONS_ROOT, next)) { + if (classIdParamRequiredGuard(toRoute, PageNames.LESSONS_ROOT, next)) { return; } showLessonsRootPage(store, toRoute.params.classId); @@ -89,11 +88,11 @@ export default [ }, }, { - name: LessonsPageNames.LESSONS_ROOT_BETTER, + name: PageNames.LESSONS_ROOT_BETTER, path: path(OPTIONAL_CLASS, ALL_LESSONS_TEMP), component: LessonsRootPage, handler(toRoute, fromRoute, next) { - if (classIdParamRequiredGuard(toRoute, LessonsPageNames.LESSONS_ROOT_BETTER, next)) { + if (classIdParamRequiredGuard(toRoute, PageNames.LESSONS_ROOT_BETTER, next)) { return; } showLessonsRootPage(store, toRoute.params.classId); @@ -103,12 +102,12 @@ export default [ }, }, { - name: LessonsPageNames.LESSON_CREATION_ROOT, + name: PageNames.LESSON_CREATION_ROOT, path: path(CLASS, ALL_LESSONS, '/new'), component: LessonCreationPage, }, { - name: LessonsPageNames.LESSON_CREATION_ROOT_BETTER, + name: PageNames.LESSON_CREATION_ROOT_BETTER, path: path(CLASS, LESSONS_TEMP, '/edit'), component: LessonCreationPage, children: [ @@ -138,12 +137,12 @@ export default [ ], }, { - name: LessonsPageNames.SUMMARY, + name: PageNames.LESSON_SUMMARY, path: path(CLASS, LESSON, '/:tabId?'), component: LessonSummaryPage, handler(toRoute, fromRoute) { if ( - fromRoute.name !== LessonsPageNames.SUMMARY || + fromRoute.name !== PageNames.LESSON_SUMMARY || toRoute.params.lessonId !== fromRoute.params.lessonId ) { return showLessonSummaryPage(store, toRoute.params); @@ -160,7 +159,7 @@ export default [ component: LessonEditDetailsPage, }, { - name: LessonsPageNames.SELECTION_ROOT, + name: PageNames.SELECTION_ROOT, path: path(CLASS, LESSON, SELECTION), component: LessonResourceSelectionPage, handler(toRoute) { @@ -168,7 +167,7 @@ export default [ }, }, { - name: LessonsPageNames.SELECTION, + name: PageNames.SELECTION, path: path(CLASS, LESSON, SELECTION, TOPIC), component: LessonResourceSelectionPage, handler(toRoute, fromRoute) { @@ -177,7 +176,7 @@ export default [ // called whether or not a change is made, because we don't track changes // enough steps back. let preHandlerPromise; - if (fromRoute.name === LessonsPageNames.SELECTION_CONTENT_PREVIEW) { + if (fromRoute.name === PageNames.SELECTION_CONTENT_PREVIEW) { preHandlerPromise = store.dispatch('lessonSummary/saveLessonResources', { lessonId: toRoute.params.lessonId, resources: store.state.lessonSummary.workingResources, @@ -191,7 +190,7 @@ export default [ }, }, { - name: LessonsPageNames.SELECTION_SEARCH, + name: PageNames.SELECTION_SEARCH, path: path(CLASS, LESSON, SELECTION, SEARCH), component: LessonResourceSelectionPage, handler(toRoute) { @@ -199,12 +198,12 @@ export default [ }, }, { - name: LessonsPageNames.LESSON_SELECTION_BOOKMARKS, + name: PageNames.LESSON_SELECTION_BOOKMARKS, path: path(CLASS, LESSON, SELECTION, TOPIC), component: LessonResourceSelectionPage, handler(toRoute, fromRoute) { let preHandlerPromise; - if (fromRoute.name === LessonsPageNames.SELECTION_CONTENT_PREVIEW) { + if (fromRoute.name === PageNames.SELECTION_CONTENT_PREVIEW) { preHandlerPromise = store.dispatch('lessonSummary/saveLessonResources', { lessonId: toRoute.params.lessonId, resources: store.state.lessonSummary.workingResources, @@ -218,7 +217,7 @@ export default [ }, }, { - name: LessonsPageNames.LESSON_SELECTION_BOOKMARKS_MAIN, + name: PageNames.LESSON_SELECTION_BOOKMARKS_MAIN, path: path(CLASS, LESSON, SELECTION), component: LessonResourceSelectionPage, handler(toRoute) { @@ -226,7 +225,7 @@ export default [ }, }, { - name: LessonsPageNames.SELECTION_CONTENT_PREVIEW, + name: PageNames.SELECTION_CONTENT_PREVIEW, path: path(CLASS, LESSON, SELECTION, PREVIEW), component: LessonSelectionContentPreviewPage, handler(toRoute) { @@ -234,7 +233,7 @@ export default [ }, }, { - name: LessonsPageNames.RESOURCE_CONTENT_PREVIEW, + name: PageNames.RESOURCE_CONTENT_PREVIEW, path: path(CLASS, LESSON, '/resource', PREVIEW), component: LessonSelectionContentPreviewPage, props(data) { @@ -246,7 +245,7 @@ export default [ }; } else { backRoute = { - name: LessonsPageNames.SUMMARY, + name: PageNames.LESSON_SUMMARY, }; } return { diff --git a/kolibri/plugins/coach/assets/src/views/common/ReportsControls.vue b/kolibri/plugins/coach/assets/src/views/common/ReportsControls.vue index a14580091c..5b0e3d5c4b 100644 --- a/kolibri/plugins/coach/assets/src/views/common/ReportsControls.vue +++ b/kolibri/plugins/coach/assets/src/views/common/ReportsControls.vue @@ -51,7 +51,6 @@ import commonCoach from '../common'; import { ClassesPageNames } from '../../../../../learn/assets/src/constants'; import { LastPages } from '../../constants/lastPagesConstants'; - import { LessonsPageNames } from '../../constants/lessonsConstants'; import { PageNames } from '../../constants'; export default { @@ -82,7 +81,7 @@ PageNames.LESSONS_ROOT_BETTER, PageNames.EXAMS_ROOT, PageNames.EXAM_SUMMARY, - LessonsPageNames.SUMMARY, + PageNames.LESSON_SUMMARY, ].includes(this.$route.name); }, classLearnersListRoute() { diff --git a/kolibri/plugins/coach/assets/src/views/common/ReportsResourceHeader.vue b/kolibri/plugins/coach/assets/src/views/common/ReportsResourceHeader.vue index c53e67495d..786cf07071 100644 --- a/kolibri/plugins/coach/assets/src/views/common/ReportsResourceHeader.vue +++ b/kolibri/plugins/coach/assets/src/views/common/ReportsResourceHeader.vue @@ -7,7 +7,9 @@

diff --git a/kolibri/plugins/coach/assets/src/views/home/HomePage/LessonsBlock.vue b/kolibri/plugins/coach/assets/src/views/home/HomePage/LessonsBlock.vue index 9ec6e7edda..953194091c 100644 --- a/kolibri/plugins/coach/assets/src/views/home/HomePage/LessonsBlock.vue +++ b/kolibri/plugins/coach/assets/src/views/home/HomePage/LessonsBlock.vue @@ -26,7 +26,7 @@ :tally="tableRow.tally" :groupNames="groupAndAdHocLearnerNames(tableRow.groups, tableRow.assignments)" :hasAssignments="tableRow.hasAssignments" - :to="classRoute(PageNames.SUMMARY, { lessonId: tableRow.key, tabId: 'tabLearners' })" + :to="classRoute(PageNames.LESSON_SUMMARY, { lessonId: tableRow.key, tabId: 'tabLearners' })" /> diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonCreationPage.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonCreationPage.vue index bb31ea8375..ec34838c9f 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonCreationPage.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonCreationPage.vue @@ -52,7 +52,7 @@ import AssignmentDetailsModal from '../common/assignments/AssignmentDetailsModal'; import commonCoach from '../common'; import CoachImmersivePage from '../CoachImmersivePage'; - import { LessonsPageNames } from '../../constants/lessonsConstants'; + import { PageNames } from '../../constants'; export default { name: 'LessonCreationPage', @@ -64,7 +64,7 @@ mixins: [commonCoach, commonCoreStrings], computed: { showSidePanel() { - return this.$route.name === LessonsPageNames.LESSON_CREATION_ROOT_BETTER; + return this.$route.name === PageNames.LESSON_CREATION_ROOT_BETTER; }, classId() { return this.$route.params.classId; diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonEditDetailsPage/index.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonEditDetailsPage/index.vue index 3974220d22..c669625437 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonEditDetailsPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonEditDetailsPage/index.vue @@ -92,7 +92,7 @@ }; }, previousPageRoute() { - return this.$router.getRoute(PageNames.SUMMARY); + return this.$router.getRoute(PageNames.LESSON_SUMMARY); }, }, created() { diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/__test__/LessonResourceSelectionPage.spec.js b/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/__test__/LessonResourceSelectionPage.spec.js index f89d090ffd..07550111fd 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/__test__/LessonResourceSelectionPage.spec.js +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/__test__/LessonResourceSelectionPage.spec.js @@ -3,7 +3,7 @@ import VueRouter from 'vue-router'; import { BookmarksResource } from 'kolibri.resources'; import LessonResourceSelectionPage from '../index.vue'; import makeStore from '../../../../../test/makeStore'; -import { LessonsPageNames } from '../../../../constants/lessonsConstants'; +import { PageNames } from '../../../../constants'; jest.mock('kolibri.client'); jest.mock('kolibri.urls'); @@ -12,7 +12,7 @@ jest.mock('kolibri.coreVue.composables.useUser'); const router = new VueRouter({ routes: [ - { name: LessonsPageNames.SUMMARY, path: '/summary' }, + { name: PageNames.LESSON_SUMMARY, path: '/summary' }, { name: 'SELECT_RESOURCES', path: '/' }, { name: 'SELECTION_ROOT', path: '/select' }, { name: 'SELECTION', path: '/select/:topicId' }, @@ -28,7 +28,7 @@ const slotDiv = { }; const store = makeStore(); -store.state.toolbarRoute = { name: LessonsPageNames.SUMMARY }; +store.state.toolbarRoute = { name: PageNames.LESSON_SUMMARY }; function makeWrapper() { const wrapper = shallowMount(LessonResourceSelectionPage, { @@ -127,7 +127,7 @@ describe('LessonResourceSelectionPage', () => { const exitRoute = () => button.props().to.name; // Exit link goes to Lesson Summary page by default - expect(exitRoute()).toEqual(LessonsPageNames.SUMMARY); + expect(exitRoute()).toEqual(PageNames.LESSON_SUMMARY); // Exit link goes to report page if that's in the URL await router.replace({ query: { last: 'LESSON_SUMMARY' } }); diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/index.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/index.vue index 108f584ac2..ee075ad1b0 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/index.vue @@ -124,7 +124,6 @@ import commonCoach from '../../common'; import CoachAppBarPage from '../../CoachAppBarPage'; import CoachImmersivePage from '../../CoachImmersivePage'; - import { LessonsPageNames } from '../../../constants/lessonsConstants'; import { PageNames, ViewMoreButtonStates } from '../../../constants/index'; import LessonsSearchBox from './SearchTools/LessonsSearchBox'; import LessonsSearchFilters from './SearchTools/LessonsSearchFilters'; @@ -231,7 +230,7 @@ return this.currentLesson.id; }, inSearchMode() { - return this.pageName === LessonsPageNames.SELECTION_SEARCH; + return this.pageName === PageNames.SELECTION_SEARCH; }, page() { return this.getUserPermissions.can_manage_content @@ -263,7 +262,7 @@ // or if all contents are topics return ( !this.inSearchMode && - this.pageName !== LessonsPageNames.SELECTION_ROOT && + this.pageName !== PageNames.SELECTION_ROOT && !every(this.contentList, this.contentIsDirectoryKind) ); }, @@ -310,13 +309,13 @@ if (this.inSearchMode && lastId) { const queryCopy = { ...this.$route.query }; delete queryCopy.last_id; - return this.$router.getRoute(LessonsPageNames.SELECTION, { topicId: lastId }, queryCopy); + return this.$router.getRoute(PageNames.SELECTION, { topicId: lastId }, queryCopy); } else if (this.inSearchMode) { return this.selectionRootLink({ ...this.routerParams }); - } else if (this.$route.query.last === PageNames.SUMMARY) { + } else if (this.$route.query.last === PageNames.LESSON_SUMMARY) { // HACK to fix #7583 and #7584 return { - name: PageNames.SUMMARY, + name: PageNames.LESSON_SUMMARY, }; } else { return this.toolbarRoute; @@ -393,7 +392,7 @@ }, getBookmarksLink() { return { - name: LessonsPageNames.LESSON_SELECTION_BOOKMARKS_MAIN, + name: PageNames.LESSON_SELECTION_BOOKMARKS_MAIN, }; }, lessonCardClicked() { @@ -437,14 +436,14 @@ return !is_leaf; }, selectionRootLink() { - return this.$router.getRoute(LessonsPageNames.SELECTION_ROOT, {}, this.$route.query); + return this.$router.getRoute(PageNames.SELECTION_ROOT, {}, this.$route.query); }, topicListingLink({ topicId }) { - return this.$router.getRoute(LessonsPageNames.SELECTION, { topicId }, this.$route.query); + return this.$router.getRoute(PageNames.SELECTION, { topicId }, this.$route.query); }, bookmarkListingLink({ topicId }) { return this.$router.getRoute( - LessonsPageNames.LESSON_SELECTION_BOOKMARKS, + PageNames.LESSON_SELECTION_BOOKMARKS, { topicId }, this.$route.query, ); @@ -455,7 +454,7 @@ } const { query } = this.$route; return { - name: LessonsPageNames.SELECTION_CONTENT_PREVIEW, + name: PageNames.SELECTION_CONTENT_PREVIEW, params: { ...this.routerParams, contentId: content.id, @@ -474,7 +473,7 @@ } const { query } = this.$route; return { - name: LessonsPageNames.SELECTION_CONTENT_PREVIEW, + name: PageNames.SELECTION_CONTENT_PREVIEW, params: { ...this.routerParams, contentId: content.id, @@ -525,7 +524,7 @@ query.last = lastPage; } this.$router.push({ - name: LessonsPageNames.SELECTION_SEARCH, + name: PageNames.SELECTION_SEARCH, params: { searchTerm, }, diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSelectionContentPreviewPage/index.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSelectionContentPreviewPage/index.vue index b9b07e19f3..13db949a3e 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonSelectionContentPreviewPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSelectionContentPreviewPage/index.vue @@ -67,7 +67,7 @@ const lastRoute = get(this.$route, ['query', 'last']); if (lastRoute) { // HACK to fix #7583 and #7584 - if (lastRoute === PageNames.SUMMARY) { + if (lastRoute === PageNames.LESSON_SUMMARY) { return { name: PageNames.SELECTION, params: { diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/index.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/index.vue index d5060ac5e5..740ad60258 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/index.vue @@ -91,7 +91,6 @@ import commonCoach from '../../common'; import CoachAppBarPage from '../../CoachAppBarPage'; import ReportsControls from '../../common/ReportsControls'; - import { LessonsPageNames } from '../../../constants/lessonsConstants'; import { REPORTS_LESSON_TABS_ID, ReportsLessonTabs } from '../../../constants/tabsConstants'; import { PageNames } from '../../../constants'; import LessonResourcesTable from './tables/LessonResourcesTable'; @@ -151,7 +150,7 @@ return this.$route.params.lessonId; }, lessonSelectionRootPage() { - return this.classRoute(LessonsPageNames.SELECTION_ROOT, { lessonId: this.lessonId }); + return this.classRoute(PageNames.SELECTION_ROOT, { lessonId: this.lessonId }); }, activeTabId() { const { tabId } = this.$route.params; @@ -174,7 +173,7 @@ tabsList.forEach(tab => { tab.to = this.classRoute( - this.group ? PageNames.GROUP_LESSON_SUMMARY : LessonsPageNames.SUMMARY, + this.group ? PageNames.GROUP_LESSON_SUMMARY : PageNames.LESSON_SUMMARY, { tabId: tab.id }, ); }); diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonsRootPage.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonsRootPage.vue index 13b265a097..e52fac8100 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonsRootPage.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonsRootPage.vue @@ -198,7 +198,6 @@ import useSnackbar from 'kolibri.coreVue.composables.useSnackbar'; import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow'; import CoachAppBarPage from '../CoachAppBarPage'; - import { LessonsPageNames } from '../../constants/lessonsConstants'; import commonCoach from '../common'; import AssignmentDetailsModal from '../common/assignments/AssignmentDetailsModal'; import { useLessons } from '../../composables/useLessons'; @@ -206,6 +205,7 @@ import * as csvFields from '../../csv/fields'; import CSVExporter from '../../csv/exporter'; import CoachHeader from '../common/CoachHeader.vue'; + import { PageNames } from '../../constants'; export default { name: 'LessonsRootPage', @@ -271,7 +271,7 @@ return countBy(this.lessons, 'active'); }, newLessonRoute() { - return { name: LessonsPageNames.LESSON_CREATION_ROOT }; + return { name: PageNames.LESSON_CREATION_ROOT }; }, hasVisibleLessons() { return this.activeLessonCounts.true; @@ -325,7 +325,7 @@ } }, lessonSummaryLink({ lessonId }) { - return this.classRoute(LessonsPageNames.SUMMARY, { lessonId }); + return this.classRoute(PageNames.LESSON_SUMMARY, { lessonId }); }, handleDetailsModalContinue(payload) { this.detailsModalIsDisabled = true; diff --git a/kolibri/plugins/coach/assets/src/views/lessons/reports/LessonLearnerPage.vue b/kolibri/plugins/coach/assets/src/views/lessons/reports/LessonLearnerPage.vue index 74da5d63be..e89f37de1d 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/reports/LessonLearnerPage.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/reports/LessonLearnerPage.vue @@ -5,7 +5,7 @@