fix: [galaxy:add] Prevent bug when submitting empty galaxy

pull/4861/head
mokaddem 2019-07-09 13:59:39 +02:00
parent fb05bc7ab0
commit 38fef5d1ae
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 5 additions and 4 deletions

View File

@ -298,13 +298,13 @@ class GalaxiesController extends AppController
$target_id_list = array($target_id);
}
$cluster_ids = $this->request->data['Galaxy']['target_ids'];
if (!empty($cluster_ids)) {
if (strlen($cluster_ids) > 0) {
$cluster_ids = json_decode($cluster_ids, true);
if ($cluster_ids === null) {
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'error' => __('Failed to parse request.'))), 'status'=>200, 'type' => 'json'));
if ($cluster_ids === null || empty($cluster_ids)) {
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => __('Failed to parse request or no clusters picked.'))), 'status'=>200, 'type' => 'json'));
}
} else {
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'error' => __('No clusters picked.'))), 'status'=>200, 'type' => 'json'));
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => __('Failed to parse request.'))), 'status'=>200, 'type' => 'json'));
}
$result = "";
if (!is_array($cluster_ids)) { // in case we only want to attach 1

View File

@ -3746,6 +3746,7 @@ function addGalaxyListener(id) {
}
function quickSubmitGalaxyForm(cluster_ids, additionalData) {
cluster_ids = cluster_ids === null ? [] : cluster_ids;
var target_id = additionalData['target_id'];
var scope = additionalData['target_type'];
var local = additionalData['local'];