Skip to content

Commit

Permalink
Merge branch 'master' into fix/ml-conditionals-cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Sep 28, 2020
2 parents 65873e1 + 25682bf commit d94894c
Show file tree
Hide file tree
Showing 90 changed files with 1,605 additions and 569 deletions.
11 changes: 10 additions & 1 deletion packages/kbn-es/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "@kbn/es",
"main": "./src/index.js",
"main": "./target/index.js",
"version": "1.0.0",
"license": "Apache-2.0",
"private": true,
"scripts": {
"kbn:bootstrap": "node scripts/build",
"kbn:watch": "node scripts/build --watch"
},
"dependencies": {
"@elastic/elasticsearch": "7.9.0-rc.1",
"@kbn/dev-utils": "1.0.0",
Expand All @@ -19,5 +23,10 @@
"tar-fs": "^2.1.0",
"tree-kill": "^1.2.2",
"yauzl": "^2.10.0"
},
"devDependencies": {
"@kbn/babel-preset": "1.0.0",
"@babel/cli": "^7.10.5",
"del": "^5.1.0"
}
}
71 changes: 71 additions & 0 deletions packages/kbn-es/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

const { resolve } = require('path');

const del = require('del');
const { run, withProcRunner } = require('@kbn/dev-utils');

const ROOT_DIR = resolve(__dirname, '..');
const BUILD_DIR = resolve(ROOT_DIR, 'target');

run(
async ({ log, flags }) => {
await withProcRunner(log, async (proc) => {
log.info('Deleting old output');
await del(BUILD_DIR);

const cwd = ROOT_DIR;

log.info(`Starting babel${flags.watch ? ' in watch mode' : ''}`);
await proc.run(`babel`, {
cmd: 'babel',
args: [
'src',
'--no-babelrc',
'--presets',
require.resolve('@kbn/babel-preset/node_preset'),
'--extensions',
'.ts,.js',
'--copy-files',
'--out-dir',
BUILD_DIR,
...(flags.watch ? ['--watch'] : ['--quiet']),
...(!flags['source-maps'] || !!process.env.CODE_COVERAGE
? []
: ['--source-maps', 'inline']),
],
wait: true,
cwd,
});

log.success('Complete');
});
},
{
description: 'Simple build tool for @kbn/es package',
flags: {
boolean: ['watch', 'source-maps'],
help: `
--watch Run in watch mode
--source-maps Include sourcemaps
`,
},
}
);
104 changes: 53 additions & 51 deletions packages/kbn-es/src/integration_tests/__fixtures__/es_bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,65 +25,67 @@ const { exitCode, start, ssl } = JSON.parse(process.argv[2]);
const { createServer } = ssl ? require('https') : require('http');
const { ES_KEY_PATH, ES_CERT_PATH } = require('@kbn/dev-utils');

process.exitCode = exitCode;
(function main() {
process.exitCode = exitCode;

if (!start) {
return;
}
if (!start) {
return;
}

let serverUrl;
const server = createServer(
{
// Note: the integration uses the ES_P12_PATH, but that keystore contains
// the same key/cert as ES_KEY_PATH and ES_CERT_PATH
key: ssl ? fs.readFileSync(ES_KEY_PATH) : undefined,
cert: ssl ? fs.readFileSync(ES_CERT_PATH) : undefined,
},
(req, res) => {
const url = new URL(req.url, serverUrl);
const send = (code, body) => {
res.writeHead(code, { 'content-type': 'application/json' });
res.end(JSON.stringify(body));
};

let serverUrl;
const server = createServer(
{
// Note: the integration uses the ES_P12_PATH, but that keystore contains
// the same key/cert as ES_KEY_PATH and ES_CERT_PATH
key: ssl ? fs.readFileSync(ES_KEY_PATH) : undefined,
cert: ssl ? fs.readFileSync(ES_CERT_PATH) : undefined,
},
(req, res) => {
const url = new URL(req.url, serverUrl);
const send = (code, body) => {
res.writeHead(code, { 'content-type': 'application/json' });
res.end(JSON.stringify(body));
};
if (url.pathname === '/_xpack') {
return send(400, {
error: {
reason: 'foo bar',
},
});
}

if (url.pathname === '/_xpack') {
return send(400, {
return send(404, {
error: {
reason: 'foo bar',
reason: 'not found',
},
});
}
);

return send(404, {
error: {
reason: 'not found',
},
});
}
);

// setup server auto close after 1 second of silence
let serverCloseTimer;
const delayServerClose = () => {
clearTimeout(serverCloseTimer);
serverCloseTimer = setTimeout(() => server.close(), 1000);
};
server.on('request', delayServerClose);
server.on('listening', delayServerClose);
// setup server auto close after 1 second of silence
let serverCloseTimer;
const delayServerClose = () => {
clearTimeout(serverCloseTimer);
serverCloseTimer = setTimeout(() => server.close(), 1000);
};
server.on('request', delayServerClose);
server.on('listening', delayServerClose);

server.listen(0, '127.0.0.1', function () {
const { port, address: hostname } = server.address();
serverUrl = new URL(
formatUrl({
protocol: 'http:',
port,
hostname,
})
);
server.listen(0, '127.0.0.1', function () {
const { port, address: hostname } = server.address();
serverUrl = new URL(
formatUrl({
protocol: 'http:',
port,
hostname,
})
);

console.log(
`[o.e.h.AbstractHttpServerTransport] [computer] publish_address {127.0.0.1:${port}}, bound_addresses {[::1]:${port}}, {127.0.0.1:${port}}`
);
console.log(
`[o.e.h.AbstractHttpServerTransport] [computer] publish_address {127.0.0.1:${port}}, bound_addresses {[::1]:${port}}, {127.0.0.1:${port}}`
);

console.log('started');
});
console.log('started');
});
})();
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
},

resolve: {
extensions: ['.js', '.ts', '.tsx', 'json'],
extensions: ['.js', '.ts', '.tsx', '.json'],
mainFields: ['browser', 'main'],
alias: {
tinymath: require.resolve('tinymath/lib/tinymath.es5.js'),
Expand Down
2 changes: 1 addition & 1 deletion scripts/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

require('../src/setup_node_env');
require('../src/setup_node_env/prebuilt_dev_only_entry');

var resolve = require('path').resolve;
var pkg = require('../package.json');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ export const createAppNavigationHandler = (targetUrl: string) => (event: MouseEv
if (event.altKey || event.metaKey || event.ctrlKey) {
return;
}
if (targetUrl.startsWith('/app/')) {
const [, appId, path] = /\/app\/(.*?)((\/|\?|#|$).*)/.exec(targetUrl) || [];
if (!appId) {
return;
}
event.preventDefault();
getServices().application.navigateToApp(appId, { path });
}
event.preventDefault();
getServices().application.navigateToUrl(targetUrl);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React from 'react';
import { EuiButton, EuiCallOut, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';

interface Props {
isMapsAvailable: boolean;
onClick: (e: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
visualizationLabel: string;
}

export function LegacyMapDeprecationMessage(props: Props) {
const getMapsMessage = !props.isMapsAvailable ? (
<FormattedMessage
id="maps_legacy.defaultDistributionMessage"
defaultMessage="To get Maps, upgrade to the {defaultDistribution} of Elasticsearch and Kibana."
values={{
defaultDistribution: (
<EuiLink
color="accent"
external
href="https://www.elastic.co/downloads/kibana"
target="_blank"
>
default distribution
</EuiLink>
),
}}
/>
) : null;

const button = props.isMapsAvailable ? (
<div>
<EuiButton onClick={props.onClick} size="s">
<FormattedMessage id="maps_legacy.openInMapsButtonLabel" defaultMessage="View in Maps" />
</EuiButton>
</div>
) : null;

return (
<EuiCallOut
className="hide-for-sharing"
data-test-subj="deprecatedVisInfo"
size="s"
title={i18n.translate('maps_legacy.legacyMapDeprecationTitle', {
defaultMessage: '{label} will migrate to Maps in 8.0.',
values: { label: props.visualizationLabel },
})}
>
<p>
<FormattedMessage
id="maps_legacy.legacyMapDeprecationMessage"
defaultMessage="With Maps, you can add multiple layers and indices, plot individual documents, symbolize features from data values, add heatmaps, grids, and clusters, and more. {getMapsMessage}"
values={{ getMapsMessage }}
/>
</p>
{button}
</EuiCallOut>
);
}
1 change: 1 addition & 0 deletions src/plugins/maps_legacy/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export * from './common/types';
export { ORIGIN } from './common/constants/origin';

export { WmsOptions } from './components/wms_options';
export { LegacyMapDeprecationMessage } from './components/legacy_map_deprecation_message';

export { lazyLoadMapsLegacyModules } from './lazy_load_bundle';

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/region_map/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"expressions",
"mapsLegacy",
"kibanaLegacy",
"data"
"data",
"share"
],
"requiredBundles": [
"kibanaUtils",
Expand Down
Loading

0 comments on commit d94894c

Please sign in to comment.