Skip to content

Commit b13806f

Browse files
committed
Use Learn content viewer when available
If the Learn plugin is present, build a URL with the content ID and navigate to it. Also pass the current location as URL parameter. If the Learn plugin can handle that parameter, it should use it to navigate back. If the Learn plugin is not present (no URL matching) display the content in a lightbox modal as before. https://phabricator.endlessm.com/T34740
1 parent f44b788 commit b13806f

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

kolibri_explore_plugin/assets/src/kolibriApi.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ContentNodeKinds } from 'kolibri.coreVue.vuex.constants';
66
import router from 'kolibri.coreVue.router';
77
import store from 'kolibri.coreVue.vuex.store';
88
import { utils } from 'eos-components';
9-
import { showTopicsContentInLightbox } from './modules/topicsTree/handlers';
9+
import { showTopicsContent } from './modules/topicsTree/handlers';
1010
import { PageNames } from './constants';
1111
import { getChannelIcon } from './customApps';
1212

@@ -39,7 +39,7 @@ class KolibriApi {
3939
}
4040

4141
navigateTo(nodeId) {
42-
showTopicsContentInLightbox(store, nodeId);
42+
showTopicsContent(store, nodeId);
4343
}
4444

4545
closeCustomPresentation() {

kolibri_explore_plugin/assets/src/modules/topicsTree/handlers.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function showTopicsChannel(store, id) {
127127
});
128128
}
129129

130-
export function showTopicsContentInLightbox(store, id) {
130+
function showTopicsContentInLightbox(store, id) {
131131
const promises = [ContentNodeResource.fetchModel({ id }), store.dispatch('setChannelInfo')];
132132
const shouldResolve = samePageCheckGenerator(store);
133133
Promise.all(promises).then(
@@ -161,6 +161,22 @@ export function showTopicsContentInLightbox(store, id) {
161161
);
162162
}
163163

164-
export function hideTopicsContentFromLightbox(store) {
164+
function showTopicsContentInLearnTab(learnUrl, id) {
165+
// Pass current URL as prevName:
166+
const prevName = encodeURIComponent(window.location.href);
167+
const contentViewerUrl = `${learnUrl()}#/topics/c/${id}?prevName=${prevName}`;
168+
window.location.replace(contentViewerUrl);
169+
}
170+
171+
export function showTopicsContent(store, id) {
172+
const learnUrl = urls['kolibri:kolibri.plugins.learn:learn'];
173+
if (learnUrl) {
174+
showTopicsContentInLearnTab(learnUrl, id);
175+
} else {
176+
showTopicsContentInLightbox(store, id);
177+
}
178+
}
179+
180+
export function hideTopicsContent(store) {
165181
store.commit('topicsTree/RESET_CONTENT');
166182
}

kolibri_explore_plugin/assets/src/views/ContentModal.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
2121
import { mapState } from 'vuex';
2222
import { responsiveMixin } from 'eos-components';
23-
import {
24-
hideTopicsContentFromLightbox,
25-
showTopicsContentInLightbox,
26-
} from '../modules/topicsTree/handlers';
23+
import { hideTopicsContent, showTopicsContent } from '../modules/topicsTree/handlers';
2724
import ContentItem from './ContentItem';
2825
2926
export default {
@@ -86,10 +83,10 @@
8683
},
8784
8885
goToContent(id) {
89-
showTopicsContentInLightbox(this.$store, id);
86+
showTopicsContent(this.$store, id);
9087
},
9188
onClose() {
92-
hideTopicsContentFromLightbox(this.$store);
89+
hideTopicsContent(this.$store);
9390
},
9491
},
9592
};

0 commit comments

Comments
 (0)