Skip to content

Commit

Permalink
bug 1170797: "unhang" release upload screen if no file provided (#186)…
Browse files Browse the repository at this point in the history
…. r=bhearsum
  • Loading branch information
njirap authored and bhearsum committed Dec 5, 2016
1 parent e9a7d5f commit 0d2341b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
39 changes: 27 additions & 12 deletions ui/app/js/controllers/release_edit_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@ function ($scope, $modalInstance, CSRF, Releases, release) {
};

$scope.saveChanges = function () {
if (!$scope.release.product.trim()) {
sweetAlert(
"Form Error",
"Product is required.",
"error"
);
return;
}
if (!$scope.dataFile) {
sweetAlert(
"Form Error",
"No file has been selected.",
"error"
);
return;
}
if (!$scope.release.name.trim()) {
sweetAlert(
"Form Error",
"Name is required",
"error"
);
return;
}

$scope.saving = true;

var file = $scope.dataFile;
Expand Down Expand Up @@ -89,18 +114,8 @@ function ($scope, $modalInstance, CSRF, Releases, release) {
});
});
};
if (typeof file === 'undefined') {
sweetAlert(
"Form Error",
"No file has been selected.",
"error"
);
$scope.saving = false;
return;
} else {
// should work
reader.readAsText(file);
}
// should work
reader.readAsText(file);

}; // /saveChanges

Expand Down
30 changes: 19 additions & 11 deletions ui/app/js/controllers/release_new_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ function($scope, $http, $modalInstance, CSRF, Releases, releases) {
);
return;
}
if (!$scope.dataFile) {
sweetAlert(
"Form Error",
"No file has been selected.",
"error"
);
return;
}

if (!$scope.release.name.trim()) {
sweetAlert(
"Form Error",
"Name is required",
"error"
);
return;
}

$scope.saving = true;
$scope.errors = {};

Expand Down Expand Up @@ -102,18 +120,8 @@ function($scope, $http, $modalInstance, CSRF, Releases, releases) {
});
});
};
if (typeof file === 'undefined') {
sweetAlert(
"Form Error",
"No file has been selected.",
"error"
);
$scope.saving = false;
return;
} else {
// should work
reader.readAsText(file);
}
reader.readAsText(file);

};

Expand Down

0 comments on commit 0d2341b

Please sign in to comment.