Skip to content

Commit

Permalink
Merge pull request #2473 from adaptlearning/release/bugpatch
Browse files Browse the repository at this point in the history
Release 0.10.2
  • Loading branch information
tomgreenfield authored Nov 8, 2019
2 parents 650cece + 6578437 commit 859227b
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 75 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ 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**.<br/>
_Note that we adhere to the [semantic versioning](http://semver.org/) scheme for release numbering._

## [0.10.2] - 2019-11-08

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))
- 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))

## [0.10.1] - 2019-10-22

Bugfix release.
Expand Down Expand Up @@ -659,6 +673,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/modules/pluginManagement/views/pluginTypeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
21 changes: 0 additions & 21 deletions frontend/src/modules/scaffold/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,7 +31,6 @@ define([

function onScaffoldUpdateSchemas(callback, context) {
Origin.trigger('schemas:loadData', function() {
builtSchemas = {};
callback.apply(context);
});
}
Expand Down Expand Up @@ -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 = {};

Expand All @@ -181,11 +165,6 @@ define([
}
}

// only cache non-volatile types
if (!isVolatileType) {
builtSchemas[type] = scaffoldSchema;
}

return scaffoldSchema;
}

Expand Down
1 change: 1 addition & 0 deletions frontend/src/modules/scaffold/views/scaffoldTagsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/bowermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
28 changes: 17 additions & 11 deletions lib/installHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -252,8 +252,14 @@ function getInstalledFrameworkVersion(callback) {
});
}

function getLatestFrameworkVersion(callback) {
checkLatestAdaptRepoVersion('adapt_framework', pkg.framework, callback);
function getLatestFrameworkVersion(installedVersion, callback) {
let versionLimit;
if (typeof installedVersion === 'function') {
callback = installedVersion;
} else {
versionLimit = semver.major(installedVersion).toString();
}
checkLatestAdaptRepoVersion('adapt_framework', versionLimit, callback);
}

function getInstalledVersions(callback) {
Expand All @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -11,7 +11,6 @@
"type": "git",
"url": "https://github.com/adaptlearning/adapt_authoring.git"
},
"framework": "2",
"main": "index",
"engines": {
"node": "10 || 12"
Expand Down
15 changes: 11 additions & 4 deletions plugins/content/bower/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
});
});
Expand Down Expand Up @@ -808,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) => {
Expand Down
50 changes: 27 additions & 23 deletions plugins/output/adapt/importsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) return 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
*/
Expand Down
4 changes: 2 additions & 2 deletions upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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);
Expand Down

0 comments on commit 859227b

Please sign in to comment.