Skip to content

Commit

Permalink
[Infra UI] Reorganize lens related types (#166285)
Browse files Browse the repository at this point in the history
part of: #165825

## Summary

While working on #166276 I noticed
that some lens types could be reorganized. This PR is for that.

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
crespocarlos and kibanamachine authored Sep 20, 2023
1 parent d1608f0 commit d0b759a
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@
*/

import { i18n } from '@kbn/i18n';
import type { TypedLensByValueInput } from '@kbn/lens-plugin/public';
import { hostLensFormulas } from '../../../formulas';
import type { MetricChartLayerParams } from '../../../../types';
import { METRICS_TOOLTIP } from '../../translations';

export interface KPIChartProps extends Pick<TypedLensByValueInput, 'id' | 'title' | 'overrides'> {
layers: MetricChartLayerParams;
toolTip: string;
}
import type { KPIChartProps } from '../../types';

export const hostKPICharts: KPIChartProps[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { logRate } from '../metric_charts/log';
import { memoryUsage, memoryUsageBreakdown } from '../metric_charts/memory';
import { rxTx } from '../metric_charts/network';
import type { XYConfig } from '../metric_charts/types';
import type { XYConfig } from '../../types';

export const hostMetricFlyoutCharts: XYConfig[] = [
cpuUsage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { i18n } from '@kbn/i18n';
import { kubernetesLensFormulas } from '../../../formulas';
import { XY_OVERRIDES } from '../../constants';
import type { XYConfig } from '../metric_charts/types';
import type { XYConfig } from '../../types';

export const kubernetesCharts: XYConfig[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { i18n } from '@kbn/i18n';
import { nginxLensFormulas } from '../../../formulas';
import { XY_OVERRIDES } from '../../constants';
import type { XYConfig } from '../metric_charts/types';
import type { XYConfig } from '../../types';

export const nginxStubstatusCharts: XYConfig[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
*/

import { hostMetricFlyoutCharts, hostMetricChartsFullPage } from './host/host_metric_charts';
import { hostKPICharts, KPIChartProps } from './host/host_kpi_charts';
import { hostKPICharts } from './host/host_kpi_charts';
import { nginxAccessCharts, nginxStubstatusCharts } from './host/nginx_charts';
import { kubernetesCharts } from './host/kubernetes_charts';

export { type KPIChartProps };
export const assetDetailsDashboards = {
host: { hostMetricFlyoutCharts, hostMetricChartsFullPage, hostKPICharts, keyField: 'host.name' },
nginx: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { i18n } from '@kbn/i18n';
import { hostLensFormulas } from '../../../formulas';
import { REFERENCE_LINE, XY_OVERRIDES } from '../../constants';
import type { XYConfig } from './types';
import type { XYConfig } from '../../types';

export const cpuUsage: XYConfig = {
id: 'cpuUsage',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { i18n } from '@kbn/i18n';
import { hostLensFormulas } from '../../../formulas';
import { XY_OVERRIDES } from '../../constants';
import type { XYConfig } from './types';
import type { XYConfig } from '../../types';

const TOP_VALUES_SIZE = 5;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { i18n } from '@kbn/i18n';
import { hostLensFormulas } from '../../../formulas';
import type { XYConfig } from './types';
import type { XYConfig } from '../../types';

export const logRate: XYConfig = {
id: 'logRate',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { i18n } from '@kbn/i18n';
import { hostLensFormulas } from '../../../formulas';
import { XY_OVERRIDES } from '../../constants';
import type { XYConfig } from './types';
import type { XYConfig } from '../../types';

export const memoryUsage: XYConfig = {
id: 'memoryUsage',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { i18n } from '@kbn/i18n';
import { hostLensFormulas } from '../../../formulas';
import { XY_OVERRIDES } from '../../constants';
import type { XYConfig } from './types';
import type { XYConfig } from '../../types';

export const rxTx: XYConfig = {
id: 'rxTx',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export { assetDetailsDashboards, type KPIChartProps } from './asset_details';
export { assetDetailsDashboards } from './asset_details';
export { hostsViewDashboards } from './hosts_view';
export { AVERAGE_SUBTITLE, METRICS_TOOLTIP } from './translations';
export { XY_MISSING_VALUE_DOTTED_LINE_CONFIG, KPI_CHART_HEIGHT } from './constants';
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 type { TypedLensByValueInput } from '@kbn/lens-plugin/public';
import type { DataViewOrigin } from '../../../../components/asset_details/types';
import type { MetricChartLayerParams, XYChartLayerParams } from '../../types';

type BaseProps = Pick<TypedLensByValueInput, 'id' | 'title' | 'overrides'>;

export interface AssetXYChartProps extends BaseProps {
layers: XYChartLayerParams[];
}

export interface XYConfig extends AssetXYChartProps {
dataViewOrigin: DataViewOrigin;
}

export interface KPIChartProps extends BaseProps {
layers: MetricChartLayerParams;
toolTip: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import React, { useCallback, useMemo } from 'react';
import type { XYVisualOptions } from '@kbn/lens-embeddable-utils';
import type { DataView } from '@kbn/data-views-plugin/public';
import { TimeRange } from '@kbn/es-query';
import type { XYConfig } from '../../../../../common/visualizations/lens/dashboards/asset_details/metric_charts/types';
import type { TimeRange } from '@kbn/es-query';
import { buildCombinedHostsFilter } from '../../../../../utils/filters/build';
import { BrushEndArgs, LensChart, OnFilterEvent } from '../../../../lens';
import { type BrushEndArgs, LensChart, type OnFilterEvent } from '../../../../lens';
import { METRIC_CHART_HEIGHT } from '../../../constants';
import { useDateRangeProviderContext } from '../../../hooks/use_date_range';
import { extractRangeFromChartFilterEvent } from './chart_utils';
import type { XYConfig } from '../../../../../common/visualizations';

export interface ChartProps extends XYConfig {
visualOptions?: XYVisualOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, { useMemo } from 'react';
import type { DataView } from '@kbn/data-views-plugin/public';
import { EuiFlexItem, EuiFlexGrid } from '@elastic/eui';
import type { TimeRange } from '@kbn/es-query';
import type { XYConfig } from '../../../../../common/visualizations/lens/dashboards/asset_details/metric_charts/types';
import type { XYConfig } from '../../../../../common/visualizations';
import { useMetadataStateProviderContext } from '../../../hooks/use_metadata_state';
import { Chart } from './chart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/
import React, { useMemo } from 'react';
import type { TypedLensByValueInput } from '@kbn/lens-plugin/public';
import type { XYVisualOptions } from '@kbn/lens-embeddable-utils';
import type { AssetXYChartProps } from '../../../../../../common/visualizations';
import { LensChart } from '../../../../../../components/lens';
import { useMetricsDataViewContext } from '../../../hooks/use_data_view';
import { useUnifiedSearchContext } from '../../../hooks/use_unified_search';
Expand All @@ -15,10 +15,8 @@ import { buildCombinedHostsFilter } from '../../../../../../utils/filters/build'
import { useHostsTableContext } from '../../../hooks/use_hosts_table';
import { useAfterLoadedState } from '../../../hooks/use_after_loaded_state';
import { METRIC_CHART_HEIGHT } from '../../../constants';
import { XYChartLayerParams } from '../../../../../../common/visualizations/types';

export interface ChartProps extends Pick<TypedLensByValueInput, 'id' | 'overrides' | 'title'> {
layers: XYChartLayerParams[];
export interface ChartProps extends AssetXYChartProps {
visualOptions?: XYVisualOptions;
}

Expand Down

0 comments on commit d0b759a

Please sign in to comment.