Skip to content

Commit

Permalink
[Infra UI] Replace node details flyout with asset details flyout in t…
Browse files Browse the repository at this point in the history
…he inventory page (#166965)

Closes #161754 
Closes #166807

To make the testing and review easier I merged the old components
[cleanup PR](jennypavlova#5) into this
one

## Summary
This PR replaces the old node details view with the asset details flyout

### Old

![image](https://github.com/elastic/kibana/assets/14139027/ffbead5b-6f89-4397-b1a4-2ade74f7f227)

### New 

![image](https://github.com/elastic/kibana/assets/14139027/89fa52cd-a462-499e-900a-e26c70d17791)

### Testing

1. Go to inventory
2. Click on a host in the waffle map
3. Click on any **host**
- These changes are related only if a `Host` is selected- in the case of
a pod the view shouldn't be changed:

![image](https://github.com/elastic/kibana/assets/14139027/d1b90b65-1bbf-4fbf-a0c6-6b95afe6162e)

4. Check the new flyout functionality 



https://github.com/elastic/kibana/assets/14139027/3557821c-7964-466e-8514-84c2f81bc2fd

Note: the selected host should have a border like in the previous
version (this I fixed in the [last
commit](ff4753a))
so it should be added if there is a selected node:
<img width="1193" alt="image"
src="https://github.com/elastic/kibana/assets/14139027/6646fe47-6333-435a-a5ec-248339402224">

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
jennypavlova and kibanamachine authored Sep 28, 2023
1 parent 726f212 commit 549195c
Show file tree
Hide file tree
Showing 43 changed files with 676 additions and 2,728 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import { i18n } from '@kbn/i18n';
import { ContentTabIds, type Tab } from '../../../../../components/asset_details/types';
import { ContentTabIds, type Tab } from '../../components/asset_details/types';

export const orderedFlyoutTabs: Tab[] = [
export const commonFlyoutTabs: Tab[] = [
{
id: ContentTabIds.OVERVIEW,
name: i18n.translate('xpack.infra.nodeDetails.tabs.overview.title', {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* 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 createContainter from 'constate';
import { fold } from 'fp-ts/lib/Either';
import { identity } from 'fp-ts/lib/function';
import { pipe } from 'fp-ts/lib/pipeable';
import { useEffect } from 'react';
import { ProcessListAPIResponse, ProcessListAPIResponseRT } from '../../../../common/http_api';
import { throwErrors, createPlainError } from '../../../../common/runtime_types';
import { useHTTPRequest } from '../../../hooks/use_http_request';
import { useSourceContext } from '../../../containers/metrics_source';

export interface SortBy {
name: string;
isAscending: boolean;
}

export function useProcessList(
hostTerm: Record<string, string>,
to: number,
sortBy: SortBy,
searchFilter: object
) {
const { createDerivedIndexPattern } = useSourceContext();
const indexPattern = createDerivedIndexPattern().title;

const decodeResponse = (response: any) => {
return pipe(
ProcessListAPIResponseRT.decode(response),
fold(throwErrors(createPlainError), identity)
);
};

const parsedSortBy =
sortBy.name === 'runtimeLength'
? {
...sortBy,
name: 'startTime',
}
: sortBy;

const { error, loading, response, makeRequest } = useHTTPRequest<ProcessListAPIResponse>(
'/api/metrics/process_list',
'POST',
JSON.stringify({
hostTerm,
indexPattern,
to,
sortBy: parsedSortBy,
searchFilter,
}),
decodeResponse
);

useEffect(() => {
makeRequest();
}, [makeRequest]);

return {
error: (error && error.message) || null,
loading,
response,
makeRequest,
};
}

function useProcessListParams(props: { hostTerm: Record<string, string>; to: number }) {
const { hostTerm, to } = props;
const { createDerivedIndexPattern } = useSourceContext();
const indexPattern = createDerivedIndexPattern().title;
return { hostTerm, indexPattern, to };
}
const ProcessListContext = createContainter(useProcessListParams);
export const [ProcessListContextProvider, useProcessListContext] = ProcessListContext;
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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 { fold } from 'fp-ts/lib/Either';
import { identity } from 'fp-ts/lib/function';
import { pipe } from 'fp-ts/lib/pipeable';
import { useEffect, useState } from 'react';
import {
ProcessListAPIChartResponse,
ProcessListAPIChartResponseRT,
} from '../../../../common/http_api';
import { throwErrors, createPlainError } from '../../../../common/runtime_types';
import { useHTTPRequest } from '../../../hooks/use_http_request';
import { useProcessListContext } from './use_process_list';

export function useProcessListRowChart(command: string) {
const [inErrorState, setInErrorState] = useState(false);
const decodeResponse = (response: any) => {
return pipe(
ProcessListAPIChartResponseRT.decode(response),
fold(throwErrors(createPlainError), identity)
);
};
const { hostTerm, indexPattern, to } = useProcessListContext();

const { error, loading, response, makeRequest } = useHTTPRequest<ProcessListAPIChartResponse>(
'/api/metrics/process_list/chart',
'POST',
JSON.stringify({
hostTerm,
indexPattern,
to,
command,
}),
decodeResponse
);

useEffect(() => setInErrorState(true), [error]);
useEffect(() => setInErrorState(false), [loading]);

useEffect(() => {
makeRequest();
}, [makeRequest]);

return {
error: inErrorState,
loading,
response,
makeRequest,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { first, last } from 'lodash';
import moment from 'moment';
import React, { useMemo } from 'react';
import { useTimelineChartTheme } from '../../../../../../../utils/use_timeline_chart_theme';
import { Color } from '../../../../../../../../common/color_palette';
import { createFormatter } from '../../../../../../../../common/formatters';
import { MetricsExplorerAggregation } from '../../../../../../../../common/http_api';
import { calculateDomain } from '../../../../../metrics_explorer/components/helpers/calculate_domain';
import { MetricExplorerSeriesChart } from '../../../../../metrics_explorer/components/series_chart';
import { MetricsExplorerChartType } from '../../../../../metrics_explorer/hooks/use_metrics_explorer_options';
import { useProcessListRowChart } from '../../../../hooks/use_process_list_row_chart';
import { calculateDomain } from '../../../../pages/metrics/metrics_explorer/components/helpers/calculate_domain';
import { useProcessListRowChart } from '../../hooks/use_process_list_row_chart';
import { useTimelineChartTheme } from '../../../../utils/use_timeline_chart_theme';
import { MetricExplorerSeriesChart } from '../../../../pages/metrics/metrics_explorer/components/series_chart';
import { Color } from '../../../../../common/color_palette';
import { createFormatter } from '../../../../../common/formatters';
import { MetricsExplorerAggregation } from '../../../../../common/http_api';
import { Process } from './types';
import { MetricsExplorerChartType } from '../../../../../common/metrics_explorer_views/types';

interface Props {
command: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import { css } from '@emotion/react';
import { EuiTableRow } from '@elastic/eui';
import { EuiIcon } from '@elastic/eui';
import { FORMATTERS } from '../../../../../common/formatters';
import type { SortBy } from '../../../../pages/metrics/inventory_view/hooks/use_process_list';
import type { SortBy } from '../../hooks/use_process_list';
import type { Process } from './types';
import { ProcessRow } from '../../../../pages/metrics/inventory_view/components/node_details/tabs/processes/process_row';
import { ProcessRow } from './process_row';
import { StateBadge } from './state_badge';
import { STATE_ORDER } from './states';
import type { ProcessListAPIResponse } from '../../../../../common/http_api';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useSourceContext } from '../../../../../containers/metrics_source';
import { useUnifiedSearchContext } from '../../hooks/use_unified_search';
import type { HostNodeRow } from '../../hooks/use_hosts_table';
import { AssetDetails } from '../../../../../components/asset_details/asset_details';
import { orderedFlyoutTabs } from './tabs';
import { commonFlyoutTabs } from '../../../../../common/asset_details_config/asset_details_tabs';

export interface Props {
node: HostNodeRow;
Expand All @@ -31,7 +31,7 @@ export const FlyoutWrapper = ({ node: { name }, closeFlyout }: Props) => {
showActionsColumn: true,
},
}}
tabs={orderedFlyoutTabs}
tabs={commonFlyoutTabs}
links={['apmServices', 'nodeDetails']}
renderMode={{
mode: 'flyout',
Expand Down
Loading

0 comments on commit 549195c

Please sign in to comment.