zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjf...@apache.org
Subject zeppelin git commit: ZEPPELIN-3520. Use the first one as the default value of dynamic form dropdown list
Date Fri, 22 Jun 2018 01:07:59 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master b9f005a62 -> 3d99e2a93


ZEPPELIN-3520. Use the first one as the default value of dynamic form dropdown list

### What is this PR for?
This PR would use the first one as the default value of dynamic form dropdown list. Otherwise
user will get error when the return value of null.

### What type of PR is it?
[Bug Fix]

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-3520
### How should this be tested?
* CI pass

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Jeff Zhang <zjffdu@apache.org>

Closes #3002 from zjffdu/ZEPPELIN-3520 and squashes the following commits:

f57e03c58 [Jeff Zhang] ZEPPELIN-3520. Use the first one as the default value of dynamic form
dropdown list


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/3d99e2a9
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/3d99e2a9
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/3d99e2a9

Branch: refs/heads/master
Commit: 3d99e2a930daa5fb18e35113b2fcd5b197fba883
Parents: b9f005a
Author: Jeff Zhang <zjffdu@apache.org>
Authored: Sat Jun 2 14:38:25 2018 +0800
Committer: Jeff Zhang <zjffdu@apache.org>
Committed: Fri Jun 22 09:07:07 2018 +0800

----------------------------------------------------------------------
 .../apache/zeppelin/spark/SparkZeppelinContext.java |  2 +-
 .../zeppelin/integration/ParagraphActionsIT.java    |  8 ++++----
 .../main/java/org/apache/zeppelin/display/GUI.java  |  6 +++++-
 .../java/org/apache/zeppelin/display/GUITest.java   | 16 ++++++++++++++++
 4 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/3d99e2a9/spark/interpreter/src/main/java/org/apache/zeppelin/spark/SparkZeppelinContext.java
----------------------------------------------------------------------
diff --git a/spark/interpreter/src/main/java/org/apache/zeppelin/spark/SparkZeppelinContext.java
b/spark/interpreter/src/main/java/org/apache/zeppelin/spark/SparkZeppelinContext.java
index 8847039..492a997 100644
--- a/spark/interpreter/src/main/java/org/apache/zeppelin/spark/SparkZeppelinContext.java
+++ b/spark/interpreter/src/main/java/org/apache/zeppelin/spark/SparkZeppelinContext.java
@@ -177,7 +177,7 @@ public class SparkZeppelinContext extends BaseZeppelinContext {
 
   @ZeppelinApi
   public Object select(String name, scala.collection.Iterable<Tuple2<Object, String>>
options) {
-    return select(name, "", options);
+    return select(name, null, options);
   }
 
   @ZeppelinApi

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/3d99e2a9/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java
----------------------------------------------------------------------
diff --git a/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java
b/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java
index e5522ec..e581410 100644
--- a/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java
+++ b/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java
@@ -571,7 +571,7 @@ public class ParagraphActionsIT extends AbstractZeppelinIT {
       waitForParagraph(1, "FINISHED");
       collector.checkThat("Output text should not display any of the options in select form",
               driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class,
'text plainTextContent')]")).getText(),
-              CoreMatchers.equalTo("Howdy "));
+              CoreMatchers.equalTo("Howdy 1"));
 
       Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1)
+ "//select)[1]"))));
 
@@ -649,13 +649,13 @@ public class ParagraphActionsIT extends AbstractZeppelinIT {
       waitForParagraph(1, "FINISHED");
       collector.checkThat("Output text should not display any of the options in select form",
               driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class,
'text plainTextContent')]")).getText(),
-              CoreMatchers.equalTo("Howdy \nHowdy "));
+              CoreMatchers.equalTo("Howdy 1\nHowdy 1"));
 
       Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1)
+ "//select)[1]"))));
       dropDownMenu.selectByVisibleText("Apple");
       collector.checkThat("After selection in drop down menu, output should display the new
option we selected",
               driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class,
'text plainTextContent')]")).getText(),
-              CoreMatchers.equalTo("Howdy 1\nHowdy "));
+              CoreMatchers.equalTo("Howdy 1\nHowdy 1"));
 
       driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click();
       clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked,
'true')]"));
@@ -665,7 +665,7 @@ public class ParagraphActionsIT extends AbstractZeppelinIT {
       waitForParagraph(1, "FINISHED");
       collector.checkThat("After 'Run on selection change' checkbox is unchecked, the paragraph
should not run if selecting a different option",
               driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class,
'text plainTextContent')]")).getText(),
-              CoreMatchers.equalTo("Howdy 1\nHowdy "));
+              CoreMatchers.equalTo("Howdy 1\nHowdy 1"));
 
       deleteTestNotebook(driver);
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/3d99e2a9/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java
index 086f805..5657c58 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java
@@ -91,11 +91,15 @@ public class GUI implements Serializable {
   }
 
   public Object select(String id, Object defaultValue, ParamOption[] options) {
+    if (defaultValue == null && options != null && options.length > 0)
{
+      defaultValue = options[0].getValue();
+    }
+    forms.put(id, new Select(id, defaultValue, options));
     Object value = params.get(id);
     if (value == null) {
       value = defaultValue;
+      params.put(id, value);
     }
-    forms.put(id, new Select(id, defaultValue, options));
     return value;
   }
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/3d99e2a9/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java
index 7d369b8..211c379 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java
@@ -47,6 +47,22 @@ public class GUITest {
   }
 
   @Test
+  public void testSelect() {
+    GUI gui = new GUI();
+    Object selected = gui.select("list_1", null, options);
+    // use the first one as the default value
+    assertEquals("1", selected);
+
+    gui = new GUI();
+    selected = gui.select("list_1", "2", options);
+    assertEquals("2", selected);
+    // "2" is selected by above statement, so even this default value is "1", the selected
value is
+    // still "2"
+    selected = gui.select("list_1", "1", options);
+    assertEquals("2", selected);
+  }
+
+  @Test
   public void testGson() {
     GUI gui = new GUI();
     gui.textbox("textbox_1", "default_text_1");


Mime
View raw message