From 580681ce3ca4e458390ed4642361ece150dcdd60 Mon Sep 17 00:00:00 2001 From: nicola Date: Fri, 24 May 2019 10:21:21 +0100 Subject: [PATCH 01/35] Cross-framework import support --- frontend/src/modules/frameworkImport/index.js | 2 +- .../frameworkImport/less/frameworkImport.less | 56 ++++ .../templates/frameworkImport.hbs | 17 +- .../frameworkImportPluginHeadingView.hbs | 20 ++ .../templates/frameworkImportPluginView.hbs | 16 ++ .../templates/frameworkImportSidebar.hbs | 2 +- .../views/frameworkImportPluginHeadingView.js | 12 + .../views/frameworkImportPluginView.js | 21 ++ .../views/frameworkImportSidebarView.js | 12 +- .../views/frameworkImportView.js | 112 +++++++- lib/outputmanager.js | 2 +- plugins/output/adapt/helpers.js | 95 +++++-- plugins/output/adapt/importsource.js | 220 ++++------------ plugins/output/adapt/importsourcecheck.js | 243 ++++++++++++++++++ plugins/output/adapt/index.js | 1 + routes/import/index.js | 18 +- routes/lang/en-application.json | 16 ++ 17 files changed, 655 insertions(+), 210 deletions(-) create mode 100644 frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs create mode 100644 frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs create mode 100644 frontend/src/modules/frameworkImport/views/frameworkImportPluginHeadingView.js create mode 100644 frontend/src/modules/frameworkImport/views/frameworkImportPluginView.js create mode 100644 plugins/output/adapt/importsourcecheck.js diff --git a/frontend/src/modules/frameworkImport/index.js b/frontend/src/modules/frameworkImport/index.js index 0f9dd05280..0f552fa46a 100644 --- a/frontend/src/modules/frameworkImport/index.js +++ b/frontend/src/modules/frameworkImport/index.js @@ -12,7 +12,7 @@ define(function(require) { Origin.permissions.addRoute('frameworkImport', data.featurePermissions); }); - Origin.on('router:frameworkImport', function(location, subLocation, action) { + Origin.on('router:frameworkImport', function() { Origin.contentPane.setView(FrameworkImportView, { model: new Backbone.Model({ globalData: data }) }); Origin.sidebar.addView(new FrameworkImportSidebarView().$el); }); diff --git a/frontend/src/modules/frameworkImport/less/frameworkImport.less b/frontend/src/modules/frameworkImport/less/frameworkImport.less index ccab821093..3e645b195f 100644 --- a/frontend/src/modules/frameworkImport/less/frameworkImport.less +++ b/frontend/src/modules/frameworkImport/less/frameworkImport.less @@ -1,5 +1,8 @@ @import 'colours'; @import 'sharedStyles'; +@framework-import-red: #ff3343; +@framework-import-amber: #ffa340; +@framework-import-green: @secondary-color; .frameworkImport .inner { .form-container-style; @@ -26,6 +29,15 @@ } } + .col-row { + display: flex; + align-items: center; + } + + .tb-row .tb-col-inner { + padding: 0; + } + li { margin-left: 0; list-style: none; @@ -43,4 +55,48 @@ padding-bottom: 5px; } } + + &.import-summary { + .title { + font-style: italic; + padding-bottom: 10px; + color: @primary-color; + + &.red { + color: @framework-import-red; + } + + &.amber { + color: @framework-import-amber; + } + + &.green { + color: @framework-import-green; + } + } + .description { + font-weight: 600; + } + } + + &.plugin-list { + .status { + padding: 10px 0; + border-radius: 3px; + color: white; + font-weight: 600; + } + + &.red .status { + background-color: @framework-import-red; + } + + &.amber .status { + background-color: @framework-import-amber; + } + + &.green .status { + background-color: @framework-import-green; + } + } } diff --git a/frontend/src/modules/frameworkImport/templates/frameworkImport.hbs b/frontend/src/modules/frameworkImport/templates/frameworkImport.hbs index 991bbaeed0..3a3a21d4f1 100644 --- a/frontend/src/modules/frameworkImport/templates/frameworkImport.hbs +++ b/frontend/src/modules/frameworkImport/templates/frameworkImport.hbs @@ -1,5 +1,5 @@ -
-
+
+
+ + \ No newline at end of file diff --git a/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs new file mode 100644 index 0000000000..ca80643bbe --- /dev/null +++ b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs @@ -0,0 +1,20 @@ +
+ +
+

{{t 'app.name'}}

+
+ +
+

{{t 'app.currentversion'}}

+
+ +
+

{{t 'app.newversion'}}

+
+ +
+

{{t 'app.status'}}

+
+ +
+
    \ No newline at end of file diff --git a/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs new file mode 100644 index 0000000000..706e8f672e --- /dev/null +++ b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs @@ -0,0 +1,16 @@ +
    +
    +
    + {{displayName}} +
    +
    + {{currentVersion}} +
    +
    + {{newVersion}} +
    +
    + {{status}} +
    +
    +
    \ No newline at end of file diff --git a/frontend/src/modules/frameworkImport/templates/frameworkImportSidebar.hbs b/frontend/src/modules/frameworkImport/templates/frameworkImportSidebar.hbs index 347ad4e24b..3685c98744 100644 --- a/frontend/src/modules/frameworkImport/templates/frameworkImportSidebar.hbs +++ b/frontend/src/modules/frameworkImport/templates/frameworkImportSidebar.hbs @@ -1,6 +1,6 @@
    - - - +
    \ No newline at end of file diff --git a/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs index ca80643bbe..ae8b901490 100644 --- a/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs +++ b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs @@ -1,15 +1,15 @@
    -
    +

    {{t 'app.name'}}

    -
    -

    {{t 'app.currentversion'}}

    +
    +

    {{t 'app.importversion'}}

    -
    -

    {{t 'app.newversion'}}

    +
    +

    {{t 'app.atversion'}}

    diff --git a/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs index 706e8f672e..db5752334f 100644 --- a/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs +++ b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs @@ -1,13 +1,13 @@
    -
    -
    +
    +
    {{displayName}}
    -
    - {{currentVersion}} +
    + {{importVersion}}
    -
    - {{newVersion}} +
    + {{authoringToolVersion}}
    {{status}} diff --git a/frontend/src/modules/frameworkImport/views/frameworkImportView.js b/frontend/src/modules/frameworkImport/views/frameworkImportView.js index db83948f0a..8092afbf66 100644 --- a/frontend/src/modules/frameworkImport/views/frameworkImportView.js +++ b/frontend/src/modules/frameworkImport/views/frameworkImportView.js @@ -78,20 +78,6 @@ define(function(require){ this.sidebarView.$('.framework-import-sidebar-save-button').removeClass('show-details'); var $details = this.$('#import_details'); var $framework_versions = $details.find('.framework-versions'); - var categoryMap = { - 'green': { - summary: 'app.plugingreensummary', - label: 'app.plugingreenlabel' - }, - 'amber': { - summary: 'app.pluginambersummary', - label: 'app.pluginamberlabel' - }, - 'red': { - summary: 'app.pluginredsummary', - label: 'app.pluginredlabel' - } - }; if (_.isEmpty(data.pluginVersions.red)) { $('.framework-import-sidebar-save-button').addClass('save'); @@ -111,27 +97,8 @@ define(function(require){ // Can/Cannot be imported summary this.displaySummary(data); - // Plugin tables - for (var category in data.pluginVersions) { - if (category === 'white') continue; - if (_.isEmpty(data.pluginVersions[category])) continue; - - var $category_display = $details.find('.plugin-list.' + category); - $category_display.text(Origin.l10n.t(categoryMap[category].summary)); - $category_display.append(new FrameworkImportPluginHeadingView().$el); - $category_display.removeClass('display-none'); - - // Sort plugins alphabetically - var pluginArray = Object.values(data.pluginVersions[category]); - pluginArray = pluginArray.sort(function(a, b) { - return a.displayName.localeCompare(b.displayName); - }); - - pluginArray.forEach(function(plugin) { - plugin.status = Origin.l10n.t(categoryMap[category].label); - $category_display.find('.frameworkImportPlugin-plugins').append(new FrameworkImportPluginView({ data: plugin }).$el); - }); - } + // Plugin list + this.displayPluginList(data); $details.removeClass('display-none'); }, @@ -150,10 +117,11 @@ define(function(require){ $summary_title.text(Origin.l10n.t('app.coursecanbeimported')); - if (!_.isEmpty(data.pluginVersions.amber) || !_.isEmpty(data.pluginVersions.green)) { + var greenExists = !(_.isEmpty(data.pluginVersions['green-install']) && _.isEmpty(data.pluginVersions['green-update'])); + if (!_.isEmpty(data.pluginVersions.amber) || greenExists) { $summary_title.addClass('amber'); $summary_description.text(Origin.l10n.t('app.coursecanbeimporteddesc')); - if (!_.isEmpty(data.pluginVersions.green) && _.isEmpty(data.pluginVersions.amber)) { + if (greenExists && _.isEmpty(data.pluginVersions.amber)) { $summary_title.removeClass('amber').addClass('green'); } return; @@ -163,6 +131,48 @@ define(function(require){ return; }, + displayPluginList: function(data) { + var $plugin_list = this.$('#import_details').find('.plugin-list'); + var categoryMap = { + 'green-install': { + label: 'app.plugingreeninstalllabel' + }, + 'green-update': { + label: 'app.plugingreenupdatelabel' + }, + 'amber': { + label: 'app.pluginamberlabel' + }, + 'red': { + label: 'app.pluginredlabel' + } + }; + var categories = ['red', 'amber', 'green-update', 'green-install']; + + $plugin_list.append(new FrameworkImportPluginHeadingView().$el); + + for (i = 0; i < categories.length; i++) { + var categoryData = data.pluginVersions[categories[i]]; + if (categories[i] === 'white') continue; + if (_.isEmpty(categoryData)) continue; + + // Sort plugins alphabetically + var pluginArray = Object.values(categoryData); + pluginArray = pluginArray.sort(function(a, b) { + return a.displayName.localeCompare(b.displayName); + }); + + pluginArray.forEach(function(plugin) { + plugin.status = Origin.l10n.t(categoryMap[categories[i]].label); + plugin.category = categories[i]; + $plugin_list.find('.frameworkImportPlugin-plugins').append(new FrameworkImportPluginView({ data: plugin }).$el); + }); + + $plugin_list.removeClass('display-none'); + $plugin_list.find('.key-field.'+ categories[i]).removeClass('display-none'); + } + }, + goBack: function() { Origin.router.navigateToHome(); }, @@ -214,6 +224,8 @@ define(function(require){ }, completeImport: function() { + this.sidebarView.updateButton('.framework-import-sidebar-save-button', Origin.l10n.t('app.importing')); + this.$('form.frameworkImportDetails').ajaxSubmit({ error: _.bind(this.onAjaxError, this), success: _.bind(this.onFormSubmitSuccess, this) diff --git a/plugins/output/adapt/helpers.js b/plugins/output/adapt/helpers.js index bc92c8a2f7..def9c0419e 100644 --- a/plugins/output/adapt/helpers.js +++ b/plugins/output/adapt/helpers.js @@ -247,9 +247,9 @@ function getPluginFrameworkVersionCategory(serverFrameworkVersion, pluginMetaDat if (semver.satisfies(serverFrameworkVersion, pluginFrameworkVersion, { includePrerelease: true })) { - return cb(null, {category: 'green', newVersion: pluginMetaData.version}); + return cb(null, {category: 'green-install', authoringToolVersion: app.polyglot.t('app.none')}); } - cb(null, {category: 'red', newVersion: app.polyglot.t('app.na')}); + cb(null, {category: 'red', authoringToolVersion: app.polyglot.t('app.none')}); } else { // A version is already installed so could be: // White - same version installed as in course @@ -259,14 +259,14 @@ function getPluginFrameworkVersionCategory(serverFrameworkVersion, pluginMetaDat var serverPluginVersion = semver.clean(serverPlugin.version); var isServerVersionLatest = semver.compare(serverPluginVersion, pluginMetaData.version); if (isServerVersionLatest === 0) { - return cb(null, {category: 'white', newVersion: app.polyglot.t('app.na')}); + return cb(null, {category: 'white', authoringToolVersion: app.polyglot.t('app.none')}); } if (semver.satisfies(serverFrameworkVersion, pluginFrameworkVersion, { includePrerelease: true }) && isServerVersionLatest < 0) { - return cb(null, {category: 'green', newVersion: pluginMetaData.version}); + return cb(null, {category: 'green-update', authoringToolVersion: serverPluginVersion}); } - cb(null, {category: 'amber', newVersion: serverPluginVersion}); + cb(null, {category: 'amber', authoringToolVersion: serverPluginVersion}); } } ], function(error, category) { diff --git a/plugins/output/adapt/importsourcecheck.js b/plugins/output/adapt/importsourcecheck.js index ef5dc485f2..438ca60ca3 100644 --- a/plugins/output/adapt/importsourcecheck.js +++ b/plugins/output/adapt/importsourcecheck.js @@ -44,7 +44,8 @@ function ImportSourceCheck(req, done) { frameworkVersions: {}, pluginVersions : { white: {}, - green: {}, + 'green-install': {}, + 'green-update': {}, amber: {}, red: {} } @@ -213,7 +214,7 @@ function ImportSourceCheck(req, done) { fs.readJSON(path.join(pluginData.location, Constants.Filenames.Bower), function(error, data) { if (error) return callback(error); helpers.getPluginFrameworkVersionCategory(details.frameworkVersions.installed, data, pluginData.type, function (error, result) { - details.pluginVersions[result.category][data.name] = { currentVersion: data.version, displayName: data.displayName, newVersion: result.newVersion }; + details.pluginVersions[result.category][data.name] = { importVersion: data.version, displayName: data.displayName, authoringToolVersion: result.authoringToolVersion }; pluginData.name = data.name; cb2(); }); diff --git a/routes/lang/en-application.json b/routes/lang/en-application.json index 38c290bfba..ebe6d0b78b 100644 --- a/routes/lang/en-application.json +++ b/routes/lang/en-application.json @@ -337,7 +337,7 @@ "app.emaillogotext": "ADAPT", "app.emailfooter": "Sent by Adapt Learning.", "app.importing": "Importing...", - "app.na": "N/A", + "app.none": "None", "app.importframeworkfileuploaded": "File has been uploaded", "app.importerrortitle": "Course import failed", "app.importcoursesuccess": "Course imported successfully!", @@ -358,15 +358,17 @@ "app.coursecanbeimporteddesc": "One of more of the plugins used in this course will be updated as part of the import process. You should test the course after the import has completed.", "app.coursecannotbeimported": "Course cannot be imported", "app.coursecannotbeimporteddesc": "One or more of the plugins used in this course is not compatible with the version of the Framework that is used by this Authoring Tool. Please remove or update these plugins and try again.", - "app.currentversion": "Current Version", - "app.newversion": "New Version", + "app.importversion": "Import Version", + "app.atversion": "Authoring Tool Version", "app.status": "Status", - "app.plugingreensummary": "The following plugins will be installed or updated in the authoring tool.", - "app.plugingreenlabel": "Compatible", - "app.pluginambersummary": "The following plugins are not supported in this authoring tool. Compatible versions of these plugins have already been installed so your course will be updated to use the compatible versions.", - "app.pluginamberlabel": "Outdated", - "app.pluginredsummary": "The following plugins are not supported in this authoring tool. You must remove or update these plugins before you can continue with the import.", - "app.pluginredlabel": "Incompatible", + "app.plugingreeninstalllabel": "Install", + "app.plugingreenupdatelabel": "Update", + "app.pluginamberlabel": "Use installed version", + "app.pluginredlabel": "Action Needed", + "app.plugingreeninstallkey": "These plugins will be installed into the Authoring Tool during import.", + "app.plugingreenupdatekey": "These plugins will be updated in the Authoring Tool during import.", + "app.pluginamberkey": "The version of these plugins included in this import is either not compatible with this Authoring Tool, or a newer version is already installed. The imported course will use the existing version.", + "app.pluginredkey": "These plugins are not supported in this authoring tool. You must remove or update these plugins before you can continue with the import.", "app.errorfetchingdata": "An error occured fetching data. Please try refreshing your page.", "app.backtoassets": "Back to assets", "app.newasset": "New Asset", From ea184c5ba1ddab12eee0109ec6d3f5e2576032fd Mon Sep 17 00:00:00 2001 From: nicola Date: Mon, 22 Jul 2019 16:31:20 +0100 Subject: [PATCH 09/35] Add valid semver version check --- plugins/output/adapt/helpers.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/output/adapt/helpers.js b/plugins/output/adapt/helpers.js index def9c0419e..04e834b0c1 100644 --- a/plugins/output/adapt/helpers.js +++ b/plugins/output/adapt/helpers.js @@ -240,10 +240,14 @@ function getPluginFrameworkVersionCategory(serverFrameworkVersion, pluginMetaDat db.retrieve(contentPlugin.bowerConfig.type, { name: pluginMetaData.name }, { jsonOnly: true }, cb); }, function categorisePlugin(records, cb) { + var importPluginVersionValid = semver.valid(pluginMetaData.version); if (records.length === 0) { // Not already installed so could be: - // Red - this plugin is not compatible + // Red - this plugin is not compatible or the version is invalid // Green - this plugin is compatible and will be installed + if (!importPluginVersionValid) { + return cb(null, {category: 'red', authoringToolVersion: app.polyglot.t('app.none')}); + } if (semver.satisfies(serverFrameworkVersion, pluginFrameworkVersion, { includePrerelease: true })) { @@ -253,10 +257,14 @@ function getPluginFrameworkVersionCategory(serverFrameworkVersion, pluginMetaDat } else { // A version is already installed so could be: // White - same version installed as in course + // Red - invalid version // Amber - newer version installed and will be used in the course instead // Green - older version installed so this newer version will be upgraded in the AT var serverPlugin = records[0]; var serverPluginVersion = semver.clean(serverPlugin.version); + if (!importPluginVersionValid) { + return cb(null, {category: 'red', authoringToolVersion: serverPluginVersion}); + } var isServerVersionLatest = semver.compare(serverPluginVersion, pluginMetaData.version); if (isServerVersionLatest === 0) { return cb(null, {category: 'white', authoringToolVersion: app.polyglot.t('app.none')}); From f6035f7a4a9a6e6094781ec11fcebdc0a00bbcf0 Mon Sep 17 00:00:00 2001 From: Andrew Bone Date: Tue, 23 Jul 2019 10:21:41 +0100 Subject: [PATCH 10/35] Move focus to postRender Move focus function to `postRender` to ensure render is complete before the focus is set. --- .../editor/contentObject/views/editorPageComponentListView.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/modules/editor/contentObject/views/editorPageComponentListView.js b/frontend/src/modules/editor/contentObject/views/editorPageComponentListView.js index c714ddce80..838b21483f 100644 --- a/frontend/src/modules/editor/contentObject/views/editorPageComponentListView.js +++ b/frontend/src/modules/editor/contentObject/views/editorPageComponentListView.js @@ -68,6 +68,8 @@ define(function(require) { this.$el.css({ right:this.$('.editor-component-list-sidebar') .width()*-1}) .velocity({ right: 0 }, {duration: 400, easing: 'easeOutQuart'}); + + this.$('.editor-component-list-sidebar-search-field input').focus(); }, closeView: function() { From 3c02caf55a8e98d0c8fed7aafbce7b2d85fbeca7 Mon Sep 17 00:00:00 2001 From: Andrew Bone Date: Tue, 23 Jul 2019 10:22:36 +0100 Subject: [PATCH 11/35] Remove focus from showComponentList Focus function has been moved to editorPageComponentListView's postRender function --- .../modules/editor/contentObject/views/editorPageBlockView.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/modules/editor/contentObject/views/editorPageBlockView.js b/frontend/src/modules/editor/contentObject/views/editorPageBlockView.js index 1aa8f34594..b3c488f6d6 100644 --- a/frontend/src/modules/editor/contentObject/views/editorPageBlockView.js +++ b/frontend/src/modules/editor/contentObject/views/editorPageBlockView.js @@ -261,8 +261,6 @@ define(function(require){ $parentElement: this.$el, parentView: this }).$el); - - $('.editor-component-list-sidebar-search-field input').focus(); }, setupPasteZones: function() { From c7de802942f3195b78ec6ff43f37bee8f22a73b2 Mon Sep 17 00:00:00 2001 From: Thomas Berger Date: Tue, 23 Jul 2019 14:13:56 +0200 Subject: [PATCH 12/35] remove temp file in assetmanager --- lib/assetmanager.js | 58 +++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/lib/assetmanager.js b/lib/assetmanager.js index 417418656b..f1c371eb57 100644 --- a/lib/assetmanager.js +++ b/lib/assetmanager.js @@ -4,7 +4,7 @@ */ var path = require('path'), - fs = require('fs'), + fs = require('fs-extra'), _ = require('underscore'), async = require('async'), util = require('util'), @@ -447,34 +447,36 @@ exports = module.exports = { var filePath = storedFile.path; - // It's better not to set thumbnailPath if it's not set. - if (storedFile.thumbnailPath) { - storedFile.thumbnailPath = storedFile.thumbnailPath; - } - - var asset = _.extend({ - title: fields.title, - description: fields.description, - repository: repository, - filename: filehash + fileExt, - directory: directory, - isDirectory: false, - tags: (fields.tags && fields.tags.length) ? fields.tags.split(',') : [], - createdBy: user._id, - dateCreated: date - }, - storedFile - ); - - self.createAsset(asset, function (createError, assetRec) { - if (createError) { // if the record creation fails, remove the file that was uploaded - logger.log('error', createError); - return storage.deleteFile(storedFile.path, function (delErr) { - if (delErr) logger.log('error', 'Failed to delete stored file in assetmanager', storedFile.path); - _respondError("An error occured during upload, please contact an Administrator."); - }); + fs.remove(uploadedFilePath, function(error) { + // It's better not to set thumbnailPath if it's not set. + if (storedFile.thumbnailPath) { + storedFile.thumbnailPath = storedFile.thumbnailPath; } - res.status(200).json({ _id: assetRec._id }); + + var asset = _.extend({ + title: fields.title, + description: fields.description, + repository: repository, + filename: filehash + fileExt, + directory: directory, + isDirectory: false, + tags: (fields.tags && fields.tags.length) ? fields.tags.split(',') : [], + createdBy: user._id, + dateCreated: date + }, + storedFile + ); + + self.createAsset(asset, function (createError, assetRec) { + if (createError) { // if the record creation fails, remove the file that was uploaded + logger.log('error', createError); + return storage.deleteFile(storedFile.path, function (delErr) { + if (delErr) logger.log('error', 'Failed to delete stored file in assetmanager', storedFile.path); + _respondError("An error occured during upload, please contact an Administrator."); + }); + } + res.status(200).json({ _id: assetRec._id }); + }); }); }); }); From a1bdd95ea723e35df940b07285a379fa1e4750aa Mon Sep 17 00:00:00 2001 From: Thomas Berger Date: Tue, 23 Jul 2019 14:14:40 +0200 Subject: [PATCH 13/35] remove uploaded zip file remove unzipped folder --- plugins/content/bower/index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/content/bower/index.js b/plugins/content/bower/index.js index 3016f6dbf7..4f8cc970b8 100644 --- a/plugins/content/bower/index.js +++ b/plugins/content/bower/index.js @@ -1142,8 +1142,21 @@ function handleUploadedPlugin (req, res, next) { if (error) { return next(error); } - res.statusCode = 200; - return res.json({ success: true, pluginType: pluginType, message: 'successfully added new plugin' }); + + function sendResponse() { + res.statusCode = 200; + return res.json({ + success: true, + pluginType: pluginType, + message: 'successfully added new plugin' + }); + } + + Promise.all([ + fs.remove(file.path), + fs.remove(outputPath) + ]).then(sendResponse).catch(sendResponse); + }); }); }); From 3fbf6ad086f0c7b1fcb173b2e26081021ecbe376 Mon Sep 17 00:00:00 2001 From: nicola Date: Wed, 24 Jul 2019 09:47:00 +0100 Subject: [PATCH 14/35] Text updates and add server plugin valid check --- .../frameworkImport/less/frameworkImport.less | 1 - .../frameworkImportPluginHeadingView.hbs | 8 +- .../templates/frameworkImportPluginView.hbs | 6 +- .../views/frameworkImportView.js | 2 +- plugins/output/adapt/helpers.js | 94 +++++++++---------- routes/lang/en-application.json | 18 ++-- 6 files changed, 64 insertions(+), 65 deletions(-) diff --git a/frontend/src/modules/frameworkImport/less/frameworkImport.less b/frontend/src/modules/frameworkImport/less/frameworkImport.less index d750499647..d352b074ec 100644 --- a/frontend/src/modules/frameworkImport/less/frameworkImport.less +++ b/frontend/src/modules/frameworkImport/less/frameworkImport.less @@ -58,7 +58,6 @@ &.import-summary { .title { - font-style: italic; padding-bottom: 10px; color: @primary-color; diff --git a/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs index ae8b901490..bd11c07e78 100644 --- a/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs +++ b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginHeadingView.hbs @@ -1,19 +1,19 @@
    -
    +

    {{t 'app.name'}}

    -
    +

    {{t 'app.importversion'}}

    -
    +

    {{t 'app.atversion'}}

    -

    {{t 'app.status'}}

    +

    {{t 'app.action'}}

    diff --git a/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs index db5752334f..1c9857b865 100644 --- a/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs +++ b/frontend/src/modules/frameworkImport/templates/frameworkImportPluginView.hbs @@ -1,12 +1,12 @@
    -
    +
    {{displayName}}
    -
    +
    {{importVersion}}
    -
    +
    {{authoringToolVersion}}
    diff --git a/frontend/src/modules/frameworkImport/views/frameworkImportView.js b/frontend/src/modules/frameworkImport/views/frameworkImportView.js index 8092afbf66..1f9d96b20e 100644 --- a/frontend/src/modules/frameworkImport/views/frameworkImportView.js +++ b/frontend/src/modules/frameworkImport/views/frameworkImportView.js @@ -87,7 +87,7 @@ define(function(require){ // Framework versions panel if (data.frameworkVersions.imported !== data.frameworkVersions.installed) { - $framework_versions.text(Origin.l10n.t('app.importframeworkversions', { + $framework_versions.html(Origin.l10n.t('app.importframeworkversions', { importVersion: data.frameworkVersions.imported, installedVersion: data.frameworkVersions.installed })); diff --git a/plugins/output/adapt/helpers.js b/plugins/output/adapt/helpers.js index 04e834b0c1..004981a4ab 100644 --- a/plugins/output/adapt/helpers.js +++ b/plugins/output/adapt/helpers.js @@ -229,54 +229,54 @@ function getPluginFrameworkVersionCategory(serverFrameworkVersion, pluginMetaDat var contentPlugin; async.waterfall([ - function getContentPlugin(cb) { - origin.contentmanager.getContentPlugin(type, cb); - }, - function getDB(plugin, cb) { - contentPlugin = plugin; - database.getDatabase(cb); - }, - function retrievePluginDoc(db, cb) { - db.retrieve(contentPlugin.bowerConfig.type, { name: pluginMetaData.name }, { jsonOnly: true }, cb); - }, - function categorisePlugin(records, cb) { - var importPluginVersionValid = semver.valid(pluginMetaData.version); - if (records.length === 0) { - // Not already installed so could be: - // Red - this plugin is not compatible or the version is invalid - // Green - this plugin is compatible and will be installed - if (!importPluginVersionValid) { - return cb(null, {category: 'red', authoringToolVersion: app.polyglot.t('app.none')}); - } - if (semver.satisfies(serverFrameworkVersion, pluginFrameworkVersion, { - includePrerelease: true - })) { - return cb(null, {category: 'green-install', authoringToolVersion: app.polyglot.t('app.none')}); - } - cb(null, {category: 'red', authoringToolVersion: app.polyglot.t('app.none')}); - } else { - // A version is already installed so could be: - // White - same version installed as in course - // Red - invalid version - // Amber - newer version installed and will be used in the course instead - // Green - older version installed so this newer version will be upgraded in the AT - var serverPlugin = records[0]; - var serverPluginVersion = semver.clean(serverPlugin.version); - if (!importPluginVersionValid) { - return cb(null, {category: 'red', authoringToolVersion: serverPluginVersion}); - } - var isServerVersionLatest = semver.compare(serverPluginVersion, pluginMetaData.version); - if (isServerVersionLatest === 0) { - return cb(null, {category: 'white', authoringToolVersion: app.polyglot.t('app.none')}); - } - if (semver.satisfies(serverFrameworkVersion, pluginFrameworkVersion, { - includePrerelease: true - }) && isServerVersionLatest < 0) { - return cb(null, {category: 'green-update', authoringToolVersion: serverPluginVersion}); - } - cb(null, {category: 'amber', authoringToolVersion: serverPluginVersion}); - } + function getContentPlugin(cb) { + origin.contentmanager.getContentPlugin(type, cb); + }, + function getDB(plugin, cb) { + contentPlugin = plugin; + database.getDatabase(cb); + }, + function retrievePluginDoc(db, cb) { + db.retrieve(contentPlugin.bowerConfig.type, { name: pluginMetaData.name }, { jsonOnly: true }, cb); + }, + function categorisePlugin(records, cb) { + var importPluginVersionValid = semver.valid(pluginMetaData.version); + if (records.length === 0) { + // Not already installed so could be: + // Red - this plugin is not compatible or the version is invalid + // Green - this plugin is compatible and will be installed + if (!importPluginVersionValid) { + return cb(null, {category: 'red', authoringToolVersion: app.polyglot.t('app.none')}); + } + if (semver.satisfies(serverFrameworkVersion, pluginFrameworkVersion, { + includePrerelease: true + })) { + return cb(null, {category: 'green-install', authoringToolVersion: app.polyglot.t('app.none')}); + } + return cb(null, {category: 'red', authoringToolVersion: app.polyglot.t('app.none')}); + } + + // A version is already installed so could be: + // White - same version installed as in course + // Red - invalid version + // Amber - newer version installed and will be used in the course instead + // Green - older version installed so this newer version will be upgraded in the AT + var serverPlugin = records[0]; + if (!importPluginVersionValid || !semver.valid(serverPlugin.version)) { + return cb(null, {category: 'red', authoringToolVersion: serverPlugin.version}); + } + var serverPluginVersion = semver.clean(serverPlugin.version); + var isServerVersionLatest = semver.compare(serverPluginVersion, pluginMetaData.version); + if (isServerVersionLatest === 0) { + return cb(null, {category: 'white', authoringToolVersion: app.polyglot.t('app.none')}); } + if (semver.satisfies(serverFrameworkVersion, pluginFrameworkVersion, { + includePrerelease: true + }) && isServerVersionLatest < 0) { + return cb(null, {category: 'green-update', authoringToolVersion: serverPluginVersion}); + } + cb(null, {category: 'amber', authoringToolVersion: serverPluginVersion}); + } ], function(error, category) { return callback(error, category); }); diff --git a/routes/lang/en-application.json b/routes/lang/en-application.json index ebe6d0b78b..1d9252e2f1 100644 --- a/routes/lang/en-application.json +++ b/routes/lang/en-application.json @@ -352,23 +352,23 @@ "app.importassetfolderstitle": "Asset Folders", "app.importassetfoldersplaceholder": "assets, images, video, audio", "app.importinvalidpackage": "Encountered an unexpected file structure. Please check you have uploaded a valid export package and try again.", - "app.importframeworkversions": "This course was built with Framework %{importVersion}, this Authoring Tool has Framework %{installedVersion} installed. If you proceed with this import then your course will use Framework %{installedVersion} and should be tested.", + "app.importframeworkversions": "Import framework version: %{importVersion}
    Installed framework version: %{installedVersion}

    If you proceed with this import then your course will use framework %{installedVersion} and should be tested.", "app.coursecanbeimported": "Course can be imported", - "app.coursecanbeimportedwhitedesc": "All of the plugins and the Framework version used in this course are identical to that in this Authoring Tool.", + "app.coursecanbeimportedwhitedesc": "All of the plugins and the framework version used in this course are identical to that in this authoring tool.", "app.coursecanbeimporteddesc": "One of more of the plugins used in this course will be updated as part of the import process. You should test the course after the import has completed.", "app.coursecannotbeimported": "Course cannot be imported", - "app.coursecannotbeimporteddesc": "One or more of the plugins used in this course is not compatible with the version of the Framework that is used by this Authoring Tool. Please remove or update these plugins and try again.", + "app.coursecannotbeimporteddesc": "One or more of the plugins used in this course are not compatible with the version of the framework that is used by this authoring tool. Please remove or update these plugins and try again.", "app.importversion": "Import Version", - "app.atversion": "Authoring Tool Version", - "app.status": "Status", + "app.atversion": "Installed Version", + "app.action": "Action", "app.plugingreeninstalllabel": "Install", "app.plugingreenupdatelabel": "Update", "app.pluginamberlabel": "Use installed version", "app.pluginredlabel": "Action Needed", - "app.plugingreeninstallkey": "These plugins will be installed into the Authoring Tool during import.", - "app.plugingreenupdatekey": "These plugins will be updated in the Authoring Tool during import.", - "app.pluginamberkey": "The version of these plugins included in this import is either not compatible with this Authoring Tool, or a newer version is already installed. The imported course will use the existing version.", - "app.pluginredkey": "These plugins are not supported in this authoring tool. You must remove or update these plugins before you can continue with the import.", + "app.plugingreeninstallkey": "This plugin will be installed into the authoring tool during import.", + "app.plugingreenupdatekey": "This plugin will be updated in the authoring tool during import.", + "app.pluginamberkey": "The version of this plugin included in this import is either not compatible with this authoring tool, or a newer version is already installed. The imported course will use the existing version.", + "app.pluginredkey": "This plugin is not supported in this authoring tool. You must remove or update this plugin before you can continue with the import.", "app.errorfetchingdata": "An error occured fetching data. Please try refreshing your page.", "app.backtoassets": "Back to assets", "app.newasset": "New Asset", From 8f39025e9344b409650910d79d98951fb81f97f9 Mon Sep 17 00:00:00 2001 From: nicola Date: Wed, 24 Jul 2019 11:49:14 +0100 Subject: [PATCH 15/35] Add front end validation to preset names --- .../editor/themeEditor/less/editorPresetEdit.less | 4 ++++ .../themeEditor/templates/editorPresetEdit.hbs | 1 + .../themeEditor/views/editorPresetEditView.js | 13 +++++++++++++ .../editor/themeEditor/views/editorThemingView.js | 7 ++++--- .../src/modules/userManagement/views/userView.js | 2 +- routes/lang/en-application.json | 2 +- 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/frontend/src/modules/editor/themeEditor/less/editorPresetEdit.less b/frontend/src/modules/editor/themeEditor/less/editorPresetEdit.less index e6b7bb6419..da5284a91c 100644 --- a/frontend/src/modules/editor/themeEditor/less/editorPresetEdit.less +++ b/frontend/src/modules/editor/themeEditor/less/editorPresetEdit.less @@ -44,6 +44,10 @@ .nameEdit { display: none; + + .preset-error { + color: red; + } } .label, diff --git a/frontend/src/modules/editor/themeEditor/templates/editorPresetEdit.hbs b/frontend/src/modules/editor/themeEditor/templates/editorPresetEdit.hbs index d022fb22fb..38a31c970a 100644 --- a/frontend/src/modules/editor/themeEditor/templates/editorPresetEdit.hbs +++ b/frontend/src/modules/editor/themeEditor/templates/editorPresetEdit.hbs @@ -15,6 +15,7 @@
    +