From 16a0d5723651e744d2235272efe72a8de3bbf996 Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Thu, 4 Apr 2019 09:16:07 +0200 Subject: [PATCH 01/13] Implement no unused properties eslint rule --- .../lib/rules/vue-no-unused-properties.js | 138 ++++ .../rules/vue-no-unused-properties.spec.js | 668 ++++++++++++++++++ 2 files changed, 806 insertions(+) create mode 100644 packages/eslint-plugin-kolibri/lib/rules/vue-no-unused-properties.js create mode 100644 packages/eslint-plugin-kolibri/tests/lib/rules/vue-no-unused-properties.spec.js diff --git a/packages/eslint-plugin-kolibri/lib/rules/vue-no-unused-properties.js b/packages/eslint-plugin-kolibri/lib/rules/vue-no-unused-properties.js new file mode 100644 index 00000000000..43ce9b7be2d --- /dev/null +++ b/packages/eslint-plugin-kolibri/lib/rules/vue-no-unused-properties.js @@ -0,0 +1,138 @@ +/** + * @fileoverview Disallow unused properties, data or computed properties. + */ + +'use strict'; + +const remove = require('lodash/remove'); +const utils = require('eslint-plugin-vue/lib/utils'); + +const getReferencesNames = references => { + if (!references || !references.length) { + return []; + } + + return references.map(reference => { + if (!reference.id || !reference.id.name) { + return; + } + + return reference.id.name; + }); +}; + +const reportUnusedProperties = (context, properties) => { + if (!properties || !properties.length) { + return; + } + + properties.forEach(property => { + let kind = 'property'; + if (property.groupName === 'data') { + kind = 'data'; + } else if (property.groupName === 'computed') { + kind = 'computed property'; + } + + context.report({ + node: property.node, + message: `Unused ${kind} found: "${property.name}"`, + }); + }); +}; + +const create = context => { + let hasTemplate; + let rootTemplateEnd; + let unusedProperties = []; + let thisExpressionsVariablesNames = []; + + const initialize = { + Program(node) { + if (context.parserServices.getTemplateBodyTokenStore == null) { + context.report({ + loc: { line: 1, column: 0 }, + message: + 'Use the latest vue-eslint-parser. See also https://vuejs.github.io/eslint-plugin-vue/user-guide/#what-is-the-use-the-latest-vue-eslint-parser-error.', + }); + return; + } + + hasTemplate = Boolean(node.templateBody); + }, + }; + + const scriptVisitor = Object.assign( + {}, + { + 'MemberExpression[object.type="ThisExpression"][property.type="Identifier"][property.name]'( + node + ) { + thisExpressionsVariablesNames.push(node.property.name); + }, + }, + utils.executeOnVue(context, obj => { + unusedProperties = Array.from( + utils.iterateProperties(obj, new Set(['props', 'data', 'computed'])) + ); + + const watchers = Array.from(utils.iterateProperties(obj, new Set(['watch']))); + const watchersNames = watchers.map(watcher => watcher.name); + + remove(unusedProperties, property => { + return ( + thisExpressionsVariablesNames.includes(property.name) || + watchersNames.includes(property.name) + ); + }); + + if (!hasTemplate && unusedProperties.length) { + reportUnusedProperties(context, unusedProperties); + } + }) + ); + + const templateVisitor = { + 'VExpressionContainer[expression!=null][references]'(node) { + const referencesNames = getReferencesNames(node.references); + + remove(unusedProperties, property => { + return referencesNames.includes(property.name); + }); + }, + // save root template end location - just a helper to be used + // for a decision if a parser reached the end of the root template + "VElement[name='template']"(node) { + if (rootTemplateEnd) { + return; + } + + rootTemplateEnd = node.loc.end; + }, + "VElement[name='template']:exit"(node) { + if (node.loc.end !== rootTemplateEnd) { + return; + } + + if (unusedProperties.length) { + reportUnusedProperties(context, unusedProperties); + } + }, + }; + + return Object.assign( + {}, + initialize, + utils.defineTemplateBodyVisitor(context, templateVisitor, scriptVisitor) + ); +}; + +module.exports = { + meta: { + docs: { + description: 'Disallow unused properties, data or computed properties', + }, + fixable: null, + }, + create, +}; diff --git a/packages/eslint-plugin-kolibri/tests/lib/rules/vue-no-unused-properties.spec.js b/packages/eslint-plugin-kolibri/tests/lib/rules/vue-no-unused-properties.spec.js new file mode 100644 index 00000000000..b14ea1463f6 --- /dev/null +++ b/packages/eslint-plugin-kolibri/tests/lib/rules/vue-no-unused-properties.spec.js @@ -0,0 +1,668 @@ +'use strict'; + +const RuleTester = require('eslint').RuleTester; +const rule = require('../../../lib/rules/vue-no-unused-properties'); + +const tester = new RuleTester({ + parser: 'vue-eslint-parser', + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, +}); + +tester.run('vue-no-unused-properties', rule, { + valid: [ + // a property used in a script expression + { + filename: 'test.vue', + code: ` + + `, + }, + + // a property being watched + { + filename: 'test.vue', + code: ` + + `, + }, + + // a property used as a template identifier + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // properties used in a template expression + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // a property used in v-if + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // a property used in v-for + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // a property used in v-html + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // a property passed in a component + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // a property used in v-on + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // data used in a script expression + { + filename: 'test.vue', + code: ` + + `, + }, + + // data being watched + { + filename: 'test.vue', + code: ` + + `, + }, + + // data used as a template identifier + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // data used in a template expression + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // data used in v-if + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // data used in v-for + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // data used in v-html + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // data used in v-model + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // data passed in a component + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // data used in v-on + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // computed property used in a script expression + { + filename: 'test.vue', + code: ` + + `, + }, + + // computed property being watched + { + filename: 'test.vue', + code: ` + + `, + }, + + // computed property used as a template identifier + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // computed properties used in a template expression + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // computed property used in v-if + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // computed property used in v-for + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // computed property used in v-html + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // computed property used in v-model + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // computed property passed in a component + { + filename: 'test.vue', + code: ` + + + + `, + }, + + // ignores unused data when marked with eslint-disable + { + filename: 'test.vue', + code: ` + + + + `, + }, + ], + + invalid: [ + // unused property + { + filename: 'test.vue', + code: ` + + + + `, + errors: [ + { + message: 'Unused property found: "count"', + line: 8, + }, + ], + }, + + // unused data + { + filename: 'test.vue', + code: ` + + + + `, + errors: [ + { + message: 'Unused data found: "count"', + line: 10, + }, + ], + }, + + // unused computed property + { + filename: 'test.vue', + code: ` + + + + `, + errors: [ + { + message: 'Unused computed property found: "count"', + line: 9, + }, + ], + }, + ], +}); From b2d6002820ebd2a60df8520bab6d29126d6488e1 Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sat, 6 Apr 2019 16:36:29 +0200 Subject: [PATCH 02/13] Turn on vue-no-unused-properties --- packages/kolibri-tools/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/kolibri-tools/.eslintrc.js b/packages/kolibri-tools/.eslintrc.js index 2881d6ca349..a3d1793949f 100644 --- a/packages/kolibri-tools/.eslintrc.js +++ b/packages/kolibri-tools/.eslintrc.js @@ -121,5 +121,6 @@ module.exports = { // Custom vue rules 'kolibri/vue-filename-and-component-name-match': ERROR, 'kolibri/vue-component-registration-casing': ERROR, + 'kolibri/vue-no-unused-properties': ERROR, }, }; From 055bfc369a1b1db6b31d29896f8bb7f549ed9287 Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sat, 6 Apr 2019 16:48:36 +0200 Subject: [PATCH 03/13] Remove unused properties --- .../core/assets/src/views/ContentRenderer/index.vue | 12 ------------ .../core/assets/src/views/ExamReport/PageStatus.vue | 4 ---- .../core/assets/src/views/KSelect/KeenUiSelect.vue | 8 -------- kolibri/core/assets/src/views/KTooltip/Popper.vue | 1 - kolibri/core/assets/src/views/icons/KLabeledIcon.vue | 9 --------- kolibri/core/assets/test/views/KTooltipExample.vue | 5 ----- .../assets/src/views/common/HeaderTabs/HeaderTab.vue | 5 ----- .../src/views/common/notifications/ActivityList.vue | 1 - .../src/views/home/HomePage/ItemProgressDisplay.vue | 4 ---- .../assets/src/views/plan/CoachExamsPage/index.vue | 5 +---- .../views/plan/CreateExamPage/CreateExamPreview.vue | 7 ------- .../assets/src/views/plan/GroupEnrollPage/index.vue | 6 ------ .../plan/LessonContentPreviewPage/ContentArea.vue | 5 ----- .../plan/LessonContentPreviewPage/QuestionList.vue | 7 ------- .../assets/src/views/plan/LessonsRootPage/index.vue | 7 +------ ...portsGroupReportLessonExerciseLearnerListPage.vue | 3 --- ...portsGroupReportLessonResourceLearnerListPage.vue | 3 --- .../views/reports/ReportsGroupReportQuizHeader.vue | 3 --- .../src/views/reports/ReportsLessonEditorPage.vue | 10 ---------- .../src/views/reports/ReportsQuizEditorPage.vue | 10 ---------- .../SelectTransferSourceModal/SelectDriveModal.vue | 1 - .../src/views/ManageContentPage/TaskProgress.vue | 1 - .../views/SelectContentPage/ContentTreeViewer.vue | 6 ------ .../assets/src/views/PdfRendererIndex.vue | 6 ------ .../assets/src/views/ClassEnrollForm.vue | 7 ------- .../assets/src/views/DataPage/index.vue | 8 -------- .../assets/src/views/UserPage/DeleteUserModal.vue | 4 ---- .../src/views/UserPage/ResetUserPasswordModal.vue | 4 ---- .../assets/src/views/UserTable.vue | 3 --- .../plugins/learn/assets/src/views/ContentPage.vue | 8 -------- kolibri/plugins/learn/assets/src/views/SearchBox.vue | 1 - kolibri/plugins/user/assets/src/views/SignUpPage.vue | 4 ---- kolibri/plugins/user/assets/src/views/UserIndex.vue | 3 --- 33 files changed, 2 insertions(+), 169 deletions(-) diff --git a/kolibri/core/assets/src/views/ContentRenderer/index.vue b/kolibri/core/assets/src/views/ContentRenderer/index.vue index e10cc135d70..cfd77547373 100644 --- a/kolibri/core/assets/src/views/ContentRenderer/index.vue +++ b/kolibri/core/assets/src/views/ContentRenderer/index.vue @@ -67,10 +67,6 @@ UiAlert, }, props: { - id: { - type: String, - required: true, - }, kind: { type: String, required: true, @@ -79,14 +75,6 @@ type: Array, default: () => [], }, - contentId: { - type: String, - default: '', - }, - channelId: { - type: String, - default: '', - }, available: { type: Boolean, default: false, diff --git a/kolibri/core/assets/src/views/ExamReport/PageStatus.vue b/kolibri/core/assets/src/views/ExamReport/PageStatus.vue index 751bb35492f..1b73e4db2d9 100644 --- a/kolibri/core/assets/src/views/ExamReport/PageStatus.vue +++ b/kolibri/core/assets/src/views/ExamReport/PageStatus.vue @@ -43,7 +43,6 @@ import KGridItem from 'kolibri.coreVue.components.KGridItem'; import ProgressIcon from 'kolibri.coreVue.components.ProgressIcon'; import ElapsedTime from 'kolibri.coreVue.components.ElapsedTime'; - import { ContentNodeKinds } from 'kolibri.coreVue.vuex.constants'; import KLabeledIcon from 'kolibri.coreVue.components.KLabeledIcon'; import KIcon from 'kolibri.coreVue.components.KIcon'; @@ -96,9 +95,6 @@ // Either return in completed or in progress return this.completed ? 1 : 0.1; }, - kind() { - return ContentNodeKinds.EXAM; - }, }, }; diff --git a/kolibri/core/assets/src/views/KSelect/KeenUiSelect.vue b/kolibri/core/assets/src/views/KSelect/KeenUiSelect.vue index 91dcd099f52..d6ed7ff6562 100644 --- a/kolibri/core/assets/src/views/KSelect/KeenUiSelect.vue +++ b/kolibri/core/assets/src/views/KSelect/KeenUiSelect.vue @@ -389,14 +389,6 @@ return this.options.findIndex(option => looseEqual(this.highlightedOption, option)); }, - // Returns the index of the currently selected option, -1 if multi-select - selectedIndex() { - if (this.multiple) { - return -1; - } - return this.options.findIndex(option => looseEqual(this.value, option)); - }, - // Returns an array containing the options and extra annotations annotatedOptions() { const options = JSON.parse(JSON.stringify(this.options)); diff --git a/kolibri/core/assets/src/views/KTooltip/Popper.vue b/kolibri/core/assets/src/views/KTooltip/Popper.vue index 3ca8f7eb7ea..167124e09de 100644 --- a/kolibri/core/assets/src/views/KTooltip/Popper.vue +++ b/kolibri/core/assets/src/views/KTooltip/Popper.vue @@ -185,7 +185,6 @@ referenceElm: null, popperJS: null, showPopper: false, - currentPlacement: '', popperOptions: { placement: 'bottom', computeStyle: { diff --git a/kolibri/core/assets/src/views/icons/KLabeledIcon.vue b/kolibri/core/assets/src/views/icons/KLabeledIcon.vue index 966884bc897..4704ec829e6 100644 --- a/kolibri/core/assets/src/views/icons/KLabeledIcon.vue +++ b/kolibri/core/assets/src/views/icons/KLabeledIcon.vue @@ -17,15 +17,6 @@ export default { name: 'KLabeledIcon', components: {}, - props: { - /** - * Whether the label should wrap - */ - nowrap: { - type: Boolean, - default: false, - }, - }, }; diff --git a/kolibri/core/assets/test/views/KTooltipExample.vue b/kolibri/core/assets/test/views/KTooltipExample.vue index 0974367ef7e..01ca796acc1 100644 --- a/kolibri/core/assets/test/views/KTooltipExample.vue +++ b/kolibri/core/assets/test/views/KTooltipExample.vue @@ -32,11 +32,6 @@ required: false, default: () => {}, }, - kTooltipText: { - type: String, - required: false, - default: '', - }, }, }; diff --git a/kolibri/plugins/coach/assets/src/views/common/HeaderTabs/HeaderTab.vue b/kolibri/plugins/coach/assets/src/views/common/HeaderTabs/HeaderTab.vue index cf6d1d34f62..0056cb292c3 100644 --- a/kolibri/plugins/coach/assets/src/views/common/HeaderTabs/HeaderTab.vue +++ b/kolibri/plugins/coach/assets/src/views/common/HeaderTabs/HeaderTab.vue @@ -33,11 +33,6 @@ required: true, }, }, - data() { - return { - active: null, - }; - }, computed: { activeClasses() { // return both fixed and dynamic classes diff --git a/kolibri/plugins/coach/assets/src/views/common/notifications/ActivityList.vue b/kolibri/plugins/coach/assets/src/views/common/notifications/ActivityList.vue index 0b3c8b00e5e..1c569f7bd7b 100644 --- a/kolibri/plugins/coach/assets/src/views/common/notifications/ActivityList.vue +++ b/kolibri/plugins/coach/assets/src/views/common/notifications/ActivityList.vue @@ -104,7 +104,6 @@ data() { return { loading: true, - error: false, moreResults: true, nextPage: 1, progressFilter: 'all', diff --git a/kolibri/plugins/coach/assets/src/views/home/HomePage/ItemProgressDisplay.vue b/kolibri/plugins/coach/assets/src/views/home/HomePage/ItemProgressDisplay.vue index ec61000adfe..3b3453ba0e8 100644 --- a/kolibri/plugins/coach/assets/src/views/home/HomePage/ItemProgressDisplay.vue +++ b/kolibri/plugins/coach/assets/src/views/home/HomePage/ItemProgressDisplay.vue @@ -58,10 +58,6 @@ type: Object, required: true, }, - isLast: { - type: Boolean, - default: false, - }, to: { type: Object, required: false, diff --git a/kolibri/plugins/coach/assets/src/views/plan/CoachExamsPage/index.vue b/kolibri/plugins/coach/assets/src/views/plan/CoachExamsPage/index.vue index 0db75088703..29729e6b5e7 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CoachExamsPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CoachExamsPage/index.vue @@ -138,7 +138,7 @@ import KRouterLink from 'kolibri.coreVue.components.KRouterLink'; import KSelect from 'kolibri.coreVue.components.KSelect'; import CoreInfoIcon from 'kolibri.coreVue.components.CoreInfoIcon'; - import { ContentNodeKinds, ERROR_CONSTANTS } from 'kolibri.coreVue.vuex.constants'; + import { ERROR_CONSTANTS } from 'kolibri.coreVue.vuex.constants'; import { crossComponentTranslator } from 'kolibri.utils.i18n'; import CatchErrors from 'kolibri.utils.CatchErrors'; import KLabeledIcon from 'kolibri.coreVue.components.KLabeledIcon'; @@ -216,9 +216,6 @@ manageExamModalStrings() { return manageExamModalStrings; }, - examKind() { - return ContentNodeKinds.EXAM; - }, sortedExams() { return this.exams.slice().reverse(); }, diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/CreateExamPreview.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/CreateExamPreview.vue index 42ee2d2fed5..17f8947c049 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/CreateExamPreview.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/CreateExamPreview.vue @@ -300,13 +300,6 @@ previewQuizStrings() { return previewQuizStrings; }, - draggableOptions() { - return { - animation: 150, - touchStartThreshold: 3, - direction: 'vertical', - }; - }, currentQuestion() { return this.selectedQuestions[this.currentQuestionIndex] || {}; }, diff --git a/kolibri/plugins/coach/assets/src/views/plan/GroupEnrollPage/index.vue b/kolibri/plugins/coach/assets/src/views/plan/GroupEnrollPage/index.vue index 1a56f77ed5c..277dbef43be 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/GroupEnrollPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/GroupEnrollPage/index.vue @@ -166,9 +166,6 @@ usersNotInClass() { return differenceWith(this.classUsers, this.currentGroupUsers, (a, b) => a.id === b.id); }, - filteredUsers() { - return this.usersNotInClass.filter(user => userMatchesFilter(user, this.filterInput)); - }, sortedFilteredUsers() { return filterAndSortUsers(this.usersNotInClass, user => userMatchesFilter(user, this.filterInput) @@ -195,9 +192,6 @@ visibleFilteredUsers() { return this.sortedFilteredUsers.slice(this.startRange, this.endRange); }, - showConfirmEnrollmentModal() { - return this.modalShown === true; - }, emptyMessage() { if (this.classUsers.length === 0) { return this.$tr('noUsersExist'); diff --git a/kolibri/plugins/coach/assets/src/views/plan/LessonContentPreviewPage/ContentArea.vue b/kolibri/plugins/coach/assets/src/views/plan/LessonContentPreviewPage/ContentArea.vue index 52426691295..698de9cb953 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/LessonContentPreviewPage/ContentArea.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/LessonContentPreviewPage/ContentArea.vue @@ -55,11 +55,6 @@ default: '', }, }, - computed: { - hasHeader() { - return Boolean(this.header); - }, - }, }; diff --git a/kolibri/plugins/coach/assets/src/views/plan/LessonContentPreviewPage/QuestionList.vue b/kolibri/plugins/coach/assets/src/views/plan/LessonContentPreviewPage/QuestionList.vue index eedd0eb9876..366f8d6666e 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/LessonContentPreviewPage/QuestionList.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/LessonContentPreviewPage/QuestionList.vue @@ -60,13 +60,6 @@ validator: value => typeof value(0) === 'string', }, }, - computed: { - buttonAndHeaderBorder() { - return { - borderBottom: `2px solid ${this.$coreTextDisabled}`, - }; - }, - }, }; diff --git a/kolibri/plugins/coach/assets/src/views/plan/LessonsRootPage/index.vue b/kolibri/plugins/coach/assets/src/views/plan/LessonsRootPage/index.vue index 424bf305e0a..0ae3642d0dd 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/LessonsRootPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/LessonsRootPage/index.vue @@ -109,11 +109,7 @@ import KSelect from 'kolibri.coreVue.components.KSelect'; import KLabeledIcon from 'kolibri.coreVue.components.KLabeledIcon'; import KIcon from 'kolibri.coreVue.components.KIcon'; - import { - ContentNodeKinds, - CollectionKinds, - ERROR_CONSTANTS, - } from 'kolibri.coreVue.vuex.constants'; + import { CollectionKinds, ERROR_CONSTANTS } from 'kolibri.coreVue.vuex.constants'; import CatchErrors from 'kolibri.utils.CatchErrors'; import { crossComponentTranslator } from 'kolibri.utils.i18n'; import LessonActive from '../../common/LessonActive'; @@ -148,7 +144,6 @@ data() { return { showModal: false, - lessonKind: ContentNodeKinds.LESSON, filterSelection: {}, }; }, diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonExerciseLearnerListPage.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonExerciseLearnerListPage.vue index c7b29043110..4d0ca5804e3 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonExerciseLearnerListPage.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonExerciseLearnerListPage.vue @@ -73,9 +73,6 @@ }, mixins: [commonCoach], computed: { - lesson() { - return this.lessonMap[this.$route.params.lessonId]; - }, recipients() { return this.getLearnersForGroups([this.$route.params.groupId]); }, diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonResourceLearnerListPage.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonResourceLearnerListPage.vue index 6480d4bdb89..5b3ce6c9b99 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonResourceLearnerListPage.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonResourceLearnerListPage.vue @@ -98,9 +98,6 @@ recipients() { return this.getLearnersForGroups([this.$route.params.groupId]); }, - avgTime() { - return this.getContentAvgTimeSpent(this.$route.params.resourceId, this.recipients); - }, tally() { return this.getContentStatusTally(this.$route.params.resourceId, this.recipients); }, diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportQuizHeader.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportQuizHeader.vue index 86060901e2d..0cc3dec8485 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportQuizHeader.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportQuizHeader.vue @@ -73,9 +73,6 @@ recipients() { return this.getLearnersForGroups([this.$route.params.groupId]); }, - tally() { - return this.getExamStatusTally(this.exam.id, this.recipients); - }, }, $trs: { back: 'All quizzes', diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonEditorPage.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonEditorPage.vue index 7c370293894..e862ea6573e 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonEditorPage.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonEditorPage.vue @@ -33,16 +33,6 @@ LessonDetailEditor, }, mixins: [commonCoach], - data() { - return { - lessonTitle: 'Lesson A', - lessonDescription: 'Ipsum lorem', - selectedCollectionIds: ['a'], - availableGroups: [{ name: 'Group A', id: 'a' }, { name: 'Group B', id: 'b' }], - selectedClassroomId: 'x', - isActive: true, - }; - }, $trs: {}, }; diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizEditorPage.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizEditorPage.vue index a569ab38eec..6a11707b28f 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizEditorPage.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizEditorPage.vue @@ -30,16 +30,6 @@ QuizDetailEditor, }, mixins: [commonCoach], - data() { - return { - lessonTitle: 'Lesson A', - lessonDescription: 'Ipsum lorem', - selectedCollectionIds: ['a'], - availableGroups: [{ name: 'Group A', id: 'a' }, { name: 'Group B', id: 'b' }], - selectedClassroomId: 'x', - isActive: true, - }; - }, $trs: {}, }; diff --git a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectTransferSourceModal/SelectDriveModal.vue b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectTransferSourceModal/SelectDriveModal.vue index f0638ce64a4..5f417bd6ebf 100644 --- a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectTransferSourceModal/SelectDriveModal.vue +++ b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectTransferSourceModal/SelectDriveModal.vue @@ -58,7 +58,6 @@ return { driveStatus: '', selectedDriveId: '', - showError: false, }; }, computed: { diff --git a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue index ad3d98d39bd..2125b7f4ec3 100644 --- a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue +++ b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue @@ -82,7 +82,6 @@ type: Number, required: true, }, - id: RequiredString, cancellable: { type: Boolean, required: true, diff --git a/kolibri/plugins/device_management/assets/src/views/SelectContentPage/ContentTreeViewer.vue b/kolibri/plugins/device_management/assets/src/views/SelectContentPage/ContentTreeViewer.vue index 89d388b22f8..7708b905cce 100644 --- a/kolibri/plugins/device_management/assets/src/views/SelectContentPage/ContentTreeViewer.vue +++ b/kolibri/plugins/device_management/assets/src/views/SelectContentPage/ContentTreeViewer.vue @@ -61,7 +61,6 @@ import KCheckbox from 'kolibri.coreVue.components.KCheckbox'; import KBreadcrumbs from 'kolibri.coreVue.components.KBreadcrumbs'; import { ContentNodeKinds } from 'kolibri.coreVue.vuex.constants'; - import last from 'lodash/last'; import every from 'lodash/every'; import omit from 'lodash/omit'; import { navigateToTopicUrl } from '../../routes/wizardTransitionRoutes'; @@ -157,11 +156,6 @@ !this.inExportMode ); }, - breadcrumbItems() { - const items = [...this.breadcrumbs]; - delete last(items).link; - return items; - }, }, methods: { ...mapActions('manageContent/wizard', ['addNodeForTransfer', 'removeNodeForTransfer']), diff --git a/kolibri/plugins/document_pdf_render/assets/src/views/PdfRendererIndex.vue b/kolibri/plugins/document_pdf_render/assets/src/views/PdfRendererIndex.vue index 0cf375398eb..93f1344252f 100644 --- a/kolibri/plugins/document_pdf_render/assets/src/views/PdfRendererIndex.vue +++ b/kolibri/plugins/document_pdf_render/assets/src/views/PdfRendererIndex.vue @@ -125,18 +125,12 @@ }), computed: { ...mapGetters(['sessionTimeSpent']), - pdfURL() { - return this.defaultFile.storage_url; - }, targetTime() { return this.totalPages * 30; }, documentLoading() { return this.progress < 1; }, - pdfPositionKey() { - return `pdfPosition-${this.files[0].id}`; - }, itemHeight() { return this.firstPageHeight * this.scale + MARGIN; }, diff --git a/kolibri/plugins/facility_management/assets/src/views/ClassEnrollForm.vue b/kolibri/plugins/facility_management/assets/src/views/ClassEnrollForm.vue index 51d49d84720..3650208e91a 100644 --- a/kolibri/plugins/facility_management/assets/src/views/ClassEnrollForm.vue +++ b/kolibri/plugins/facility_management/assets/src/views/ClassEnrollForm.vue @@ -85,7 +85,6 @@ import KFilterTextbox from 'kolibri.coreVue.components.KFilterTextbox'; import { userMatchesFilter, filterAndSortUsers } from '../userSearchUtils'; import UserTable from './UserTable'; - import { Modals } from './../constants'; export default { name: 'ClassEnrollForm', @@ -139,9 +138,6 @@ usersNotInClass() { return differenceWith(this.facilityUsers, this.classUsers, (a, b) => a.id === b.id); }, - filteredUsers() { - return this.usersNotInClass.filter(user => userMatchesFilter(user, this.filterInput)); - }, sortedFilteredUsers() { return filterAndSortUsers(this.usersNotInClass, user => userMatchesFilter(user, this.filterInput) @@ -168,9 +164,6 @@ visibleFilteredUsers() { return this.sortedFilteredUsers.slice(this.startRange, this.endRange); }, - showConfirmEnrollmentModal() { - return this.modalShown === Modals.CONFIRM_ENROLLMENT; - }, emptyMessage() { if (this.facilityUsers.length === 0) { return this.$tr('noUsersExist'); diff --git a/kolibri/plugins/facility_management/assets/src/views/DataPage/index.vue b/kolibri/plugins/facility_management/assets/src/views/DataPage/index.vue index 83cee29b6b5..b027238eddc 100644 --- a/kolibri/plugins/facility_management/assets/src/views/DataPage/index.vue +++ b/kolibri/plugins/facility_management/assets/src/views/DataPage/index.vue @@ -100,11 +100,6 @@ DataPageTaskProgress, }, mixins: [themeMixin], - data() { - return { - lista: urls, - }; - }, metaInfo() { return { title: this.$tr('documentTitle'), @@ -144,9 +139,6 @@ cannotDownload() { return isAndroidWebView(); }, - generatingCSVFile() { - return this.inSummaryCSVCreation || this.inSessionCSVCreation; - }, inDataExportPage() { return this.pageName === PageNames.DATA_EXPORT_PAGE; }, diff --git a/kolibri/plugins/facility_management/assets/src/views/UserPage/DeleteUserModal.vue b/kolibri/plugins/facility_management/assets/src/views/UserPage/DeleteUserModal.vue index f677a7802c6..4e0c3b7df92 100644 --- a/kolibri/plugins/facility_management/assets/src/views/UserPage/DeleteUserModal.vue +++ b/kolibri/plugins/facility_management/assets/src/views/UserPage/DeleteUserModal.vue @@ -37,10 +37,6 @@ type: String, required: true, }, - name: { - type: String, - required: true, - }, username: { type: String, required: true, diff --git a/kolibri/plugins/facility_management/assets/src/views/UserPage/ResetUserPasswordModal.vue b/kolibri/plugins/facility_management/assets/src/views/UserPage/ResetUserPasswordModal.vue index 05ea1c4a6fa..bfc99da69e1 100644 --- a/kolibri/plugins/facility_management/assets/src/views/UserPage/ResetUserPasswordModal.vue +++ b/kolibri/plugins/facility_management/assets/src/views/UserPage/ResetUserPasswordModal.vue @@ -51,10 +51,6 @@ type: String, required: true, }, - name: { - type: String, - required: true, - }, username: { type: String, required: true, diff --git a/kolibri/plugins/facility_management/assets/src/views/UserTable.vue b/kolibri/plugins/facility_management/assets/src/views/UserTable.vue index 8b8ff592d9c..7afefa6fb8f 100644 --- a/kolibri/plugins/facility_management/assets/src/views/UserTable.vue +++ b/kolibri/plugins/facility_management/assets/src/views/UserTable.vue @@ -124,9 +124,6 @@ type: Array, required: true, }, - title: { - type: String, - }, emptyMessage: { type: String, }, diff --git a/kolibri/plugins/learn/assets/src/views/ContentPage.vue b/kolibri/plugins/learn/assets/src/views/ContentPage.vue index 3247cad7ff9..58510334327 100644 --- a/kolibri/plugins/learn/assets/src/views/ContentPage.vue +++ b/kolibri/plugins/learn/assets/src/views/ContentPage.vue @@ -229,14 +229,6 @@ recommendedText() { return this.$tr('recommended'); }, - parentTopic() { - const { breadcrumbs = [] } = this.content; - if (breadcrumbs.length > 0) { - return breadcrumbs[breadcrumbs.length - 1]; - } - - return undefined; - }, progress() { if (this.isUserLoggedIn) { // if there no attempts for this exercise, there is no progress diff --git a/kolibri/plugins/learn/assets/src/views/SearchBox.vue b/kolibri/plugins/learn/assets/src/views/SearchBox.vue index b0c5adebb15..9b61fc60f92 100644 --- a/kolibri/plugins/learn/assets/src/views/SearchBox.vue +++ b/kolibri/plugins/learn/assets/src/views/SearchBox.vue @@ -164,7 +164,6 @@ searchQuery: this.$store.state.search.searchTerm, contentKindFilterSelection: {}, channelFilterSelection: {}, - test: 10, }; }, computed: { diff --git a/kolibri/plugins/user/assets/src/views/SignUpPage.vue b/kolibri/plugins/user/assets/src/views/SignUpPage.vue index ac815343233..ce7acfebe49 100644 --- a/kolibri/plugins/user/assets/src/views/SignUpPage.vue +++ b/kolibri/plugins/user/assets/src/views/SignUpPage.vue @@ -115,7 +115,6 @@ import KSelect from 'kolibri.coreVue.components.KSelect'; import PrivacyInfoModal from 'kolibri.coreVue.components.PrivacyInfoModal'; import { ERROR_CONSTANTS } from 'kolibri.coreVue.vuex.constants'; - import { PageNames } from '../constants'; import LanguageSwitcherFooter from './LanguageSwitcherFooter'; export default { @@ -167,9 +166,6 @@ computed: { ...mapGetters(['facilities', 'session']), ...mapState('signUp', ['errors', 'busy']), - signInPage() { - return { name: PageNames.SIGN_IN }; - }, facilityList() { return this.facilities.map(facility => ({ label: facility.name, diff --git a/kolibri/plugins/user/assets/src/views/UserIndex.vue b/kolibri/plugins/user/assets/src/views/UserIndex.vue index 5fd2779753e..519f10ed260 100644 --- a/kolibri/plugins/user/assets/src/views/UserIndex.vue +++ b/kolibri/plugins/user/assets/src/views/UserIndex.vue @@ -49,9 +49,6 @@ currentPage() { return pageNameComponentMap[this.pageName] || null; }, - navBarNeeded() { - return this.pageName !== PageNames.SIGN_IN && this.pageName !== PageNames.SIGN_UP; - }, PageNames() { return PageNames; }, From 582dcaba097bc4ef7de276757908ed0189cfa3ed Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sat, 6 Apr 2019 17:14:43 +0200 Subject: [PATCH 04/13] Remove constants from data Those constants are referenced directly, they're actually not used as a component instance data. --- .../SelectNetworkAddressModal/SelectAddressForm.vue | 1 - .../assets/src/views/ManageContentPage/TaskProgress.vue | 1 - .../plugins/learn/assets/src/views/ContentCardGroupCarousel.vue | 2 -- 3 files changed, 4 deletions(-) diff --git a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectNetworkAddressModal/SelectAddressForm.vue b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectNetworkAddressModal/SelectAddressForm.vue index 2b1ba4768e3..3701e922b52 100644 --- a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectNetworkAddressModal/SelectAddressForm.vue +++ b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectNetworkAddressModal/SelectAddressForm.vue @@ -90,7 +90,6 @@ selectedAddressId: '', showUiAlerts: false, stage: '', - Stages, }; }, computed: { diff --git a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue index 2125b7f4ec3..4ed3dce1d2b 100644 --- a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue +++ b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue @@ -97,7 +97,6 @@ }; }, computed: { - TaskStatuses: () => TaskStatuses, stageText() { // Special case for Channel DB downloading, since they never go into RUNNING if (this.type === 'UPDATING_CHANNEL') { diff --git a/kolibri/plugins/learn/assets/src/views/ContentCardGroupCarousel.vue b/kolibri/plugins/learn/assets/src/views/ContentCardGroupCarousel.vue index 0480499f192..c89908e9bbb 100644 --- a/kolibri/plugins/learn/assets/src/views/ContentCardGroupCarousel.vue +++ b/kolibri/plugins/learn/assets/src/views/ContentCardGroupCarousel.vue @@ -112,8 +112,6 @@ panBackwards: false, // tracks whether the carousel has been interacted with interacted: false, - contentCardWidth, - gutterWidth, }; }, computed: { From d5bf7dafed27d3c62ca3044758eb05da8d3094ef Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sat, 6 Apr 2019 17:17:23 +0200 Subject: [PATCH 05/13] Fix property casing --- kolibri/core/assets/src/views/ContentIcon.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kolibri/core/assets/src/views/ContentIcon.vue b/kolibri/core/assets/src/views/ContentIcon.vue index cf3fe43f2e6..8bea9f1569f 100644 --- a/kolibri/core/assets/src/views/ContentIcon.vue +++ b/kolibri/core/assets/src/views/ContentIcon.vue @@ -120,7 +120,7 @@ return validateContentNodeKind(value, [USER]); }, }, - colorstyle: { + colorStyle: { type: String, default: 'action', }, From 9ca2daeb4db2d615c5d3965801653055c9065a73 Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sat, 6 Apr 2019 17:22:25 +0200 Subject: [PATCH 06/13] Comment out unused properties that are needed for TODO template commented out code. --- .../coach/assets/src/views/reports/ReportsGroupHeader.vue | 2 ++ .../assets/src/views/reports/ReportsGroupReportLessonPage.vue | 2 ++ .../coach/assets/src/views/reports/ReportsLessonHeader.vue | 2 ++ .../coach/assets/src/views/reports/ReportsLessonReportPage.vue | 2 ++ .../coach/assets/src/views/reports/ReportsQuizHeader.vue | 2 ++ 5 files changed, 10 insertions(+) diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupHeader.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupHeader.vue index e6a2e9ac1a5..03fbefa4ebf 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupHeader.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupHeader.vue @@ -79,6 +79,7 @@ group() { return this.groupMap[this.$route.params.groupId]; }, + /** TODO COACH recipients() { return this.group.member_ids; }, @@ -92,6 +93,7 @@ } return this._.meanBy(statuses, 'score'); }, + */ }, $trs: { back: 'All groups', diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonPage.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonPage.vue index cce3c9d7027..8f2de3b5d12 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonPage.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonPage.vue @@ -93,6 +93,7 @@ components: {}, mixins: [commonCoach], computed: { + /** TODO COACH actionOptions() { return [ { label: this.coachStrings.$tr('editDetailsAction'), value: 'ReportsLessonEditorPage' }, @@ -102,6 +103,7 @@ }, ]; }, + */ lesson() { return this.lessonMap[this.$route.params.lessonId]; }, diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonHeader.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonHeader.vue index 0ecda9af876..ab82ad5195f 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonHeader.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonHeader.vue @@ -79,6 +79,7 @@ components: {}, mixins: [commonCoach], computed: { + /** TODO COACH actionOptions() { return [ { label: this.coachStrings.$tr('editDetailsAction'), value: 'ReportsLessonEditorPage' }, @@ -88,6 +89,7 @@ }, ]; }, + */ lesson() { return this.lessonMap[this.$route.params.lessonId]; }, diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonReportPage.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonReportPage.vue index e4d17785edb..27a0a0115a3 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonReportPage.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsLessonReportPage.vue @@ -81,6 +81,7 @@ emptyMessage() { return LessonSummaryPageStrings.$tr('noResourcesInLesson'); }, + /** TODO COACH actionOptions() { return [ { label: this.coachStrings.$tr('editDetailsAction'), value: 'ReportsLessonEditorPage' }, @@ -90,6 +91,7 @@ }, ]; }, + */ lesson() { return this.lessonMap[this.$route.params.lessonId]; }, diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizHeader.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizHeader.vue index 25c236cda81..3ad4516339b 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizHeader.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizHeader.vue @@ -80,12 +80,14 @@ avgScore() { return this.getExamAvgScore(this.$route.params.quizId, this.recipients); }, + /** TODO COACH actionOptions() { return [ { label: this.coachStrings.$tr('previewAction'), value: 'ReportsQuizPreviewPage' }, { label: this.coachStrings.$tr('editDetailsAction'), value: 'ReportsQuizEditorPage' }, ]; }, + */ exam() { return this.examMap[this.$route.params.quizId]; }, From f525da8e7e0877f825dbc16a9a024574f2bf8c3a Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sat, 6 Apr 2019 17:39:58 +0200 Subject: [PATCH 07/13] Fix back link label --- .../reports/ReportsGroupReportLessonResourceLearnerListPage.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonResourceLearnerListPage.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonResourceLearnerListPage.vue index 5b3ce6c9b99..4e854d49de2 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonResourceLearnerListPage.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsGroupReportLessonResourceLearnerListPage.vue @@ -13,7 +13,7 @@

From 71a436d39023a51109d0973cc3d40351990ee07f Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sun, 7 Apr 2019 09:55:02 +0200 Subject: [PATCH 08/13] Define constants for properties groups and their labels --- .../lib/rules/vue-no-unused-properties.js | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/eslint-plugin-kolibri/lib/rules/vue-no-unused-properties.js b/packages/eslint-plugin-kolibri/lib/rules/vue-no-unused-properties.js index 43ce9b7be2d..9fa810c0330 100644 --- a/packages/eslint-plugin-kolibri/lib/rules/vue-no-unused-properties.js +++ b/packages/eslint-plugin-kolibri/lib/rules/vue-no-unused-properties.js @@ -7,6 +7,17 @@ const remove = require('lodash/remove'); const utils = require('eslint-plugin-vue/lib/utils'); +const GROUP_PROPERTY = 'props'; +const GROUP_DATA = 'data'; +const GROUP_COMPUTED_PROPERTY = 'computed'; +const GROUP_WATCHER = 'watch'; + +const PROPERTY_LABEL = { + [GROUP_PROPERTY]: 'property', + [GROUP_DATA]: 'data', + [GROUP_COMPUTED_PROPERTY]: 'computed property', +}; + const getReferencesNames = references => { if (!references || !references.length) { return []; @@ -27,16 +38,9 @@ const reportUnusedProperties = (context, properties) => { } properties.forEach(property => { - let kind = 'property'; - if (property.groupName === 'data') { - kind = 'data'; - } else if (property.groupName === 'computed') { - kind = 'computed property'; - } - context.report({ node: property.node, - message: `Unused ${kind} found: "${property.name}"`, + message: `Unused ${PROPERTY_LABEL[property.groupName]} found: "${property.name}"`, }); }); }; @@ -73,10 +77,10 @@ const create = context => { }, utils.executeOnVue(context, obj => { unusedProperties = Array.from( - utils.iterateProperties(obj, new Set(['props', 'data', 'computed'])) + utils.iterateProperties(obj, new Set([GROUP_PROPERTY, GROUP_DATA, GROUP_COMPUTED_PROPERTY])) ); - const watchers = Array.from(utils.iterateProperties(obj, new Set(['watch']))); + const watchers = Array.from(utils.iterateProperties(obj, new Set([GROUP_WATCHER]))); const watchersNames = watchers.map(watcher => watcher.name); remove(unusedProperties, property => { From 29349667c08c5a4af1b6af6694815cb8f5b910ce Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sun, 7 Apr 2019 09:55:23 +0200 Subject: [PATCH 09/13] Move constants back to data/computed and reference them using this --- .../SelectAddressForm.vue | 32 +++++++++-------- .../views/ManageContentPage/TaskProgress.vue | 11 +++--- .../src/views/ContentCardGroupCarousel.vue | 34 ++++++++++--------- 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectNetworkAddressModal/SelectAddressForm.vue b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectNetworkAddressModal/SelectAddressForm.vue index 3701e922b52..e14f65391f4 100644 --- a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectNetworkAddressModal/SelectAddressForm.vue +++ b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/SelectNetworkAddressModal/SelectAddressForm.vue @@ -90,6 +90,7 @@ selectedAddressId: '', showUiAlerts: false, stage: '', + Stages, }; }, computed: { @@ -98,23 +99,26 @@ submitDisabled() { return ( this.selectedAddressId === '' || - this.stage === Stages.FETCHING_ADDRESSES || - this.stage === Stages.DELETING_ADDRESS + this.stage === this.Stages.FETCHING_ADDRESSES || + this.stage === this.Stages.DELETING_ADDRESS ); }, newAddressButtonDisabled() { - return this.stage === Stages.FETCHING_ADDRESSES; + return this.stage === this.Stages.FETCHING_ADDRESSES; }, requestsSucessful() { return ( - this.stage === Stages.FETCHING_SUCCESSFUL || this.stage === Stages.DELETING_SUCCESSFUL + this.stage === this.Stages.FETCHING_SUCCESSFUL || + this.stage === this.Stages.DELETING_SUCCESSFUL ); }, requestsFailed() { - return this.stage === Stages.FETCHING_FAILED || this.stage === Stages.DELETING_FAILED; + return ( + this.stage === this.Stages.FETCHING_FAILED || this.stage === this.Stages.DELETING_FAILED + ); }, uiAlertProps() { - if (this.stage === Stages.FETCHING_ADDRESSES) { + if (this.stage === this.Stages.FETCHING_ADDRESSES) { return { text: this.$tr('fetchingAddressesText'), type: 'info', @@ -126,13 +130,13 @@ type: 'info', }; } - if (this.stage === Stages.FETCHING_FAILED) { + if (this.stage === this.Stages.FETCHING_FAILED) { return { text: this.$tr('fetchingFailedText'), type: 'error', }; } - if (this.stage === Stages.DELETING_FAILED) { + if (this.stage === this.Stages.DELETING_FAILED) { return { text: this.$tr('deletingFailedText'), type: 'error', @@ -153,16 +157,16 @@ }, methods: { refreshAddressList() { - this.stage = Stages.FETCHING_ADDRESSES; + this.stage = this.Stages.FETCHING_ADDRESSES; this.addresses = []; return fetchAddresses(this.isImportingMore ? this.transferredChannel.id : '') .then(addresses => { this.addresses = addresses; this.resetSelectedAddress(); - this.stage = Stages.FETCHING_SUCCESSFUL; + this.stage = this.Stages.FETCHING_SUCCESSFUL; }) .catch(() => { - this.stage = Stages.FETCHING_FAILED; + this.stage = this.Stages.FETCHING_FAILED; }); }, resetSelectedAddress() { @@ -174,16 +178,16 @@ } }, removeAddress(id) { - this.stage = Stages.DELETING_ADDRESS; + this.stage = this.Stages.DELETING_ADDRESS; return deleteAddress(id) .then(() => { this.addresses = this.addresses.filter(a => a.id !== id); this.resetSelectedAddress(this.addresses); - this.stage = Stages.DELETING_SUCCESSFUL; + this.stage = this.Stages.DELETING_SUCCESSFUL; this.$emit('removed_address'); }) .catch(() => { - this.stage = Stages.DELETING_FAILED; + this.stage = this.Stages.DELETING_FAILED; }); }, handleSubmit() { diff --git a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue index 4ed3dce1d2b..79edff46d66 100644 --- a/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue +++ b/kolibri/plugins/device_management/assets/src/views/ManageContentPage/TaskProgress.vue @@ -97,6 +97,7 @@ }; }, computed: { + TaskStatuses: () => TaskStatuses, stageText() { // Special case for Channel DB downloading, since they never go into RUNNING if (this.type === 'UPDATING_CHANNEL') { @@ -106,7 +107,7 @@ return this.$tr('downloadingChannelContents'); } - if (this.status === TaskStatuses.RUNNING) { + if (this.status === this.TaskStatuses.RUNNING) { switch (this.type) { case TaskTypes.REMOTE_IMPORT: case TaskTypes.LOCAL_IMPORT: @@ -137,13 +138,15 @@ return ''; }, taskHasFailed() { - return this.status === TaskStatuses.FAILED; + return this.status === this.TaskStatuses.FAILED; }, taskHasCompleted() { - return this.status === TaskStatuses.COMPLETED; + return this.status === this.TaskStatuses.COMPLETED; }, taskIsPreparing() { - return this.status === TaskStatuses.QUEUED || this.status === TaskStatuses.SCHEDULED; + return ( + this.status === this.TaskStatuses.QUEUED || this.status === this.TaskStatuses.SCHEDULED + ); }, formattedPercentage() { return this.percentage * 100; diff --git a/kolibri/plugins/learn/assets/src/views/ContentCardGroupCarousel.vue b/kolibri/plugins/learn/assets/src/views/ContentCardGroupCarousel.vue index c89908e9bbb..6f8751c2787 100644 --- a/kolibri/plugins/learn/assets/src/views/ContentCardGroupCarousel.vue +++ b/kolibri/plugins/learn/assets/src/views/ContentCardGroupCarousel.vue @@ -112,6 +112,8 @@ panBackwards: false, // tracks whether the carousel has been interacted with interacted: false, + contentCardWidth, + gutterWidth, }; }, computed: { @@ -119,10 +121,10 @@ return this.isRtl ? 'right' : 'left'; }, contentSetSize() { - if (this.elementWidth > 2 * contentCardWidth) { - const numOfCards = Math.floor(this.elementWidth / contentCardWidth); + if (this.elementWidth > 2 * this.contentCardWidth) { + const numOfCards = Math.floor(this.elementWidth / this.contentCardWidth); const numOfGutters = numOfCards - 1; - const totalWidth = numOfCards * contentCardWidth + numOfGutters * gutterWidth; + const totalWidth = numOfCards * this.contentCardWidth + numOfGutters * this.gutterWidth; if (this.elementWidth >= totalWidth) { return numOfCards; } @@ -140,26 +142,26 @@ return this.contentSetEnd >= this.contents.length - 1; }, contentSetStyles() { - const cards = this.contentSetSize * contentCardWidth + horizontalShadowOffset; - const gutters = (this.contentSetSize - 1) * gutterWidth; + const cards = this.contentSetSize * this.contentCardWidth + horizontalShadowOffset; + const gutters = (this.contentSetSize - 1) * this.gutterWidth; const maxCardShadowOffset = 14; // determined by css styles on cards const topShadowOffset = 10; return { - 'min-width': `${contentCardWidth}px`, + 'min-width': `${this.contentCardWidth}px`, 'overflow-x': 'hidden', width: `${cards + gutters + maxCardShadowOffset}px`, // Bottom shadow is a little bit bigger, so add a few pixels more - height: `${contentCardWidth + maxCardShadowOffset + topShadowOffset + 3}px`, + height: `${this.contentCardWidth + maxCardShadowOffset + topShadowOffset + 3}px`, position: 'relative', 'padding-top': `${topShadowOffset}px`, }; }, contentControlsContainerStyles() { - const cards = this.contentSetSize * contentCardWidth; - const gutters = (this.contentSetSize - 1) * gutterWidth; + const cards = this.contentSetSize * this.contentCardWidth; + const gutters = (this.contentSetSize - 1) * this.gutterWidth; return { width: `${cards + gutters}px`, - height: `${contentCardWidth}px`, + height: `${this.contentCardWidth}px`, overflow: 'visible', position: 'relative', }; @@ -209,8 +211,8 @@ methods: { positionCalc(index) { const indexInSet = index - this.contentSetStart; - const gutterOffset = indexInSet * gutterWidth; - const cardOffset = indexInSet * contentCardWidth; + const gutterOffset = indexInSet * this.gutterWidth; + const cardOffset = indexInSet * this.contentCardWidth; return { [this.animationAttr]: `${cardOffset + gutterOffset + horizontalShadowOffset}px` }; }, setStartPosition(el) { @@ -218,8 +220,8 @@ // sets the initial spot from which cards will be sliding into place from // direction depends on `panBackwards` const originalPosition = parseInt(el.style[this.animationAttr], 10); - const cards = this.contentSetSize * contentCardWidth; - const gutters = this.contentSetSize * gutterWidth; + const cards = this.contentSetSize * this.contentCardWidth; + const gutters = this.contentSetSize * this.gutterWidth; const carouselContainerOffset = cards + gutters; const sign = this.panBackwards ? -1 : 1; @@ -231,8 +233,8 @@ // moves cards from their starting point by their offset // direction depends on `panBackwards` const originalPosition = parseInt(el.style[this.animationAttr], 10); - const cards = this.contentSetSize * contentCardWidth; - const gutters = this.contentSetSize * gutterWidth; + const cards = this.contentSetSize * this.contentCardWidth; + const gutters = this.contentSetSize * this.gutterWidth; const carouselContainerOffset = cards + gutters; const sign = this.panBackwards ? 1 : -1; From ef93e541a46585665717178401f6a0714e5297d6 Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sun, 7 Apr 2019 10:23:20 +0200 Subject: [PATCH 10/13] Remove obsolete props from ContentRender parents - id, contentId, channelId - related AssessmentWrapper and its parent (ContentPage) cleanup --- kolibri/core/assets/src/views/ExamReport/index.vue | 2 -- kolibri/core/assets/test/content-renderer.spec.js | 1 - .../assets/src/views/common/LearnerExerciseReport.vue | 2 -- .../assets/src/views/common/QuestionLearnersReport.vue | 2 -- .../assets/src/views/plan/CoachExamsPage/ExamPreview.vue | 2 -- .../src/views/plan/CreateExamPage/CreateExamPreview.vue | 2 -- .../views/plan/LessonContentPreviewPage/ContentArea.vue | 3 --- .../LearnerExerciseDetailPage/LearnerExerciseReportOld.vue | 3 --- .../learn/assets/src/views/AssessmentWrapper/index.vue | 7 ------- kolibri/plugins/learn/assets/src/views/ContentPage.vue | 4 ---- kolibri/plugins/learn/assets/src/views/ExamPage/index.vue | 3 --- 11 files changed, 31 deletions(-) diff --git a/kolibri/core/assets/src/views/ExamReport/index.vue b/kolibri/core/assets/src/views/ExamReport/index.vue index 3f03376fbd1..dc2916ed0eb 100644 --- a/kolibri/core/assets/src/views/ExamReport/index.vue +++ b/kolibri/core/assets/src/views/ExamReport/index.vue @@ -38,12 +38,10 @@ /> { function defaultPropsDataFromFiles(files = defaultFiles) { return { - id: 'testing', kind: 'test', files, }; diff --git a/kolibri/plugins/coach/assets/src/views/common/LearnerExerciseReport.vue b/kolibri/plugins/coach/assets/src/views/common/LearnerExerciseReport.vue index b13664af013..7c92f27b34c 100644 --- a/kolibri/plugins/coach/assets/src/views/common/LearnerExerciseReport.vue +++ b/kolibri/plugins/coach/assets/src/views/common/LearnerExerciseReport.vue @@ -58,13 +58,11 @@ />
[], }, - contentId: { - type: String, - default: '', - }, channelId: { type: String, default: '', diff --git a/kolibri/plugins/learn/assets/src/views/ContentPage.vue b/kolibri/plugins/learn/assets/src/views/ContentPage.vue index 58510334327..0405163359b 100644 --- a/kolibri/plugins/learn/assets/src/views/ContentPage.vue +++ b/kolibri/plugins/learn/assets/src/views/ContentPage.vue @@ -15,13 +15,10 @@ Date: Sun, 7 Apr 2019 10:32:57 +0200 Subject: [PATCH 11/13] Remove obsolete props from TaskProgress parents --- .../assets/src/views/SelectContentPage/index.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/kolibri/plugins/device_management/assets/src/views/SelectContentPage/index.vue b/kolibri/plugins/device_management/assets/src/views/SelectContentPage/index.vue index 5c1fab2c2ba..7be29caf82d 100644 --- a/kolibri/plugins/device_management/assets/src/views/SelectContentPage/index.vue +++ b/kolibri/plugins/device_management/assets/src/views/SelectContentPage/index.vue @@ -9,7 +9,6 @@