From 04c6ce878904972b0f979a7faa5ea6adf9583910 Mon Sep 17 00:00:00 2001
From: Samuel Gaist <samuel.gaist@idiap.ch>
Date: Thu, 4 Oct 2018 16:34:25 +0200
Subject: [PATCH] [experiments][js][pannels] Better handling of empty
 environment list

If a user for some reason doesn't have any environment at its disposal,
he should at least be able to get up to the setup page even if he can't
go further.
---
 beat/web/experiments/static/experiments/js/panels.js | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/beat/web/experiments/static/experiments/js/panels.js b/beat/web/experiments/static/experiments/js/panels.js
index bcc99550e..b2281934a 100644
--- a/beat/web/experiments/static/experiments/js/panels.js
+++ b/beat/web/experiments/static/experiments/js/panels.js
@@ -1221,6 +1221,7 @@ beat.experiments.panels.Settings.prototype._resetDatasetPanel = function(btn) {
 beat.experiments.panels.Settings.prototype._updateRunButton = function()
 {
   if (($('#' + this.id + '_name')[0].value.trim().length > 0) &&
+      !$.isEmptyObject(this.environments) &&
       (this.configuration.nbBlocksConfigured() == this.toolchain.declaration.blocks.length) &&
       (this.configuration.nbDatasetsConfigured() == this.toolchain.declaration.datasets.length) &&
       (this.configuration.nbAnalyzersConfigured() == this.toolchain.declaration.analyzers.length))
@@ -1559,7 +1560,9 @@ beat.experiments.panels.Parameters.prototype.initialize = function(configuration
   }
 
   environment_selector.selectedIndex = selected_environment_index;
-  this._onEnvironmentSelected();
+  if (environments.length > 0) {
+    this._onEnvironmentSelected();
+  }
 
 
   var selected_algorithms = this.configuration.algorithms();
@@ -2524,7 +2527,9 @@ beat.experiments.panels.BlockParameters = function(first_row, configuration, blo
 
 
   // Environment & queues
-  this.createEnvironmentControls(first_row, block_name, !has_parameters);
+  if (environments) {
+    this.createEnvironmentControls(first_row, block_name, !has_parameters);
+  }
 
 
   // Parameters
-- 
GitLab