Skip to content

Commit

Permalink
update routes
Browse files Browse the repository at this point in the history
  • Loading branch information
uidp committed Aug 21, 2024
1 parent 21b5ad1 commit df913f8
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 42 deletions.
6 changes: 4 additions & 2 deletions src/components/atoms/vCustomBreadcrumbs.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ describe("@/components/atoms/vCustomBreadcrumbs", () => {
plugins: [createTestingVuetify(), createTestingI18n()],
},
props: {
breadcrumbs: [{ title: "Cursos actuales", to: "/rooms-overview" }],
breadcrumbs: [
{ title: "Cursos actuales", to: "/rooms/courses-overview" },
],
},
});

Expand All @@ -26,7 +28,7 @@ describe("@/components/atoms/vCustomBreadcrumbs", () => {
name: "v-breadcrumbs-item",
});

expect(breadcrumbsItem.props().to).toStrictEqual("/rooms-overview");
expect(breadcrumbsItem.props().to).toStrictEqual("/rooms/courses-overview");
expect(breadcrumbsItem.element.innerHTML).toContain("Cursos actuales");
});
});
2 changes: 1 addition & 1 deletion src/layouts/LoggedIn.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { VApp } from "vuetify/lib/components/index.mjs";
import NewLoggedIn from "./LoggedIn.layout.vue";

jest.mock("vue-router", () => ({
useRoute: () => ({ path: "rooms-list" }),
useRoute: () => ({ path: "rooms/courses-list" }),
}));

