Skip to content

Commit

Permalink
Merge branch 'main' into implement/babel-register-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer authored Dec 22, 2022
2 parents 97be880 + 251bdce commit 129d0fc
Show file tree
Hide file tree
Showing 40 changed files with 421 additions and 309 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"@elastic/datemath": "5.0.3",
"@elastic/elasticsearch": "npm:@elastic/[email protected]",
"@elastic/ems-client": "8.3.3",
"@elastic/eui": "71.0.0",
"@elastic/eui": "72.0.0",
"@elastic/filesaver": "1.1.2",
"@elastic/node-crypto": "1.2.1",
"@elastic/numeral": "^2.5.1",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,9 @@ export const getEuiContextMapping = (): EuiTokensObject => {
'euiQuickSelect.valueLabel': i18n.translate('core.euiQuickSelect.valueLabel', {
defaultMessage: 'Time value',
}),
'euiQuickSelectPopover.buttonLabel': i18n.translate('core.euiQuickSelectPopover.buttonLabel', {
defaultMessage: 'Date quick select',
}),
'euiRecentlyUsed.legend': i18n.translate('core.euiRecentlyUsed.legend', {
defaultMessage: 'Recently used date ranges',
}),
Expand Down
2 changes: 1 addition & 1 deletion src/dev/license_checker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ export const LICENSE_OVERRIDES = {
'[email protected]': ['Eclipse Distribution License - v 1.0'], // cf. https://github.com/bjornharrtell/jsts
'@mapbox/[email protected]': ['MIT'], // license in readme https://github.com/tmcw/jsonlint
'@elastic/[email protected]': ['Elastic License 2.0'],
'@elastic/eui@71.0.0': ['SSPL-1.0 OR Elastic License 2.0'],
'@elastic/eui@72.0.0': ['SSPL-1.0 OR Elastic License 2.0'],
'[email protected]': ['CC-BY-4.0'], // retired ODC‑By license https://github.com/mattcg/language-subtag-registry
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React, { ComponentType, useState } from 'react';
import classNames from 'classnames';
import { useIsWithinBreakpoints } from '@elastic/eui';
import { EuiPageSideBarProps } from '@elastic/eui/src/components/page/page_side_bar';
import { EuiPageSideBarProps_Deprecated as EuiPageSideBarProps } from '@elastic/eui/src/components/page/page_side_bar';
import { KibanaPageTemplateSolutionNav, KibanaPageTemplateSolutionNavProps } from './solution_nav';
import { KibanaPageTemplateProps } from '.';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function selectDataViewPickerOption(instance: ShallowWrapper, selectedLabel: str
? { ...option, checked: 'on' }
: { ...option, checked: undefined }
);
return getDataViewPickerList(instance).prop('onChange')!(options, event);
const selectedOption = { label: selectedLabel };
return getDataViewPickerList(instance).prop('onChange')!(options, event, selectedOption);
}

describe('DataView list component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ function selectTextLanguagePickerOption(instance: ShallowWrapper, selectedLabel:
? { ...option, checked: 'on' }
: { ...option, checked: undefined }
);
return getTextLanguagesPickerList(instance).prop('onChange')!(options, event);
const selectedOption = { label: selectedLabel };
return getTextLanguagesPickerList(instance).prop('onChange')!(options, event, selectedOption);
}

