You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by cl...@apache.org on 2017/05/04 11:55:33 UTC

zeppelin git commit: [ZEPPELIN-2452] block update paragraph event on revision mode

Repository: zeppelin
Updated Branches:
  refs/heads/master a231cf5dd -> bb72b3dea


[ZEPPELIN-2452] block update paragraph event on revision mode

### What is this PR for?
In revision mode using git-repository, by default all paragraphs must remain unmodifiable.
However, we are currently performing an incorrect update.

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

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

### How should this be tested?
1. create note and modify to paragraph and version control commit on web
2. modify to paragraph and execute
3. open your 2 browser - one browser is HEAD, and other browser move to before commit
4. insert paragarph or modify and execute.
check update

### Screenshots (if appropriate)

#### problem
![incorrectrevisionupdate](https://cloud.githubusercontent.com/assets/10525473/25425492/1a0ebcce-2aa7-11e7-9a06-cfc84a1c1fe3.gif)

#### fixed (this pr)
![correctrevisionupdate](https://cloud.githubusercontent.com/assets/10525473/25425498/1dce1bfc-2aa7-11e7-816c-c25a64963475.gif)

### 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 #2288 from cloverhearts/fix/invalidupdateonrevision and squashes the following commits:

8fe72c9c [CloverHearts] add block event on revision mode
19e74799 [CloverHearts] block update paragraph event on revision mode


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

Branch: refs/heads/master
Commit: bb72b3dea818fdeb3069e497db838d9dbcfd060d
Parents: a231cf5
Author: CloverHearts <cl...@gmail.com>
Authored: Fri Apr 28 14:02:48 2017 +0900
Committer: CloverHearts <cl...@gmail.com>
Committed: Thu May 4 20:55:26 2017 +0900

----------------------------------------------------------------------
 .../src/app/notebook/notebook.controller.js      | 10 ++++++++--
 .../notebook/paragraph/paragraph.controller.js   | 19 +++++++++++++------
 2 files changed, 21 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/bb72b3de/zeppelin-web/src/app/notebook/notebook.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js
index e481e9b..4b02f1a 100644
--- a/zeppelin-web/src/app/notebook/notebook.controller.js
+++ b/zeppelin-web/src/app/notebook/notebook.controller.js
@@ -483,20 +483,23 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope,
   }
 
   $scope.$on('addParagraph', function (event, paragraph, index) {
-    if ($scope.paragraphUrl) {
+    if ($scope.paragraphUrl || $scope.revisionView === true) {
       return
     }
     addPara(paragraph, index)
   })
 
   $scope.$on('removeParagraph', function (event, paragraphId) {
-    if ($scope.paragraphUrl) {
+    if ($scope.paragraphUrl || $scope.revisionView === true) {
       return
     }
     removePara(paragraphId)
   })
 
   $scope.$on('moveParagraph', function (event, paragraphId, newIdx) {
+    if ($scope.revisionView === true) {
+      return
+    }
     let removedPara = removePara(paragraphId)
     if (removedPara && removedPara.length === 1) {
       addPara(removedPara[0], newIdx)
@@ -958,6 +961,9 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope,
   })
 
   $scope.$on('insertParagraph', function (event, paragraphId, position) {
+    if ($scope.revisionView === true) {
+      return
+    }
     let newIndex = -1
     for (let i = 0; i < $scope.note.paragraphs.length; i++) {
       if ($scope.note.paragraphs[i].id === paragraphId) {

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/bb72b3de/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 3dcc4ed..a6564d4 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -610,7 +610,9 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca
     let session = editor.getSession()
     let dirtyText = session.getValue()
     $scope.dirtyText = dirtyText
-    $scope.startSaveTimer()
+    if ($scope.dirtyText !== $scope.originalText) {
+      $scope.startSaveTimer()
+    }
     setParagraphMode(session, dirtyText, editor.getCursorPosition())
   }
 
@@ -1252,23 +1254,28 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca
   }
 
   $scope.updateParagraph = function (oldPara, newPara, updateCallback) {
-     // 1. get status, refreshed
+     // 1. can't update on revision view
+    if ($scope.revisionView === true) {
+      return
+    }
+
+     // 2. get status, refreshed
     const statusChanged = (newPara.status !== oldPara.status)
     const resultRefreshed = (newPara.dateFinished !== oldPara.dateFinished) ||
        isEmpty(newPara.results) !== isEmpty(oldPara.results) ||
        newPara.status === ParagraphStatus.ERROR ||
        (newPara.status === ParagraphStatus.FINISHED && statusChanged)
 
-     // 2. update texts managed by $scope
+     // 3. update texts managed by $scope
     $scope.updateAllScopeTexts(oldPara, newPara)
 
-     // 3. execute callback to update result
+     // 4. execute callback to update result
     updateCallback()
 
-     // 4. update remaining paragraph objects
+     // 5. update remaining paragraph objects
     $scope.updateParagraphObjectWhenUpdated(newPara)
 
-     // 5. handle scroll down by key properly if new paragraph is added
+     // 6. handle scroll down by key properly if new paragraph is added
     if (statusChanged || resultRefreshed) {
        // when last paragraph runs, zeppelin automatically appends new paragraph.
        // this broadcast will focus to the newly inserted paragraph