Skip to content

Commit

Permalink
Merge branch 'master' into quickfix-tx
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Nov 6, 2019
2 parents 6946d71 + 12391da commit c366d4b
Show file tree
Hide file tree
Showing 107 changed files with 3,653 additions and 714 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
"chance": "1.0.18",
"cheerio": "0.22.0",
"chokidar": "3.2.1",
"chromedriver": "^77.0.0",
"chromedriver": "^78.0.1",
"classnames": "2.2.6",
"dedent": "^0.7.0",
"delete-empty": "^2.0.0",
Expand Down
30 changes: 25 additions & 5 deletions packages/kbn-babel-preset/node_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@
*/

module.exports = (_, options = {}) => {
const overrides = [];
if (!process.env.ALLOW_PERFORMANCE_HOOKS_IN_TASK_MANAGER) {
overrides.push(
{
test: [/x-pack[\/\\]legacy[\/\\]plugins[\/\\]task_manager/],
plugins: [
[
'filter-imports',
{
imports: {
perf_hooks: ['performance'],
},
},
],
],
}
);
}

return {
presets: [
[
Expand All @@ -39,7 +58,7 @@ module.exports = (_, options = {}) => {
modules: 'cjs',
corejs: 3,

...(options['@babel/preset-env'] || {})
...(options['@babel/preset-env'] || {}),
},
],
require('./common_preset'),
Expand All @@ -48,9 +67,10 @@ module.exports = (_, options = {}) => {
[
require.resolve('babel-plugin-transform-define'),
{
'global.__BUILT_WITH_BABEL__': 'true'
}
]
]
'global.__BUILT_WITH_BABEL__': 'true',
},
],
],
overrides,
};
};
3 changes: 2 additions & 1 deletion packages/kbn-babel-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-modules-commonjs": "^7.5.0",
"@babel/preset-env": "^7.5.5",
"@babel/preset-react":"^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@kbn/elastic-idx": "1.0.0",
"babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-filter-imports": "^3.0.0",
"babel-plugin-transform-define": "^1.3.1",
"babel-plugin-typescript-strip-namespaces": "^1.1.1"
}
Expand Down
39 changes: 0 additions & 39 deletions src/core/server/http/http_server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,45 +577,6 @@ test('exposes route details of incoming request to a route handler', async () =>
});
});

describe('conditional compression', () => {
test('disables compression when there is a referer', async () => {
const { registerRouter, server: innerServer } = await server.setup(config);

const router = new Router('', logger, enhanceWithContext);
router.get({ path: '/', validate: false }, (context, req, res) =>
// we need the large body here so that compression would normally be used
res.ok({ body: 'hello'.repeat(500), headers: { 'Content-Type': 'text/html; charset=UTF-8' } })
);
registerRouter(router);

await server.start();
const response = await supertest(innerServer.listener)
.get('/')
.set('accept-encoding', 'gzip')
.set('referer', 'http://some-other-site/');

expect(response.header).not.toHaveProperty('content-encoding');
});

test(`enables compression when there isn't a referer`, async () => {
const { registerRouter, server: innerServer } = await server.setup(config);

const router = new Router('', logger, enhanceWithContext);
router.get({ path: '/', validate: false }, (context, req, res) =>
// we need the large body here so that compression will be used
res.ok({ body: 'hello'.repeat(500), headers: { 'Content-Type': 'text/html; charset=UTF-8' } })
);
registerRouter(router);

await server.start();
const response = await supertest(innerServer.listener)
.get('/')
.set('accept-encoding', 'gzip');

expect(response.header).toHaveProperty('content-encoding', 'gzip');
});
});

