Skip to content

Commit

Permalink
Merge pull request #6 from learningequality/release-v0.16.x
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
nick2432 authored Jan 17, 2024
2 parents 8f442b4 + f24fdf3 commit 6ac05b6
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 71 deletions.
10 changes: 0 additions & 10 deletions kolibri/core/assets/src/views/CorePage/AppBarPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
class="app-bar"
:title="title"
@toggleSideNav="navShown = !navShown"
@showLanguageModal="languageModalShown = true"
>
<template #sub-nav>
<slot name="subNav"></slot>
Expand Down Expand Up @@ -44,12 +43,6 @@
@shouldFocusFirstEl="findFirstEl()"
/>
</transition>
<LanguageSwitcherModal
v-if="languageModalShown"
ref="languageSwitcherModal"
:style="{ color: $themeTokens.text }"
@cancel="languageModalShown = false"
/>

</div>

Expand All @@ -60,7 +53,6 @@
import { mapGetters } from 'vuex';
import { throttle } from 'frame-throttle';
import LanguageSwitcherModal from 'kolibri.coreVue.components.LanguageSwitcherModal';
import ScrollingHeader from 'kolibri.coreVue.components.ScrollingHeader';
import useKResponsiveWindow from 'kolibri.coreVue.composables.useKResponsiveWindow';
import SideNav from 'kolibri.coreVue.components.SideNav';
Expand All @@ -75,7 +67,6 @@
name: 'AppBarPage',
components: {
AppBar,
LanguageSwitcherModal,
ScrollingHeader,
SideNav,
StorageNotification,
Expand Down Expand Up @@ -110,7 +101,6 @@
data() {
return {
appBarHeight: 0,
languageModalShown: false,
navShown: false,
lastScrollTop: 0,
hideAppBars: true,
Expand Down
16 changes: 0 additions & 16 deletions kolibri/core/assets/test/views/app-bar-core-page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,4 @@ describe('AppBarPage', () => {
expect(wrapper.findComponent({ name: 'SideNav' }).vm.navShown).toBe(false);
});
});

describe('Toggling the language switcher modal', () => {
it('should show the side nav when the AppBar.showLanguageModal event is emitted', async () => {
const wrapper = createWrapper();
expect(wrapper.findComponent({ name: 'LanguageSwitcherModal' }).exists()).toBe(false);
await wrapper.vm.$refs.appBar.$emit('showLanguageModal');
expect(wrapper.findComponent({ name: 'LanguageSwitcherModal' }).exists()).toBe(true);
});
it('should hide the language switcher modal when LanguageSwitcherModal.cancel is emitted', async () => {
const wrapper = createWrapper();
await wrapper.setData({ languageModalShown: true });
expect(wrapper.findComponent({ name: 'LanguageSwitcherModal' }).exists()).toBe(true);
await wrapper.vm.$refs.languageSwitcherModal.$emit('cancel');
expect(wrapper.findComponent({ name: 'LanguageSwitcherModal' }).exists()).toBe(false);
});
});
});
2 changes: 1 addition & 1 deletion kolibri/core/content/utils/content_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def _get_import_metadata(client, contentnode_id):
return response.json()
except NetworkLocationResponseFailure as e:
# 400 level errors, like 404, are ignored
if e.response and 400 <= e.response.status_code < 500:
if e.response is not None and 400 <= e.response.status_code < 500:
logger.debug(
"Metadata request failure: GET {} {}".format(
url_path, e.response.status_code
Expand Down
5 changes: 4 additions & 1 deletion kolibri/plugins/coach/assets/src/composables/useCoreCoach.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import find from 'lodash/find';
import logger from 'kolibri.lib.logging';
import { get } from '@vueuse/core';
import { computed, getCurrentInstance } from 'kolibri.lib.vueCompositionApi';
import { currentLanguage, isRtl } from 'kolibri.utils.i18n';
import { coachStrings } from '../views/common/commonCoachStrings';

const logging = logger.getLogger(__filename);

export default function useCoreCoach(store) {
store = store || getCurrentInstance().proxy.$store;
const route = computed(() => store.state.route);
Expand Down Expand Up @@ -60,7 +63,7 @@ export default function useCoreCoach(store) {
return coachStrings.$tr(part);
}
} catch (err) {
console.error(
logging.error(
"Failed to obtain page title. Ensure that this route's meta.titleParts are corrrectly configured."
);
return '';
Expand Down
5 changes: 4 additions & 1 deletion kolibri/plugins/device/assets/src/modules/wizard/handlers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import find from 'lodash/find';
import router from 'kolibri.coreVue.router';
import logger from 'kolibri.lib.logging';
import samePageCheckGenerator from 'kolibri.utils.samePageCheckGenerator';
import { TransferTypes } from 'kolibri.utils.syncTaskUtils';
import { ContentNodeGranularResource, RemoteChannelResource } from 'kolibri.resources';
Expand All @@ -12,6 +13,8 @@ import {
} from './apiPeerImport';
import { getChannelWithContentSizes } from './apiChannelMetadata';

const logging = logger.getLogger(__filename);

// Utilities for the show*Page actions
function getSelectedDrive(store, driveId) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -168,7 +171,7 @@ export function showSelectContentPage(store, params) {
// are no data for this channel on a device yet (download channel
// metadata task will be triggered later for this situation)
if (error.response && error.response.status === 404) {
console.log(
logging.error(
`^^^ 404 (Not Found) error returned while requesting "${error.response.config.url}..." is an expected response.`
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@
import { mapGetters } from 'vuex';
import find from 'lodash/find';
import urls from 'kolibri.urls';
import logger from 'kolibri.lib.logging';
import { ref } from 'kolibri.lib.vueCompositionApi';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import UiAlert from 'kolibri-design-system/lib/keen/UiAlert';
Expand All @@ -374,6 +375,8 @@
import RemoveStorageLocationModal from './RemoveStorageLocationModal';
import ServerRestartModal from './ServerRestartModal';
const logging = logger.getLogger(__filename);
const SignInPageOptions = Object.freeze({
LOCKED_CONTENT: 'LOCKED_CONTENT',
DISALLOW_GUEST_ACCESS: 'DISALLOW_GUEST_ACCESS',
Expand Down Expand Up @@ -840,7 +843,7 @@
}
})
.catch(err => {
console.error(err);
logging.error(err);
this.$store.dispatch('createSnackbar', this.$tr('saveFailureNotification'));
});
},
Expand Down
5 changes: 4 additions & 1 deletion kolibri/plugins/facility/assets/src/routes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import store from 'kolibri.coreVue.vuex.store';
import router from 'kolibri.coreVue.router';
import logger from 'kolibri.lib.logging';
import VueRouter from 'vue-router';
import ManageSyncSchedule from 'kolibri-common/components/SyncSchedule/ManageSyncSchedule';
import EditDeviceSyncSchedule from 'kolibri-common/components/SyncSchedule/EditDeviceSyncSchedule';
Expand All @@ -25,6 +26,8 @@ import {
} from './modules/classAssignMembers/handlers';
import { PageNames } from './constants';

const logging = logger.getLogger(__filename);

function facilityParamRequiredGuard(toRoute, subtopicName) {
const { isNavigationFailure, NavigationFailureType } = VueRouter;
if (store.getters.userIsMultiFacilityAdmin && !toRoute.params.facility_id) {
Expand All @@ -35,7 +38,7 @@ function facilityParamRequiredGuard(toRoute, subtopicName) {
})
.catch(e => {
if (!isNavigationFailure(e, NavigationFailureType.duplicated)) {
console.debug(e);
logging.debug(e);
throw Error(e);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
// Original line: 17

import { renderTextLayer } from 'pdfjs-dist/legacy/build/pdf';
import logger from 'kolibri.lib.logging';

const logging = logger.getLogger(__filename);

const EXPAND_DIVS_TIMEOUT = 300; // ms

Expand Down Expand Up @@ -150,7 +153,7 @@ class TextLayerBuilder {
// Modified: Logging errors
// Original line: 118
err => {
console.error('Error rendering text layer: ', err);
logging.error('Error rendering text layer: ', err);
}
);
}
Expand Down
15 changes: 9 additions & 6 deletions kolibri/plugins/pdf_viewer/assets/src/views/PdfRendererIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
import Hammer from 'hammerjs';
import throttle from 'lodash/throttle';
import debounce from 'lodash/debounce';
import logger from 'kolibri.lib.logging';
import { RecycleList } from 'vue-virtual-scroller';
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
// polyfill necessary for recycle list
Expand All @@ -134,6 +135,8 @@
import PdfPage from './PdfPage';
import SideBar from './SideBar';
const logging = logger.getLogger(__filename);
// How often should we respond to changes in scrolling to render new pages?
const renderDebounceTime = 300;
const scaleIncrement = 0.25;
Expand Down Expand Up @@ -512,13 +515,13 @@
Promise.resolve(dest === 'string' ? this.pdfDocument.getDestination(dest) : dest).then(
explicitDest => {
if (!Array.isArray(explicitDest)) {
console.error('Error getting destination');
logging.error('Error getting destination');
return;
}
this.getDestinationPageNumber(explicitDest).then(pageNumber => {
if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
console.error('Invalid destination page');
logging.error('Invalid destination page');
return;
}
Expand Down Expand Up @@ -549,13 +552,13 @@
Promise.resolve(dest === 'string' ? this.pdfDocument.getDestination(dest) : dest).then(
explicitDest => {
if (!Array.isArray(explicitDest)) {
console.error('Error getting destination');
logging.error('Error getting destination');
return;
}
this.getDestinationPageNumber(explicitDest).then(pageNumber => {
if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
console.error('Invalid destination page');
logging.error('Invalid destination page');
return;
}
Expand Down Expand Up @@ -618,14 +621,14 @@
resolve(pageIndex + 1);
})
.catch(e => {
console.error('Error getting destination page number', e);
logging.error('Error getting destination page number', e);
resolve();
});
}
if (Number.isInteger(destRef)) {
return resolve(destRef + 1);
}
console.error('Invalid destination reference');
logging.error('Invalid destination reference');
resolve();
});
},
Expand Down
6 changes: 4 additions & 2 deletions packages/hashi/downloadH5PVendor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const targetFolder = path.resolve(__dirname, './vendor/h5p');

const h5pStaticFolder = path.resolve(__dirname, '../../kolibri/core/content/static/h5p');

const logging = console; // eslint-disable-line no-console

const fileManifest = [
/styles\/h5p\.css/,
/styles\/h5p-core-button\.css/,
Expand All @@ -33,7 +35,7 @@ const fileManifest = [
function downloadFiles() {
https.get(url.parse(zipUrl), function(res) {
if (res.statusCode !== 200) {
console.log(res);
logging.log(res);
// handle error
return;
}
Expand Down Expand Up @@ -98,7 +100,7 @@ function downloadFiles() {
);
})
.then(() => {
console.log(`${i} files downloaded and unpacked`);
logging.log(`${i} files downloaded and unpacked`);
});
});
});
Expand Down
10 changes: 6 additions & 4 deletions packages/hashi/src/H5P/H5PRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import loadBinary from './loadBinary';

const H5PFilename = filenameObj.filename;

const logging = console; //eslint-disable-line no-console

class Zip {
constructor(file) {
this.zipfile = file;
Expand Down Expand Up @@ -104,7 +106,7 @@ export function replacePaths(dep, packageFiles) {
return `${p1}${newUrl}${p3}`;
}
} catch (e) {
console.debug('Error during URL handling', e); // eslint-disable-line no-console
logging.debug('Error during URL handling', e);
}
// Otherwise just return the match so that it is unchanged.
return match;
Expand Down Expand Up @@ -220,7 +222,7 @@ export default class H5PRunner {
// dependencies have been loaded.
this.setDependencies();
return this.processFiles().then(() => {
console.debug(`H5P file processed in ${performance.now() - start} ms`);
logging.debug(`H5P file processed in ${performance.now() - start} ms`);
this.metadata = pick(this.rootConfig, metadataKeys);
// Do any URL substitition on CSS dependencies
// and turn them into Blob URLs.
Expand Down Expand Up @@ -381,7 +383,7 @@ export default class H5PRunner {
debouncedHandlers[verb] = debounce(
function(statement) {
contentWindow.xAPI.sendStatement(statement, true).catch(err => {
console.error('Statement: ', statement, 'gave the following error: ', err);
logging.error('Statement: ', statement, 'gave the following error: ', err);
});
},
debounceDelay * 1000,
Expand Down Expand Up @@ -412,7 +414,7 @@ export default class H5PRunner {
debouncedHandlers[statement.verb.id](statement);
} else {
contentWindow.xAPI.sendStatement(event.data.statement, true).catch(err => {
console.error('Statement: ', statement, 'gave the following error: ', err);
logging.error('Statement: ', statement, 'gave the following error: ', err);
});
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/hashi/src/h5pBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import '../vendor/h5p/styles/h5p.css';
import '../vendor/h5p/styles/h5p-core-button.css';
import '../vendor/h5p/styles/h5p-confirmation-dialog.css';

const logging = console; //elsint-disable-line no-console

window.H5P = {
jQuery,
// H5P complains if this is undefined, but because of our monkey patching
Expand All @@ -30,7 +32,7 @@ window.H5P.jQuery.fn.load = function(url) {
* now is elem.on('load', fn)
*/
if (typeof url === 'function') {
console.warn('You are using a deprecated H5P library. Please upgrade!');
logging.warn('You are using a deprecated H5P library. Please upgrade!');
const args = Array.prototype.slice.call(arguments);
args.unshift('load');
return window.H5P.jQuery.fn.on.apply(this, args);
Expand Down
6 changes: 4 additions & 2 deletions packages/hashi/src/iframeClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { events, nameSpace } from './hashiBase';
import H5P from './H5P/H5PInterface';
import xAPI from './xAPI/xAPIInterface';

const logging = console; //eslint-disable-line no-console

/*
* This class is initialized inside the context of a sandboxed iframe.
* It provides shims for various APIs that would otherwise be blocked
Expand Down Expand Up @@ -82,8 +84,8 @@ export default class SandboxEnvironment {
this.xAPI.iframeInitialize(this.iframe.contentWindow);
patchIndexedDB(this.contentNamespace, this.iframe.contentWindow);
} catch (e) {
console.debug(e);
console.log('Shimming storage APIs failed, data will not persist'); // eslint-disable-line no-console
logging.debug(e);
logging.log('Shimming storage APIs failed, data will not persist');
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/hashi/src/xAPI/xAPIInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import BaseShim from '../baseShim';
import { XAPIVerbMap } from './xAPIVocabulary';
import { OBJECT_TYPES } from './xAPIConstants';

const logging = console; //eslint-disable-line no-console

function actorsEqual(actor1, actor2) {
if (actor1.mbox && actor2.mbox) {
return actor1.mbox === actor2.mbox;
Expand Down Expand Up @@ -286,7 +288,7 @@ export default class xAPI extends BaseShim {
try {
statement = Statement.clean(statement);
} catch (e) {
console.debug('Statement: ', statement, 'gave the following error: ', e);
logging.debug('Statement: ', statement, 'gave the following error: ', e);
statement.error = e.message;
}
if (compress) {
Expand Down
Loading

0 comments on commit 6ac05b6

Please sign in to comment.