{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/kibana/pulls/comments/158081363","pull_request_review_id":84832560,"id":158081363,"diff_hunk":"@@ -1,106 +1,182 @@\n import $ from 'jquery';\n-import _ from 'lodash';\n import { SpyModesRegistryProvider } from 'ui/registry/spy_modes';\n import { uiModules } from 'ui/modules';\n import spyTemplate from 'ui/visualize/spy.html';\n+import { PersistedState } from 'ui/persisted_state';\n \n uiModules\n   .get('app/visualize')\n-  .directive('visualizeSpy', function (Private, $compile) {\n+  .directive('visualizeSpy', function (Private, $compile, $timeout) {\n \n     const spyModes = Private(SpyModesRegistryProvider);\n-    const defaultMode = spyModes.inOrder[0].name;\n \n     return {\n       restrict: 'E',\n       template: spyTemplate,\n+      scope: {\n+        vis: '<',\n+        spy: '<',\n+        searchSource: '<',\n+        uiState: '<',\n+        visElement: '<',\n+      },\n       link: function ($scope, $el) {\n+\n+        // If no uiState has been passed, create a local one for this spy.\n+        if (!$scope.uiState) $scope.uiState = new PersistedState({});\n+\n         let currentSpy;\n+        let defaultModeName;\n+\n         const $container = $el.find('[data-spy-content-container]');\n-        let fullPageSpy = _.get($scope.spy, 'mode.fill', false);\n-        $scope.modes = spyModes;\n-        $scope.spy.params = $scope.spy.params || {};\n \n-        function getSpyObject(name) {\n-          name = _.isUndefined(name) ? $scope.spy.mode.name : name;\n-          fullPageSpy = (_.isNull(name)) ? false : fullPageSpy;\n+        $scope.modes = [];\n \n-          return {\n-            name: name,\n-            fill: fullPageSpy,\n-          };\n+        $scope.currentMode = null;\n+        $scope.maximizedSpy = false;\n+        $scope.forceMaximized = false;\n+\n+        function checkForcedMaximized() {\n+          $timeout(() => {\n+            if ($scope.visElement && $scope.visElement.height() < 180) {\n+              $scope.forceMaximized = true;\n+            } else {\n+              $scope.forceMaximized = false;\n+            }\n+          });\n         }\n \n-        function setSpyMode(modeName) {\n-          if (!_.isString(modeName)) modeName = null;\n-          $scope.spy.mode = getSpyObject(modeName);\n-          $scope.$emit('render');\n+        checkForcedMaximized();\n+\n+\n+        /**\n+         * Filter for modes that should actually be active for this visualization.\n+         * This will call the showMode method of the mode, pass it the vis object.\n+         * Depending on whether or not that returns a truthy value, it will be shown\n+         * or not. If the method is not present, the mode will always be shown.\n+         */\n+        function filterModes() {","path":"src/ui/public/visualize/spy.js","position":75,"original_position":75,"commit_id":"b6cf14d883e080e65b705b9a9539d696d38ee5c6","original_commit_id":"ac705faedc51f77bf2b7dbb9a233cea77d2ae96c","user":{"login":"timroes","id":877229,"avatar_url":"https://avatars0.githubusercontent.com/u/877229?v=4","gravatar_id":"","url":"https://api.github.com/users/timroes","html_url":"https://github.com/timroes","followers_url":"https://api.github.com/users/timroes/followers","following_url":"https://api.github.com/users/timroes/following{/other_user}","gists_url":"https://api.github.com/users/timroes/gists{/gist_id}","starred_url":"https://api.github.com/users/timroes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timroes/subscriptions","organizations_url":"https://api.github.com/users/timroes/orgs","repos_url":"https://api.github.com/users/timroes/repos","events_url":"https://api.github.com/users/timroes/events{/privacy}","received_events_url":"https://api.github.com/users/timroes/received_events","type":"User","site_admin":false},"body":"tested in unit tests without extraction","created_at":"2017-12-20T17:06:46Z","updated_at":"2017-12-20T17:06:46Z","html_url":"https://github.com/elastic/kibana/pull/15682#discussion_r158081363","pull_request_url":"https://api.github.com/repos/elastic/kibana/pulls/15682","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/elastic/kibana/pulls/comments/158081363"},"html":{"href":"https://github.com/elastic/kibana/pull/15682#discussion_r158081363"},"pull_request":{"href":"https://api.github.com/repos/elastic/kibana/pulls/15682"}},"in_reply_to_id":158008664},"pull_request":{"url":"https://api.github.com/repos/elastic/kibana/pulls/15682","id":159145915,"html_url":"https://github.com/elastic/kibana/pull/15682","diff_url":"https://github.com/elastic/kibana/pull/15682.diff","patch_url":"https://github.com/elastic/kibana/pull/15682.patch","issue_url":"https://api.github.com/repos/elastic/kibana/issues/15682","number":15682,"state":"open","locked":false,"title":"Refactor spy panels","user":{"login":"timroes","id":877229,"avatar_url":"https://avatars0.githubusercontent.com/u/877229?v=4","gravatar_id":"","url":"https://api.github.com/users/timroes","html_url":"https://github.com/timroes","followers_url":"https://api.github.com/users/timroes/followers","following_url":"https://api.github.com/users/timroes/following{/other_user}","gists_url":"https://api.github.com/users/timroes/gists{/gist_id}","starred_url":"https://api.github.com/users/timroes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timroes/subscriptions","organizations_url":"https://api.github.com/users/timroes/orgs","repos_url":"https://api.github.com/users/timroes/repos","events_url":"https://api.github.com/users/timroes/events{/privacy}","received_events_url":"https://api.github.com/users/timroes/received_events","type":"User","site_admin":false},"body":"This PR fixes the following issues:\r\n\r\n* Fix design issues introduced due to the switch to EUI.\r\n* Allow each spy mode to individually check whether or not if wants to be shown for a visualization.\r\n* Clean up code of spy panel a bit.\r\n","created_at":"2017-12-19T11:43:22Z","updated_at":"2017-12-20T17:06:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0b73ca5bc73b4912d6d64fdec2285dc29d272d24","assignee":null,"assignees":[],"requested_reviewers":[{"login":"ppisljar","id":13629809,"avatar_url":"https://avatars2.githubusercontent.com/u/13629809?v=4","gravatar_id":"","url":"https://api.github.com/users/ppisljar","html_url":"https://github.com/ppisljar","followers_url":"https://api.github.com/users/ppisljar/followers","following_url":"https://api.github.com/users/ppisljar/following{/other_user}","gists_url":"https://api.github.com/users/ppisljar/gists{/gist_id}","starred_url":"https://api.github.com/users/ppisljar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppisljar/subscriptions","organizations_url":"https://api.github.com/users/ppisljar/orgs","repos_url":"https://api.github.com/users/ppisljar/repos","events_url":"https://api.github.com/users/ppisljar/events{/privacy}","received_events_url":"https://api.github.com/users/ppisljar/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/kibana/pulls/15682/commits","review_comments_url":"https://api.github.com/repos/elastic/kibana/pulls/15682/comments","review_comment_url":"https://api.github.com/repos/elastic/kibana/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/kibana/issues/15682/comments","statuses_url":"https://api.github.com/repos/elastic/kibana/statuses/b6cf14d883e080e65b705b9a9539d696d38ee5c6","head":{"label":"timroes:spy-panels-refactoring","ref":"spy-panels-refactoring","sha":"b6cf14d883e080e65b705b9a9539d696d38ee5c6","user":{"login":"timroes","id":877229,"avatar_url":"https://avatars0.githubusercontent.com/u/877229?v=4","gravatar_id":"","url":"https://api.github.com/users/timroes","html_url":"https://github.com/timroes","followers_url":"https://api.github.com/users/timroes/followers","following_url":"https://api.github.com/users/timroes/following{/other_user}","gists_url":"https://api.github.com/users/timroes/gists{/gist_id}","starred_url":"https://api.github.com/users/timroes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timroes/subscriptions","organizations_url":"https://api.github.com/users/timroes/orgs","repos_url":"https://api.github.com/users/timroes/repos","events_url":"https://api.github.com/users/timroes/events{/privacy}","received_events_url":"https://api.github.com/users/timroes/received_events","type":"User","site_admin":false},"repo":{"id":30105345,"name":"kibana","full_name":"timroes/kibana","owner":{"login":"timroes","id":877229,"avatar_url":"https://avatars0.githubusercontent.com/u/877229?v=4","gravatar_id":"","url":"https://api.github.com/users/timroes","html_url":"https://github.com/timroes","followers_url":"https://api.github.com/users/timroes/followers","following_url":"https://api.github.com/users/timroes/following{/other_user}","gists_url":"https://api.github.com/users/timroes/gists{/gist_id}","starred_url":"https://api.github.com/users/timroes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timroes/subscriptions","organizations_url":"https://api.github.com/users/timroes/orgs","repos_url":"https://api.github.com/users/timroes/repos","events_url":"https://api.github.com/users/timroes/events{/privacy}","received_events_url":"https://api.github.com/users/timroes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/timroes/kibana","description":"Kibana","fork":true,"url":"https://api.github.com/repos/timroes/kibana","forks_url":"https://api.github.com/repos/timroes/kibana/forks","keys_url":"https://api.github.com/repos/timroes/kibana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/timroes/kibana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/timroes/kibana/teams","hooks_url":"https://api.github.com/repos/timroes/kibana/hooks","issue_events_url":"https://api.github.com/repos/timroes/kibana/issues/events{/number}","events_url":"https://api.github.com/repos/timroes/kibana/events","assignees_url":"https://api.github.com/repos/timroes/kibana/assignees{/user}","branches_url":"https://api.github.com/repos/timroes/kibana/branches{/branch}","tags_url":"https://api.github.com/repos/timroes/kibana/tags","blobs_url":"https://api.github.com/repos/timroes/kibana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/timroes/kibana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/timroes/kibana/git/refs{/sha}","trees_url":"https://api.github.com/repos/timroes/kibana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/timroes/kibana/statuses/{sha}","languages_url":"https://api.github.com/repos/timroes/kibana/languages","stargazers_url":"https://api.github.com/repos/timroes/kibana/stargazers","contributors_url":"https://api.github.com/repos/timroes/kibana/contributors","subscribers_url":"https://api.github.com/repos/timroes/kibana/subscribers","subscription_url":"https://api.github.com/repos/timroes/kibana/subscription","commits_url":"https://api.github.com/repos/timroes/kibana/commits{/sha}","git_commits_url":"https://api.github.com/repos/timroes/kibana/git/commits{/sha}","comments_url":"https://api.github.com/repos/timroes/kibana/comments{/number}","issue_comment_url":"https://api.github.com/repos/timroes/kibana/issues/comments{/number}","contents_url":"https://api.github.com/repos/timroes/kibana/contents/{+path}","compare_url":"https://api.github.com/repos/timroes/kibana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/timroes/kibana/merges","archive_url":"https://api.github.com/repos/timroes/kibana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/timroes/kibana/downloads","issues_url":"https://api.github.com/repos/timroes/kibana/issues{/number}","pulls_url":"https://api.github.com/repos/timroes/kibana/pulls{/number}","milestones_url":"https://api.github.com/repos/timroes/kibana/milestones{/number}","notifications_url":"https://api.github.com/repos/timroes/kibana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/timroes/kibana/labels{/name}","releases_url":"https://api.github.com/repos/timroes/kibana/releases{/id}","deployments_url":"https://api.github.com/repos/timroes/kibana/deployments","created_at":"2015-01-31T07:05:20Z","updated_at":"2016-12-17T07:34:21Z","pushed_at":"2017-12-20T17:04:51Z","git_url":"git://github.com/timroes/kibana.git","ssh_url":"git@github.com:timroes/kibana.git","clone_url":"https://github.com/timroes/kibana.git","svn_url":"https://github.com/timroes/kibana","homepage":"http://www.elasticsearch.org/overview/kibana/","size":281330,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"1d92807a18e4c5a2d0cb842771979f7efb072553","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars0.githubusercontent.com/u/6764390?v=4","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":7833168,"name":"kibana","full_name":"elastic/kibana","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars0.githubusercontent.com/u/6764390?v=4","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/kibana","description":":bar_chart: Kibana analytics and search dashboard for Elasticsearch","fork":false,"url":"https://api.github.com/repos/elastic/kibana","forks_url":"https://api.github.com/repos/elastic/kibana/forks","keys_url":"https://api.github.com/repos/elastic/kibana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/kibana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/kibana/teams","hooks_url":"https://api.github.com/repos/elastic/kibana/hooks","issue_events_url":"https://api.github.com/repos/elastic/kibana/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/kibana/events","assignees_url":"https://api.github.com/repos/elastic/kibana/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/kibana/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/kibana/tags","blobs_url":"https://api.github.com/repos/elastic/kibana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/kibana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/kibana/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/kibana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/kibana/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/kibana/languages","stargazers_url":"https://api.github.com/repos/elastic/kibana/stargazers","contributors_url":"https://api.github.com/repos/elastic/kibana/contributors","subscribers_url":"https://api.github.com/repos/elastic/kibana/subscribers","subscription_url":"https://api.github.com/repos/elastic/kibana/subscription","commits_url":"https://api.github.com/repos/elastic/kibana/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/kibana/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/kibana/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/kibana/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/kibana/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/kibana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/kibana/merges","archive_url":"https://api.github.com/repos/elastic/kibana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/kibana/downloads","issues_url":"https://api.github.com/repos/elastic/kibana/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/kibana/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/kibana/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/kibana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/kibana/labels{/name}","releases_url":"https://api.github.com/repos/elastic/kibana/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/kibana/deployments","created_at":"2013-01-26T04:00:59Z","updated_at":"2017-12-20T12:40:20Z","pushed_at":"2017-12-20T17:04:56Z","git_url":"git://github.com/elastic/kibana.git","ssh_url":"git@github.com:elastic/kibana.git","clone_url":"https://github.com/elastic/kibana.git","svn_url":"https://github.com/elastic/kibana","homepage":"https://www.elastic.co/products/kibana","size":298309,"stargazers_count":8550,"watchers_count":8550,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3278,"mirror_url":null,"archived":false,"open_issues_count":2154,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":3278,"open_issues":2154,"watchers":8550,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/kibana/pulls/15682"},"html":{"href":"https://github.com/elastic/kibana/pull/15682"},"issue":{"href":"https://api.github.com/repos/elastic/kibana/issues/15682"},"comments":{"href":"https://api.github.com/repos/elastic/kibana/issues/15682/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/kibana/pulls/15682/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/kibana/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/kibana/pulls/15682/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/kibana/statuses/b6cf14d883e080e65b705b9a9539d696d38ee5c6"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"timroes"}}