From 72d55439104c54ed58fc65d3aeb8ebc83cd95830 Mon Sep 17 00:00:00 2001 From: Tom Greenfield Date: Wed, 23 Oct 2019 16:08:39 +0100 Subject: [PATCH 01/14] Handle error when updating plugin --- .../pluginManagement/views/pluginTypeView.js | 22 +++++++++---------- plugins/content/bower/index.js | 9 +++++--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/frontend/src/modules/pluginManagement/views/pluginTypeView.js b/frontend/src/modules/pluginManagement/views/pluginTypeView.js index 55d19eedc0..a5fd64232b 100644 --- a/frontend/src/modules/pluginManagement/views/pluginTypeView.js +++ b/frontend/src/modules/pluginManagement/views/pluginTypeView.js @@ -81,18 +81,18 @@ define(function(require){ }); $icon.removeClass().addClass('fa fa-refresh fa-spin'); - $.post(this.model.urlRoot + '/update', { 'targets': [this.model.get('_id')] }, _.bind(function(data) { - if(!_.contains(data.upgraded, this.model.get('_id'))) { - $btn.attr({title: Origin.l10n.t('app.updatefailed')}); + $.post(this.model.urlRoot + '/update', { 'targets': [ this.model.get('_id') ] }) + .done(function() { + Origin.trigger('scaffold:updateSchemas', function() { + $btn.attr('title', Origin.l10n.t('app.uptodate')); + $icon.removeClass().addClass('fa fa-check'); + this.model.fetch(); + }, this); + }.bind(this)) + .fail(function() { + $btn.attr('title', Origin.l10n.t('app.updatefailed')); $icon.removeClass().addClass('fa fa-times'); - return; - } - Origin.trigger('scaffold:updateSchemas', function() { - $btn.attr({title: Origin.l10n.t('app.uptodate')}); - $icon.removeClass().addClass('fa fa-check'); - this.model.fetch(); - }, this); - }, this)); + }); return false; }, diff --git a/plugins/content/bower/index.js b/plugins/content/bower/index.js index ecc4accec8..8a62d2dd4c 100644 --- a/plugins/content/bower/index.js +++ b/plugins/content/bower/index.js @@ -552,9 +552,12 @@ BowerPlugin.prototype.initialize = function (plugin) { { _searchItems: pluginNames } ); - return self.updatePackages(plugin, options, function () { - // @TODO figure out how to determine if the update failed? - return res.json({ success: true, upgraded: upgradeTargets }); + return self.updatePackages(plugin, options, function(err) { + if (err) { + logger.log('error', err); + res.statusCode = 400; + } + return res.json({ success: !err, message: err && err.message }); }); }); }); From 3a3a1daf744f4cbf58aff00d35a819ee45d38676 Mon Sep 17 00:00:00 2001 From: Tom Greenfield Date: Wed, 23 Oct 2019 16:23:30 +0100 Subject: [PATCH 02/14] Ignore existing target attribute if same plugin type and name --- plugins/content/bower/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/content/bower/index.js b/plugins/content/bower/index.js index 8a62d2dd4c..40eb478637 100644 --- a/plugins/content/bower/index.js +++ b/plugins/content/bower/index.js @@ -811,7 +811,11 @@ function addPackage (plugin, packageInfo, options, cb) { async.some([ 'componenttype', 'extensiontype', 'menutype', 'themetype' ], (type, asyncCallback) => { if (!targetAttribute) return asyncCallback(); - db.retrieve(type, { targetAttribute: targetAttribute }, (err, results) => { + const query = type === plugin.type ? + { name: { $ne: pkgMeta.name }, targetAttribute: targetAttribute } : + { targetAttribute: targetAttribute }; + + db.retrieve(type, query, (err, results) => { asyncCallback(err, results && results.length); }); }, (err, targetAttributeExists) => { From 8542571324491e81fca19ef6fba8484ba65f07f6 Mon Sep 17 00:00:00 2001 From: Tom Greenfield Date: Thu, 24 Oct 2019 11:13:27 +0100 Subject: [PATCH 03/14] Switch to asynchronous test function --- lib/bowermanager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bowermanager.js b/lib/bowermanager.js index 95ff8ddd76..2c39e65c27 100644 --- a/lib/bowermanager.js +++ b/lib/bowermanager.js @@ -180,7 +180,7 @@ BowerManager.prototype.installLatestCompatibleVersion = function (pluginName, ca requiredFrameworkVersion = result.framework; cb(); }); - }, function isCompatible() { + }, async function isCompatible() { return semver.satisfies(installedFrameworkVersion, requiredFrameworkVersion); }, function(error, version) { if(error) { From 02bfe7779322262e367896671c8bc89c404e40a9 Mon Sep 17 00:00:00 2001 From: Tom Greenfield Date: Thu, 24 Oct 2019 16:36:18 +0100 Subject: [PATCH 04/14] Improve falsy check --- lib/installHelpers.js | 4 ++-- upgrade.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/installHelpers.js b/lib/installHelpers.js index a9830dc705..a0d3d36acd 100644 --- a/lib/installHelpers.js +++ b/lib/installHelpers.js @@ -42,8 +42,8 @@ var inputHelpers = { readline.moveCursor(process.stdout, 0, -1); return v; }, - isFalsyString: function(v) { - if (typeof v !== 'string') return false; + isFalsy: function(v) { + if (typeof v !== 'string') return !v; switch (v.trim()) { case '': case 'N': diff --git a/upgrade.js b/upgrade.js index a6adfb316b..d3d3eaec9d 100644 --- a/upgrade.js +++ b/upgrade.js @@ -142,7 +142,7 @@ function checkForUpdates(callback) { function doUpdate(data) { async.series([ function upgradeAuthoring(cb) { - if (installHelpers.inputHelpers.isFalsyString(data.adapt_authoring)) { + if (installHelpers.inputHelpers.isFalsy(data.adapt_authoring)) { return cb(); } installHelpers.updateAuthoring({ @@ -159,7 +159,7 @@ function doUpdate(data) { }); }, function upgradeFramework(cb) { - if (installHelpers.inputHelpers.isFalsyString(data.adapt_framework)) { + if (installHelpers.inputHelpers.isFalsy(data.adapt_framework)) { return cb(); } var dir = path.join(configuration.tempDir, configuration.getConfig('masterTenantID'), OutputConstants.Folders.Framework); From 883e028ec3aa7cf4b333a59b35b57520dbfeca09 Mon Sep 17 00:00:00 2001 From: Tom Greenfield Date: Thu, 24 Oct 2019 16:38:49 +0100 Subject: [PATCH 05/14] Restrict to installed major version for automatic framework upgrade --- lib/installHelpers.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/installHelpers.js b/lib/installHelpers.js index a0d3d36acd..19e8874a33 100644 --- a/lib/installHelpers.js +++ b/lib/installHelpers.js @@ -252,8 +252,14 @@ function getInstalledFrameworkVersion(callback) { }); } -function getLatestFrameworkVersion(callback) { - checkLatestAdaptRepoVersion('adapt_framework', pkg.framework, callback); +function getLatestFrameworkVersion(installedVersion, callback) { + let versionLimit = pkg.framework; + if (typeof installedVersion === 'function') { + callback = installedVersion; + } else { + versionLimit = semver.major(installedVersion).toString(); + } + checkLatestAdaptRepoVersion('adapt_framework', versionLimit, callback); } function getInstalledVersions(callback) { @@ -268,20 +274,20 @@ function getInstalledVersions(callback) { }); } -function getLatestVersions(callback) { +function getLatestVersions(installedVersions, callback) { async.parallel([ exports.getLatestServerVersion, - exports.getLatestFrameworkVersion + async.apply(exports.getLatestFrameworkVersion, installedVersions.adapt_framework) ], function(error, results) { - callback(error, { - adapt_authoring: results[0], - adapt_framework: results[1] - }); + callback(error, [ + installedVersions, + { adapt_authoring: results[0], adapt_framework: results[1] } + ]); }); } function getUpdateData(callback) { - async.parallel([ + async.waterfall([ exports.getInstalledVersions, exports.getLatestVersions ], function(error, results) { From 177170c08043875ac916101506b90089254d4574 Mon Sep 17 00:00:00 2001 From: Tom Greenfield Date: Thu, 24 Oct 2019 16:40:03 +0100 Subject: [PATCH 06/14] Install framework 4 by default --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 70da2e1951..e9478a4022 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "type": "git", "url": "https://github.com/adaptlearning/adapt_authoring.git" }, - "framework": "2", + "framework": "4", "main": "index", "engines": { "node": "10 || 12" From 544012a50e64a77e7bcc311d8d04ff6a9541e97d Mon Sep 17 00:00:00 2001 From: Tom Greenfield Date: Mon, 28 Oct 2019 16:22:51 +0000 Subject: [PATCH 07/14] Scrap package JSON framework limit --- lib/installHelpers.js | 2 +- package.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/installHelpers.js b/lib/installHelpers.js index 19e8874a33..6e1bb5180f 100644 --- a/lib/installHelpers.js +++ b/lib/installHelpers.js @@ -253,7 +253,7 @@ function getInstalledFrameworkVersion(callback) { } function getLatestFrameworkVersion(installedVersion, callback) { - let versionLimit = pkg.framework; + let versionLimit; if (typeof installedVersion === 'function') { callback = installedVersion; } else { diff --git a/package.json b/package.json index e9478a4022..1d526992fc 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "type": "git", "url": "https://github.com/adaptlearning/adapt_authoring.git" }, - "framework": "4", "main": "index", "engines": { "node": "10 || 12" From ebd70064ba5a17f509fea551dfb38a2c3edc04cc Mon Sep 17 00:00:00 2001 From: Dan Gray Date: Tue, 29 Oct 2019 09:43:38 +0000 Subject: [PATCH 08/14] Add array tags in callback --- plugins/output/adapt/importsource.js | 50 +++++++++++++++------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/plugins/output/adapt/importsource.js b/plugins/output/adapt/importsource.js index 2e5b0a9e5a..bdc6ff39bf 100644 --- a/plugins/output/adapt/importsource.js +++ b/plugins/output/adapt/importsource.js @@ -172,25 +172,6 @@ function ImportSource(req, done) { var assetJson = assetsJson[assetName]; var tags = []; - if (assetJson) { - assetTitle = assetJson.title; - assetDescription = assetJson.description; - - assetJson.tags.forEach(function(tag) { - const tagTitle = tag.title; - const warn = (error) => logger.log('warn', `Failed to create asset tag '${tagTitle}' ${error}`); - - if(!tagTitle) return warn(new Error('Tag has no title')); - - app.contentmanager.getContentPlugin('tag', function(error, plugin) { - if(error) return warn(error); - plugin.create({ title: tagTitle }, function(error, record) { // @note retrieves if tag already exists - if(error) return warn(error); - tags.push(record._id); - }); - }); - }); - } var fileMeta = { oldId: assetId, title: assetTitle, @@ -203,15 +184,38 @@ function ImportSource(req, done) { repository: repository, createdBy: app.usermanager.getCurrentUser()._id }; - if(!fileMeta) { - return doneAsset(new helpers.ImportError('No metadata found for asset: ' + assetName)); - } - helpers.importAsset(fileMeta, metadata, doneAsset); + + if (!assetJson) helpers.importAsset(fileMeta, metadata, doneAsset); + + addAssetTags(assetJson, function(error, assetTags) { + const warn = (error) => logger.log('warn', `Failed to create asset tag ${error}`); + if (error) return warn(new Error(error)); + fileMeta.title = assetJson.title; + fileMeta.description = assetJson.description; + fileMeta.tags = assetTags; + helpers.importAsset(fileMeta, metadata, doneAsset); + }); }, doneAssetFolder); }); }, done); } + function addAssetTags(assetJson, cb) { + var assetTags = []; + assetJson.tags.forEach(function(tag) { + var tagTitle = tag.title; + if(!tagTitle) return cb('Tag has no title'); + app.contentmanager.getContentPlugin('tag', function(error, plugin) { + if(error) return cb(tagTitle.concat(' ', error)); + plugin.create({ title: tagTitle }, function(error, record) { // @note retrieves if tag already exists + if(error) return cb(tagTitle.concat(' ', error)); + assetTags.push(record._id); + }); + }); + }); + cb(null, assetTags); + } + /** * Stores plugin metadata for use later */ From 35fa28ba5652c8899cdb3759d69d27a31847b735 Mon Sep 17 00:00:00 2001 From: Dan Gray Date: Wed, 30 Oct 2019 15:41:13 +0000 Subject: [PATCH 09/14] Add loading class to selectize setup fixes #2460 --- .../assetManagement/views/assetManagementModalNewAssetView.js | 1 + frontend/src/modules/scaffold/views/scaffoldTagsView.js | 1 + 2 files changed, 2 insertions(+) diff --git a/frontend/src/modules/assetManagement/views/assetManagementModalNewAssetView.js b/frontend/src/modules/assetManagement/views/assetManagementModalNewAssetView.js index b21151b089..46b5b3605a 100644 --- a/frontend/src/modules/assetManagement/views/assetManagementModalNewAssetView.js +++ b/frontend/src/modules/assetManagement/views/assetManagementModalNewAssetView.js @@ -34,6 +34,7 @@ define(function(require){ this.$('#tags_control').selectize({ create: true, labelField: 'title', + loadingClass: 'selectize-loading', load: function(query, callback) { $.ajax({ url: 'api/autocomplete/tag', diff --git a/frontend/src/modules/scaffold/views/scaffoldTagsView.js b/frontend/src/modules/scaffold/views/scaffoldTagsView.js index f9a897b91b..a1719fad69 100644 --- a/frontend/src/modules/scaffold/views/scaffoldTagsView.js +++ b/frontend/src/modules/scaffold/views/scaffoldTagsView.js @@ -23,6 +23,7 @@ define([ 'core/origin', 'backbone-forms' ], function(Origin, BackboneForms) { this.$el.selectize({ create: true, labelField: 'title', + loadingClass: 'selectize-loading', load: function(query, callback) { $.ajax({ url: 'api/autocomplete/tag', From 06dbb34a5381f531206bd0859e6e670072dc7e78 Mon Sep 17 00:00:00 2001 From: Dan Gray Date: Tue, 5 Nov 2019 15:49:20 +0000 Subject: [PATCH 10/14] Return if no assetJson --- plugins/output/adapt/importsource.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/output/adapt/importsource.js b/plugins/output/adapt/importsource.js index bdc6ff39bf..f40b9bb841 100644 --- a/plugins/output/adapt/importsource.js +++ b/plugins/output/adapt/importsource.js @@ -185,7 +185,7 @@ function ImportSource(req, done) { createdBy: app.usermanager.getCurrentUser()._id }; - if (!assetJson) helpers.importAsset(fileMeta, metadata, doneAsset); + if (!assetJson) return helpers.importAsset(fileMeta, metadata, doneAsset); addAssetTags(assetJson, function(error, assetTags) { const warn = (error) => logger.log('warn', `Failed to create asset tag ${error}`); From eabe0c2c4e1e3ef9f41adddfa0f66c1b6555c49c Mon Sep 17 00:00:00 2001 From: Dan Gray Date: Wed, 6 Nov 2019 10:39:36 +0000 Subject: [PATCH 11/14] Remove built schema cache, fixes #2467 --- frontend/src/modules/scaffold/index.js | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/frontend/src/modules/scaffold/index.js b/frontend/src/modules/scaffold/index.js index ce0db38366..8b27d00d95 100644 --- a/frontend/src/modules/scaffold/index.js +++ b/frontend/src/modules/scaffold/index.js @@ -17,7 +17,6 @@ define([ ], function(Origin, Helpers, Schemas, BackboneForms, BackboneFormsLists, Overrides, ScaffoldAssetView, ScaffoldAssetItemView, ScaffoldCodeEditorView, ScaffoldColourPickerView, ScaffoldDisplayTitleView, ScaffoldItemsModalView, ScaffoldListView, ScaffoldTagsView, ScaffoldUsersView) { var Scaffold = {}; - var builtSchemas = {}; var alternativeModel; var alternativeAttribute; var currentModel; @@ -32,7 +31,6 @@ define([ function onScaffoldUpdateSchemas(callback, context) { Origin.trigger('schemas:loadData', function() { - builtSchemas = {}; callback.apply(context); }); } @@ -146,20 +144,6 @@ define([ } function buildSchema(schema, options, type) { - // these types of schemas change frequently and cannot be cached - var isVolatileType = _.contains([ - 'course', - 'config', - 'article', - 'block', - 'component' - ], type); - - var builtSchema = builtSchemas[type]; - - if (!isVolatileType && builtSchema) { - return builtSchema; - } var scaffoldSchema = {}; @@ -181,11 +165,6 @@ define([ } } - // only cache non-volatile types - if (!isVolatileType) { - builtSchemas[type] = scaffoldSchema; - } - return scaffoldSchema; } From bea2b43ee1f9f04ed01699a1d35ed35b861dee30 Mon Sep 17 00:00:00 2001 From: Tom Greenfield Date: Mon, 4 Nov 2019 16:05:45 +0000 Subject: [PATCH 12/14] Prep for release --- CHANGELOG.md | 14 ++++++++++++++ package.json | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e3e4a0631..f01093ad41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ All notable changes to the Adapt authoring tool are documented in this file. **IMPORTANT**: For information on how to **correctly and safely** update your installation, please consult **INSTALL.md**.
_Note that we adhere to the [semantic versioning](http://semver.org/) scheme for release numbering._ +## [0.10.2] - 2019-11-XX + +Bugfix release. + +### Fixed +- Asset tags are not preserved on import ([#2439](https://github.com/adaptlearning/adapt_authoring/issues/2439)) +- Cannot update plugin via the UI ([#2455](https://github.com/adaptlearning/adapt_authoring/issues/2455)) +- Install script hangs when installing legacy framework ([#2457](https://github.com/adaptlearning/adapt_authoring/issues/2457)) +- Input box briefly fills screen when enering tags in asset upload modal ([#2460](https://github.com/adaptlearning/adapt_authoring/issues/2460)) + +### Added +- Upgrade script should check for compatible framework updates ([#2307](https://github.com/adaptlearning/adapt_authoring/issues/2307)) + ## [0.10.1] - 2019-10-22 Bugfix release. @@ -659,6 +672,7 @@ Initial release. - Loading screen of death - Session cookie security issues +[0.10.2]: https://github.com/adaptlearning/adapt_authoring/compare/v0.10.1...v0.10.2 [0.10.1]: https://github.com/adaptlearning/adapt_authoring/compare/v0.10.0...v0.10.1 [0.10.0]: https://github.com/adaptlearning/adapt_authoring/compare/v0.9.0...v0.10.0 [0.9.0]: https://github.com/adaptlearning/adapt_authoring/compare/v0.8.1...v0.9.0 diff --git a/package.json b/package.json index 1d526992fc..84666f0546 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "adapt_authoring", - "version": "0.10.1", + "version": "0.10.2", "license": "GPL-3.0", "description": "A server-based user interface for authoring eLearning courses using the Adapt Framework.", "keywords": [ From 11d56e6e2e104646fbd1ce685ce0c9099dac23cd Mon Sep 17 00:00:00 2001 From: tomgreenfield Date: Thu, 7 Nov 2019 10:56:32 +0000 Subject: [PATCH 13/14] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f01093ad41..92c71646f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to the Adapt authoring tool are documented in this file. **IMPORTANT**: For information on how to **correctly and safely** update your installation, please consult **INSTALL.md**.
_Note that we adhere to the [semantic versioning](http://semver.org/) scheme for release numbering._ -## [0.10.2] - 2019-11-XX +## [0.10.2] - 2019-11-11 Bugfix release. @@ -14,6 +14,7 @@ Bugfix release. - Cannot update plugin via the UI ([#2455](https://github.com/adaptlearning/adapt_authoring/issues/2455)) - Install script hangs when installing legacy framework ([#2457](https://github.com/adaptlearning/adapt_authoring/issues/2457)) - Input box briefly fills screen when enering tags in asset upload modal ([#2460](https://github.com/adaptlearning/adapt_authoring/issues/2460)) +- Extensions go missing from components ([#2467](https://github.com/adaptlearning/adapt_authoring/issues/2467)) ### Added - Upgrade script should check for compatible framework updates ([#2307](https://github.com/adaptlearning/adapt_authoring/issues/2307)) From 657843776ac4bab355e3c3020ab9c37f6b0f3b19 Mon Sep 17 00:00:00 2001 From: tomgreenfield Date: Fri, 8 Nov 2019 15:13:22 +0000 Subject: [PATCH 14/14] Slump date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c71646f6..bacab05aad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to the Adapt authoring tool are documented in this file. **IMPORTANT**: For information on how to **correctly and safely** update your installation, please consult **INSTALL.md**.
_Note that we adhere to the [semantic versioning](http://semver.org/) scheme for release numbering._ -## [0.10.2] - 2019-11-11 +## [0.10.2] - 2019-11-08 Bugfix release.