Skip to content

Commit

Permalink
Remove LessonPageNames
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVelezLl committed Nov 7, 2024
1 parent 6e14b34 commit c7e56c0
Show file tree
Hide file tree
Showing 22 changed files with 73 additions and 98 deletions.
2 changes: 1 addition & 1 deletion kolibri/plugins/coach/assets/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions kolibri/plugins/coach/assets/src/composables/useLessons.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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 => {
Expand Down
6 changes: 2 additions & 4 deletions kolibri/plugins/coach/assets/src/constants/index.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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.
};
19 changes: 0 additions & 19 deletions kolibri/plugins/coach/assets/src/constants/lessonsConstants.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const pageNameToNotificationPropsMap = [
isMultiple: true,
isWholeClass: true,
},
value: PageNames.SUMMARY,
value: PageNames.LESSON_SUMMARY,
},
{
key: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(() => {
Expand All @@ -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,
});
},
Expand All @@ -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],
});
Expand All @@ -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],
});
});
Expand Down Expand Up @@ -222,15 +222,15 @@ 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,
},
query: otherQueryParams,
});
} else {
store.commit('SET_TOOLBAR_ROUTE', {
name: LessonsPageNames.SELECTION,
name: PageNames.SELECTION,
params: {
topicId: contentNode.parent,
},
Expand Down Expand Up @@ -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 => {
Expand All @@ -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,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions kolibri/plugins/coach/assets/src/modules/pluginModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
}
Expand Down
3 changes: 1 addition & 2 deletions kolibri/plugins/coach/assets/src/routes/baseRoutes.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
37 changes: 18 additions & 19 deletions kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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: [
Expand Down Expand Up @@ -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);
Expand All @@ -160,15 +159,15 @@ export default [
component: LessonEditDetailsPage,
},
{
name: LessonsPageNames.SELECTION_ROOT,
name: PageNames.SELECTION_ROOT,
path: path(CLASS, LESSON, SELECTION),
component: LessonResourceSelectionPage,
handler(toRoute) {
showLessonResourceSelectionRootPage(store, toRoute.params);
},
},
{
name: LessonsPageNames.SELECTION,
name: PageNames.SELECTION,
path: path(CLASS, LESSON, SELECTION, TOPIC),
component: LessonResourceSelectionPage,
handler(toRoute, fromRoute) {
Expand All @@ -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,
Expand All @@ -191,20 +190,20 @@ export default [
},
},
{
name: LessonsPageNames.SELECTION_SEARCH,
name: PageNames.SELECTION_SEARCH,
path: path(CLASS, LESSON, SELECTION, SEARCH),
component: LessonResourceSelectionPage,
handler(toRoute) {
showLessonResourceSearchPage(store, toRoute.params, toRoute.query);
},
},
{
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,
Expand All @@ -218,23 +217,23 @@ export default [
},
},
{
name: LessonsPageNames.LESSON_SELECTION_BOOKMARKS_MAIN,
name: PageNames.LESSON_SELECTION_BOOKMARKS_MAIN,
path: path(CLASS, LESSON, SELECTION),
component: LessonResourceSelectionPage,
handler(toRoute) {
showLessonResourceBookmarksMain(store, toRoute.params, toRoute.query);
},
},
{
name: LessonsPageNames.SELECTION_CONTENT_PREVIEW,
name: PageNames.SELECTION_CONTENT_PREVIEW,
path: path(CLASS, LESSON, SELECTION, PREVIEW),
component: LessonSelectionContentPreviewPage,
handler(toRoute) {
showLessonSelectionContentPreview(store, toRoute.params, toRoute.query);
},
},
{
name: LessonsPageNames.RESOURCE_CONTENT_PREVIEW,
name: PageNames.RESOURCE_CONTENT_PREVIEW,
path: path(CLASS, LESSON, '/resource', PREVIEW),
component: LessonSelectionContentPreviewPage,
props(data) {
Expand All @@ -246,7 +245,7 @@ export default [
};
} else {
backRoute = {
name: LessonsPageNames.SUMMARY,
name: PageNames.LESSON_SUMMARY,
};
}
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -82,7 +81,7 @@
PageNames.LESSONS_ROOT_BETTER,
PageNames.EXAMS_ROOT,
PageNames.EXAM_SUMMARY,
LessonsPageNames.SUMMARY,
PageNames.LESSON_SUMMARY,
].includes(this.$route.name);
},
classLearnersListRoute() {
Expand Down
Loading

0 comments on commit c7e56c0

Please sign in to comment.