Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Inventory][ECO] Use ControlGroupRenderer to filter by entity types #199174

Merged
merged 27 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
568cc99
lots of changes
cauemarcondes Nov 6, 2024
4a488cf
more changes
cauemarcondes Nov 6, 2024
8d604d7
filtering on grid
cauemarcondes Nov 7, 2024
96bf645
updating
cauemarcondes Nov 7, 2024
5a89904
refactoring
cauemarcondes Nov 7, 2024
05519cd
fixing tests
cauemarcondes Nov 7, 2024
f358bf1
fixing ci
cauemarcondes Nov 7, 2024
d301233
removing kuery from alerts search
cauemarcondes Nov 7, 2024
5ea6ad3
Merge branch 'main' into inventory-control-group-2
cauemarcondes Nov 7, 2024
22ecb88
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 7, 2024
9118ccd
fixing ci
cauemarcondes Nov 7, 2024
d27b087
Merge branch 'inventory-control-group-2' of github.com:cauemarcondes/…
cauemarcondes Nov 7, 2024
70b762e
Merge branch 'main' into inventory-control-group-2
cauemarcondes Nov 8, 2024
f29d810
fixing TS
cauemarcondes Nov 8, 2024
aeff7ac
addressing pr comments
cauemarcondes Nov 8, 2024
5b412e9
feedback
cauemarcondes Nov 8, 2024
2eab8b1
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 8, 2024
47c8755
reverting
cauemarcondes Nov 8, 2024
0841578
Merge branch 'inventory-control-group-2' of github.com:cauemarcondes/…
cauemarcondes Nov 8, 2024
94f4e5c
unused import
cauemarcondes Nov 8, 2024
740845b
removing useless code
cauemarcondes Nov 8, 2024
61ff739
fixing i18n
cauemarcondes Nov 8, 2024
df8eefc
Merge branch 'main' of github.com:elastic/kibana into inventory-contr…
cauemarcondes Nov 11, 2024
405f7e9
Addressing PR comments
cauemarcondes Nov 11, 2024
ce078af
updating limits
cauemarcondes Nov 11, 2024
c94adec
unskipping test
cauemarcondes Nov 11, 2024
827f89e
pr comments
cauemarcondes Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
ALERT_STATUS_RECOVERED,
ALERT_STATUS_UNTRACKED,
} from '@kbn/rule-data-utils';
import { useUrlState } from '@kbn/observability-shared-plugin/public';
import { ContentTabIds } from '../types';
import { useUrlState } from '../../../hooks/use_url_state';
import { ASSET_DETAILS_URL_STATE_KEY } from '../constants';
import { ALERT_STATUS_ALL } from '../../shared/alerts/constants';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { useUiTracker, useUrlState } from '@kbn/observability-shared-plugin/public';
import {
MutationContext,
SavedViewResult,
Expand All @@ -23,7 +23,6 @@ import {
} from '../../common/http_api/latest';
import type { InventoryView } from '../../common/inventory_views';
import { useKibanaContextForPlugin } from './use_kibana';
import { useUrlState } from './use_url_state';
import { useSavedViewsNotifier } from './use_saved_views_notifier';
import { useSourceContext } from '../containers/metrics_source';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
import { useUiTracker, useUrlState } from '@kbn/observability-shared-plugin/public';

import {
MutationContext,
Expand All @@ -23,7 +23,6 @@ import {
UpdateMetricsExplorerViewAttributesRequestPayload,
} from '../../common/http_api/latest';
import { MetricsExplorerView } from '../../common/metrics_explorer_views';
import { useUrlState } from './use_url_state';
import { useSavedViewsNotifier } from './use_saved_views_notifier';
import { useSourceContext } from '../containers/metrics_source';
import { useKibanaContextForPlugin } from './use_kibana';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import { pipe } from 'fp-ts/lib/pipeable';
import * as rt from 'io-ts';
import { useUrlState } from '../../../hooks/use_url_state';
import { useUrlState } from '@kbn/observability-shared-plugin/public';
import {
useKibanaTimefilterTime,
useSyncKibanaTimeFilterTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import moment from 'moment';
import * as rt from 'io-ts';
import type { TimeRange as KibanaTimeRange } from '@kbn/es-query';
import { decodeOrThrow } from '@kbn/io-ts-utils';
import { useUrlState } from '@kbn/observability-shared-plugin/public';
import { TimeRange } from '../../../../common/time/time_range';
import { useUrlState } from '../../../hooks/use_url_state';
import {
useKibanaTimefilterTime,
useSyncKibanaTimeFilterTime,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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 { ControlPanels } from '@kbn/observability-shared-plugin/public';

export const availableControlsPanels = {
HOST_OS_NAME: 'host.os.name',
CLOUD_PROVIDER: 'cloud.provider',
SERVICE_NAME: 'service.name',
};

export const controlPanelConfigs: ControlPanels = {
[availableControlsPanels.HOST_OS_NAME]: {
order: 0,
width: 'medium',
grow: false,
type: 'optionsListControl',
fieldName: availableControlsPanels.HOST_OS_NAME,
title: 'Operating System',
},
[availableControlsPanels.CLOUD_PROVIDER]: {
order: 1,
width: 'medium',
grow: false,
type: 'optionsListControl',
fieldName: availableControlsPanels.CLOUD_PROVIDER,
title: 'Cloud Provider',
},
[availableControlsPanels.SERVICE_NAME]: {
order: 2,
width: 'medium',
grow: false,
type: 'optionsListControl',
fieldName: availableControlsPanels.SERVICE_NAME,
title: 'Service Name',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
* 2.0.
*/

import React, { useCallback, useEffect, useRef } from 'react';
import {
ControlGroupRenderer,
ControlGroupRendererApi,
DataControlApi,
ControlGroupRuntimeState,
DataControlApi,
} from '@kbn/controls-plugin/public';
import type { Filter, Query, TimeRange } from '@kbn/es-query';
import { DataView } from '@kbn/data-views-plugin/public';
import { Subscription } from 'rxjs';
import type { Filter, Query, TimeRange } from '@kbn/es-query';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { useControlPanels } from '../../hooks/use_control_panels_url_state';
import { useControlPanels } from '@kbn/observability-shared-plugin/public';
import React, { useCallback, useEffect, useRef } from 'react';
import { Subscription } from 'rxjs';
import { controlPanelConfigs } from './control_panels_config';
import { ControlTitle } from './controls_title';

interface Props {
Expand All @@ -34,7 +35,7 @@ export const ControlsContent: React.FC<Props> = ({
timeRange,
onFiltersChange,
}) => {
const [controlPanels, setControlPanels] = useControlPanels(dataView);
const [controlPanels, setControlPanels] = useControlPanels(controlPanelConfigs, dataView);
const subscriptions = useRef<Subscription>(new Subscription());

const getInitialInput = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import React from 'react';
import { EuiFormLabel, EuiText, EuiLink, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { availableControlsPanels } from '../../hooks/use_control_panels_url_state';
import { Popover } from '../common/popover';
import { availableControlsPanels } from './control_panels_config';

const helpMessages = {
[availableControlsPanels.SERVICE_NAME]: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { constant, identity } from 'fp-ts/lib/function';
import useLocalStorage from 'react-use/lib/useLocalStorage';
import deepEqual from 'fast-deep-equal';
import { useReducer } from 'react';
import { useUrlState } from '../../../../hooks/use_url_state';
import { useUrlState } from '@kbn/observability-shared-plugin/public';
import { DEFAULT_PAGE_SIZE, LOCAL_STORAGE_PAGE_SIZE_KEY } from '../constants';

export const GET_DEFAULT_TABLE_PROPERTIES: TableProperties = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as rt from 'io-ts';
import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import { useUrlState } from '../../../../hooks/use_url_state';
import { useUrlState } from '@kbn/observability-shared-plugin/public';

const DEFAULT_QUERY = {
language: 'kuery',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as rt from 'io-ts';
import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import { useUrlState } from '../../../../hooks/use_url_state';
import { useUrlState } from '@kbn/observability-shared-plugin/public';

const TAB_ID_URL_STATE_KEY = 'tabId';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { constant, identity } from 'fp-ts/lib/function';
import { enumeration } from '@kbn/securitysolution-io-ts-types';
import { FilterStateStore } from '@kbn/es-query';
import useLocalStorage from 'react-use/lib/useLocalStorage';
import { useUrlState } from '../../../../hooks/use_url_state';
import { useUrlState } from '@kbn/observability-shared-plugin/public';
import {
useKibanaTimefilterTime,
useSyncKibanaTimeFilterTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as rt from 'io-ts';
import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import { useUrlState } from '../../../../hooks/use_url_state';
import { useUrlState } from '@kbn/observability-shared-plugin/public';

export const GET_DEFAULT_PROPERTIES: AssetDetailsFlyoutProperties = {
detailsItemId: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import createContainter from 'constate';
import { useUrlState } from '@kbn/observability-shared-plugin/public';
import {
type InventoryFiltersState,
inventoryFiltersStateRT,
} from '../../../../../common/inventory_views';
import { useAlertPrefillContext } from '../../../../alerting/use_alert_prefill';
import { useUrlState } from '../../../../hooks/use_url_state';
import { useMetricsDataViewContext } from '../../../../containers/metrics_source';
import { convertKueryToElasticSearchQuery } from '../../../../utils/kuery';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import createContainer from 'constate';
import type { InventoryItemType } from '@kbn/metrics-data-access-plugin/common';
import { useUrlState } from '@kbn/observability-shared-plugin/public';
import { InventoryViewOptions } from '../../../../../common/inventory_views/types';
import {
type InventoryLegendOptions,
Expand All @@ -24,7 +25,6 @@ import type {
SnapshotGroupBy,
SnapshotCustomMetricInput,
} from '../../../../../common/http_api/snapshot_api';
import { useUrlState } from '../../../../hooks/use_url_state';

export const DEFAULT_LEGEND: WaffleLegendOptions = {
palette: 'cool',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { fold } from 'fp-ts/lib/Either';
import DateMath from '@kbn/datemath';
import { constant, identity } from 'fp-ts/lib/function';
import createContainer from 'constate';
import { useUrlState } from '../../../../hooks/use_url_state';
import { useUrlState } from '@kbn/observability-shared-plugin/public';
import { useKibanaTimefilterTime } from '../../../../hooks/use_kibana_timefilter_time';
export const DEFAULT_WAFFLE_TIME_STATE: WaffleTimeState = {
currentTime: Date.now(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import * as rt from 'io-ts';
import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import { useUrlState } from '@kbn/observability-shared-plugin/public';
import { replaceStateKeyInQueryString } from '../../../../../common/url_state_storage_service';
import { useUrlState } from '../../../../hooks/use_url_state';

const parseRange = (range: MetricsTimeInput) => {
const parsedFrom = dateMath.parse(range.from.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,6 @@ export const ENTITIES_LATEST_ALIAS = entitiesAliasPattern({
dataset: ENTITY_LATEST,
});

const entityArrayRt = t.array(t.string);
export const entityTypesRt = new t.Type<string[], string, unknown>(
'entityTypesRt',
entityArrayRt.is,
(input, context) => {
if (typeof input === 'string') {
const arr = input.split(',');
const validation = entityArrayRt.decode(arr);
if (isRight(validation)) {
return t.success(validation.right);
}
} else if (Array.isArray(input)) {
const validation = entityArrayRt.decode(input);
if (isRight(validation)) {
return t.success(validation.right);
}
}

return t.failure(input, context);
},
(arr) => arr.join()
);

export interface Entity {
[ENTITY_LAST_SEEN]: string;
[ENTITY_ID]: string;
Expand All @@ -115,5 +92,5 @@ export interface Entity {
export type EntityGroup = {
count: number;
} & {
[key: string]: any;
[key: string]: string;
};

This file was deleted.

Loading