Skip to content

Commit

Permalink
Merge branch 'main' into fix-byref-top-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Nov 3, 2021
2 parents cdf7f3a + 0681348 commit b0cf955
Show file tree
Hide file tree
Showing 33 changed files with 847 additions and 810 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export interface Series {
terms_size?: string;
time_range_mode?: string;
trend_arrows?: number;
type?: string;
value_template?: string;
var_name?: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ interface AggProps extends HTMLAttributes<HTMLElement> {
siblings: Metric[];
uiRestrictions: TimeseriesUIRestrictions;
dragHandleProps: DragHandleProps;
onChange: (part: Partial<Series>) => void;
onModelChange: (part: Partial<Series>) => void;
onAdd: () => void;
onDelete: () => void;
}

export function Agg(props: AggProps) {
const { model, uiRestrictions, series, name, onChange, fields, siblings } = props;
const { model, uiRestrictions, series, name, onModelChange, fields, siblings } = props;

let Component = aggToComponent[model.type];

Expand Down Expand Up @@ -72,8 +72,8 @@ export function Agg(props: AggProps) {
const isKibanaIndexPattern = props.panel.use_kibana_indexes || indexPattern === '';

const onAggChange = useMemo(
() => seriesChangeHandler({ name, model: series, onChange }, siblings),
[name, onChange, siblings, series]
() => seriesChangeHandler({ name, model: series, onChange: onModelChange }, siblings),
[name, onModelChange, siblings, series]
);

useEffect(() => {
Expand All @@ -86,17 +86,25 @@ export function Agg(props: AggProps) {
);

if (isNumberFormatter && !isNumericMetric) {
onChange({ formatter: DATA_FORMATTERS.DEFAULT });
onModelChange({ formatter: DATA_FORMATTERS.DEFAULT });
}
// in case of string index pattern mode, change default formatter depending on metric type
// "number" formatter for numeric metric and "" as custom formatter for any other type
if (formatterType === DATA_FORMATTERS.DEFAULT && !isKibanaIndexPattern) {
onChange({
onModelChange({
formatter: isNumericMetric ? DATA_FORMATTERS.NUMBER : '',
});
}
}
}, [indexPattern, model, onChange, fields, series.formatter, isKibanaIndexPattern, siblings]);
}, [
indexPattern,
model,
onModelChange,
fields,
series.formatter,
isKibanaIndexPattern,
siblings,
]);

return (
<div className={props.className} style={style}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Aggs extends PureComponent<AggsProps> {
name={name}
model={row}
onAdd={() => handleAdd(this.props, newMetricAggFn)}
onChange={onChange}
onModelChange={onChange}
onDelete={() => handleDelete(this.props, row)}
panel={panel}
series={model}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const runTest = (aggType, name, test, additionalProps = {}) => {
<div>
<Agg
onAdd={jest.fn()}
onChange={jest.fn()}
onModelChange={jest.fn()}
onDelete={jest.fn()}
panel={panel}
fields={FIELDS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ import { IndexPatternSelect } from './lib/index_pattern_select';
import { YesNo } from './yes_no';
import { LastValueModePopover } from './last_value_mode_popover';
import { KBN_FIELD_TYPES } from '../../../../../data/public';
import { FormValidationContext } from '../contexts/form_validation_context';
import { isGteInterval, validateReInterval, isAutoInterval } from './lib/get_interval';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { PANEL_TYPES, TIME_RANGE_DATA_MODES, TIME_RANGE_MODE_KEY } from '../../../common/enums';
import { AUTO_INTERVAL } from '../../../common/constants';
import { isTimerangeModeEnabled } from '../lib/check_ui_restrictions';
import { VisDataContext } from '../contexts/vis_data_context';
import { PanelModelContext } from '../contexts/panel_model_context';
import { FormValidationContext } from '../contexts/form_validation_context';
import { getDataStart, getUISettings } from '../../services';
import { UI_SETTINGS } from '../../../../../data/common';
import { fetchIndexPattern } from '../../../common/index_patterns_utils';
Expand Down Expand Up @@ -76,12 +77,15 @@ export const IndexPattern = ({
const maxBarsName = `${prefix}max_bars`;
const dropBucketName = `${prefix}drop_last_bucket`;
const updateControlValidity = useContext(FormValidationContext);

const panelModel = useContext(PanelModelContext);
const uiRestrictions = get(useContext(VisDataContext), 'uiRestrictions');

const maxBarsUiSettings = config.get(UI_SETTINGS.HISTOGRAM_MAX_BARS);

const [fetchedIndex, setFetchedIndex] = useState(null);

const isTimeSeries = panelModel.type === PANEL_TYPES.TIMESERIES;

const handleMaxBarsChange = useCallback(
({ target }) => {
onChange({
Expand Down Expand Up @@ -126,7 +130,7 @@ export const IndexPattern = ({
const selectedTimeRangeOption = timeRangeOptions.find(
({ value }) => model[TIME_RANGE_MODE_KEY] === value
);
const isTimeSeries = model.type === PANEL_TYPES.TIMESERIES;

const isDataTimerangeModeInvalid =
!disabled &&
selectedTimeRangeOption &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ describe('convert series to datatables', () => {
],
split_mode: 'terms',
terms_field: 'Cancelled',
type: 'timeseries',
},
],
} as TimeseriesVisParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
import { Split } from '../../split';
import { createTextHandler } from '../../lib/create_text_handler';
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
import { PANEL_TYPES } from '../../../../../common/enums';

const TimeseriesSeriesUI = injectI18n(function (props) {
const {
Expand All @@ -45,7 +44,6 @@ const TimeseriesSeriesUI = injectI18n(function (props) {

const defaults = {
label: '',
type: PANEL_TYPES.TIMESERIES,
};
const model = { ...defaults, ...props.model };

Expand Down
3 changes: 1 addition & 2 deletions test/functional/apps/visualize/_tsvb_time_series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/115529
describe.skip('Elastic charts', () => {
describe('Elastic charts', () => {
beforeEach(async () => {
await visualBuilder.toggleNewChartsLibraryWithDebug(true);
await visualBuilder.clickPanelOptions('timeSeries');
Expand Down
10 changes: 8 additions & 2 deletions test/functional/page_objects/visual_builder_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,10 @@ export class VisualBuilderPageObject extends FtrService {
public async setBackgroundColor(colorHex: string): Promise<void> {
await this.clickColorPicker();
await this.checkColorPickerPopUpIsPresent();
await this.find.setValue('.euiColorPicker input', colorHex);
await this.testSubjects.setValue('euiColorPickerInput_top', colorHex, {
clearWithKeyboard: true,
typeCharByChar: true,
});
await this.clickColorPicker();
await this.visChart.waitForVisualizationRenderingStabilized();
}
Expand All @@ -677,7 +680,10 @@ export class VisualBuilderPageObject extends FtrService {
public async setColorPickerValue(colorHex: string, nth: number = 0): Promise<void> {
await this.clickColorPicker(nth);
await this.checkColorPickerPopUpIsPresent();
await this.find.setValue('.euiColorPicker input', colorHex);
await this.testSubjects.setValue('euiColorPickerInput_top', colorHex, {
clearWithKeyboard: true,
typeCharByChar: true,
});
await this.clickColorPicker(nth);
await this.visChart.waitForVisualizationRenderingStabilized();
}
Expand Down
10 changes: 9 additions & 1 deletion test/functional/page_objects/visualize_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@ export class VisualizePageObject extends FtrService {

public async openSavedVisualization(vizName: string) {
const dataTestSubj = `visListingTitleLink-${vizName.split(' ').join('-')}`;
await this.testSubjects.click(dataTestSubj, 20000);
await this.retry.try(async () => {
await this.testSubjects.click(dataTestSubj, 20000);
await this.notOnLandingPageOrFail();
});
await this.header.waitUntilLoadingHasFinished();
}

Expand All @@ -337,6 +340,11 @@ export class VisualizePageObject extends FtrService {
return await this.testSubjects.exists('visualizationLandingPage');
}

public async notOnLandingPageOrFail() {
this.log.debug(`VisualizePage.notOnLandingPageOrFail`);
return await this.testSubjects.missingOrFail('visualizationLandingPage');
}

public async gotoLandingPage() {
this.log.debug('VisualizePage.gotoLandingPage');
const onPage = await this.onLandingPage();
Expand Down
Loading

0 comments on commit b0cf955

Please sign in to comment.