Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into alerting-ui-fix-e…
Browse files Browse the repository at this point in the history
…rror-message-on-edit-not-registered

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
  • Loading branch information
YulNaumenko committed Mar 17, 2020
2 parents 8a37442 + 631d93d commit b998e12
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 82 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
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

0 comments on commit b998e12

Please sign in to comment.