You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mi...@apache.org on 2017/01/13 08:15:10 UTC

zeppelin git commit: [HOTFIX : ZEPPELIN-1932] paragraph blur error

Repository: zeppelin
Updated Branches:
  refs/heads/master 729020032 -> 2b0e2a41c


[HOTFIX : ZEPPELIN-1932] paragraph blur error

### What is this PR for?
When one or more hidden editors are present, clicking on the editor will cause a blur error.
This means that when a paragraph is hidden through ng-if,
Caused by calling the blur method in the absence of an editor object.

### What type of PR is it?
Hot Fix

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1932

### How should this be tested?
1. create paragraph and open debug console.
2. enable hide paragraph.
3. page refresh
4. click to anywhere paragraph.

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

Author: cloverhearts <cl...@gmail.com>

Closes #1879 from cloverhearts/hotfix/paragraphOnfocusEvent and squashes the following commits:

7071638 [cloverhearts] fix show title and paragraph context issue
8f4d0bf [cloverhearts] fixed readonly event error
5ecfabb [cloverhearts] check editor object is undeifned.


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

Branch: refs/heads/master
Commit: 2b0e2a41cb7e0d7fc160d5c9193413ffe4d94f68
Parents: 7290200
Author: cloverhearts <cl...@gmail.com>
Authored: Thu Jan 12 18:53:10 2017 -0800
Committer: Mina Lee <mi...@apache.org>
Committed: Fri Jan 13 17:14:55 2017 +0900

----------------------------------------------------------------------
 .../notebook/paragraph/paragraph.controller.js  | 40 +++++++++++++-------
 1 file changed, 27 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/2b0e2a41/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
index 6c612dd..5dbe1a0 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -192,6 +192,9 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
   };
 
   $scope.$watch($scope.getEditor, function(newValue, oldValue) {
+    if (!$scope.editor) {
+      return;
+    }
     if (newValue === null || newValue === undefined) {
       console.log('editor isnt loaded yet, returning');
       return;
@@ -267,7 +270,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
   };
 
   $scope.copyPara = function(position) {
-    var editorValue = $scope.editor.getValue();
+    var editorValue = $scope.getEditorValue();
     if (editorValue) {
       $scope.copyParagraph(editorValue, position);
     }
@@ -395,15 +398,19 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
   };
 
   $scope.showLineNumbers = function(paragraph) {
-    paragraph.config.lineNumbers = true;
-    $scope.editor.renderer.setShowGutter(true);
-    commitParagraph(paragraph);
+    if ($scope.editor) {
+      paragraph.config.lineNumbers = true;
+      $scope.editor.renderer.setShowGutter(true);
+      commitParagraph(paragraph);
+    }
   };
 
   $scope.hideLineNumbers = function(paragraph) {
-    paragraph.config.lineNumbers = false;
-    $scope.editor.renderer.setShowGutter(false);
-    commitParagraph(paragraph);
+    if ($scope.editor) {
+      paragraph.config.lineNumbers = false;
+      $scope.editor.renderer.setShowGutter(false);
+      commitParagraph(paragraph);
+    }
   };
 
   $scope.columnWidthClass = function(n) {
@@ -761,7 +768,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
   };
 
   $scope.getEditorValue = function() {
-    return $scope.editor.getValue();
+    return !$scope.editor ? $scope.paragraph.text : $scope.editor.getValue();
   };
 
   $scope.getProgress = function() {
@@ -1035,7 +1042,9 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
       $scope.paragraph.status = data.paragraph.status;
       $scope.paragraph.results = data.paragraph.results;
       $scope.paragraph.settings = data.paragraph.settings;
-      $scope.editor.setReadOnly($scope.isRunning(data.paragraph));
+      if ($scope.editor) {
+        $scope.editor.setReadOnly($scope.isRunning(data.paragraph));
+      }
 
       if (!$scope.asIframe) {
         $scope.paragraph.config = data.paragraph.config;
@@ -1081,7 +1090,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
         // move focus to next paragraph
         $scope.$emit('moveFocusToNextParagraph', paragraphId);
       } else if (keyEvent.shiftKey && keyCode === 13) { // Shift + Enter
-        $scope.run($scope.paragraph, $scope.editor.getValue());
+        $scope.run($scope.paragraph, $scope.getEditorValue());
       } else if (keyEvent.ctrlKey && keyEvent.altKey && keyCode === 67) { // Ctrl + Alt + c
         $scope.cancelParagraph($scope.paragraph);
       } else if (keyEvent.ctrlKey && keyEvent.altKey && keyCode === 68) { // Ctrl + Alt + d
@@ -1133,6 +1142,9 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
   });
 
   $scope.$on('focusParagraph', function(event, paragraphId, cursorPos, mouseEvent) {
+    if (!$scope.editor) {
+      return;
+    }
     if ($scope.paragraph.id === paragraphId) {
       // focus editor
       if (!$scope.paragraph.config.editorHide) {
@@ -1159,7 +1171,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
   });
 
   $scope.$on('saveInterpreterBindings', function(event, paragraphId) {
-    if ($scope.paragraph.id === paragraphId) {
+    if ($scope.paragraph.id === paragraphId && $scope.editor) {
       setInterpreterBindings = true;
       setParagraphMode($scope.editor.getSession(), $scope.editor.getSession().getValue());
     }
@@ -1177,8 +1189,10 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
         ), 1000);
 
       deferred.promise.then(function(data) {
-        $scope.editor.focus();
-        $scope.goToEnd($scope.editor);
+        if ($scope.editor) {
+          $scope.editor.focus();
+          $scope.goToEnd($scope.editor);
+        }
       });
     }
   });