Skip to content

Commit

Permalink
FLUID-6038: Minor refactoring based on code review
Browse files Browse the repository at this point in the history
- Updated comments in test
- renamed vars for consistency between functions
- removed some unnecessary code
  • Loading branch information
jobara committed Nov 7, 2016
1 parent e2e155d commit 33b5021
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/components/uploader/js/FileQueueView.js
Expand Up @@ -223,13 +223,12 @@ var fluid_2_0_0 = fluid_2_0_0 || {};
};

fluid.uploader.fileQueueView.refreshAfterUpload = function (that) {
var fileRows = that.locate("fileRows");
var rowButtons = that.locate("fileIconBtn", fileRows);
var rows = that.locate("fileRows");
var rowButtons = that.locate("fileIconBtn", rows);
// only re-enable rowButtons for files that have not been uploaded.
rowButtons.each(function (index, rowButton) {
rowButton = $(rowButton);
// TODO: Improve detection of completed files so as not to rely on row styling.
rowButton.prop("disabled", fileRows.eq(index).hasClass(that.options.styles.uploaded));
$(rowButton).prop("disabled", rows.eq(index).hasClass(that.options.styles.uploaded));
});
rowButtons.removeClass(that.options.styles.dim);
fluid.uploader.fileQueueView.enableRows(that.locate("fileRows"), true);
Expand All @@ -247,11 +246,11 @@ var fluid_2_0_0 = fluid_2_0_0 || {};
fluid.enabled(row, false);

// update the click event and the styling for the file delete button
var removeRowBtn = that.locate("fileIconBtn", row);
removeRowBtn.prop("disabled", true);
removeRowBtn.off("click");
removeRowBtn.removeClass(that.options.styles.remove);
removeRowBtn.attr("title", that.options.strings.status.success);
var rowButton = that.locate("fileIconBtn", row);
rowButton.prop("disabled", true);
rowButton.off("click");
rowButton.removeClass(that.options.styles.remove);
rowButton.attr("title", that.options.strings.status.success);
};

fluid.uploader.fileQueueView.renderErrorInfoFromTemplate = function (that, fileRow, error) {
Expand Down
7 changes: 6 additions & 1 deletion tests/component-tests/uploader/js/FileQueueViewTests.js
Expand Up @@ -181,7 +181,9 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
jqUnit.assertTrue("Button should be disabled. ",
rowButtons.prop("disabled"));

//assume upload is stopped, but file not uploaded. call refreshAfterUpload
// Simulates the workflow where an upload is started but the stopped
// before any files have completed uploading.
// prepareForUpload -> "upload interrupted" -> refreshAfterUpload
q.refreshAfterUpload();
jqUnit.assertFalse("Button should be enabled.", rowButtons.prop("disabled"));
});
Expand Down Expand Up @@ -227,6 +229,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt

var q = createFileQueue();
q.addFile(mountainTestFile);
q.prepareForUpload(mountainTestFile);
q.markFileComplete(mountainTestFile);

var row = q.container.find("#" + mountainTestFile.id);
Expand All @@ -241,6 +244,8 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
jqUnit.assertTrue("Remove file button should be disabled", rowButton.prop("disabled"));

//assume upload is done. call refreshAfterUpload
// Simulates the workflow where an upload is started and completed
// prepareForUpload -> markFileComplete -> refreshAfterUpload
q.refreshAfterUpload();
jqUnit.assertTrue("Remove file button should still be disabled after upload finished. ", rowButton.prop("disabled"));
});
Expand Down

0 comments on commit 33b5021

Please sign in to comment.