Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover] shim with local application service #49483

Merged
merged 219 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
6046c50
Move doc folder to discover folder
kertal Oct 7, 2019
16a7a6a
Move doc_viewer folder to discover folder
kertal Oct 7, 2019
522db68
Move context folder to discover folder
kertal Oct 7, 2019
6ca152e
Move context scss import to discover folder
kertal Oct 7, 2019
3c762b7
Introduce legacy folder, start migration
kertal Oct 7, 2019
fd7e81b
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 13, 2019
1cbd678
Add basic NP structure, structural refactoring
kertal Oct 14, 2019
fdbdde0
Migrate discover imports to dependencies.ts
kertal Oct 15, 2019
9fe6e84
Add context placeholder readme
kertal Oct 15, 2019
9ac64ac
Move doc_viewer directive to angular
kertal Oct 15, 2019
e65ae78
Move doc_table directive to angular directory
kertal Oct 15, 2019
2af2593
Migrate doc_table dependencies to central file
kertal Oct 15, 2019
09e2c22
Migrate chrome usage to new platform
kertal Oct 15, 2019
62f3164
centralize dependencies
flash1293 Oct 18, 2019
0bf00ae
move more stuff into kibana_services
flash1293 Oct 18, 2019
e72e51a
fix tests and dependency
flash1293 Oct 18, 2019
b42f417
bootstrap home via local application service
flash1293 Oct 19, 2019
0d2521e
fix routing for home app
flash1293 Oct 19, 2019
12fb70b
Merge remote-tracking branch 'upstream/master' into centralize-home
flash1293 Oct 21, 2019
b5aa43c
fix merge conflixts
kertal Oct 21, 2019
af3ad7f
switch to dependency getter instead of direct exports
flash1293 Oct 21, 2019
a455322
Merge branch 'centralize-home' into local-application-service
flash1293 Oct 21, 2019
4424545
Refactor dependencies.ts to kibana_services.ts
kertal Oct 21, 2019
a1295d3
clean up
flash1293 Oct 21, 2019
082748a
add redirect functionality to local application service
flash1293 Oct 21, 2019
2bf3bf6
return early from route change handlers on dummy wrapper route
flash1293 Oct 21, 2019
7ee29c6
Improve basic plugin structure
kertal Oct 21, 2019
398299c
fix jest tests
flash1293 Oct 21, 2019
44bcd46
Start shimming dashboard
flash1293 Oct 21, 2019
0f6c147
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 21, 2019
dbdb5d2
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 22, 2019
001fcd5
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 22, 2019
b0d0a04
Centralize context deps
kertal Oct 22, 2019
822cdac
Merge remote-tracking branch 'upstream/master' into centralize-home
flash1293 Oct 22, 2019
103a8f2
Centralize embeddable deps
kertal Oct 22, 2019
d824612
Migrate context to angular folder
kertal Oct 22, 2019
4ea2e63
fix broken tests
flash1293 Oct 22, 2019
22c5588
Merge branch 'centralize-home' into local-application-service
flash1293 Oct 22, 2019
1bd6b3b
local application service
flash1293 Oct 22, 2019
ae8dd12
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Oct 22, 2019
fa25ee7
Refactor adding getServices to kibana_services.ts
kertal Oct 22, 2019
162d14d
Replace npStart usage by getService usage
kertal Oct 22, 2019
afafe10
wip
flash1293 Oct 22, 2019
a7f2826
wip
flash1293 Oct 22, 2019
dbcf159
Merge branch 'local-application-service' into shim-dashboard
flash1293 Oct 22, 2019
c417060
fix mounting home several times
flash1293 Oct 22, 2019
0f2b23b
Merge branch 'local-application-service' into shim-dashboard
flash1293 Oct 22, 2019
03fd207
wip
flash1293 Oct 22, 2019
40ed5e4
Cleanup / centralize leftover dependencies
kertal Oct 22, 2019
72bfb43
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 22, 2019
ae9ae7e
Fix no_results.test.js
kertal Oct 23, 2019
be9fc5a
Fix SCSS import paths
kertal Oct 23, 2019
46a0cca
Restructure kibana_services.ts
kertal Oct 23, 2019
de9fcbf
Fix no_results.test.js
kertal Oct 23, 2019
2337329
Move field_name directive back to field_chooser
kertal Oct 23, 2019
77ab276
Fix open_search_panel.test.js
kertal Oct 23, 2019
293365e
Skip doc_viewer tests (unskip later)
kertal Oct 23, 2019
6dc3a71
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 23, 2019
7e88216
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 23, 2019
80351b5
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 23, 2019
8ab13d7
Separate services from stateless dependencies
kertal Oct 23, 2019
889b771
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 23, 2019
7f324d2
unskip doc_viewer.test.tsx
kertal Oct 23, 2019
ca5cdb7
Restore the initial way embeddables are registered
kertal Oct 23, 2019
0388c48
Remove TODOs from doc_viewer.test.tsx
kertal Oct 23, 2019
9407bbb
Refactor SEARCH_EMBEDDABLE_TYPE to contants.ts
kertal Oct 23, 2019
66a4651
Fix open_search_panel.test.js
kertal Oct 23, 2019
b1e71fe
Change import of SEARCH_EMBEDDABLE_TYPE to fix x-pack test failures
kertal Oct 23, 2019
07287af
Fix doc.test.tsx
kertal Oct 24, 2019
01f815b
Fix doc.test.tsx
kertal Oct 24, 2019
0e8bb19
Add embeddable comments
kertal Oct 24, 2019
c8efbe2
Add addBasePath + getInjector to services
kertal Oct 24, 2019
006dbba
Refactor embeddable registration
kertal Oct 24, 2019
eea7c62
move handlers from addSetupWork into legacy_compat
flash1293 Oct 24, 2019
4f0c5b2
pass dependencies into angular configurator
flash1293 Oct 24, 2019
f1ff388
centralize dependencies and clean up shim
flash1293 Oct 24, 2019
48ecdf7
Merge branch 'master' into flash1293/local-application-service
elasticmachine Oct 24, 2019
a56617d
Implement createEsService function
kertal Oct 24, 2019
05feea4
Adaption of ui/public modules
kertal Oct 16, 2019
d1700d2
remove requireDefaultIndex and provide helper function
flash1293 Oct 25, 2019
0dd5d3a
rename function and improve documentation
flash1293 Oct 25, 2019
e8c8886
Initial version
kertal Oct 26, 2019
02cd426
Adaptions for doc service
kertal Oct 27, 2019
74fb184
Merge remote-tracking branch 'upstream/master' into flash1293/local-a…
flash1293 Oct 28, 2019
79a1a14
Merge branch 'flash1293/local-application-service' of github.com:flas…
flash1293 Oct 28, 2019
50b1d97
Merge branch 'flash1293/local-application-service' into shim-dashboard
flash1293 Oct 28, 2019
ffe6adc
Merging local_application_service changes
kertal Oct 28, 2019
4f9d6a9
Adapting context + doc url routes
kertal Oct 28, 2019
105af0a
redirect unknown urls to default app
flash1293 Oct 28, 2019
e0e80c2
Adaptions to render_app.ts
kertal Oct 28, 2019
6decd13
Add promise to provide functional indexPattern resolving
kertal Oct 28, 2019
747ed66
Implement getSavedSearchById as service
kertal Oct 29, 2019
f9b47f1
only wire up local angular once
flash1293 Oct 29, 2019
d52c6c9
Add $listen and $watchMulti directives
kertal Oct 29, 2019
68b7c4b
context adaptions
kertal Oct 30, 2019
a4dc8f5
Add icon directive
kertal Oct 30, 2019
bd31c10
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Oct 30, 2019
0777b47
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Oct 30, 2019
e435c7d
Implement forwarding
kertal Oct 30, 2019
1246675
fix top nav and dashboard only mode
flash1293 Oct 30, 2019
87c243b
Add even more missing directives
kertal Oct 30, 2019
3cf5fe4
Refactor collabsible_sidebar.js
kertal Oct 30, 2019
55ebcb0
Refactor debounce.js
kertal Oct 30, 2019
91723c5
Refactor fixed_scroll.js
kertal Oct 30, 2019
4ce4a06
Refactor css_truncate.js
kertal Oct 30, 2019
253045f
Implement getAngularDependencies function
kertal Oct 31, 2019
44b4303
Refactor code to use getAngularDependencies function
kertal Oct 31, 2019
cf087b8
Shim filterbar directive + depended directives
kertal Oct 31, 2019
a34dd9f
decouple frome home shim PR
flash1293 Oct 31, 2019
d1defcc
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Oct 31, 2019
e8c59f7
fix typing problems
flash1293 Oct 31, 2019
e238a5d
fix other bugs
flash1293 Oct 31, 2019
4e76a5e
merge upstream/master
kertal Oct 31, 2019
3ef6254
got rid of two other angular dependencies
flash1293 Oct 31, 2019
ce902cd
fix i18n issue
flash1293 Oct 31, 2019
8022d4d
fix various issues
flash1293 Oct 31, 2019
936f09a
added some debug notes
flash1293 Oct 31, 2019
784a20e
fix vis filters
flash1293 Oct 31, 2019
ba78539
improve
flash1293 Nov 1, 2019
ac462b5
fix hooks handling for local routes in legacy_compat
flash1293 Nov 3, 2019
72b52ae
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 3, 2019
3c619d2
fix embedded visualize handler tests
flash1293 Nov 3, 2019
02caf27
fix test failures
flash1293 Nov 3, 2019
144699b
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 3, 2019
78855e1
remove buggy test
flash1293 Nov 3, 2019
14d8fd4
different take on global state handling
flash1293 Nov 4, 2019
fa13e4b
fix detection of url state
flash1293 Nov 4, 2019
2a5c0fb
fix broken test
flash1293 Nov 4, 2019
08c8740
Fix reporting imports to prevent loading the whole embeddable
kertal Nov 5, 2019
f5599ab
Fix tests and embeddables
kertal Nov 5, 2019
a47e412
Fix types
kertal Nov 5, 2019
0cb6533
Add render-complete directive
kertal Nov 5, 2019
d5acbd3
Fix functional test in firefox
kertal Nov 6, 2019
45e875d
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 7, 2019
5f9120b
never update state in dummy route mode
flash1293 Nov 7, 2019
8079a3f
Fix jest test
kertal Nov 7, 2019
2d868f2
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Nov 7, 2019
296c174
clean up implementation
flash1293 Nov 7, 2019
8fb0fbd
fix type error
flash1293 Nov 7, 2019
c1adec3
Fix eventually undefined searchScore at search_embeddable
kertal Nov 7, 2019
a82bd86
Fix mocha test
kertal Nov 7, 2019
af1ed6c
Merge and adapt joe changes
kertal Nov 7, 2019
bf5a71e
Merge branch 'flash1293-shim-dashboard' into kertal-pr-2019-10-24-dis…
kertal Nov 7, 2019
1f6329f
Fix unresolved dependencies
kertal Nov 7, 2019
fff216c
Merge branch 'flash1293-shim-dashboard' into kertal-pr-2019-10-24-dis…
kertal Nov 7, 2019
42a0d8b
Fix breadcrumbs
kertal Nov 8, 2019
d93bb6c
Refactor to use ensureDefaultIndexPattern
kertal Nov 8, 2019
f5ebcf7
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 8, 2019
fad42dd
remove session storage global state handling for now
flash1293 Nov 8, 2019
0f395c7
Fix tests
kertal Oct 24, 2019
f954975
Fix context test
kertal Nov 11, 2019
39ce528
remove session storage global state handling for now
flash1293 Nov 8, 2019
6d3b63c
Merge branch 'flash1293-shim-dashboard' into kertal-pr-2019-10-24-dis…
kertal Nov 11, 2019
f6d4e75
Bootstrap separate angular module for embeddables first draft
kertal Nov 12, 2019
f005b4e
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 12, 2019
dcb9a88
remove unused dependencies
flash1293 Nov 12, 2019
01edc51
Slim embeddable angular
kertal Nov 12, 2019
a21ba30
started centralizing and cleaning up imports
flash1293 Nov 12, 2019
d0c4817
Refactor queryFilter in embeddable
kertal Nov 12, 2019
7ec261d
centralize external imports
flash1293 Nov 12, 2019
aaf0a8e
Invoke plugin async
kertal Nov 13, 2019
168001b
Revert chromedriver update (#50324)
flash1293 Nov 12, 2019
928f34f
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 13, 2019
a0abd00
fix import bugs
flash1293 Nov 13, 2019
42db084
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 13, 2019
8bdca65
fix merge bugs and rename main dynamic entrypoint
flash1293 Nov 13, 2019
042f2e8
fix jest tests
flash1293 Nov 13, 2019
363a907
fix saved object finder bug
flash1293 Nov 13, 2019
a0c72cf
Fix unit test, refactor angular bootstrapping to be done when needed
kertal Nov 13, 2019
9296c4c
revert using stateless component for this PR
flash1293 Nov 13, 2019
259cc5d
Adapt even more unit tests to bootstrap the local angular just in case
kertal Nov 13, 2019
8d41818
fix types
flash1293 Nov 13, 2019
44c15d7
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 14, 2019
a4dd4ff
revert unrelated changes and improve implementation
flash1293 Nov 14, 2019
d51dcd5
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 14, 2019
f3e10c7
merge shim-dashboard
kertal Nov 14, 2019
90bf3aa
Cleanup
kertal Nov 14, 2019
08d709b
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 14, 2019
ac541f2
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 14, 2019
3448cfb
Refactoring of services + better typescript types
kertal Nov 15, 2019
e8a6d95
Change the way isEditable is used in embeddable_factory (caused failure)
kertal Nov 15, 2019
819b127
Don't catch if setServices is called twice (2 embeddables rendered pa…
kertal Nov 15, 2019
0ccd9ad
Restructure and add comments
kertal Nov 16, 2019
314f78a
fix jest tests
kertal Nov 16, 2019
c1ccc16
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 18, 2019
c4c5bc2
review fixes
flash1293 Nov 18, 2019
4b873e7
fix functional tests
flash1293 Nov 18, 2019
1b20af9
fix dashboard icon
flash1293 Nov 18, 2019
4718578
merge shim-dashboard/fix conflicts
kertal Nov 19, 2019
e780906
Fix missing filter bar in context view
kertal Nov 19, 2019
75904ed
Fix isLoading state in embeddable rendering
kertal Nov 19, 2019
8078022
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Nov 19, 2019
2ea9238
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 19, 2019
c445d72
remove bad import and do not deep-import types from data plugin
flash1293 Nov 19, 2019
6c4e756
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 19, 2019
6f4bbdb
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 19, 2019
78fd82c
Fix invalid share url
kertal Nov 19, 2019
1dc39eb
merge shim-dashboard
kertal Nov 20, 2019
6e770a6
Add missing lib for unit testing
kertal Nov 20, 2019
b5c86b5
improve types and remove unused imports
kertal Nov 20, 2019
91fd89f
merge upstream/master
kertal Nov 20, 2019
6dda3ae
merge upstream/master
kertal Nov 20, 2019
ad13c2e
Add some comments
kertal Nov 21, 2019
28cc1fe
Review improvements
kertal Nov 22, 2019
298fac9
Implement use of FilterStateManger to solve state <-> url syncing
kertal Nov 25, 2019
48257f1
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Nov 25, 2019
ea1755c
Refactor to replace localApplicationService
kertal Nov 25, 2019
e4cf0ee
Cleanup filterStateManager when scope is destroyed
kertal Nov 25, 2019
7511ed7
Remove unnecessary ts-ignore
kertal Nov 26, 2019
c04f54a
Tiny type changes
kertal Nov 26, 2019
cf91768
Remove missing `searchScope` warning for embeddables
kertal Nov 26, 2019
83f1bb4
Address review feedback
kertal Nov 26, 2019
2ff88db
Improve app mountpoint, remove innerHTML
kertal Nov 26, 2019
d466df1
Improve types
kertal Nov 27, 2019
b33c13a
Add findByCssSelector to ensure the charts have been rendered
kertal Nov 26, 2019
9aae0d1
Merge remote-tracking branch upstream/master into kertal-pr-2019-10-2…
kertal Nov 27, 2019
088b56e
Fix type error
kertal Nov 27, 2019
c7bdc8a
Merge conflicts
kertal Nov 27, 2019
d055d83
Fix merge conflicts
kertal Nov 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ export default function (kibana) {

uiExports: {
hacks: [
'plugins/kibana/discover',
'plugins/kibana/dev_tools',
],
savedObjectTypes: [
'plugins/kibana/visualize/saved_visualizations/saved_visualization_register',
'plugins/kibana/discover/saved_searches/saved_search_register',
'plugins/kibana/dashboard/saved_dashboard/saved_dashboard_register',
],
app: {
Expand Down
42 changes: 22 additions & 20 deletions src/legacy/core_plugins/kibana/public/dashboard/dashboard_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@
import { uiModules } from 'ui/modules';
import { capabilities } from 'ui/capabilities';

uiModules.get('kibana')
.provider('dashboardConfig', () => {
let hideWriteControls = !capabilities.get().dashboard.showWriteControls;
export function dashboardConfigProvider() {
let hideWriteControls = !capabilities.get().dashboard.showWriteControls;

return {
/**
* Part of the exposed plugin API - do not remove without careful consideration.
* @type {boolean}
*/
turnHideWriteControlsOn() {
hideWriteControls = true;
},
$get() {
return {
getHideWriteControls() {
return hideWriteControls;
}
};
}
};
}

return {
/**
* Part of the exposed plugin API - do not remove without careful consideration.
* @type {boolean}
*/
turnHideWriteControlsOn() {
hideWriteControls = true;
},
$get() {
return {
getHideWriteControls() {
return hideWriteControls;
}
};
}
};
});
uiModules.get('kibana')
.provider('dashboardConfig', dashboardConfigProvider);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import _ from 'lodash';
import sinon from 'sinon';
import ngMock from 'ng_mock';
import expect from '@kbn/expect';
import '../../components/field_chooser/discover_field';
import { pluginInstance } from 'plugins/kibana/discover/index';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

// Load the kibana app dependencies.
Expand All @@ -32,8 +32,9 @@ describe('discoverField', function () {
let $scope;
let indexPattern;
let $elem;

beforeEach(ngMock.module('kibana'));
beforeEach(() => pluginInstance.initializeServices(true));
beforeEach(() => pluginInstance.initializeInnerAngular());
beforeEach(ngMock.module('app/discover'));
beforeEach(ngMock.inject(function (Private, $rootScope, $compile) {
$elem = angular.element(`
<discover-field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


import _ from 'lodash';
import { pluginInstance } from 'plugins/kibana/discover/index';
import ngMock from 'ng_mock';
import { fieldCalculator } from '../../components/field_chooser/lib/field_calculator';
import expect from '@kbn/expect';
Expand All @@ -29,7 +30,8 @@ import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logsta
let indexPattern;

describe('fieldCalculator', function () {
beforeEach(ngMock.module('kibana'));
beforeEach(() => pluginInstance.initializeInnerAngular());
beforeEach(ngMock.module('app/discover'));
beforeEach(ngMock.inject(function (Private) {
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import _ from 'lodash';
import sinon from 'sinon';
import expect from '@kbn/expect';
import $ from 'jquery';
import '../../components/field_chooser/field_chooser';
import { pluginInstance } from 'plugins/kibana/discover/index';
import FixturesHitsProvider from 'fixtures/hits';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import { SimpleSavedObject } from '../../../../../../../core/public';
Expand Down Expand Up @@ -70,8 +70,10 @@ describe('discover field chooser directives', function () {
on-remove-field="removeField"
></disc-field-chooser>
`);
beforeEach(() => pluginInstance.initializeServices(true));
beforeEach(() => pluginInstance.initializeInnerAngular());

beforeEach(ngMock.module('kibana', ($provide) => {
beforeEach(ngMock.module('app/discover', ($provide) => {
$provide.decorator('config', ($delegate) => {
// disable shortDots for these tests
$delegate.get = _.wrap($delegate.get, function (origGet, name) {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/discover/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@import 'embeddable/index';

// Doc Viewer
@import 'doc_viewer/index';
@import 'components/doc_viewer/index';

// Context styles
@import 'angular/context/index';
59 changes: 34 additions & 25 deletions src/legacy/core_plugins/kibana/public/discover/angular/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { getServices, subscribeWithScope } from './../kibana_services';
import { getAngularModule, getServices, subscribeWithScope } from './../kibana_services';

import './context_app';
import contextAppRouteTemplate from './context.html';
import { getRootBreadcrumbs } from '../breadcrumbs';
const { FilterBarQueryFilterProvider, uiRoutes, chrome } = getServices();
import { getRootBreadcrumbs } from '../helpers/breadcrumbs';
import { FilterStateManager } from '../../../../data/public/filter/filter_manager';
const { chrome } = getServices();

const k7Breadcrumbs = $route => {
const { indexPattern } = $route.current.locals;
Expand All @@ -44,26 +45,33 @@ const k7Breadcrumbs = $route => {
];
};

uiRoutes
// deprecated route, kept for compatibility
// should be removed in the future
.when('/context/:indexPatternId/:type/:id*', {
redirectTo: '/context/:indexPatternId/:id',
})
.when('/context/:indexPatternId/:id*', {
controller: ContextAppRouteController,
k7Breadcrumbs,
controllerAs: 'contextAppRoute',
resolve: {
indexPattern: function ($route, indexPatterns) {
return indexPatterns.get($route.current.params.indexPatternId);
getAngularModule().config($routeProvider => {
$routeProvider
// deprecated route, kept for compatibility
// should be removed in the future
.when('/discover/context/:indexPatternId/:type/:id*', {
redirectTo: '/discover/context/:indexPatternId/:id',
})
.when('/discover/context/:indexPatternId/:id*', {
controller: ContextAppRouteController,
k7Breadcrumbs,
controllerAs: 'contextAppRoute',
resolve: {
indexPattern: ($route, Promise) => {
const indexPattern = getServices().indexPatterns.get(
$route.current.params.indexPatternId
);
return Promise.props({ ip: indexPattern });
},
},
},
template: contextAppRouteTemplate,
});
template: contextAppRouteTemplate,
});
});

function ContextAppRouteController($routeParams, $scope, AppState, config, indexPattern, Private) {
const queryFilter = Private(FilterBarQueryFilterProvider);
function ContextAppRouteController($routeParams, $scope, AppState, config, $route, getAppState, globalState) {
const filterManager = getServices().filterManager;
const filterStateManager = new FilterStateManager(globalState, getAppState, filterManager);
const indexPattern = $route.current.locals.indexPattern.ip;

this.state = new AppState(createDefaultAppState(config, indexPattern));
this.state.save(true);
Expand All @@ -77,19 +85,20 @@ function ContextAppRouteController($routeParams, $scope, AppState, config, index
() => this.state.save(true)
);

const updateSubsciption = subscribeWithScope($scope, queryFilter.getUpdates$(), {
const updateSubsciption = subscribeWithScope($scope, filterManager.getUpdates$(), {
next: () => {
this.filters = _.cloneDeep(queryFilter.getFilters());
this.filters = _.cloneDeep(filterManager.getFilters());
},
});

$scope.$on('$destroy', function () {
$scope.$on('$destroy', () => {
filterStateManager.destroy();
updateSubsciption.unsubscribe();
});
this.anchorId = $routeParams.id;
this.indexPattern = indexPattern;
this.discoverUrl = chrome.navLinks.get('kibana:discover').url;
this.filters = _.cloneDeep(queryFilter.getFilters());
this.filters = _.cloneDeep(filterManager.getFilters());
}

function createDefaultAppState(config, indexPattern) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@

import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import { pluginInstance } from 'plugins/kibana/discover/index';

import { createIndexPatternsStub, createSearchSourceStub } from './_stubs';

import { fetchAnchorProvider } from '../anchor';

describe('context app', function () {
beforeEach(ngMock.module('kibana'));
beforeEach(() => pluginInstance.initializeInnerAngular());
beforeEach(ngMock.module('app/discover'));

describe('function fetchAnchor', function () {
let fetchAnchor;
Expand All @@ -35,11 +37,11 @@ describe('context app', function () {
$provide.value('indexPatterns', createIndexPatternsStub());
}));

beforeEach(ngMock.inject(function createPrivateStubs(Private) {
beforeEach(ngMock.inject(function createPrivateStubs() {
searchSourceStub = createSearchSourceStub([
{ _id: 'hit1' },
]);
fetchAnchor = Private(fetchAnchorProvider);
fetchAnchor = fetchAnchorProvider(createIndexPatternsStub(), searchSourceStub);
}));

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import moment from 'moment';
import * as _ from 'lodash';
import { pluginInstance } from 'plugins/kibana/discover/index';

import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs';

Expand All @@ -33,7 +34,8 @@ const ANCHOR_TIMESTAMP_1000 = (new Date(MS_PER_DAY * 1000)).toJSON();
const ANCHOR_TIMESTAMP_3000 = (new Date(MS_PER_DAY * 3000)).toJSON();

describe('context app', function () {
beforeEach(ngMock.module('kibana'));
beforeEach(() => pluginInstance.initializeInnerAngular());
beforeEach(ngMock.module('app/discover'));

describe('function fetchPredecessors', function () {
let fetchPredecessors;
Expand All @@ -43,7 +45,7 @@ describe('context app', function () {
$provide.value('indexPatterns', createIndexPatternsStub());
}));

beforeEach(ngMock.inject(function createPrivateStubs(Private) {
beforeEach(ngMock.inject(function createPrivateStubs() {
searchSourceStub = createContextSearchSourceStub([], '@timestamp', MS_PER_DAY * 8);
fetchPredecessors = (indexPatternId, timeField, sortDir, timeValIso, timeValNr, tieBreakerField, tieBreakerValue, size) => {
const anchor = {
Expand All @@ -53,7 +55,7 @@ describe('context app', function () {
sort: [timeValNr, tieBreakerValue]
};

return Private(fetchContextProvider).fetchSurroundingDocs(
return fetchContextProvider(createIndexPatternsStub()).fetchSurroundingDocs(
'predecessors',
indexPatternId,
anchor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import moment from 'moment';
import * as _ from 'lodash';
import { pluginInstance } from 'plugins/kibana/discover/index';

import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs';

Expand All @@ -32,17 +33,14 @@ const ANCHOR_TIMESTAMP_3 = (new Date(MS_PER_DAY * 3)).toJSON();
const ANCHOR_TIMESTAMP_3000 = (new Date(MS_PER_DAY * 3000)).toJSON();

describe('context app', function () {
beforeEach(ngMock.module('kibana'));
beforeEach(() => pluginInstance.initializeInnerAngular());
beforeEach(ngMock.module('app/discover'));

describe('function fetchSuccessors', function () {
let fetchSuccessors;
let searchSourceStub;

beforeEach(ngMock.module(function createServiceStubs($provide) {
$provide.value('indexPatterns', createIndexPatternsStub());
}));

beforeEach(ngMock.inject(function createPrivateStubs(Private) {
beforeEach(ngMock.inject(function createPrivateStubs() {
searchSourceStub = createContextSearchSourceStub([], '@timestamp');

fetchSuccessors = (indexPatternId, timeField, sortDir, timeValIso, timeValNr, tieBreakerField, tieBreakerValue, size) => {
Expand All @@ -53,7 +51,7 @@ describe('context app', function () {
sort: [timeValNr, tieBreakerValue]
};

return Private(fetchContextProvider).fetchSurroundingDocs(
return fetchContextProvider(createIndexPatternsStub()).fetchSurroundingDocs(
'successors',
indexPatternId,
anchor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { getServices } from '../../../kibana_services';

const { SearchSource } = getServices();
export function fetchAnchorProvider(indexPatterns) {
export function fetchAnchorProvider(indexPatterns, searchSource) {
return async function fetchAnchor(
indexPatternId,
anchorId,
sort
) {
const indexPattern = await indexPatterns.get(indexPatternId);
const searchSource = new SearchSource()
searchSource
.setParent(undefined)
.setField('index', indexPattern)
.setField('version', true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
* under the License.
*/

import { SortDirection } from '../../../../../../../ui/public/courier';
import { IndexPatterns, IndexPattern, getServices } from '../../../kibana_services';
import { reverseSortDir } from './utils/sorting';
import { IndexPatterns, IndexPattern, SearchSource } from '../../../kibana_services';
import { reverseSortDir, SortDirection } from './utils/sorting';
import { extractNanos, convertIsoToMillis } from './utils/date_conversion';
import { fetchHitsInInterval } from './utils/fetch_hits_in_interval';
import { generateIntervals } from './utils/generate_intervals';
Expand All @@ -35,8 +34,6 @@ export interface EsHitRecord {
}
export type EsHitRecordList = EsHitRecord[];

const { SearchSource } = getServices();

const DAY_MILLIS = 24 * 60 * 60 * 1000;

// look from 1 day up to 10000 days into the past and future
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { reverseSortDir } from '../sorting';
import { SortDirection } from '../../../../../../../../../ui/public/courier';

jest.mock('ui/new_platform');
import { reverseSortDir, SortDirection } from '../sorting';

describe('function reverseSortDir', function() {
test('reverse a given sort direction', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
* under the License.
*/

import { SortDirection } from '../../../../../../../../ui/public/courier';
import { IndexPattern } from '../../../../kibana_services';

export enum SortDirection {
asc = 'asc',
desc = 'desc',
}

/**
* The list of field names that are allowed for sorting, but not included in
* index pattern fields.
Expand Down
Loading