Skip to content

Commit

Permalink
Merge branch 'master' into fix/kbn-pm/bootstrap-outside-repo
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Mar 17, 2020
2 parents bb2cc7a + 631d93d commit 929496b
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 91 deletions.
13 changes: 6 additions & 7 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,32 @@
/src/plugins/dashboard/ @elastic/kibana-app

# App Architecture
/examples/url_generators_examples/ @elastic/kibana-app-arch
/examples/url_generators_explorer/ @elastic/kibana-app-arch
/packages/kbn-interpreter/ @elastic/kibana-app-arch
/src/legacy/core_plugins/data/ @elastic/kibana-app-arch
/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js @elastic/kibana-app-arch
/src/legacy/core_plugins/embeddable_api/ @elastic/kibana-app-arch
/src/legacy/core_plugins/interpreter/ @elastic/kibana-app-arch
/src/legacy/core_plugins/kibana_react/ @elastic/kibana-app-arch
/src/legacy/core_plugins/kibana/public/management/ @elastic/kibana-app-arch
/src/legacy/core_plugins/kibana/server/field_formats/ @elastic/kibana-app-arch
/src/legacy/core_plugins/kibana/server/routes/api/management/ @elastic/kibana-app-arch
/src/legacy/core_plugins/kibana/server/routes/api/suggestions/ @elastic/kibana-app-arch
/src/legacy/core_plugins/visualizations/ @elastic/kibana-app-arch
/src/legacy/server/index_patterns/ @elastic/kibana-app-arch
/src/plugins/advanced_settings/ @elastic/kibana-app-arch
/src/plugins/bfetch/ @elastic/kibana-app-arch
/src/plugins/data/ @elastic/kibana-app-arch
/src/plugins/embeddable/ @elastic/kibana-app-arch
/src/plugins/expressions/ @elastic/kibana-app-arch
/src/plugins/inspector/ @elastic/kibana-app-arch
/src/plugins/kibana_react/ @elastic/kibana-app-arch
/src/plugins/kibana_react/public/code_editor @elastic/kibana-canvas
/src/plugins/kibana_utils/ @elastic/kibana-app-arch
/src/plugins/management/ @elastic/kibana-app-arch
/src/plugins/navigation/ @elastic/kibana-app-arch
/src/plugins/share/ @elastic/kibana-app-arch
/src/plugins/ui_actions/ @elastic/kibana-app-arch
/src/plugins/visualizations/ @elastic/kibana-app-arch
/src/plugins/share/ @elastic/kibana-app-arch
/examples/url_generators_examples/ @elastic/kibana-app-arch
/examples/url_generators_explorer/ @elastic/kibana-app-arch
/x-pack/plugins/advanced_ui_actions/ @elastic/kibana-app-arch
/x-pack/plugins/data_enhanced/ @elastic/kibana-app-arch
/x-pack/plugins/drilldowns/ @elastic/kibana-app-arch

# APM
Expand Down
4 changes: 1 addition & 3 deletions docs/settings/monitoring-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ which support the same values as <<settings,{kib} configuration settings>>.
To control how data is collected from your {es} nodes, you configure
{ref}/monitoring-settings.html[`xpack.monitoring.collection`
settings] in `elasticsearch.yml`. To control how monitoring data is collected
from Logstash, you configure
{logstash-ref}/monitoring-internal-collection.html#monitoring-settings[`xpack.monitoring` settings]
in `logstash.yml`.
from Logstash, configure monitoring settings in `logstash.yml`.

