-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
x-pack/plugins/monitoring/public/components/chart/get_technical_preview.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { chain } from 'lodash'; | ||
|
||
/* | ||
* Chart titles are taken from `metric.title` or `metric.label` fields in the series data. | ||
* Use title if found, otherwise use label | ||
*/ | ||
export function getTechnicalPreview(series = []) { | ||
return chain( | ||
series.map((s) => { | ||
return Boolean(s.metric.technicalPreview); | ||
}) | ||
) | ||
.first() | ||
.value(); | ||
} |
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/monitoring/public/components/chart/get_technical_preview.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { getTechnicalPreview } from './get_technical_preview'; | ||
|
||
describe('getTechnicalPreview', function () { | ||
it('with metric.technicalPreview undefined', () => { | ||
const series = [{ metric: {} }, { metric: { technicalPreview: true } }]; | ||
expect(getTechnicalPreview(series)).to.be(false); | ||
}); | ||
|
||
it('with metric.technicalPreview false', () => { | ||
const series = [ | ||
{ metric: { technicalPreview: false } }, | ||
{ metric: { technicalPreview: true } }, | ||
]; | ||
expect(getTechnicalPreview(series)).to.be(false); | ||
}); | ||
|
||
it('with metric.technicalPreview true', () => { | ||
const series = [ | ||
{ metric: { technicalPreview: true } }, | ||
{ metric: { technicalPreview: false } }, | ||
]; | ||
expect(getTechnicalPreview(series)).to.be(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters