Skip to content

Commit 79c4874

Browse files
Merge branch 'master' of github.com:elastic/kibana into fix/siem-timeline-footer-styles
2 parents b62f127 + ec78348 commit 79c4874

File tree

14 files changed

+362
-43
lines changed

14 files changed

+362
-43
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"typespec": "typings-tester --config x-pack/legacy/plugins/canvas/public/lib/aeroelastic/tsconfig.json x-pack/legacy/plugins/canvas/public/lib/aeroelastic/__fixtures__/typescript/typespec_tests.ts",
5353
"checkLicenses": "node scripts/check_licenses --dev",
5454
"build": "node scripts/build --all-platforms",
55-
"start": "node --trace-warnings --throw-deprecation scripts/kibana --dev",
55+
"start": "node scripts/kibana --dev",
5656
"debug": "node --nolazy --inspect scripts/kibana --dev",
5757
"debug-break": "node --nolazy --inspect-brk scripts/kibana --dev",
5858
"lint": "yarn run lint:es && yarn run lint:sass",

src/dev/ci_setup/setup_env.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cacheDir="$HOME/.kibana"
1414
RED='\033[0;31m'
1515
C_RESET='\033[0m' # Reset color
1616

17-
export NODE_OPTIONS="$NODE_OPTIONS --throw-deprecation --max-old-space-size=4096"
17+
export NODE_OPTIONS="$NODE_OPTIONS --max-old-space-size=4096"
1818

1919
###
2020
### Since the Jenkins logging output collector doesn't look like a TTY
@@ -168,4 +168,4 @@ if [[ -d "$ES_DIR" && -f "$ES_JAVA_PROP_PATH" ]]; then
168168
export JAVA_HOME=$HOME/.java/$ES_BUILD_JAVA
169169
fi
170170

171-
export CI_ENV_SETUP=true
171+
export CI_ENV_SETUP=true
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
if (process.noProcessWarnings !== true) {
21+
var ignore = ['MaxListenersExceededWarning'];
22+
23+
process.on('warning', function(warn) {
24+
if (ignore.includes(warn.name)) return;
25+
26+
if (process.traceProcessWarnings === true) {
27+
console.error('Node.js process-warning detected - Terminating process...');
28+
} else {
29+
console.error('Node.js process-warning detected:');
30+
console.error();
31+
console.error(warn.stack);
32+
console.error();
33+
console.error('Terminating process...');
34+
}
35+
36+
process.exit(1);
37+
});
38+
}

src/setup_node_env/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
* under the License.
1818
*/
1919

20-
require('./harden'); // this require MUST be executed before any others
20+
// The following require statements MUST be executed before any others - BEGIN
21+
require('./exit_on_warning');
22+
require('./harden');
23+
// The following require statements MUST be executed before any others - END
24+
2125
require('symbol-observable');
2226
require('./root');
2327
require('./node_version_validator');

x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/dynamic_color_property.js

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -101,34 +101,26 @@ export class DynamicColorProperty extends DynamicStyleProperty {
101101
}
102102