For more information, see
{ref}/monitor-elasticsearch-cluster.html[Monitor a cluster].
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"@elastic/apm-rum": "^4.6.0",
"@elastic/charts": "^17.1.1",
"@elastic/datemath": "5.0.2",
"@elastic/ems-client": "7.6.0",
"@elastic/ems-client": "7.7.0",
"@elastic/eui": "20.0.2",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "8.1.1-kibana2",
Expand Down
3 changes: 2 additions & 1 deletion src/legacy/ui/public/vis/map/service_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ uiModules
this._showZoomMessage = true;
this._emsClient = new EMSClient({
language: i18n.getLocale(),
kbnVersion: kbnVersion,
appVersion: kbnVersion,
appName: 'kibana',
fileApiUrl: mapConfig.emsFileApiUrl,
tileApiUrl: mapConfig.emsTileApiUrl,
htmlSanitizer: $sanitize,
Expand Down
4 changes: 3 additions & 1 deletion x-pack/legacy/plugins/maps/public/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
EMS_FILES_CATALOGUE_PATH,
EMS_TILES_CATALOGUE_PATH,
EMS_GLYPHS_PATH,
EMS_APP_NAME,
} from '../common/constants';
import chrome from 'ui/chrome';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -56,7 +57,8 @@ export function getEMSClient() {

emsClient = new EMSClient({
language: i18n.getLocale(),
kbnVersion: chrome.getInjected('kbnPkgVersion'),
appVersion: chrome.getInjected('kbnPkgVersion'),
appName: EMS_APP_NAME,
tileApiUrl,
fileApiUrl,
landingPageUrl: chrome.getInjected('emsLandingPageUrl'),
Expand Down
4 changes: 3 additions & 1 deletion x-pack/legacy/plugins/maps/server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import {
EMS_APP_NAME,
EMS_CATALOGUE_PATH,
EMS_FILES_API_PATH,
EMS_FILES_CATALOGUE_PATH,
Expand Down Expand Up @@ -38,7 +39,8 @@ export function initRoutes(server, licenseUid) {
if (mapConfig.includeElasticMapsService) {
emsClient = new EMSClient({
language: i18n.getLocale(),
kbnVersion: serverConfig.get('pkg.version'),
appVersion: serverConfig.get('pkg.version'),
appName: EMS_APP_NAME,
fileApiUrl: mapConfig.emsFileApiUrl,
tileApiUrl: mapConfig.emsTileApiUrl,
landingPageUrl: mapConfig.emsLandingPageUrl,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
"@babel/runtime": "^7.5.5",
"@elastic/apm-rum-react": "^0.3.2",
"@elastic/datemath": "5.0.2",
"@elastic/ems-client": "7.6.0",
"@elastic/ems-client": "7.7.0",
"@elastic/eui": "20.0.2",
"@elastic/filesaver": "1.1.2",
"@elastic/maki": "6.1.0",
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
export const EMS_APP_NAME = 'kibana';
export const EMS_CATALOGUE_PATH = 'ems/catalogue';

export const EMS_FILES_CATALOGUE_PATH = 'ems/files';
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/ml/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"features",
"home",
"licensing",
"usageCollection"
"usageCollection",
"share"
],
"optionalPlugins": [
"security",
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ml/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const App: FC<AppProps> = ({ coreStart, deps, appMountParams }) => {
application: coreStart.application,
http: coreStart.http,
security: deps.security,
urlGenerators: deps.share.urlGenerators,
});

const mlLicense = setLicenseCache(deps.licensing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import { TIME_RANGE_TYPE, URL_TYPE } from './constants';

import rison from 'rison-node';
// import url from 'url';
import url from 'url';

// import { npStart } from 'ui/new_platform';
// import { DASHBOARD_APP_URL_GENERATOR } from '../../../../../../../../src/plugins/dashboard_embeddable_container/public';
import { DASHBOARD_APP_URL_GENERATOR } from '../../../../../../../../src/plugins/dashboard/public';

import { ML_RESULTS_INDEX_PATTERN } from '../../../../../common/constants/index_patterns';
import { getPartitioningFieldNames } from '../../../../../common/util/job_utils';
Expand All @@ -19,7 +18,7 @@ import { replaceTokensInUrlValue, isValidLabel } from '../../../util/custom_url_
import { ml } from '../../../services/ml_api_service';
import { mlJobService } from '../../../services/job_service';
import { escapeForElasticsearchQuery } from '../../../util/string_utils';
// import { getSavedObjectsClient } from '../../../util/dependency_cache';
import { getSavedObjectsClient, getGetUrlGenerator } from '../../../util/dependency_cache';

export function getNewCustomUrlDefaults(job, dashboards, indexPatterns) {
// Returns the settings object in the format used by the custom URL editor
Expand Down Expand Up @@ -119,7 +118,7 @@ export function buildCustomUrlFromSettings(settings) {
// Dashboard URL returns a Promise as a query is made to obtain the full dashboard config.
// So wrap the other two return types in a Promise for consistent return type.
if (settings.type === URL_TYPE.KIBANA_DASHBOARD) {
// return buildDashboardUrlFromSettings(settings);
return buildDashboardUrlFromSettings(settings);
} else if (settings.type === URL_TYPE.KIBANA_DISCOVER) {
return Promise.resolve(buildDiscoverUrlFromSettings(settings));
} else {
Expand All @@ -132,72 +131,70 @@ export function buildCustomUrlFromSettings(settings) {
}
}

// function buildDashboardUrlFromSettings(settings) {
// // Get the complete list of attributes for the selected dashboard (query, filters).
// return new Promise((resolve, reject) => {
// const { dashboardId, queryFieldNames } = settings.kibanaSettings;

// const savedObjectsClient = getSavedObjectsClient();
// savedObjectsClient
// .get('dashboard', dashboardId)
// .then(response => {
// // Use the filters from the saved dashboard if there are any.
// // let filters = [];

// // Use the query from the dashboard only if no job entities are selected.
// let query = undefined;

// const searchSourceJSON = response.get('kibanaSavedObjectMeta.searchSourceJSON');
// if (searchSourceJSON !== undefined) {
// const searchSourceData = JSON.parse(searchSourceJSON);
// if (searchSourceData.filter !== undefined) {
// filters = searchSourceData.filter;
// }
// query = searchSourceData.query;
// }

// const queryFromEntityFieldNames = buildAppStateQueryParam(queryFieldNames);
// if (queryFromEntityFieldNames !== undefined) {
// query = queryFromEntityFieldNames;
// }

// const generator = npStart.plugins.share.urlGenerators.getUrlGenerator(
// DASHBOARD_APP_URL_GENERATOR
// );

// return generator
// .createUrl({
// dashboardId,
// timeRange: {
// from: '$earliest$',
// to: '$latest$',
// mode: 'absolute',
// },
// filters,
// query,
// // Don't hash the URL since this string will be 1. shown to the user and 2. used as a
// // template to inject the time parameters.
// useHash: false,
// })
// .then(urlValue => {
// const urlToAdd = {
// url_name: settings.label,
// url_value: decodeURIComponent(`kibana${url.parse(urlValue).hash}`),
// time_range: TIME_RANGE_TYPE.AUTO,
// };

// if (settings.timeRange.type === TIME_RANGE_TYPE.INTERVAL) {
// urlToAdd.time_range = settings.timeRange.interval;
// }

// resolve(urlToAdd);
// });
// })
// .catch(resp => {
// reject(resp);
// });
// });
// }
function buildDashboardUrlFromSettings(settings) {
// Get the complete list of attributes for the selected dashboard (query, filters).
return new Promise((resolve, reject) => {
const { dashboardId, queryFieldNames } = settings.kibanaSettings;

const savedObjectsClient = getSavedObjectsClient();
savedObjectsClient
.get('dashboard', dashboardId)
.then(response => {
// Use the filters from the saved dashboard if there are any.
let filters = [];

// Use the query from the dashboard only if no job entities are selected.
let query = undefined;

const searchSourceJSON = response.get('kibanaSavedObjectMeta.searchSourceJSON');
if (searchSourceJSON !== undefined) {
const searchSourceData = JSON.parse(searchSourceJSON);
if (searchSourceData.filter !== undefined) {
filters = searchSourceData.filter;
}
query = searchSourceData.query;
}

const queryFromEntityFieldNames = buildAppStateQueryParam(queryFieldNames);
if (queryFromEntityFieldNames !== undefined) {
query = queryFromEntityFieldNames;
}

const getUrlGenerator = getGetUrlGenerator();
const generator = getUrlGenerator(DASHBOARD_APP_URL_GENERATOR);
return generator
.createUrl({
dashboardId,
timeRange: {
from: '$earliest$',
to: '$latest$',
mode: 'absolute',
},
filters,
query,
// Don't hash the URL since this string will be 1. shown to the user and 2. used as a
// template to inject the time parameters.
useHash: false,
})
.then(urlValue => {
const urlToAdd = {
url_name: settings.label,
url_value: decodeURIComponent(`kibana${url.parse(urlValue).hash}`),
time_range: TIME_RANGE_TYPE.AUTO,
};

if (settings.timeRange.type === TIME_RANGE_TYPE.INTERVAL) {
urlToAdd.time_range = settings.timeRange.interval;
}

resolve(urlToAdd);
});
})
.catch(resp => {
reject(resp);
});
});
}

function buildDiscoverUrlFromSettings(settings) {
const { discoverIndexPatternId, queryFieldNames } = settings.kibanaSettings;
Expand Down
11 changes: 11 additions & 0 deletions x-pack/plugins/ml/public/application/util/dependency_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ChromeRecentlyAccessed,
IBasePath,
} from 'kibana/public';
import { SharePluginStart } from 'src/plugins/share/public';
import { SecurityPluginSetup } from '../../../../security/public';

export interface DependencyCache {
Expand All @@ -40,6 +41,7 @@ export interface DependencyCache {
http: HttpStart | null;
security: SecurityPluginSetup | null;
i18n: I18nStart | null;
urlGenerators: SharePluginStart['urlGenerators'] | null;
}

const cache: DependencyCache = {
Expand All @@ -59,6 +61,7 @@ const cache: DependencyCache = {
http: null,
security: null,
i18n: null,
urlGenerators: null,
};

export function setDependencyCache(deps: Partial<DependencyCache>) {
Expand All @@ -78,6 +81,7 @@ export function setDependencyCache(deps: Partial<DependencyCache>) {
cache.http = deps.http || null;
cache.security = deps.security || null;
cache.i18n = deps.i18n || null;
cache.urlGenerators = deps.urlGenerators || null;
}

export function getTimefilter() {
Expand Down Expand Up @@ -191,6 +195,13 @@ export function getI18n() {
return cache.i18n;
}

export function getGetUrlGenerator() {
if (cache.urlGenerators === null) {
throw new Error("urlGenerators hasn't been initialized");
}
return cache.urlGenerators.getUrlGenerator;
}

export function clearCache() {
console.log('clearing dependency cache'); // eslint-disable-line no-console
Object.keys(cache).forEach(k => {
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/ml/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { i18n } from '@kbn/i18n';
import { Plugin, CoreStart, CoreSetup, AppMountParameters } from 'kibana/public';
import { ManagementSetup } from 'src/plugins/management/public';
import { SharePluginStart } from 'src/plugins/share/public';

import { DataPublicPluginStart } from 'src/plugins/data/public';
import { SecurityPluginSetup } from '../../security/public';
Expand All @@ -17,6 +18,7 @@ import { PLUGIN_ID, PLUGIN_ICON } from '../common/constants/app';

export interface MlStartDependencies {
data: DataPublicPluginStart;
share: SharePluginStart;
}
export interface MlSetupDependencies {
security: SecurityPluginSetup;
Expand All @@ -41,6 +43,7 @@ export class MlPlugin implements Plugin<Setup, Start> {
coreStart,
{
data: pluginsStart.data,
share: pluginsStart.share,
security: pluginsSetup.security,
licensing: pluginsSetup.licensing,
management: pluginsSetup.management,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1916,10 +1916,10 @@
once "^1.4.0"
pump "^3.0.0"

"@elastic/ems-client@7.6.0":
version "7.6.0"
resolved "https://registry.yarnpkg.com/@elastic/ems-client/-/ems-client-7.6.0.tgz#ca548aba1a1f5170a1892de129b537b5248c74be"
integrity sha512-oBtLH24qIgTaMhlSske49FTd35Y0nv+PlZCZaHkBhOH+ScsTDL3LO2lbIcSmcYQod43Ly34v/xwJvFCTxojVEQ==
"@elastic/ems-client@7.7.0":
version "7.7.0"
resolved "https://registry.yarnpkg.com/@elastic/ems-client/-/ems-client-7.7.0.tgz#7d36d716dd941f060b9fcdae94f186a9aecc5cc2"
integrity sha512-JatsSyLik/8MTEOEimzEZ3NYjvGL1YzjbGujuSCgaXhPRqzu/wvMLEL8dlVpmYFZ7ALbGNsVdho4Hr8tngsIMw==
dependencies:
lodash "^4.17.15"
node-fetch "^1.7.3"
Expand Down

0 comments on commit 929496b

Please sign in to comment.