Skip to content

Commit

Permalink
Merge branch 'main' into fix/slo-installation
Browse files Browse the repository at this point in the history
  • Loading branch information
kdelemme authored Aug 9, 2023
2 parents 41c06a4 + b59af8b commit 3bac470
Show file tree
Hide file tree
Showing 75 changed files with 576 additions and 461 deletions.
1 change: 1 addition & 0 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ enabled:
- x-pack/test/functional/config_security_basic.ts
- x-pack/test/functional/config.ccs.ts
- x-pack/test/functional/config.firefox.js
- x-pack/test/functional/config.upgrade_assistant.ts
- x-pack/test/functional_cloud/config.ts
- x-pack/test/kubernetes_security/basic/config.ts
- x-pack/test/licensing_plugin/config.public.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const getLegendActions = (
panelItems.push(
{
name: i18n.translate('expressionPartitionVis.legend.filterForValueButtonAriaLabel', {
defaultMessage: 'Filter for value',
defaultMessage: 'Filter for',
}),
'data-test-subj': `legend-${title}-filterIn`,
icon: <EuiIcon type="plusInCircle" size="m" />,
Expand All @@ -75,7 +75,7 @@ export const getLegendActions = (
},
{
name: i18n.translate('expressionPartitionVis.legend.filterOutValueButtonAriaLabel', {
defaultMessage: 'Filter out value',
defaultMessage: 'Filter out',
}),
'data-test-subj': `legend-${title}-filterOut`,
icon: <EuiIcon type="minusInCircle" size="m" />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const LegendActionPopover: React.FunctionComponent<LegendActionPopoverPro
items: [
{
name: i18n.translate('expressionXY.legend.filterForValueButtonAriaLabel', {
defaultMessage: 'Filter for value',
defaultMessage: 'Filter for',
}),
'data-test-subj': `legend-${label}-filterIn`,
icon: <EuiIcon type="plusInCircle" size="m" />,
Expand All @@ -67,7 +67,7 @@ export const LegendActionPopover: React.FunctionComponent<LegendActionPopoverPro
},
{
name: i18n.translate('expressionXY.legend.filterOutValueButtonAriaLabel', {
defaultMessage: 'Filter out value',
defaultMessage: 'Filter out',
}),
'data-test-subj': `legend-${label}-filterOut`,
icon: <EuiIcon type="minusInCircle" size="m" />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ export const createGridColumns = (
const filterForText = i18n.translate(
'visTypeTable.tableCellFilter.filterForValueText',
{
defaultMessage: 'Filter for value',
defaultMessage: 'Filter for',
}
);
const filterForAriaLabel = i18n.translate(
'visTypeTable.tableCellFilter.filterForValueAriaLabel',
{
defaultMessage: 'Filter for value: {cellContent}',
defaultMessage: 'Filter for: {cellContent}',
values: {
cellContent,
},
Expand Down Expand Up @@ -105,13 +105,13 @@ export const createGridColumns = (
const filterOutText = i18n.translate(
'visTypeTable.tableCellFilter.filterOutValueText',
{
defaultMessage: 'Filter out value',
defaultMessage: 'Filter out',
}
);
const filterOutAriaLabel = i18n.translate(
'visTypeTable.tableCellFilter.filterOutValueAriaLabel',
{
defaultMessage: 'Filter out value: {cellContent}',
defaultMessage: 'Filter out: {cellContent}',
values: {
cellContent,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const VisLegendItemComponent = ({
{
id: 'filterIn',
label: i18n.translate('visTypeVislib.vislib.legend.filterForValueButtonAriaLabel', {
defaultMessage: 'Filter for value {legendDataLabel}',
defaultMessage: 'Filter for {legendDataLabel}',
values: { legendDataLabel: item.label },
}),
iconType: 'plusInCircle',
Expand All @@ -74,7 +74,7 @@ const VisLegendItemComponent = ({
{
id: 'filterOut',
label: i18n.translate('visTypeVislib.vislib.legend.filterOutValueButtonAriaLabel', {
defaultMessage: 'Filter out value {legendDataLabel}',
defaultMessage: 'Filter out {legendDataLabel}',
values: { legendDataLabel: item.label },
}),
iconType: 'minusInCircle',
Expand Down
10 changes: 0 additions & 10 deletions test/functional/apps/visualize/group6/_tsvb_tsdb_basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,5 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
expect(isFieldForAggregationValid).to.be(true);
expect(await testSubjects.exists('visualization-error-text')).to.be(false);
});

it('should show an error when using an unsupported tsdb field type', async () => {
await visualBuilder.selectAggType('Average');
await visualBuilder.setFieldForAggregation('bytes_counter');
// this is still returning true
const isFieldForAggregationValid = await visualBuilder.checkFieldForAggregationValidity();
expect(isFieldForAggregationValid).to.be(true);
// but an error should appear in visualization
expect(await testSubjects.exists('visualization-error-text')).to.be(true);
});
});
}
8 changes: 6 additions & 2 deletions x-pack/packages/ml/aiops_components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@

export { DualBrush, DualBrushAnnotation } from './src/dual_brush';
export { ProgressControls } from './src/progress_controls';
export { DocumentCountChart } from './src/document_count_chart';
export type { DocumentCountChartPoint, DocumentCountChartProps } from './src/document_count_chart';
export {
DocumentCountChart,
type BrushSettings,
type BrushSelectionUpdateHandler,
} from './src/document_count_chart';
export type { DocumentCountChartProps } from './src/document_count_chart';
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,21 @@ import {

import { i18n } from '@kbn/i18n';
import { IUiSettingsClient } from '@kbn/core/public';
import { getSnappedWindowParameters, getWindowParameters } from '@kbn/aiops-utils';
import type { WindowParameters } from '@kbn/aiops-utils';
import {
getLogRateAnalysisType,
getSnappedWindowParameters,
getWindowParameters,
type LogRateAnalysisType,
type LogRateHistogramItem,
type WindowParameters,
} from '@kbn/aiops-utils';
import { MULTILAYER_TIME_AXIS_STYLE } from '@kbn/charts-plugin/common';

import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public';

import { DualBrush, DualBrushAnnotation } from '../..';

import { BrushBadge } from './brush_badge';

declare global {
Expand All @@ -51,20 +58,6 @@ interface TimeFilterRange {
to: number;
}

/**
* Datum for the bar chart
*/
export interface DocumentCountChartPoint {
/**
* Time of bucket
*/
time: number | string;
/**
* Number of doc count for that time bucket
*/
value: number;
}

/**
* Brush settings
*/
Expand All @@ -83,6 +76,19 @@ export interface BrushSettings {
badgeWidth?: number;
}

/**
* Callback function which gets called when the brush selection has changed
*
* @param windowParameters Baseline and deviation time ranges.
* @param force Force update
* @param logRateAnalysisType `spike` or `dip` based on median log rate bucket size
*/
export type BrushSelectionUpdateHandler = (
windowParameters: WindowParameters,
force: boolean,
logRateAnalysisType: LogRateAnalysisType
) => void;

/**
* Props for document count chart
*/
Expand All @@ -94,14 +100,14 @@ export interface DocumentCountChartProps {
fieldFormats: FieldFormatsStart;
uiSettings: IUiSettingsClient;
};
/** Optional callback function which gets called the brush selection has changed */
brushSelectionUpdateHandler?: (windowParameters: WindowParameters, force: boolean) => void;
/** Optional callback for handling brush selection updates */
brushSelectionUpdateHandler?: BrushSelectionUpdateHandler;
/** Optional width */
width?: number;
/** Data chart points */
chartPoints: DocumentCountChartPoint[];
chartPoints: LogRateHistogramItem[];
/** Data chart points split */
chartPointsSplit?: DocumentCountChartPoint[];
chartPointsSplit?: LogRateHistogramItem[];
/** Start time range for the chart */
timeRangeEarliest: number;
/** Ending time range for the chart */
Expand Down Expand Up @@ -162,42 +168,30 @@ function getBaselineBadgeOverflow(
/**
* Document count chart with draggable brushes to select time ranges
* by default use `Baseline` and `Deviation` for the badge names
* @param dependencies - List of Kibana services that are required as dependencies
* @param brushSelectionUpdateHandler - Optional callback function which gets called the brush selection has changed
* @param width - Optional width
* @param chartPoints - Data chart points
* @param chartPointsSplit - Data chart points split
* @param timeRangeEarliest - Start time range for the chart
* @param timeRangeLatest - Ending time range for the chart
* @param interval - Time interval for the document count buckets
* @param chartPointsSplitLabel - Label to name the adjustedChartPointsSplit histogram
* @param isBrushCleared - Whether or not brush has been reset
* @param autoAnalysisStart - Timestamp for start of initial analysis
* @param barColorOverride - Optional color override for the default bar color for charts
* @param barStyleAccessor - Optional style to override bar chart
* @param barHighlightColorOverride - Optional color override for the highlighted bar color for charts
* @param deviationBrush - Optional settings override for the 'deviation' brush
* @param baselineBrush - Optional settings override for the 'baseline' brush
* @constructor
*
* @param props DocumentCountChart component props
* @returns The DocumentCountChart component.
*/
export const DocumentCountChart: FC<DocumentCountChartProps> = ({
dependencies,
brushSelectionUpdateHandler,
width,
chartPoints,
chartPointsSplit,
timeRangeEarliest,
timeRangeLatest,
interval,
chartPointsSplitLabel,
isBrushCleared,
autoAnalysisStart,
barColorOverride,
barStyleAccessor,
barHighlightColorOverride,
deviationBrush = {},
baselineBrush = {},
}) => {
export const DocumentCountChart: FC<DocumentCountChartProps> = (props) => {
const {
dependencies,
brushSelectionUpdateHandler,
width,
chartPoints,
chartPointsSplit,
timeRangeEarliest,
timeRangeLatest,
interval,
chartPointsSplitLabel,
isBrushCleared,
autoAnalysisStart,
barColorOverride,
barStyleAccessor,
barHighlightColorOverride,
deviationBrush = {},
baselineBrush = {},
} = props;

const { data, uiSettings, fieldFormats, charts } = dependencies;

const chartTheme = charts.theme.useChartsTheme();
Expand Down Expand Up @@ -333,8 +327,13 @@ export const DocumentCountChart: FC<DocumentCountChartProps> = ({
const wpSnap = getSnappedWindowParameters(wp, snapTimestamps);
setOriginalWindowParameters(wpSnap);
setWindowParameters(wpSnap);

if (brushSelectionUpdateHandler !== undefined) {
brushSelectionUpdateHandler(wpSnap, true);
brushSelectionUpdateHandler(
wpSnap,
true,
getLogRateAnalysisType(adjustedChartPoints, wpSnap)
);
}
}
}
Expand Down Expand Up @@ -385,7 +384,7 @@ export const DocumentCountChart: FC<DocumentCountChartProps> = ({
}
setWindowParameters(wp);
setWindowParametersAsPixels(wpPx);
brushSelectionUpdateHandler(wp, false);
brushSelectionUpdateHandler(wp, false, getLogRateAnalysisType(adjustedChartPoints, wp));
}

const [mlBrushWidth, setMlBrushWidth] = useState<number>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
*/

export { DocumentCountChart } from './document_count_chart';
export type { DocumentCountChartPoint, DocumentCountChartProps } from './document_count_chart';
export type {
BrushSelectionUpdateHandler,
BrushSettings,
DocumentCountChartProps,
} from './document_count_chart';
45 changes: 10 additions & 35 deletions x-pack/packages/ml/aiops_components/src/dual_brush/dual_brush.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { isEqual } from 'lodash';
import React, { useEffect, useRef } from 'react';
import React, { useEffect, useRef, type FC } from 'react';

import * as d3Brush from 'd3-brush';
import * as d3Scale from 'd3-scale';
Expand Down Expand Up @@ -54,6 +54,9 @@ const BRUSH_MARGIN = 4;
const BRUSH_HANDLE_SIZE = 4;
const BRUSH_HANDLE_ROUNDED_CORNER = 2;

/**
* Props for the DualBrush React Component
*/
interface DualBrushProps {
/**
* Min and max numeric timestamps for the two brushes
Expand Down Expand Up @@ -88,40 +91,12 @@ interface DualBrushProps {
/**
* DualBrush React Component
* Dual brush component that overlays the document count chart
* @type {FC<DualBrushProps>}
* @param props - `DualBrushProps` component props
* @returns {React.ReactElement} The DualBrush component.
*
* @param props DualBrushProps component props
* @returns The DualBrush component.
*/
export function DualBrush({
/**
* Min and max numeric timestamps for the two brushes
*/
windowParameters,
/**
* Min timestamp for x domain
*/
min,
/**
* Max timestamp for x domain
*/
max,
/**
* Callback function whenever the brush changes
*/
onChange,
/**
* Margin left
*/
marginLeft,
/**
* Nearest timestamps to snap to the brushes to
*/
snapTimestamps,
/**
* Width
*/
width,
}: DualBrushProps) {
export const DualBrush: FC<DualBrushProps> = (props) => {
const { windowParameters, min, max, onChange, marginLeft, snapTimestamps, width } = props;
const d3BrushContainer = useRef(null);
const brushes = useRef<DualBrush[]>([]);

Expand Down Expand Up @@ -383,4 +358,4 @@ export function DualBrush({
)}
</>
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ interface BrushAnnotationProps {
/**
* DualBrushAnnotation React Component
* Dual brush annotation component that overlays the document count chart
* @type {FC<BrushAnnotationProps>}
* @param props - `BrushAnnotationProps` component props
* @returns {React.ReactElement} The DualBrushAnnotation component.
*
* @param props BrushAnnotationProps component props
* @returns The DualBrushAnnotation component.
*/
export const DualBrushAnnotation: FC<BrushAnnotationProps> = ({ id, min, max, style }) => {
export const DualBrushAnnotation: FC<BrushAnnotationProps> = (props) => {
const { id, min, max, style } = props;
const { euiTheme } = useEuiTheme();
const { colors } = euiTheme;

Expand Down
Loading

0 comments on commit 3bac470

Please sign in to comment.