Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into fix/autocompl…
Browse files Browse the repository at this point in the history
…ete-for-distance_feature

* 'master' of github.com:elastic/kibana:
  [SIEM] Fixes escape bug for filterQuery  (elastic#43030)
  Export saved objects based on search criteria (elastic#44723)
  refactor(webhook-whitelisting): Removed unneeded schema config (elastic#44974)
  [APM] Make number of x ticks responsive to the plot width (elastic#44870)
  [ML] Single metric viewer: Fix top nav refresh behaviour. (elastic#44860)
  • Loading branch information
jloleysens committed Sep 6, 2019
2 parents 9e128a9 + d909457 commit b6a35c5
Show file tree
Hide file tree
Showing 23 changed files with 307 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';

import { ObjectsTable, POSSIBLE_TYPES } from '../objects_table';
import { ObjectsTable } from '../objects_table';
import { Flyout } from '../components/flyout/';
import { Relationships } from '../components/relationships/';
import { findObjects } from '../../../lib';
Expand Down Expand Up @@ -57,10 +57,6 @@ jest.mock('../../../lib/fetch_export_objects', () => ({
fetchExportObjects: jest.fn(),
}));

jest.mock('../../../lib/fetch_export_by_type', () => ({
fetchExportByType: jest.fn(),
}));

jest.mock('../../../lib/get_saved_object_counts', () => ({
getSavedObjectCounts: jest.fn().mockImplementation(() => {
return {
Expand Down Expand Up @@ -318,7 +314,7 @@ describe('ObjectsTable', () => {
});

it('should export all', async () => {
const { fetchExportByType } = require('../../../lib/fetch_export_by_type');
const { fetchExportObjects } = require('../../../lib/fetch_export_objects');
const { saveAs } = require('@elastic/filesaver');
const component = shallowWithIntl(
<ObjectsTable.WrappedComponent
Expand All @@ -333,11 +329,11 @@ describe('ObjectsTable', () => {

// Set up mocks
const blob = new Blob([JSON.stringify(allSavedObjects)], { type: 'application/ndjson' });
fetchExportByType.mockImplementation(() => blob);
fetchExportObjects.mockImplementation(() => blob);

await component.instance().onExportAll();

expect(fetchExportByType).toHaveBeenCalledWith(POSSIBLE_TYPES, true);
expect(fetchExportObjects).toHaveBeenCalledWith(allSavedObjects.map(so => ({ type: so.type, id: so.id })), true);
expect(saveAs).toHaveBeenCalledWith(blob, 'export.ndjson');
expect(addSuccessMock).toHaveBeenCalledWith({ title: 'Your file is downloading in the background' });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ jest.mock('ui/chrome', () => ({
addBasePath: () => ''
}));

jest.mock('../../../../../lib/fetch_export_by_type', () => ({
fetchExportByType: jest.fn(),
}));

jest.mock('../../../../../lib/fetch_export_objects', () => ({
fetchExportObjects: jest.fn(),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import {
getRelationships,
getSavedObjectLabel,
fetchExportObjects,
fetchExportByType,
findObjects,
} from '../../lib';
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
Expand Down Expand Up @@ -303,20 +302,14 @@ class ObjectsTableUI extends Component {

onExportAll = async () => {
const { intl } = this.props;
const { exportAllSelectedOptions, isIncludeReferencesDeepChecked } = this.state;
const exportTypes = Object.entries(exportAllSelectedOptions).reduce(
(accum, [id, selected]) => {
if (selected) {
accum.push(id);
}
return accum;
},
[]
);

const { exportAllSelectedOptions, isIncludeReferencesDeepChecked, savedObjects } = this.state;

const exportObjects = savedObjects.filter(so => exportAllSelectedOptions[so.type]).map(so => ({ type: so.type, id: so.id }));

let blob;
try {
blob = await fetchExportByType(exportTypes, isIncludeReferencesDeepChecked);
blob = await fetchExportObjects(exportObjects, isIncludeReferencesDeepChecked);
} catch (e) {
toastNotifications.addDanger({
title: intl.formatMessage({
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

export * from './fetch_export_by_type';
export * from './fetch_export_objects';
export * from './in_app_url';
export * from './get_relationships';
Expand Down
9 changes: 3 additions & 6 deletions x-pack/legacy/plugins/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ export function actions(kibana: any) {
return Joi.object()
.keys({
enabled: Joi.boolean().default(false),
whitelistedHosts: Joi.alternatives()
.try(
Joi.array()
.items(Joi.string().hostname())
.sparse(false)
)
whitelistedHosts: Joi.array()
.items(Joi.string().hostname())
.sparse(false)
.default([]),
})
.default();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import { isValidCoordinateValue } from '../../../../utils/isValidCoordinateValue
// see https://github.com/uber/react-vis/issues/1214
const getNull = d => isValidCoordinateValue(d.y) && !isNaN(d.y);

const X_TICK_TOTAL = 7;

class StaticPlot extends PureComponent {
getVisSeries(series, plotValues) {
return series
Expand Down Expand Up @@ -141,12 +139,23 @@ class StaticPlot extends PureComponent {
}

render() {
const { series, tickFormatX, tickFormatY, plotValues, noHits } = this.props;
const {
width,
series,
tickFormatX,
tickFormatY,
plotValues,
noHits
} = this.props;
const { yTickValues } = plotValues;

// approximate number of x-axis ticks based on the width of the plot. There should by approx 1 tick per 100px
// d3 will determine the exact number of ticks based on the selected range
const xTickTotal = Math.floor(width / 100);

return (
<SharedPlot plotValues={plotValues}>
<XAxis tickSize={0} tickTotal={X_TICK_TOTAL} tickFormat={tickFormatX} />
<XAxis tickSize={0} tickTotal={xTickTotal} tickFormat={tickFormatX} />
{noHits ? (
<StatusText
marginLeft={30}
Expand Down Expand Up @@ -181,5 +190,6 @@ StaticPlot.propTypes = {
series: PropTypes.array.isRequired,
plotValues: PropTypes.object.isRequired,
tickFormatX: PropTypes.func,
tickFormatY: PropTypes.func.isRequired
tickFormatY: PropTypes.func.isRequired,
width: PropTypes.number.isRequired
};
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export class InnerCustomPlot extends PureComponent {
<Fragment>
<div style={{ position: 'relative', height: plotValues.XY_HEIGHT }}>
<StaticPlot
width={width}
noHits={noHits}
plotValues={plotValues}
series={enabledSeries}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ describe('when response has no data', () => {
onHover={onHover}
onMouseLeave={onMouseLeave}
onSelectionEnd={onSelectionEnd}
width={100}
width={800}
tickFormatX={x => x.getTime()} // Avoid timezone issues in snapshots
/>
);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b6a35c5

Please sign in to comment.