const setup = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/data/board/BoardPageInformation.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const useBoardPageInformation = () => {
? [
{
title: t("common.words.courses"),
to: "/rooms-overview",
to: "/rooms/courses-overview",
disabled: false,
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ui/layout/sidebar/Sidebar.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { SchulcloudTheme } from "@/serverApi/v3";
import { envsFactory } from "@@/tests/test-utils";

jest.mock("vue-router", () => ({
useRoute: () => ({ path: "rooms-list" }),
useRoute: () => ({ path: "rooms/courses-list" }),
}));

const setup = (permissions?: string[]) => {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ui/layout/sidebar/SidebarCategoryItem.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const groupItem: SidebarGroupItem = {
};

jest.mock("vue-router", () => ({
useRoute: () => ({ path: "rooms-list" }),
useRoute: () => ({ path: "rooms/courses-list" }),
}));

describe("@ui-layout/SidebarCategoryItem", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/ui/layout/sidebar/SidebarItem.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const childItem: SidebarSingleItem = {
};

jest.mock("vue-router", () => ({
useRoute: () => ({ path: "rooms-list" }),
useRoute: () => ({ path: "rooms/courses-list" }),
}));

describe("@ui-layout/SidebarItem", () => {
Expand Down Expand Up @@ -56,7 +56,7 @@ describe("@ui-layout/SidebarItem", () => {
icon: "mdiOpen",
title: "title",
testId: "testId",
to: "/rooms-overview",
to: "/rooms/courses-overview",
});

expect(wrapper.classes()).toContain("v-list-item--active");
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ui/layout/sidebar/SidebarItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const route = useRoute();
const isActive = computed(() => {
const anyCoursePageIsActive =
route.path.includes("room") && props.item.to === "/rooms-overview";
route.path.includes("room") && props.item.to === "/rooms/courses-overview";
if (anyCoursePageIsActive) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ui/layout/sidebar/SidebarItems.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const useSidebarItems = () => {
},
{
title: "global.sidebar.item.courses",
to: "/rooms-overview",
to: "/rooms/courses-overview",
icon: "$mdiSchoolOutline",
testId: "Course-Overview",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ const { t } = useI18n();
const contextRoute = computed(() => `/rooms/${props.contextId}`);
const breadcrumbs: ComputedRef<Breadcrumb[]> = computed(() => {
const crumbs = [{ title: t("common.words.courses"), to: "/rooms-overview/" }];
const crumbs = [
{ title: t("common.words.courses"), to: "/rooms/courses-overview/" },
];
if (courseTitle.value) {
crumbs.push({ title: courseTitle.value, to: contextRoute });
Expand Down
4 changes: 2 additions & 2 deletions src/pages/rooms/CourseRoomDetails.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default defineComponent({
breadcrumbs: [
{
title: this.$t("common.words.courses"),
to: "/rooms-overview",
to: "/rooms/courses-overview",
disabled: false,
},
],
Expand Down Expand Up @@ -525,7 +525,7 @@ export default defineComponent({
"/rooms/" + copyResult.id.replace(/[^a-z\d]/g, "")
);
} else {
await this.$router.push("/rooms-overview");
await this.$router.push("/rooms/courses-overview");
}
},
async onCopyBoardElement(payload) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/rooms/CourseRoomList.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<v-btn
variant="outlined"
size="small"
to="/rooms-overview"
to="/rooms/courses-overview"
data-testid="go-to-active-courses"
>
{{ $t("pages.rooms.index.courses.active") }}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/rooms/CourseRoomOverview.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<v-btn
variant="outlined"
size="small"
to="/rooms-list"
to="/rooms/courses-list"
data-testid="go-to-all-courses"
>
{{ $t("pages.rooms.index.courses.all") }}
Expand Down Expand Up @@ -390,7 +390,7 @@ export default defineComponent({
if (id) {
this.$router.replace({ name: "rooms-id", params: { id } });
} else {
this.$router.replace({ name: "rooms-overview" });
this.$router.replace({ name: "course-room-overview" });
courseRoomListModule.fetch();
}
},
Expand Down
44 changes: 29 additions & 15 deletions src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,33 +231,47 @@ export const routes: Readonly<RouteRecordRaw[]> = [
beforeEnter: createPermissionGuard(["news_edit"]),
},
{
path: `/rooms/:id(${REGEX_ID})`,
component: () => import("@/pages/rooms/CourseRoomDetails.page.vue"),
name: "rooms-id",
},
{
// TODO BC-7822, BC-7823 target this route at new rooms page
path: `/rooms`,
redirect: { name: "rooms-overview" },
redirect: { name: "course-room-overview" },
name: "rooms",
},
// TODO Is this redirect really necessary? How likely is it that there are bookmarks?
{
path: `/rooms/:id(${REGEX_ID})/board`,
component: async () => (await import("@page-board")).ColumnBoardPage,
name: "rooms-board",
props: (route: RouteLocationNormalized) => ({
boardId: route.params.id,
}),
path: "/rooms-list",
redirect: { name: "course-room-list" },
name: "rooms-list",
},
{
path: "/rooms-list",
path: "/rooms/courses-list",
component: () => import("@/pages/rooms/CourseRoomList.page.vue"),
name: "rooms-list",
name: "course-room-list",
},
{
path: "/rooms-overview",
component: () => import("@/pages/rooms/CourseRoomOverview.page.vue"),
redirect: { name: "course-room-overview" },
name: "rooms-overview",
},
{
path: "/rooms/courses-overview",
component: () => import("@/pages/rooms/CourseRoomOverview.page.vue"),
name: "course-room-overview",
},
{
// TODO BC-7822, BC-7823 target this route at new room details page
// and decide on that page which sub-component (page) has to be rendered
path: `/rooms/:id(${REGEX_ID})`,
component: () => import("@/pages/rooms/CourseRoomDetails.page.vue"),
name: "rooms-id",
},
{
path: `/rooms/:id(${REGEX_ID})/board`,
component: async () => (await import("@page-board")).ColumnBoardPage,
name: "rooms-board",
props: (route: RouteLocationNormalized) => ({
boardId: route.params.id,
}),
},
{
path: "/tasks",
component: () => import("@/pages/tasks/TaskOverview.page.vue"),
Expand Down
8 changes: 5 additions & 3 deletions src/router/vue-client-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ const vueRoutes = [
`^/news/new/?$`,
`^/news/${mongoId}/edit/?$`,
`^/poc-files/?$`,
`^/rooms-overview/?$`,
`^/rooms-list/?$`,
`^/h5p/player/${h5pId}/?$`,
`^/h5p/editor/?$`,
`^/h5p/editor/${h5pId}/?$`,
`^/rooms/${mongoId}/?$`,
`^/rooms/?$`,
`^/rooms/rooms-list/?$`,
`^/rooms/courses-list/?$`,
`^/rooms/courses-overview/?$`,
`^/rooms-overview/?$`,
`^/rooms/${mongoId}/?$`,
`^/rooms/${mongoId}/board?$`,
`^/tasks/?$`,
`^/error/?$`,
Expand Down
2 changes: 1 addition & 1 deletion src/store/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class ShareModule extends VuexModule {
shareTokenPayload
);
if (!shareTokenResult) return undefined;
const shareUrl = `${window.location.origin}/rooms-overview?import=${shareTokenResult.data.token}`;
const shareUrl = `${window.location.origin}/rooms/courses-overview?import=${shareTokenResult.data.token}`;
this.setShareUrl(shareUrl);
return shareTokenResult.data;
} catch {
Expand Down
2 changes: 1 addition & 1 deletion src/store/share.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("share module", () => {
await shareModule.createShareUrl(sharePayload);
const result = setShareUrlMock.mock.calls[0][0];

expect(result).toContain("rooms-overview?import=sampleToken");
expect(result).toContain("rooms/courses-overview?import=sampleToken");
});

it("should return undefined on error", async () => {
Expand Down
8 changes: 2 additions & 6 deletions src/utils/sidebar-base-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,10 @@ const getSidebarItems = (): SidebarItemList => [
},
{
title: "global.sidebar.item.courses",
to: "/rooms-overview",
to: "/rooms/courses-overview",
icon: "$mdiSchoolOutline",
testId: "Course-Overview",
activeForUrls: [
"^/rooms-overview($|/.*)",
"^/rooms($|/.*)",
"^/rooms-list($|/.*)",
],
activeForUrls: ["^/rooms($|/.*)"],
},
{
title: "global.sidebar.item.teams",
Expand Down

0 comments on commit df913f8

Please sign in to comment.