diff --git a/cms/static/js/factories/import.js b/cms/static/js/factories/import.js index 2577844e42..acefd1a6c6 100644 --- a/cms/static/js/factories/import.js +++ b/cms/static/js/factories/import.js @@ -28,6 +28,7 @@ define([ autoUpload: false, add: function(e, data) { CourseImport.clearImportDisplay(); + CourseImport.okayToNavigateAway = false; submitBtn.unbind('click'); file = data.files[0]; if (file.name.match(/tar\.gz$/)) { @@ -97,7 +98,9 @@ define([ }, start: function(event) { window.onbeforeunload = function() { - return gettext('Your import is in progress; navigating away will abort it.'); + if (!CourseImport.okayToNavigateAway) { + return "${_('Your import is in progress; navigating away will abort it.')}"; + } }; }, sequentialUploads: true, diff --git a/cms/static/js/views/import.js b/cms/static/js/views/import.js index 4ded865a47..00aa7826ff 100644 --- a/cms/static/js/views/import.js +++ b/cms/static/js/views/import.js @@ -49,6 +49,7 @@ define( */ var getStatus = function (url, timeout, stage) { var currentStage = stage || 0; + if (currentStage > 1) { CourseImport.okayToNavigateAway = true; } if (CourseImport.stopGetStatus) { return ;} if (currentStage === 4) { @@ -87,6 +88,10 @@ define( * progress. */ stopGetStatus: false, + /** + * Whether its fine to navigate away while import is in progress + */ + okayToNavigateAway: false, /** * Update DOM to set all stages as not-started (for retrying an upload that