Skip to content

Commit d9585cd

Browse files
Merge branch 'master' of github.com:elastic/kibana into ingest_pipelines/component_tests
2 parents 29c2f4c + e3b4b99 commit d9585cd

30 files changed

Lines changed: 593 additions & 480 deletions

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ module.exports = {
112112
files: ['x-pack/plugins/lens/**/*.{js,ts,tsx}'],
113113
rules: {
114114
'react-hooks/exhaustive-deps': 'off',
115-
'react-hooks/rules-of-hooks': 'off',
116115
},
117116
},
118117
{

test/common/services/elasticsearch.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@
1818
*/
1919

2020
import { format as formatUrl } from 'url';
21-
21+
import fs from 'fs';
2222
import { Client } from '@elastic/elasticsearch';
23+
import { CA_CERT_PATH } from '@kbn/dev-utils';
2324

2425
import { FtrProviderContext } from '../ftr_provider_context';
2526

2627
export function ElasticsearchProvider({ getService }: FtrProviderContext) {
2728
const config = getService('config');
2829

2930
return new Client({
31+
ssl: {
32+
ca: fs.readFileSync(CA_CERT_PATH, 'utf-8'),
33+
},
3034
nodes: [formatUrl(config.get('servers.elasticsearch'))],
3135
requestTimeout: config.get('timeouts.esRequestTimeout'),
3236
});

x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export function LayerPanel(
4343
}
4444
) {
4545
const dragDropContext = useContext(DragContext);
46+
const [popoverState, setPopoverState] = useState<DimensionPopoverState>({
47+
isOpen: false,
48+
openId: null,
49+
addingToGroupId: null,
50+
});
51+
4652
const { framePublicAPI, layerId, activeVisualization, isOnlyLayer, onRemoveLayer } = props;
4753
const datasourcePublicAPI = framePublicAPI.datasourceLayers[layerId];
4854
if (!datasourcePublicAPI) {
@@ -74,12 +80,6 @@ export function LayerPanel(
7480
dateRange: props.framePublicAPI.dateRange,
7581
};
7682

77-
const [popoverState, setPopoverState] = useState<DimensionPopoverState>({
78-
isOpen: false,
79-
openId: null,
80-
addingToGroupId: null,
81-
});
82-
8383
const { groups } = activeVisualization.getConfiguration(layerVisualizationConfigProps);
8484
const isEmptyLayer = !groups.some(d => d.accessors.length > 0);
8585

x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ export function InnerWorkspacePanel({
122122
framePublicAPI.filters,
123123
]);
124124

125+
useEffect(() => {
126+
// reset expression error if component attempts to run it again
127+
if (expression && localState.expressionBuildError) {
128+
setLocalState(s => ({
129+
...s,
130+
expressionBuildError: undefined,
131+
}));
132+
}
133+
}, [expression]);
134+
125135
function onDrop() {
126136
if (suggestionForDraggedField) {
127137
trackUiEvent('drop_onto_workspace');
@@ -174,16 +184,6 @@ export function InnerWorkspacePanel({
174184
}
175185

176186
function renderVisualization() {
177-
useEffect(() => {
178-
// reset expression error if component attempts to run it again
179-
if (expression && localState.expressionBuildError) {
180-
setLocalState(s => ({
181-
...s,
182-
expressionBuildError: undefined,
183-
}));
184-
}
185-
}, [expression]);
186-
187187
if (expression === null) {
188188
return renderEmptyWorkspace();
189189
}

x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,17 @@ describe('IndexPattern Data Panel', () => {
258258

259259
it('should render a warning if there are no index patterns', () => {
260260
const wrapper = shallowWithIntl(
261-
<InnerIndexPatternDataPanel {...defaultProps} currentIndexPatternId="" indexPatterns={{}} />
261+
<IndexPatternDataPanel
262+
{...defaultProps}
263+
state={{
264+
...initialState,
265+
currentIndexPatternId: '',
266+
indexPatterns: {},
267+
}}
268+
setState={jest.fn()}
269+
dragDropContext={{ dragging: {}, setDragging: () => {} }}
270+
changeIndexPattern={jest.fn()}
271+
/>
262272
);
263273
expect(wrapper.find('[data-test-subj="indexPattern-no-indexpatterns"]')).toHaveLength(1);
264274
});

x-pack/plugins/lens/public/indexpattern_datasource/datapanel.tsx

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,49 @@ export function IndexPatternDataPanel({
144144
indexPatternList.map(x => `${x.title}:${x.timeFieldName}`).join(','),
145145
]}
146146
/>
147-
<MemoizedDataPanel
148-
currentIndexPatternId={currentIndexPatternId}
149-
indexPatternRefs={indexPatternRefs}
150-
indexPatterns={indexPatterns}
151-
query={query}
152-
dateRange={dateRange}
153-
filters={filters}
154-
dragDropContext={dragDropContext}
155-
showEmptyFields={state.showEmptyFields}
156-
onToggleEmptyFields={onToggleEmptyFields}
157-
core={core}
158-
data={data}
159-
onChangeIndexPattern={onChangeIndexPattern}
160-
existingFields={state.existingFields}
161-
/>
147+
148+
{Object.keys(indexPatterns).length === 0 ? (
149+
<EuiFlexGroup
150+
gutterSize="m"
151+
className="lnsInnerIndexPatternDataPanel"
152+
direction="column"
153+
responsive={false}
154+
>
155+
<EuiFlexItem grow={null}>
156+
<EuiCallOut
157+
data-test-subj="indexPattern-no-indexpatterns"
158+
title={i18n.translate('xpack.lens.indexPattern.noPatternsLabel', {
159+
defaultMessage: 'No index patterns',
160+
})}
161+
color="warning"
162+
iconType="alert"
163+
>
164+
<p>
165+
<FormattedMessage
166+
id="xpack.lens.indexPattern.noPatternsDescription"
167+
defaultMessage="Please create an index pattern or switch to another data source"
168+
/>
169+
</p>
170+
</EuiCallOut>
171+
</EuiFlexItem>
172+
</EuiFlexGroup>
173+
) : (
174+
<MemoizedDataPanel
175+
currentIndexPatternId={currentIndexPatternId}
176+
indexPatternRefs={indexPatternRefs}
177+
indexPatterns={indexPatterns}
178+
query={query}
179+
dateRange={dateRange}
180+
filters={filters}
181+
dragDropContext={dragDropContext}
182+
showEmptyFields={state.showEmptyFields}
183+
onToggleEmptyFields={onToggleEmptyFields}
184+
core={core}
185+
data={data}
186+
onChangeIndexPattern={onChangeIndexPattern}
187+
existingFields={state.existingFields}
188+
/>
189+
)}
162190
</>
163191
);
164192
}
@@ -194,35 +222,6 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
194222
onChangeIndexPattern: (newId: string) => void;
195223
existingFields: IndexPatternPrivateState['existingFields'];
196224
}) {
197-
if (Object.keys(indexPatterns).length === 0) {
198-
return (
199-
<EuiFlexGroup
200-
gutterSize="m"
201-
className="lnsInnerIndexPatternDataPanel"
202-
direction="column"
203-
responsive={false}
204-
>
205-
<EuiFlexItem grow={null}>
206-
<EuiCallOut
207-
data-test-subj="indexPattern-no-indexpatterns"
208-
title={i18n.translate('xpack.lens.indexPattern.noPatternsLabel', {
209-
defaultMessage: 'No index patterns',
210-
})}
211-
color="warning"
212-
iconType="alert"
213-
>
214-
<p>
215-
<FormattedMessage
216-
id="xpack.lens.indexPattern.noPatternsDescription"
217-
defaultMessage="Please create an index pattern or switch to another data source"
218-
/>
219-
</p>
220-
</EuiCallOut>
221-
</EuiFlexItem>
222-
</EuiFlexGroup>
223-
);
224-
}
225-
226225
const [localState, setLocalState] = useState<DataPanelState>({
227226
nameFilter: '',
228227
typeFilter: [],

x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/bucket_nesting_editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function BucketNestingEditor({
127127
defaultMessage: 'Entire data set',
128128
}),
129129
},
130-
...aggColumns,
130+
...aggColumns.map(({ value, text }) => ({ value, text })),
131131
]}
132132
value={prevColumn}
133133
onChange={e => setColumns(nestColumn(layer.columnOrder, e.target.value, columnId))}

x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,22 +251,6 @@ function FieldItemPopoverContents(props: State & FieldItemProps) {
251251

252252
const IS_DARK_THEME = core.uiSettings.get('theme:darkMode');
253253
const chartTheme = IS_DARK_THEME ? EUI_CHARTS_THEME_DARK.theme : EUI_CHARTS_THEME_LIGHT.theme;
254-
255-
if (props.isLoading) {
256-
return <EuiLoadingSpinner />;
257-
} else if (
258-
(!props.histogram || props.histogram.buckets.length === 0) &&
259-
(!props.topValues || props.topValues.buckets.length === 0)
260-
) {
261-
return (
262-
<EuiText size="s">
263-
{i18n.translate('xpack.lens.indexPattern.fieldStatsNoData', {
264-
defaultMessage: 'No data to display.',
265-
})}
266-
</EuiText>
267-
);
268-
}
269-
270254
let histogramDefault = !!props.histogram;
271255

272256
const totalValuesCount =
@@ -309,6 +293,21 @@ function FieldItemPopoverContents(props: State & FieldItemProps) {
309293

310294
let title = <></>;
311295

296+
if (props.isLoading) {
297+
return <EuiLoadingSpinner />;
298+
} else if (
299+
(!props.histogram || props.histogram.buckets.length === 0) &&
300+
(!props.topValues || props.topValues.buckets.length === 0)
301+
) {
302+
return (
303+
<EuiText size="s">
304+
{i18n.translate('xpack.lens.indexPattern.fieldStatsNoData', {
305+
defaultMessage: 'No data to display.',
306+
})}
307+
</EuiText>
308+
);
309+
}
310+
312311
if (histogram && histogram.buckets.length && topValues && topValues.buckets.length) {
313312
title = (
314313
<EuiButtonGroup

x-pack/plugins/ml/server/models/bucket_span_estimator/__tests__/bucket_span_estimator.js renamed to x-pack/plugins/ml/server/models/bucket_span_estimator/bucket_span_estimator.test.ts

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import expect from '@kbn/expect';
8-
import { estimateBucketSpanFactory } from '../bucket_span_estimator';
7+
import { APICaller } from 'kibana/server';
8+
9+
import { ES_AGGREGATION } from '../../../common/constants/aggregation_types';
10+
11+
import { estimateBucketSpanFactory, BucketSpanEstimatorData } from './bucket_span_estimator';
912

1013
// Mock callWithRequest with the ability to simulate returning different
1114
// permission settings. On each call using `ml.privilegeCheck` we retrieve
@@ -14,7 +17,7 @@ import { estimateBucketSpanFactory } from '../bucket_span_estimator';
1417
// sufficient permissions should be returned, the second time insufficient
1518
// permissions.
1619
const permissions = [false, true];
17-
const callWithRequest = method => {
20+
const callWithRequest: APICaller = (method: string) => {
1821
return new Promise(resolve => {
1922
if (method === 'ml.privilegeCheck') {
2023
resolve({
@@ -28,34 +31,19 @@ const callWithRequest = method => {
2831
return;
2932
}
3033
resolve({});
31-
});
34+
}) as Promise<any>;
3235
};
3336

34-
const callWithInternalUser = () => {
37+
const callWithInternalUser: APICaller = () => {
3538
return new Promise(resolve => {
3639
resolve({});
37-
});
40+
}) as Promise<any>;
3841
};
3942

40-
// mock xpack_main plugin
41-
function mockXpackMainPluginFactory(isEnabled = false, licenseType = 'platinum') {
42-
return {
43-
info: {
44-
isAvailable: () => true,
45-
feature: () => ({
46-
isEnabled: () => isEnabled,
47-
}),
48-
license: {
49-
getType: () => licenseType,
50-
},
51-
},
52-
};
53-
}
54-
5543
// mock configuration to be passed to the estimator
56-
const formConfig = {
57-
aggTypes: ['count'],
58-
duration: {},
44+
const formConfig: BucketSpanEstimatorData = {
45+
aggTypes: [ES_AGGREGATION.COUNT],
46+
duration: { start: 0, end: 1 },
5947
fields: [null],
6048
index: '',
6149
query: {
@@ -64,58 +52,45 @@ const formConfig = {
6452
must_not: [],
6553
},
6654
},
55+
splitField: undefined,
56+
timeField: undefined,
6757
};
6858

6959
describe('ML - BucketSpanEstimator', () => {
7060
it('call factory', () => {
7161
expect(function() {
72-
estimateBucketSpanFactory(callWithRequest, callWithInternalUser);
73-
}).to.not.throwError('Not initialized.');
62+
estimateBucketSpanFactory(callWithRequest, callWithInternalUser, false);
63+
}).not.toThrow('Not initialized.');
7464
});
7565

7666
it('call factory and estimator with security disabled', done => {
7767
expect(function() {
7868
const estimateBucketSpan = estimateBucketSpanFactory(
7969
callWithRequest,
8070
callWithInternalUser,
81-
mockXpackMainPluginFactory()
71+
true
8272
);
8373

8474
estimateBucketSpan(formConfig).catch(catchData => {
85-
expect(catchData).to.be('Unable to retrieve cluster setting search.max_buckets');
75+
expect(catchData).toBe('Unable to retrieve cluster setting search.max_buckets');
8676

8777
done();
8878
});
89-
}).to.not.throwError('Not initialized.');
79+
}).not.toThrow('Not initialized.');
9080
});
9181

92-
it('call factory and estimator with security enabled and sufficient permissions.', done => {
82+
it('call factory and estimator with security enabled.', done => {
9383
expect(function() {
9484
const estimateBucketSpan = estimateBucketSpanFactory(
9585
callWithRequest,
9686
callWithInternalUser,
97-
mockXpackMainPluginFactory(true)
87+
false
9888
);
9989
estimateBucketSpan(formConfig).catch(catchData => {
100-
expect(catchData).to.be('Unable to retrieve cluster setting search.max_buckets');
90+
expect(catchData).toBe('Unable to retrieve cluster setting search.max_buckets');
10191

10292
done();
10393
});
104-
}).to.not.throwError('Not initialized.');
105-
});
106-
107-
it('call factory and estimator with security enabled and insufficient permissions.', done => {
108-
expect(function() {
109-
const estimateBucketSpan = estimateBucketSpanFactory(
110-
callWithRequest,
111-
callWithInternalUser,
112-
mockXpackMainPluginFactory(true)
113-
);
114-
115-
estimateBucketSpan(formConfig).catch(catchData => {
116-
expect(catchData).to.be('Insufficient permissions to call bucket span estimation.');
117-
done();
118-
});
119-
}).to.not.throwError('Not initialized.');
94+
}).not.toThrow('Not initialized.');
12095
});
12196
});

x-pack/plugins/ml/server/models/job_validation/__tests__/mock_farequote_cardinality.json renamed to x-pack/plugins/ml/server/models/job_validation/__mocks__/mock_farequote_cardinality.json

File renamed without changes.

0 commit comments

Comments
 (0)