103103
_getMbColor() {
104-
const isDynamicConfigComplete =
105-
_.has(this._options, 'field.name') && _.has(this._options, 'color');
106-
if (!isDynamicConfigComplete) {
104+
if (!_.get(this._options, 'field.name')) {
107105
return null;
108106
}
109107

110-
const targetName = getComputedFieldName(this._styleName, this._options.field.name);
111-
if (this.isCategorical()) {
112-
return this._getMbDataDrivenCategoricalColor({ targetName });
113-
} else {
114-
return this._getMbDataDrivenOrdinalColor({ targetName });
115-
}
108+
return this.isCategorical()
109+
? this._getCategoricalColorMbExpression()
110+
: this._getOrdinalColorMbExpression();
116111
}
117112

118-
_getMbDataDrivenOrdinalColor({ targetName }) {
119-
if (
120-
this._options.useCustomColorRamp &&
121-
(!this._options.customColorRamp || !this._options.customColorRamp.length)
122-
) {
123-
return null;
124-
}
125-
126-
const colorStops = this._getMbOrdinalColorStops();
127-
if (!colorStops) {
128-
return null;
129-
}
130-
113+
_getOrdinalColorMbExpression() {
114+
const targetName = getComputedFieldName(this._styleName, this._options.field.name);
131115
if (this._options.useCustomColorRamp) {
116+
if (!this._options.customColorRamp || !this._options.customColorRamp.length) {
117+
// custom color ramp config is not complete
118+
return null;
119+
}
120+
121+
const colorStops = this._options.customColorRamp.reduce((accumulatedStops, nextStop) => {
122+
return [...accumulatedStops, nextStop.stop, nextStop.color];
123+
}, []);
132124
const firstStopValue = colorStops[0];
133125
const lessThenFirstStopValue = firstStopValue - 1;
134126
return [
@@ -138,6 +130,11 @@ export class DynamicColorProperty extends DynamicStyleProperty {
138130
...colorStops,
139131
];
140132
}
133+
134+
const colorStops = getOrdinalColorRampStops(this._options.color);
135+
if (!colorStops) {
136+
return null;
137+
}
141138
return [
142139
'interpolate',
143140
['linear'],
@@ -194,7 +191,7 @@ export class DynamicColorProperty extends DynamicStyleProperty {
194191
};
195192
}
196193

197-
_getMbDataDrivenCategoricalColor() {
194+
_getCategoricalColorMbExpression() {
198195
if (
199196
this._options.useCustomColorPalette &&
200197
(!this._options.customColorPalette || !this._options.customColorPalette.length)
@@ -226,16 +223,6 @@ export class DynamicColorProperty extends DynamicStyleProperty {
226223
return ['match', ['to-string', ['get', this._options.field.name]], ...mbStops];
227224
}
228225

229-
_getMbOrdinalColorStops() {
230-
if (this._options.useCustomColorRamp) {
231-
return this._options.customColorRamp.reduce((accumulatedStops, nextStop) => {
232-
return [...accumulatedStops, nextStop.stop, nextStop.color];
233-
}, []);
234-
} else {
235-
return getOrdinalColorRampStops(this._options.color);
236-
}
237-
}
238-
239226
renderRangeLegendHeader() {
240227
if (this._options.color) {
241228
return <ColorGradient colorRampName={this._options.color} />;

x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/dynamic_color_property.test.js

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,226 @@ test('Should pluck the categorical style-meta from fieldmeta', async () => {
237237
});
238238
});
239239

240+
describe('get mapbox color expression', () => {
241+
describe('ordinal color ramp', () => {
242+
test('should return null when field is not provided', async () => {
243+
const dynamicStyleOptions = {
244+
type: COLOR_MAP_TYPE.ORDINAL,
245+
};
246+
const colorProperty = makeProperty(dynamicStyleOptions);
247+
expect(colorProperty._getMbColor()).toBeNull();
248+
});
249+
250+
test('should return null when field name is not provided', async () => {
251+
const dynamicStyleOptions = {
252+
type: COLOR_MAP_TYPE.ORDINAL,
253+
field: {},
254+
};
255+
const colorProperty = makeProperty(dynamicStyleOptions);
256+
expect(colorProperty._getMbColor()).toBeNull();
257+
});
258+
259+
describe('pre-defined color ramp', () => {
260+
test('should return null when color ramp is not provided', async () => {
261+
const dynamicStyleOptions = {
262+
type: COLOR_MAP_TYPE.ORDINAL,
263+
field: {
264+
name: 'myField',
265+
},
266+
};
267+
const colorProperty = makeProperty(dynamicStyleOptions);
268+
expect(colorProperty._getMbColor()).toBeNull();
269+
});
270+
271+
test('should return mapbox expression for color ramp', async () => {
272+
const dynamicStyleOptions = {
273+
type: COLOR_MAP_TYPE.ORDINAL,
274+
field: {
275+
name: 'myField',
276+
},
277+
color: 'Blues',
278+
};
279+
const colorProperty = makeProperty(dynamicStyleOptions);
280+
expect(colorProperty._getMbColor()).toEqual([
281+
'interpolate',
282+
['linear'],
283+
['coalesce', ['feature-state', '__kbn__dynamic__myField__lineColor'], -1],
284+
-1,
285+
'rgba(0,0,0,0)',
286+
0,
287+
'#f7faff',
288+
0.125,
289+
'#ddeaf7',
290+
0.25,
291+
'#c5daee',
292+
0.375,
293+
'#9dc9e0',
294+
0.5,
295+
'#6aadd5',
296+
0.625,
297+
'#4191c5',
298+
0.75,
299+
'#2070b4',
300+
0.875,
301+
'#072f6b',
302+
]);
303+
});
304+
});
305+
306+
describe('custom color ramp', () => {
307+
test('should return null when customColorRamp is not provided', async () => {
308+
const dynamicStyleOptions = {
309+
type: COLOR_MAP_TYPE.ORDINAL,
310+
field: {
311+
name: 'myField',
312+
},
313+
useCustomColorRamp: true,
314+
};
315+
const colorProperty = makeProperty(dynamicStyleOptions);
316+
expect(colorProperty._getMbColor()).toBeNull();
317+
});
318+
319+
test('should return null when customColorRamp is empty', async () => {
320+
const dynamicStyleOptions = {
321+
type: COLOR_MAP_TYPE.ORDINAL,
322+
field: {
323+
name: 'myField',
324+
},
325+
useCustomColorRamp: true,
326+
customColorRamp: [],
327+
};
328+
const colorProperty = makeProperty(dynamicStyleOptions);
329+
expect(colorProperty._getMbColor()).toBeNull();
330+
});
331+
332+
test('should return mapbox expression for custom color ramp', async () => {
333+
const dynamicStyleOptions = {
334+
type: COLOR_MAP_TYPE.ORDINAL,
335+
field: {
336+
name: 'myField',
337+
},
338+
useCustomColorRamp: true,
339+
customColorRamp: [
340+
{ stop: 10, color: '#f7faff' },
341+
{ stop: 100, color: '#072f6b' },
342+
],
343+
};
344+
const colorProperty = makeProperty(dynamicStyleOptions);
345+
expect(colorProperty._getMbColor()).toEqual([
346+
'step',
347+
['coalesce', ['feature-state', '__kbn__dynamic__myField__lineColor'], 9],
348+
'rgba(0,0,0,0)',
349+
10,
350+
'#f7faff',
351+
100,
352+
'#072f6b',
353+
]);
354+
});
355+
});
356+
});
357+
358+
describe('categorical color palette', () => {
359+
test('should return null when field is not provided', async () => {
360+
const dynamicStyleOptions = {
361+
type: COLOR_MAP_TYPE.CATEGORICAL,
362+
};
363+
const colorProperty = makeProperty(dynamicStyleOptions);
364+
expect(colorProperty._getMbColor()).toBeNull();
365+
});
366+
367+
test('should return null when field name is not provided', async () => {
368+
const dynamicStyleOptions = {
369+
type: COLOR_MAP_TYPE.CATEGORICAL,
370+
field: {},
371+
};
372+
const colorProperty = makeProperty(dynamicStyleOptions);
373+
expect(colorProperty._getMbColor()).toBeNull();
374+
});
375+
376+
describe('pre-defined color palette', () => {
377+
test('should return null when color palette is not provided', async () => {
378+
const dynamicStyleOptions = {
379+
type: COLOR_MAP_TYPE.CATEGORICAL,
380+
field: {
381+
name: 'myField',
382+
},
383+
};
384+
const colorProperty = makeProperty(dynamicStyleOptions);
385+
expect(colorProperty._getMbColor()).toBeNull();
386+
});
387+
388+
test('should return mapbox expression for color palette', async () => {
389+
const dynamicStyleOptions = {
390+
type: COLOR_MAP_TYPE.CATEGORICAL,
391+
field: {
392+
name: 'myField',
393+
},
394+
colorCategory: 'palette_0',
395+
};
396+
const colorProperty = makeProperty(dynamicStyleOptions);
397+
expect(colorProperty._getMbColor()).toEqual([
398+
'match',
399+
['to-string', ['get', 'myField']],
400+
'US',
401+
'#54B399',
402+
'CN',
403+
'#6092C0',
404+
'#D36086',
405+
]);
406+
});
407+
});
408+
409+
describe('custom color palette', () => {
410+
test('should return null when customColorPalette is not provided', async () => {
411+
const dynamicStyleOptions = {
412+
type: COLOR_MAP_TYPE.CATEGORICAL,
413+
field: {
414+
name: 'myField',
415+
},
416+
useCustomColorPalette: true,
417+
};
418+
const colorProperty = makeProperty(dynamicStyleOptions);
419+
expect(colorProperty._getMbColor()).toBeNull();
420+
});
421+
422+
test('should return null when customColorPalette is empty', async () => {
423+
const dynamicStyleOptions = {
424+
type: COLOR_MAP_TYPE.CATEGORICAL,
425+
field: {
426+
name: 'myField',
427+
},
428+
useCustomColorPalette: true,
429+
customColorPalette: [],
430+
};
431+
const colorProperty = makeProperty(dynamicStyleOptions);
432+
expect(colorProperty._getMbColor()).toBeNull();
433+
});
434+
435+
test('should return mapbox expression for custom color palette', async () => {
436+
const dynamicStyleOptions = {
437+
type: COLOR_MAP_TYPE.CATEGORICAL,
438+
field: {
439+
name: 'myField',
440+
},
441+
useCustomColorPalette: true,
442+
customColorPalette: [
443+
{ stop: null, color: '#f7faff' },
444+
{ stop: 'MX', color: '#072f6b' },
445+
],
446+
};
447+
const colorProperty = makeProperty(dynamicStyleOptions);
448+
expect(colorProperty._getMbColor()).toEqual([
449+
'match',
450+
['to-string', ['get', 'myField']],
451+
'MX',
452+
'#072f6b',
453+
'#f7faff',
454+
]);
455+
});
456+
});
457+
});
458+
});
459+
240460
test('isCategorical should return true when type is categorical', async () => {
241461
const categoricalColorStyle = makeProperty({
242462
type: COLOR_MAP_TYPE.CATEGORICAL,

0 commit comments

Comments
 (0)