describe('Text based languages list component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { dataVisualizerRefresh$ } from '../../../index_data_visualizer/services/
import { useUrlState } from '../../util/url_state';

const DEFAULT_REFRESH_INTERVAL_MS = 5000;
const DATE_PICKER_MAX_WIDTH = 540;

interface TimePickerQuickRange {
from: string;
Expand Down Expand Up @@ -69,10 +70,11 @@ function updateLastRefresh(timeRange?: OnRefreshProps) {
}

// FIXME: Consolidate this component with ML and AIOps's component
export const DatePickerWrapper: FC<{ isAutoRefreshOnly?: boolean; showRefresh?: boolean }> = ({
isAutoRefreshOnly,
showRefresh,
}) => {
export const DatePickerWrapper: FC<{
isAutoRefreshOnly?: boolean;
showRefresh?: boolean;
compact?: boolean;
}> = ({ isAutoRefreshOnly, showRefresh, compact = false }) => {
const {
services,
notifications: { toasts },
Expand Down Expand Up @@ -242,9 +244,18 @@ export const DatePickerWrapper: FC<{ isAutoRefreshOnly?: boolean; showRefresh?:
<EuiFlexGroup
gutterSize="s"
alignItems="center"
className="mlNavigationMenu__datePickerWrapper"
data-test-subj="mlNavigationMenuDatePickerWrapper"
>
<EuiFlexItem grow={false}>
<EuiFlexItem
grow={false}
css={
compact
? {
maxWidth: DATE_PICKER_MAX_WIDTH,
}
: null
}
>
<EuiSuperDatePicker
start={time.from}
end={time.to}
Expand All @@ -257,6 +268,7 @@ export const DatePickerWrapper: FC<{ isAutoRefreshOnly?: boolean; showRefresh?:
recentlyUsedRanges={recentlyUsedRanges}
dateFormat={dateFormat}
commonlyUsedRanges={commonlyUsedRanges}
updateButtonProps={{ iconOnly: compact }}
/>
</EuiFlexItem>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { FC, useCallback, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import {
Axis,
BarSeries,
HistogramBarSeries,
BrushEndListener,
Chart,
ElementClickListener,
Expand All @@ -22,7 +22,7 @@ import {
import moment from 'moment';
import { IUiSettingsClient } from '@kbn/core/public';
import { MULTILAYER_TIME_AXIS_STYLE } from '@kbn/charts-plugin/common';
import { EuiLoadingSpinner, EuiFlexItem } from '@elastic/eui';
import { EuiFlexGroup, EuiLoadingSpinner, EuiFlexItem } from '@elastic/eui';
import { useDataVisualizerKibana } from '../../../../kibana_context';

export interface DocumentCountChartPoint {
Expand Down Expand Up @@ -137,8 +137,9 @@ export const DocumentCountChart: FC<Props> = ({
const timeZone = getTimezone(uiSettings);

return (
<div
style={{ width: width ?? '100%', height: 120, display: 'flex', alignItems: 'center' }}
<EuiFlexGroup
alignItems="center"
css={{ width: width ?? '100%' }}
data-test-subj="dataVisualizerDocumentCountChart"
>
{loading ? (
Expand All @@ -147,6 +148,7 @@ export const DocumentCountChart: FC<Props> = ({
<Chart
size={{
width: '100%',
height: 120,
}}
>
<Settings
Expand All @@ -161,11 +163,13 @@ export const DocumentCountChart: FC<Props> = ({
position={Position.Bottom}
showOverlappingTicks={true}
tickFormat={(value) => xAxisFormatter.convert(value)}
// temporary fix to reduce horizontal chart margin until fixed in Elastic Charts itself
labelFormat={useLegacyTimeAxis ? undefined : () => ''}
timeAxisLayerCount={useLegacyTimeAxis ? 0 : 2}
style={useLegacyTimeAxis ? {} : MULTILAYER_TIME_AXIS_STYLE}
/>
<Axis id="left" position={Position.Left} />
<BarSeries
<HistogramBarSeries
id={SPEC_ID}
name={seriesName}
xScaleType={ScaleType.Time}
Expand All @@ -174,9 +178,10 @@ export const DocumentCountChart: FC<Props> = ({
yAccessors={['value']}
data={adjustedChartPoints}
timeZone={timeZone}
yNice
/>
</Chart>
)}
</div>
</EuiFlexGroup>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const FieldCountPanel: FC<Props> = ({
data-test-subj="dataVisualizerFieldCountPanel"
responsive={false}
className="dvFieldCount__panel"
wrap
>
<TotalFieldsCount fieldsCountStats={fieldsCountStats} />
<MetricFieldsCount metricsStats={metricsStats} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const FieldsStatsGrid: FC<Props> = ({ results }) => {
gutterSize="xs"
style={{ marginLeft: 4 }}
data-test-subj="dataVisualizerFieldCountPanel"
responsive={true}
>
<TotalFieldsCount fieldsCountStats={fieldsCountStats} />
<MetricFieldsCount metricsStats={metricsStats} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
EuiPanel,
EuiLink,
} from '@elastic/eui';
import { useCurrentEuiTheme } from '../../hooks/use_current_eui_theme';

export interface LinkCardProps {
icon: IconType;
Expand All @@ -41,6 +42,8 @@ export const LinkCard: FC<LinkCardProps> = ({
isDisabled,
'data-test-subj': dataTestSubj,
}) => {
const euiTheme = useCurrentEuiTheme();

const linkHrefAndOnClickProps = {
...(href ? { href } : {}),
...(onClick ? { onClick } : {}),
Expand All @@ -62,10 +65,10 @@ export const LinkCard: FC<LinkCardProps> = ({
color="subdued"
{...linkHrefAndOnClickProps}
>
<EuiFlexGroup gutterSize="l" responsive={true}>
<EuiFlexItem grow={false} style={{ paddingTop: '8px' }}>
<EuiFlexGroup gutterSize="s" responsive={true}>
<EuiFlexItem grow={false} css={{ paddingTop: euiTheme.euiSizeXS }}>
{typeof icon === 'string' ? (
<EuiIcon size="xl" type={icon} aria-label={iconAreaLabel} />
<EuiIcon size="m" type={icon} aria-label={iconAreaLabel} />
) : (
icon
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import {
EuiPopoverTitle,
EuiSpacer,
} from '@elastic/eui';
import React, { FC, ReactNode, useEffect, useMemo, useState } from 'react';
import React, { FC, ReactNode, useEffect, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { euiDarkVars as euiThemeDark, euiLightVars as euiThemeLight } from '@kbn/ui-theme';
import { useDataVisualizerKibana } from '../../../kibana_context';
import type { SerializedStyles } from '@emotion/react';
import { css } from '@emotion/react';
import { useCurrentEuiTheme } from '../../hooks/use_current_eui_theme';

export interface Option {
name?: string | ReactNode;
Expand All @@ -27,6 +28,8 @@ export interface Option {
disabled?: boolean;
}

const SELECT_PICKER_HEIGHT = '250px';

const NoFilterItems = () => {
return (
<div className="euiFilterSelect__note">
Expand All @@ -44,23 +47,19 @@ const NoFilterItems = () => {
);
};

export function useCurrentEuiTheme() {
const { services } = useDataVisualizerKibana();
const uiSettings = services.uiSettings;
return useMemo(
() => (uiSettings.get('theme:darkMode') ? euiThemeDark : euiThemeLight),
[uiSettings]
);
interface MultiSelectPickerStyles {
filterGroup?: SerializedStyles;
filterItemContainer?: SerializedStyles;
}

export const MultiSelectPicker: FC<{
options: Option[];
onChange?: (items: string[]) => void;
title?: string;
checkedOptions: string[];
dataTestSubj: string;
postfix?: React.ReactElement;
}> = ({ options, onChange, title, checkedOptions, dataTestSubj, postfix }) => {
cssStyles?: MultiSelectPickerStyles;
}> = ({ options, onChange, title, checkedOptions, dataTestSubj, postfix, cssStyles }) => {
const euiTheme = useCurrentEuiTheme();

const [items, setItems] = useState<Option[]>(options);
Expand Down Expand Up @@ -114,7 +113,7 @@ export const MultiSelectPicker: FC<{
);

return (
<EuiFilterGroup data-test-subj={dataTestSubj} style={{ marginLeft: 8 }}>
<EuiFilterGroup data-test-subj={dataTestSubj} css={cssStyles?.filterGroup}>
<EuiPopover
ownFocus
data-test-subj={`${dataTestSubj}-popover`}
Expand All @@ -130,7 +129,15 @@ export const MultiSelectPicker: FC<{
data-test-subj={`${dataTestSubj}-searchInput`}
/>
</EuiPopoverTitle>
<div style={{ maxHeight: 250, overflow: 'auto' }}>
<div
css={
cssStyles?.filterItemContainer ??
css`
max-height: ${SELECT_PICKER_HEIGHT};
overflow: auto;
`
}
>
{Array.isArray(items) && items.length > 0 ? (
items.map((item, index) => {
const checked =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

.dvFieldCount__item {
max-width: 300px;
min-width: 300px;
min-width: 200px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export const DataVisualizerTable = <T extends DataVisualizerTableItem>({
);
const [showDistributions, setShowDistributions] = useState<boolean>(showPreviewByDefault ?? true);
const [dimensions, setDimensions] = useState(calculateTableColumnsDimensions());
const [tableWidth, setTableWidth] = useState<number>(1400);

const toggleExpandAll = useCallback(
(shouldExpandAll: boolean) => {
Expand All @@ -109,10 +108,9 @@ export const DataVisualizerTable = <T extends DataVisualizerTableItem>({
throttle((e: { width: number; height: number }) => {
// When window or table is resized,
// update the column widths and other settings accordingly
setTableWidth(e.width);
setDimensions(calculateTableColumnsDimensions(e.width));
}, 500),
[tableWidth]
[]
);

const toggleShowDistribution = useCallback(() => {
Expand All @@ -138,6 +136,8 @@ export const DataVisualizerTable = <T extends DataVisualizerTableItem>({
const columns = useMemo(() => {
const expanderColumn: EuiTableComputedColumnType<DataVisualizerTableItem> = {
name:
// EUI will automatically show an expander button when table is mobile view (where width <700)
// so we need to not render any addition button
dimensions.breakPoint !== 'small' ? (
<EuiButtonIcon
data-test-subj={`dataVisualizerToggleDetailsForAllRowsButton ${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
*/

import d3 from 'd3';
import { useMemo } from 'react';
import { euiLightVars as euiThemeLight, euiDarkVars as euiThemeDark } from '@kbn/ui-theme';

import { i18n } from '@kbn/i18n';

import { useDataVisualizerKibana } from '../../../../kibana_context';
import { useCurrentEuiTheme } from '../../../hooks/use_current_eui_theme';

/**
* Custom color scale factory that takes the amount of feature influencers
Expand Down Expand Up @@ -159,7 +158,7 @@ export const useColorRange = (
colorRangeScale = COLOR_RANGE_SCALE.LINEAR,
featureCount = 1
) => {
const { euiTheme } = useCurrentEuiTheme();
const euiTheme = useCurrentEuiTheme();

const colorRanges: Record<COLOR_RANGE, string[]> = {
[COLOR_RANGE.BLUE]: [
Expand Down Expand Up @@ -197,13 +196,3 @@ export const useColorRange = (
};

export type EuiThemeType = typeof euiThemeLight | typeof euiThemeDark;

export function useCurrentEuiTheme() {
const {
services: { uiSettings },
} = useDataVisualizerKibana();
return useMemo(
() => ({ euiTheme: uiSettings.get('theme:darkMode') ? euiThemeDark : euiThemeLight }),
[uiSettings]
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import type { PartialTheme } from '@elastic/charts';
import { useMemo } from 'react';
import { useCurrentEuiTheme } from './use_color_range';
import { useCurrentEuiTheme } from '../../../hooks/use_current_eui_theme';
export const useDataVizChartTheme = (): PartialTheme => {
const { euiTheme } = useCurrentEuiTheme();
const euiTheme = useCurrentEuiTheme();
const chartTheme = useMemo<PartialTheme>(() => {
const AREA_SERIES_COLOR = euiTheme.euiColorVis0;
return {
Expand Down
Loading

0 comments on commit 129d0fc

Please sign in to comment.