feat: mentor has no medialibrary
This commit is contained in:
parent
4866602c26
commit
14e8d5da49
|
|
@ -22,6 +22,7 @@ import {
|
||||||
getLearningPathUrl,
|
getLearningPathUrl,
|
||||||
getMediaCenterUrl,
|
getMediaCenterUrl,
|
||||||
} from "@/utils/utils";
|
} from "@/utils/utils";
|
||||||
|
import { useCockpitStore } from "@/stores/cockpit";
|
||||||
|
|
||||||
log.debug("MainNavigationBar created");
|
log.debug("MainNavigationBar created");
|
||||||
|
|
||||||
|
|
@ -68,6 +69,13 @@ const appointmentsUrl = computed(() => {
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
log.debug("MainNavigationBar mounted");
|
log.debug("MainNavigationBar mounted");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const hasMediaLibrary = computed(() => {
|
||||||
|
if (useCockpitStore().hasMentorCockpitType) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return inCourse() && Boolean(courseSessionsStore.currentCourseSession);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -78,6 +86,7 @@ onMounted(() => {
|
||||||
v-if="userStore.loggedIn"
|
v-if="userStore.loggedIn"
|
||||||
:show="state.showMobileNavigationMenu"
|
:show="state.showMobileNavigationMenu"
|
||||||
:course-session="courseSessionsStore.currentCourseSession"
|
:course-session="courseSessionsStore.currentCourseSession"
|
||||||
|
:has-media-library="hasMediaLibrary"
|
||||||
:media-url="
|
:media-url="
|
||||||
getMediaCenterUrl(courseSessionsStore.currentCourseSession?.course?.slug)
|
getMediaCenterUrl(courseSessionsStore.currentCourseSession?.course?.slug)
|
||||||
"
|
"
|
||||||
|
|
@ -211,10 +220,10 @@ onMounted(() => {
|
||||||
|
|
||||||
<div class="flex items-stretch justify-start space-x-8">
|
<div class="flex items-stretch justify-start space-x-8">
|
||||||
<router-link
|
<router-link
|
||||||
v-if="inCourse() && courseSessionsStore.currentCourseSession"
|
v-if="hasMediaLibrary"
|
||||||
:to="
|
:to="
|
||||||
getMediaCenterUrl(
|
getMediaCenterUrl(
|
||||||
courseSessionsStore.currentCourseSession.course.slug
|
courseSessionsStore.currentCourseSession?.course.slug
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
data-cy="medialibrary-link"
|
data-cy="medialibrary-link"
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ const router = useRouter();
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
show: boolean;
|
show: boolean;
|
||||||
|
hasMediaLibrary: boolean;
|
||||||
courseSession: CourseSession | undefined;
|
courseSession: CourseSession | undefined;
|
||||||
mediaUrl?: string;
|
mediaUrl?: string;
|
||||||
user: UserState | undefined;
|
user: UserState | undefined;
|
||||||
|
|
@ -97,7 +98,7 @@ const courseSessionsStore = useCourseSessionsStore();
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
<li class="mb-6">
|
<li v-if="hasMediaLibrary" class="mb-6">
|
||||||
<button
|
<button
|
||||||
data-cy="medialibrary-link"
|
data-cy="medialibrary-link"
|
||||||
@click="clickLink(getMediaCenterUrl(courseSession.course.slug))"
|
@click="clickLink(getMediaCenterUrl(courseSession.course.slug))"
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,19 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useCockpitStore } from "@/stores/cockpit";
|
import { useCockpitStore } from "@/stores/cockpit";
|
||||||
import { useCurrentCourseSession } from "@/composables";
|
import { useCurrentCourseSession } from "@/composables";
|
||||||
import { onMounted } from "vue";
|
|
||||||
import CockpitExpertPage from "./CockpitExpertPage.vue";
|
import CockpitExpertPage from "./CockpitExpertPage.vue";
|
||||||
import CockpitMentorPage from "./CockpitMentorPage.vue";
|
import CockpitMentorPage from "./CockpitMentorPage.vue";
|
||||||
|
|
||||||
const courseSession = useCurrentCourseSession();
|
|
||||||
const cockpitStore = useCockpitStore();
|
const cockpitStore = useCockpitStore();
|
||||||
|
const courseSession = useCurrentCourseSession();
|
||||||
onMounted(async () => {
|
|
||||||
await cockpitStore.fetchCockpitType(courseSession.value.course.id);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-gray-200">
|
<div class="bg-gray-200">
|
||||||
<template v-if="cockpitStore.cockpitType == 'expert'">
|
<template v-if="cockpitStore.hasExpertCockpitType">
|
||||||
<CockpitExpertPage :course-slug="courseSession.course.slug" />
|
<CockpitExpertPage :course-slug="courseSession.course.slug" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="cockpitStore.cockpitType == 'mentor'">
|
<template v-else-if="cockpitStore.hasMentorCockpitType">
|
||||||
<CockpitMentorPage :course-slug="courseSession.course.slug" />
|
<CockpitMentorPage :course-slug="courseSession.course.slug" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { useCockpitStore } from "@/stores/cockpit";
|
||||||
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
||||||
import { useUserStore } from "@/stores/user";
|
import { useUserStore } from "@/stores/user";
|
||||||
import type { NavigationGuard, RouteLocationNormalized } from "vue-router";
|
import type { NavigationGuard, RouteLocationNormalized } from "vue-router";
|
||||||
|
|
@ -61,6 +62,10 @@ export async function handleCurrentCourseSession(to: RouteLocationNormalized) {
|
||||||
if (!courseSessionsStore.loaded) {
|
if (!courseSessionsStore.loaded) {
|
||||||
await courseSessionsStore.loadCourseSessionsData();
|
await courseSessionsStore.loadCourseSessionsData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Must be after loadCourseSessionsData & _currentCourseSlug is set!
|
||||||
|
const courseId = courseSessionsStore.currentCourseSession?.course.id || null;
|
||||||
|
await useCockpitStore().fetchCockpitType(courseId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,36 @@
|
||||||
import { itGetCached } from "@/fetchHelpers";
|
import { itGetCached } from "@/fetchHelpers";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import type { Ref } from "vue";
|
import type { Ref } from "vue";
|
||||||
import { ref } from "vue";
|
import { computed, ref } from "vue";
|
||||||
|
|
||||||
type CockpitType = "mentor" | "expert" | null;
|
type CockpitType = "mentor" | "expert" | null;
|
||||||
|
|
||||||
export const useCockpitStore = defineStore("cockpit", () => {
|
export const useCockpitStore = defineStore("cockpit", () => {
|
||||||
const cockpitType: Ref<CockpitType> = ref(null);
|
const cockpitType: Ref<CockpitType> = ref(null);
|
||||||
const cockpitTypeIsLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
||||||
async function fetchCockpitType(courseId: string) {
|
const hasExpertCockpitType = computed(() => cockpitType.value === "expert");
|
||||||
cockpitTypeIsLoading.value = true;
|
const hasMentorCockpitType = computed(() => cockpitType.value === "mentor");
|
||||||
|
const hasNoCockpitType = computed(() => cockpitType.value === null);
|
||||||
|
|
||||||
|
async function fetchCockpitType(courseId: string | null) {
|
||||||
|
if (!courseId) {
|
||||||
|
cockpitType.value = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isLoading.value = true;
|
||||||
const url = `/api/course/${courseId}/cockpit/`;
|
const url = `/api/course/${courseId}/cockpit/`;
|
||||||
const response = await itGetCached(url);
|
const response = await itGetCached(url);
|
||||||
cockpitType.value = response.type;
|
cockpitType.value = response.type;
|
||||||
cockpitTypeIsLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { cockpitType, cockpitTypeIsLoading, fetchCockpitType };
|
return {
|
||||||
|
fetchCockpitType,
|
||||||
|
hasExpertCockpitType,
|
||||||
|
hasMentorCockpitType,
|
||||||
|
hasNoCockpitType,
|
||||||
|
isLoading,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue