Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into alerts-create-for…
Browse files Browse the repository at this point in the history
…m-ui-flyout

# Conflicts:
#	x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/action_connector_form.test.tsx
#	x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/action_connector_form/connector_add_flyout.test.tsx
#	x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/sections/alerts_list/components/alerts_list.tsx
#	x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/types.ts
  • Loading branch information
YulNaumenko committed Feb 3, 2020
2 parents 87d6a9b + 4f4d3d7 commit 21a0631
Show file tree
Hide file tree
Showing 264 changed files with 5,823 additions and 1,871 deletions.
23 changes: 14 additions & 9 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@
/src/plugins/dev_tools/ @elastic/kibana-app

# App Architecture
/src/plugins/data/ @elastic/kibana-app-arch
/src/plugins/embeddable/ @elastic/kibana-app-arch
/src/plugins/expressions/ @elastic/kibana-app-arch
/src/plugins/kibana_react/ @elastic/kibana-app-arch
/src/plugins/kibana_utils/ @elastic/kibana-app-arch
/src/plugins/navigation/ @elastic/kibana-app-arch
/src/plugins/ui_actions/ @elastic/kibana-app-arch
/src/plugins/visualizations/ @elastic/kibana-app-arch
/x-pack/plugins/advanced_ui_actions/ @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
Expand All @@ -48,6 +40,19 @@
/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/bfetch/ @elastic/kibana-app-arch
/src/plugins/dashboard_embeddable_container/ @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_utils/ @elastic/kibana-app-arch
/src/plugins/management/ @elastic/kibana-app-arch
/src/plugins/navigation/ @elastic/kibana-app-arch
/src/plugins/ui_actions/ @elastic/kibana-app-arch
/src/plugins/visualizations/ @elastic/kibana-app-arch
/x-pack/plugins/advanced_ui_actions/ @elastic/kibana-app-arch

# APM
/x-pack/legacy/plugins/apm/ @elastic/apm-ui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function getSettingsFromFile(log: ToolingLog, path: string, settingOverrid
return transformDeprecations(settingsWithDefaults, logDeprecation);
}

export async function readConfigFile(log: ToolingLog, path: string, settingOverrides: any) {
export async function readConfigFile(log: ToolingLog, path: string, settingOverrides: any = {}) {
return new Config({
settings: await getSettingsFromFile(log, path, settingOverrides),
primary: true,
Expand Down
88 changes: 88 additions & 0 deletions src/core/public/application/ui/app_container.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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 { mount } from 'enzyme';

import { AppContainer } from './app_container';
import { Mounter, AppMountParameters, AppStatus } from '../types';

describe('AppContainer', () => {
const appId = 'someApp';
const setAppLeaveHandler = jest.fn();

const flushPromises = async () => {
await new Promise(async resolve => {
setImmediate(() => resolve());
});
};

const createResolver = (): [Promise<void>, () => void] => {
let resolve: () => void | undefined;
const promise = new Promise<void>(r => {
resolve = r;
});
return [promise, resolve!];
};

const createMounter = (promise: Promise<void>): Mounter => ({
appBasePath: '/base-path',
appRoute: '/some-route',
unmountBeforeMounting: false,
mount: async ({ element }: AppMountParameters) => {
await promise;
const container = document.createElement('div');
container.innerHTML = 'some-content';
element.appendChild(container);
return () => container.remove();
},
});

it('should hide the "not found" page before mounting the route', async () => {
const [waitPromise, resolvePromise] = createResolver();
const mounter = createMounter(waitPromise);

const wrapper = mount(
<AppContainer
appId={appId}
appStatus={AppStatus.inaccessible}
mounter={mounter}
setAppLeaveHandler={setAppLeaveHandler}
/>
);

expect(wrapper.text()).toContain('Application Not Found');

wrapper.setProps({
appId,
setAppLeaveHandler,
mounter,
appStatus: AppStatus.accessible,
});
wrapper.update();

expect(wrapper.text()).toEqual('');

resolvePromise();
await flushPromises();
wrapper.update();

expect(wrapper.text()).toContain('some-content');
});
});
18 changes: 10 additions & 8 deletions src/core/public/application/ui/app_container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,27 @@ export const AppContainer: FunctionComponent<Props> = ({
unmountRef.current = null;
}
};
const mount = async () => {
if (!mounter || appStatus !== AppStatus.accessible) {
return setAppNotFound(true);
}

if (mounter.unmountBeforeMounting) {
unmount();
}
if (!mounter || appStatus !== AppStatus.accessible) {
return setAppNotFound(true);
}
setAppNotFound(false);

if (mounter.unmountBeforeMounting) {
unmount();
}

const mount = async () => {
unmountRef.current =
(await mounter.mount({
appBasePath: mounter.appBasePath,
element: elementRef.current!,
onAppLeave: handler => setAppLeaveHandler(appId, handler),
})) || null;
setAppNotFound(false);
};

mount();

return unmount;
}, [appId, appStatus, mounter, setAppLeaveHandler]);

Expand Down
1 change: 1 addition & 0 deletions src/core/server/http/integration_tests/lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ describe('Auth', () => {
res.ok({
headers: {
'www-authenticate': 'from handler',
'another-header': 'yet another header',
},
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/lifecycle/on_pre_response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export function adoptToHapiOnPreResponseFormat(fn: OnPreResponseHandler, log: Lo
...(result.headers as any), // hapi types don't specify string[] as valid value
};
} else {
findHeadersIntersection(response.headers, result.headers, log);
for (const [headerName, headerValue] of Object.entries(result.headers)) {
findHeadersIntersection(response.headers, result.headers, log);
response.header(headerName, headerValue as any); // hapi types don't specify string[] as valid value
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/dev/ci_setup/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ export KIBANA_PKG_BRANCH="$kbnBranch"
###
### download node
###
nodeVersion="$(cat "$dir/.node-version")"
nodeDir="$cacheDir/node/$nodeVersion"
nodeBin="$nodeDir/bin"
classifier="x64.tar.gz"

UNAME=$(uname)
OS="linux"
if [[ "$UNAME" = *"MINGW64_NT"* ]]; then
OS="win"
nodeBin="$HOME/node"
classifier="x64.zip"
elif [[ "$UNAME" == "Darwin" ]]; then
OS="darwin"
fi
echo " -- Running on OS: $OS"

nodeVersion="$(cat "$dir/.node-version")"
nodeDir="$cacheDir/node/$nodeVersion"

if [[ "$OS" == "win" ]]; then
nodeBin="$HOME/node"
nodeUrl="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/dist/v$nodeVersion/node-v$nodeVersion-win-x64.zip"
else
nodeBin="$nodeDir/bin"
nodeUrl="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/dist/v$nodeVersion/node-v$nodeVersion-linux-x64.tar.gz"
fi
nodeUrl="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/dist/v$nodeVersion/node-v$nodeVersion-${OS}-${classifier}"

if [[ "$installNode" == "true" ]]; then
echo " -- node: version=v${nodeVersion} dir=$nodeDir"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,23 @@ import Fs from 'fs';
import { createGunzip, createGzip, Z_BEST_COMPRESSION } from 'zlib';
import { promisify } from 'util';
import globby from 'globby';
import { ToolingLog } from '@kbn/dev-utils';

import { createPromiseFromStreams } from '../../legacy/utils';

const unlinkAsync = promisify(Fs.unlink);

export async function editAction({ prefix, dataDir, log, handler }) {
export async function editAction({
prefix,
dataDir,
log,
handler,
}: {
prefix: string;
dataDir: string;
log: ToolingLog;
handler: () => Promise<any>;
}) {
const archives = (
await globby('**/*.gz', {
cwd: prefix ? resolve(dataDir, prefix) : dataDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/

import { Client } from 'elasticsearch';
import { ToolingLog, KbnClient } from '@kbn/dev-utils';

import { migrateKibanaIndex, deleteKibanaIndices, createStats } from '../lib';

export async function emptyKibanaIndexAction({ client, log, kbnClient }) {
export async function emptyKibanaIndexAction({
client,
log,
kbnClient,
}: {
client: Client;
log: ToolingLog;
kbnClient: KbnClient;
}) {
const stats = createStats('emptyKibanaIndex', log);
const kibanaPluginIds = await kbnClient.plugins.getEnabledIds();

await deleteKibanaIndices({ client, stats });
await migrateKibanaIndex({ client, log, stats, kibanaPluginIds });
await deleteKibanaIndices({ client, stats, log });
await migrateKibanaIndex({ client, log, kibanaPluginIds });
return stats;
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

import { resolve } from 'path';
import { createReadStream } from 'fs';
import { Readable } from 'stream';
import { ToolingLog, KbnClient } from '@kbn/dev-utils';
import { Client } from 'elasticsearch';

import { createPromiseFromStreams, concatStreamProviders } from '../../legacy/utils';

Expand All @@ -38,12 +41,26 @@ import {
// pipe a series of streams into each other so that data and errors
// flow from the first stream to the last. Errors from the last stream
// are not listened for
const pipeline = (...streams) =>
const pipeline = (...streams: Readable[]) =>
streams.reduce((source, dest) =>
source.once('error', error => dest.emit('error', error)).pipe(dest)
source.once('error', error => dest.emit('error', error)).pipe(dest as any)
);

export async function loadAction({ name, skipExisting, client, dataDir, log, kbnClient }) {
export async function loadAction({
name,
skipExisting,
client,
dataDir,
log,
kbnClient,
}: {
name: string;
skipExisting: boolean;
client: Client;
dataDir: string;
log: ToolingLog;
kbnClient: KbnClient;
}) {
const inputDir = resolve(dataDir, name);
const stats = createStats(name, log);
const files = prioritizeMappings(await readDirectory(inputDir));
Expand All @@ -64,20 +81,20 @@ export async function loadAction({ name, skipExisting, client, dataDir, log, kbn
{ objectMode: true }
);

const progress = new Progress('load progress');
const progress = new Progress();
progress.activate(log);

await createPromiseFromStreams([
recordStream,
createCreateIndexStream({ client, stats, skipExisting, log, kibanaPluginIds }),
createCreateIndexStream({ client, stats, skipExisting, log }),
createIndexDocRecordsStream(client, stats, progress),
]);

progress.deactivate();
const result = stats.toJSON();

for (const [index, { docs }] of Object.entries(result)) {
if (!docs && docs.indexed > 0) {
if (docs && docs.indexed > 0) {
log.info('[%s] Indexed %d docs into %j', name, docs.indexed, index);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
*/

import { resolve, dirname, relative } from 'path';

import { stat, rename, createReadStream, createWriteStream } from 'fs';

import { Readable, Writable } from 'stream';
import { fromNode } from 'bluebird';
import { ToolingLog } from '@kbn/dev-utils';

import { createPromiseFromStreams } from '../../legacy/utils';

import {
prioritizeMappings,
readDirectory,
Expand All @@ -33,12 +32,20 @@ import {
createFormatArchiveStreams,
} from '../lib';

async function isDirectory(path) {
async function isDirectory(path: string): Promise<boolean> {
const stats = await fromNode(cb => stat(path, cb));
return stats.isDirectory();
}

export async function rebuildAllAction({ dataDir, log, rootDir = dataDir }) {
export async function rebuildAllAction({
dataDir,
log,
rootDir = dataDir,
}: {
dataDir: string;
log: ToolingLog;
rootDir?: string;
}) {
const childNames = prioritizeMappings(await readDirectory(dataDir));
for (const childName of childNames) {
const childPath = resolve(dataDir, childName);
Expand All @@ -58,11 +65,11 @@ export async function rebuildAllAction({ dataDir, log, rootDir = dataDir }) {
const tempFile = childPath + (gzip ? '.rebuilding.gz' : '.rebuilding');

await createPromiseFromStreams([
createReadStream(childPath),
createReadStream(childPath) as Readable,
...createParseArchiveStreams({ gzip }),
...createFormatArchiveStreams({ gzip }),
createWriteStream(tempFile),
]);
] as [Readable, ...Writable[]]);

await fromNode(cb => rename(tempFile, childPath, cb));
log.info(`${archiveName} Rebuilt ${childName}`);
Expand Down
Loading

0 comments on commit 21a0631

Please sign in to comment.