describe('setup contract', () => {
describe('#createSessionStorage', () => {
it('creates session storage factory', async () => {
Expand Down
18 changes: 0 additions & 18 deletions src/core/server/http/http_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export class HttpServer {

const basePathService = new BasePath(config.basePath);
this.setupBasePathRewrite(config, basePathService);
this.setupConditionalCompression();

return {
registerRouter: this.registerRouter.bind(this),
Expand Down Expand Up @@ -176,23 +175,6 @@ export class HttpServer {
});
}

private setupConditionalCompression() {
if (this.server === undefined) {
throw new Error('Server is not created yet');
}

this.server.ext('onRequest', (request, h) => {
// whenever there is a referrer, don't use compression even if the client supports it
if (request.info.referrer !== '') {
this.log.debug(
`Not using compression because there is a referer: ${request.info.referrer}`
);
request.info.acceptEncoding = '';
}
return h.continue;
});
}

private registerOnPostAuth(fn: OnPostAuthHandler) {
if (this.server === undefined) {
throw new Error('Server is not created yet');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
margin-top: $euiSizeXS;
}

.globalFilterBar__addButton {
min-height: $euiSizeL + $euiSizeXS; // same height as the badges
}

// sass-lint:disable quotes
.globalFilterGroup__branch {
padding: $euiSizeS $euiSizeM 0 0;
Expand Down Expand Up @@ -40,4 +44,3 @@
margin-top: $euiSize * -1;
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '@elastic/eui/src/components/form/mixins';
@import '@elastic/eui/src/components/form/variables';
@import '@elastic/eui/src/components/form/mixins';

/**
* 1. Allow wrapping of long filter items
Expand All @@ -19,11 +19,17 @@

&:not(.globalFilterItem-isDisabled) {
@include euiFormControlDefaultShadow;
box-shadow: #{$euiFormControlBoxShadow}, inset 0 0 0 1px $kbnGlobalFilterItemBorderColor; // Make the actual border more visible
}

&:focus-within {
animation: none !important; // Remove focus ring animation otherwise it overrides simulated border via box-shadow
}
}

.globalFilterItem-isDisabled {
background-color: transparentize($euiColorLightShade, .4);
color: $euiColorDarkShade;
background-color: transparentize($euiColorLightShade, 0.5);
text-decoration: line-through;
font-weight: $euiFontWeightRegular;
font-style: italic;
Expand All @@ -39,12 +45,22 @@
bottom: 0;
left: 0;
width: $euiSizeXS;
background-color: $euiColorVis0;
background-color: $kbnGlobalFilterItemBorderColor;
border-top-left-radius: $euiBorderRadius / 2;
border-bottom-left-radius: $euiBorderRadius / 2;
}
}

.globalFilterItem-isExcluded {
&:not(.globalFilterItem-isDisabled) {
box-shadow: #{$euiFormControlBoxShadow}, inset 0 0 0 1px $kbnGlobalFilterItemBorderColorExcluded;

&::before {
background-color: $kbnGlobalFilterItemPinnedColorExcluded;
}
}
}

.globalFilterItem__editorForm {
padding: $euiSizeM;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@import 'variables';
@import 'global_filter_group';
@import 'global_filter_item';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$kbnGlobalFilterItemBorderColor: tintOrShade($euiColorMediumShade, 35%, 20%);
$kbnGlobalFilterItemBorderColorExcluded: tintOrShade($euiColorDanger, 70%, 50%);
$kbnGlobalFilterItemPinnedColorExcluded: tintOrShade($euiColorDanger, 30%, 20%);
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function FilterBarUI(props: Props) {
size="xs"
onClick={() => setIsAddFilterPopoverOpen(true)}
data-test-subj="addFilter"
className="globalFilterBar__addButton"
>
+{' '}
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,86 @@
* under the License.
*/

import React, { Fragment } from 'react';
import { EuiTextColor } from '@elastic/eui';
import { Filter } from '@kbn/es-query';
import { i18n } from '@kbn/i18n';
import { existsOperator, isOneOfOperator } from './filter_operators';

export function getFilterDisplayText(filter: Filter, filterDisplayName: string) {
const prefix = filter.meta.negate
const prefixText = filter.meta.negate
? ` ${i18n.translate('data.filter.filterBar.negatedFilterPrefix', {
defaultMessage: 'NOT ',
})}`
: '';
const prefix =
filter.meta.negate && !filter.meta.disabled ? (
<EuiTextColor color="danger">{prefixText}</EuiTextColor>
) : (
prefixText
);

if (filter.meta.alias !== null) {
return `${prefix}${filter.meta.alias}`;
}

switch (filter.meta.type) {
case 'exists':
return `${prefix}${filter.meta.key} ${existsOperator.message}`;
return (
<Fragment>
{prefix}
{filter.meta.key} {existsOperator.message}
</Fragment>
);
case 'geo_bounding_box':
return `${prefix}${filter.meta.key}: ${filterDisplayName}`;
return (
<Fragment>
{prefix}
{filter.meta.key}: {filterDisplayName}
</Fragment>
);
case 'geo_polygon':
return `${prefix}${filter.meta.key}: ${filterDisplayName}`;
return (
<Fragment>
{prefix}
{filter.meta.key}: {filterDisplayName}
</Fragment>
);
case 'phrase':
return `${prefix}${filter.meta.key}: ${filterDisplayName}`;
return (
<Fragment>
{prefix}
{filter.meta.key}: {filterDisplayName}
</Fragment>
);
case 'phrases':
return `${prefix}${filter.meta.key} ${isOneOfOperator.message} ${filterDisplayName}`;
return (
<Fragment>
{prefix}
{filter.meta.key} {isOneOfOperator.message} {filterDisplayName}
</Fragment>
);
case 'query_string':
return `${prefix}${filterDisplayName}`;
return (
<Fragment>
{prefix}
{filterDisplayName}
</Fragment>
);
case 'range':
return `${prefix}${filter.meta.key}: ${filterDisplayName}`;
case 'phrase':
return (
<Fragment>
{prefix}
{filter.meta.key}: {filterDisplayName}
</Fragment>
);
default:
return `${prefix}${JSON.stringify(filter.query)}`;
return (
<Fragment>
{prefix}
{JSON.stringify(filter.query)}
</Fragment>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { EuiBadge } from '@elastic/eui';
import { EuiBadge, useInnerText } from '@elastic/eui';
import { Filter, isFilterPinned } from '@kbn/es-query';
import { i18n } from '@kbn/i18n';
import React, { SFC } from 'react';
Expand All @@ -36,9 +36,12 @@ export const FilterView: SFC<Props> = ({
displayName,
...rest
}: Props) => {
const [ref, innerText] = useInnerText();
const displayText = <span ref={ref}>{getFilterDisplayText(filter, displayName)}</span>;

let title = i18n.translate('data.filter.filterBar.moreFilterActionsMessage', {
defaultMessage: 'Filter: {displayText}. Select for more filter actions.',
values: { displayText: getFilterDisplayText(filter, displayName) },
defaultMessage: 'Filter: {innerText}. Select for more filter actions.',
values: { innerText },
});

if (isFilterPinned(filter)) {
Expand Down Expand Up @@ -72,7 +75,7 @@ export const FilterView: SFC<Props> = ({
})}
{...rest}
>
<span>{getFilterDisplayText(filter, displayName)}</span>
{displayText}
</EuiBadge>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {

import { InjectedIntl, injectI18n, FormattedMessage } from '@kbn/i18n/react';
import { debounce, compact, isEqual } from 'lodash';
import { documentationLinks } from 'ui/documentation_links';
import { Toast } from 'src/core/public';
import {
AutocompleteSuggestion,
Expand Down Expand Up @@ -348,15 +347,15 @@ export class QueryBarInputUI extends Component<Props, State> {
suggestion.field.subType.nested &&
!this.services.storage.get('kibana.KQLNestedQuerySyntaxInfoOptOut')
) {
const notifications = this.services.notifications;
const { notifications, docLinks } = this.services;

const onKQLNestedQuerySyntaxInfoOptOut = (toast: Toast) => {
if (!this.services.storage) return;
this.services.storage.set('kibana.KQLNestedQuerySyntaxInfoOptOut', true);
notifications!.toasts.remove(toast);
};

if (notifications) {
if (notifications && docLinks) {
const toast = notifications.toasts.add({
title: this.props.intl.formatMessage({
id: 'data.query.queryBar.KQLNestedQuerySyntaxInfoTitle',
Expand All @@ -372,7 +371,7 @@ export class QueryBarInputUI extends Component<Props, State> {
Learn more in our {link}."
values={{
link: (
<EuiLink href={documentationLinks.query.kueryQuerySyntax} target="_blank">
<EuiLink href={docLinks.links.query.kueryQuerySyntax} target="_blank">
<FormattedMessage
id="data.query.queryBar.KQLNestedQuerySyntaxInfoDocLinkText"
defaultMessage="docs"
Expand Down
Loading

0 comments on commit c366d4b

Please sign in to comment.