[Infra UI] Reorganize lens related types (#166285)

part of: https://github.com/elastic/kibana/issues/165825

## Summary

While working on https://github.com/elastic/kibana/pull/166276 I noticed
that some lens types could be reorganized. This PR is for that.

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Carlos Crespo 2023-09-20 17:12:52 +02:00 committed by GitHub
parent d1608f070d
commit d0b759a47a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 41 additions and 40 deletions

View file

@ -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[] = [
{

View file

@ -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,

View file

@ -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[] = [
{

View file

@ -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[] = [
{

View file

@ -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: {

View file

@ -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',

View file

@ -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;

View file

@ -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',

View file

@ -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',

View file

@ -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',

View file

@ -1,14 +0,0 @@
/*
* 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 { XYChartLayerParams } from '../../../../types';
export type XYConfig = Pick<TypedLensByValueInput, 'id' | 'title' | 'overrides'> & {
dataViewOrigin: DataViewOrigin;
layers: XYChartLayerParams[];
};

View file

@ -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';

View file

@ -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;
}

View file

@ -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;

View file

@ -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';

View file

@ -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';
@ -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;
}