-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move dashboard panel rendering logic to each registered type.
Let external plugins register panel renderer providers keep loadedPanel promise on the scope for tests Not great to keep this around only for tests, but it follows the previous logic. Fix tests that expect the panel-content div to be the old style Communicate panel title from renderer. Fix tests with extra request Theres an extra request in there because of the getTitle function. Our tests assumed one, this makes it handle any number of requests in them mget (assuming the mock response for each one is sufficient).
- Loading branch information
1 parent
46c832d
commit 70f1827
Showing
16 changed files
with
256 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/core_plugins/kibana/public/dashboard/panel/get_object_loaders_for_dashboard.js
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/core_plugins/kibana/public/dashboard/panel/load_saved_object.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/core_plugins/kibana/public/discover/embeddable/search_embeddable_handler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import searchTemplate from './search_template.html'; | ||
import angular from 'angular'; | ||
import * as columnActions from 'ui/doc_table/actions/columns'; | ||
import { getPersistedStateId } from 'plugins/kibana/dashboard/panel/panel_state'; | ||
import { FilterManagerProvider } from 'ui/filter_manager'; | ||
|
||
export class SearchEmbeddableHandler { | ||
constructor($compile, $rootScope, searchLoader, Private) { | ||
this.$compile = $compile; | ||
this.searchLoader = searchLoader; | ||
this.filterManager = Private(FilterManagerProvider); | ||
this.$rootScope = $rootScope; | ||
this.name = 'search'; | ||
this.title = 'Saved Searches'; | ||
} | ||
|
||
getEditPath(panel) { | ||
return this.searchLoader.urlFor(panel.id); | ||
} | ||
|
||
canRenderType(type) { | ||
return type === 'search'; | ||
} | ||
|
||
getTitleFor(panel) { | ||
return this.searchLoader.get(panel.id).then(savedObject => savedObject.title); | ||
} | ||
|
||
renderAt(domNode, panel, actions) { | ||
return this.searchLoader.get(panel.id).then((savedObject) => { | ||
const editUrl = this.searchLoader.urlFor(panel.id); | ||
const searchScope = this.$rootScope.$new(); | ||
searchScope.editUrl = editUrl; | ||
searchScope.savedObj = savedObject; | ||
searchScope.panel = panel; | ||
|
||
// This causes changes to a saved search to be hidden, but also allows | ||
// the user to locally modify and save changes to a saved search only in a dashboard. | ||
// See https://github.com/elastic/kibana/issues/9523 for more details. | ||
actions.saveState({ | ||
columns: searchScope.panel.columns || searchScope.savedObj.columns, | ||
sort: searchScope.panel.sort || searchScope.savedObj.sort | ||
}); | ||
|
||
const uiState = savedObject.uiStateJSON ? JSON.parse(savedObject.uiStateJSON) : {}; | ||
searchScope.uiState = actions.createChildUiState(getPersistedStateId(panel), uiState); | ||
|
||
searchScope.setSortOrder = function setSortOrder(columnName, direction) { | ||
actions.saveState({ sort: [columnName, direction] }); | ||
}; | ||
|
||
searchScope.addColumn = function addColumn(columnName) { | ||
savedObject.searchSource.get('index').popularizeField(columnName, 1); | ||
columnActions.addColumn(searchScope.panel.columns, columnName); | ||
actions.saveState({}); // sync to sharing url | ||
}; | ||
|
||
searchScope.removeColumn = function removeColumn(columnName) { | ||
savedObject.searchSource.get('index').popularizeField(columnName, 1); | ||
columnActions.removeColumn(searchScope.panel.columns, columnName); | ||
actions.saveState({}); // sync to sharing url | ||
}; | ||
|
||
searchScope.moveColumn = function moveColumn(columnName, newIndex) { | ||
columnActions.moveColumn(searchScope.panel.columns, columnName, newIndex); | ||
actions.saveState({}); // sync to sharing url | ||
}; | ||
|
||
searchScope.filter = function (field, value, operator) { | ||
const index = savedObject.searchSource.get('index').id; | ||
this.filterManager.add(field, value, operator, index); | ||
}; | ||
|
||
const searchInstance = this.$compile(searchTemplate)(searchScope); | ||
const rootNode = angular.element(domNode); | ||
rootNode.append(searchInstance); | ||
}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/core_plugins/kibana/public/discover/embeddable/search_embeddable_handler_provider.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SearchEmbeddableHandler } from './search_embeddable_handler'; | ||
|
||
export function searchEmbeddableHandlerProvider(Private) { | ||
const SearchEmbeddableHandlerProvider = ($compile, $rootScope, savedSearches, Private) => { | ||
return new SearchEmbeddableHandler($compile, $rootScope, savedSearches, Private); | ||
}; | ||
return Private(SearchEmbeddableHandlerProvider); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/core_plugins/kibana/public/discover/embeddable/search_template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<doc-table | ||
search-source="savedObj.searchSource" | ||
sorting="panel.sort" | ||
columns="panel.columns" | ||
data-shared-item | ||
data-title="{{savedObj.title}}" | ||
data-description="{{savedObj.description}}" | ||
render-counter | ||
class="panel-content" | ||
filter="filter" | ||
on-add-column="addColumn" | ||
on-change-sort-order="setSortOrder" | ||
on-move-column="moveColumn" | ||
on-remove-column="removeColumn" | ||
> | ||
</doc-table> |
Oops, something went wrong.