Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kolibri_explore_plugin/assets/src/kolibriApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ContentNodeKinds } from 'kolibri.coreVue.vuex.constants';
import router from 'kolibri.coreVue.router';
import store from 'kolibri.coreVue.vuex.store';
import { utils } from 'eos-components';
import { showTopicsContentInLightbox } from './modules/topicsTree/handlers';
import { showTopicsContent } from './modules/topicsTree/handlers';
import { PageNames } from './constants';
import { getChannelIcon } from './customApps';

Expand Down Expand Up @@ -39,7 +39,7 @@ class KolibriApi {
}

navigateTo(nodeId) {
showTopicsContentInLightbox(store, nodeId);
showTopicsContent(store, nodeId);
}

closeCustomPresentation() {
Expand Down
20 changes: 18 additions & 2 deletions kolibri_explore_plugin/assets/src/modules/topicsTree/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function showTopicsChannel(store, id) {
});
}

export function showTopicsContentInLightbox(store, id) {
function showTopicsContentInLightbox(store, id) {
const promises = [ContentNodeResource.fetchModel({ id }), store.dispatch('setChannelInfo')];
const shouldResolve = samePageCheckGenerator(store);
Promise.all(promises).then(
Expand Down Expand Up @@ -161,6 +161,22 @@ export function showTopicsContentInLightbox(store, id) {
);
}

export function hideTopicsContentFromLightbox(store) {
function showTopicsContentInLearnTab(learnUrl, id) {
// Pass current URL as prevName:
const prevName = encodeURIComponent(window.location.href);
const contentViewerUrl = `${learnUrl()}#/topics/c/${id}?prevName=${prevName}`;
window.location.replace(contentViewerUrl);
}

export function showTopicsContent(store, id) {
const learnUrl = urls['kolibri:kolibri.plugins.learn:learn'];
if (learnUrl) {
showTopicsContentInLearnTab(learnUrl, id);
} else {
showTopicsContentInLightbox(store, id);
}
}

export function hideTopicsContent(store) {
store.commit('topicsTree/RESET_CONTENT');
}
9 changes: 3 additions & 6 deletions kolibri_explore_plugin/assets/src/views/ContentModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@

import { mapState } from 'vuex';
import { responsiveMixin } from 'eos-components';
import {
hideTopicsContentFromLightbox,
showTopicsContentInLightbox,
} from '../modules/topicsTree/handlers';
import { hideTopicsContent, showTopicsContent } from '../modules/topicsTree/handlers';
import ContentItem from './ContentItem';

export default {
Expand Down Expand Up @@ -86,10 +83,10 @@
},

goToContent(id) {
showTopicsContentInLightbox(this.$store, id);
showTopicsContent(this.$store, id);
},
onClose() {
hideTopicsContentFromLightbox(this.$store);
hideTopicsContent(this.$store);
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/eos-components/src/components/ContentCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'shadow': isHovered,
}"
>
<ContentLink :url="url" @isHovered="(hovered) => isHovered = hovered">
<ContentLink :url="url" :nodeId="node.id" @isHovered="(hovered) => isHovered = hovered">
<b-card-body>
<div
class="card-img"
Expand Down
12 changes: 11 additions & 1 deletion packages/eos-components/src/components/ContentLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ export default {
type: String,
required: true,
},
nodeId: {
type: String,
required: false,
default: null,
},
},
emits: ['isHovered'],
methods: {
handleHover(hovered) {
this.$emit('isHovered', hovered);
},
onClick() {
this.$router.push(this.url);
if (this.nodeId) {
window.kolibri.navigateTo(this.nodeId);
}
else {
this.$router.push(this.url);
}
},
},
};
Expand Down