You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2017/04/04 19:57:00 UTC

zeppelin git commit: [ZEPPELIN-1492] fixing the issue where updating a paragraph was not propagated correctly

Repository: zeppelin
Updated Branches:
  refs/heads/master 6ae578cad -> c23aa8871


[ZEPPELIN-1492] fixing the issue where updating a paragraph was not propagated correctly

### What is this PR for?

This pull request fixes two issues regarding paragraphs not being updated and therefore overwritten unintentionally. The first issue yields to local changes being overwritten when remote changes are made. The second issue yields to changes being overwritten when, e.g., the notebook is renamed.

The first change happens in the `updateParagraph` broadcast event handler function. This function has the purpose to update the local state of the paragraph in the paragraph controller scope when there is an update from the web socket.

However, it did not update the state if the only thing that has changed was the text. Now it will, which fixes the original issue in the issue description. This was one of the issues identified by https://issues.apache.org/jira/browse/ZEPPELIN-1492?focusedCommentId=15744928&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15744928

The second issue is fixed by saving the paragraph when the editor loses focus.

### What type of PR is it?

Bug Fix

### What is the Jira issue?

- https://issues.apache.org/jira/browse/ZEPPELIN-1492

### How should this be tested?

The first issue can be reproduced with the following two browser-windows and a single notebook.

Browser A:

```
%pyspark
print "Original Zeppelin Notebook"
```

In Browser B, edit the notebook and the above command to:

```
%pyspark
print "Notebook is updated...."
```

If I run the notebook via browser A followed by Browser B, everything is updated nicely. Now also if I you add the following line to the Notebook though Browser B:

```
print "....once again"
```

and run the notebook through Browser B again, the content in Browser A will be updated.

The second issue can be reproduced by editing a cell without executing it and renaming the notebook right afterwards. The rename will reset your cell to the previous state. With the fix, your state is saved.

Author: Frank Rosner <fr...@fam-rosner.de>

Closes #2120 from FRosner/ZEPPELIN-1492 and squashes the following commits:

be28a5d [Frank Rosner] ZEPPELIN-1492 save paragraph on editor blur
4a0cf72 [Frank Rosner] ZEPPELIN-1492 newPara is already a paragraph I guess :S
c5c53fd [Frank Rosner] ZEPPELIN-1492 also update paragraph if the text has changed


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

Branch: refs/heads/master
Commit: c23aa88717488788d88305f34a36ee9cddc90152
Parents: 6ae578c
Author: Frank Rosner <fr...@fam-rosner.de>
Authored: Mon Mar 13 11:32:08 2017 +0100
Committer: Lee moon soo <mo...@apache.org>
Committed: Wed Apr 5 04:56:52 2017 +0900

----------------------------------------------------------------------
 zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c23aa887/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 f0c301b..dbc6f4d 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -681,6 +681,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
 
       $scope.editor.on('blur', function() {
         handleFocus(false);
+        $scope.saveParagraph($scope.paragraph);
       });
 
       $scope.editor.on('paste', function(e) {
@@ -1120,6 +1121,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
   function isUpdateRequired(oldPara, newPara) {
     return (newPara.id === oldPara.id &&
       (newPara.dateCreated !== oldPara.dateCreated ||
+      newPara.text !== oldPara.text ||
       newPara.dateFinished !== oldPara.dateFinished ||
       newPara.dateStarted !== oldPara.dateStarted ||
       newPara.dateUpdated !== oldPara.dateUpdated ||