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

[FEATURE] MDS support in Integrations for observability plugin #2051

Merged
merged 21 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
"enabledWorkflows": Array [],
}
}
handleSelectedDataSourceChange={[Function]}
integration={
Object {
"assets": Array [],
Expand Down Expand Up @@ -255,6 +256,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
"enabledWorkflows": Array [],
}
}
handleSelectedDataSourceChange={[Function]}
integration={
Object {
"assets": Array [],
Expand Down Expand Up @@ -935,6 +937,8 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
"enabledWorkflows": Array [],
}
}
dataSourceMDSId=""
dataSourceMDSLabel=""
integration={
Object {
"assets": Array [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { waitFor } from '@testing-library/react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { waitFor } from '@testing-library/react';
import { AddedIntegrationsTable } from '../added_integration_table';
import { addedIntegrationData } from './testing_constants';
import React from 'react';
import { AddedIntegrationsTable } from '../added_integration_table';
import { addedIntegrationData, addedIntegrationDataWithoutMDS } from './testing_constants';

describe('Added Integration Table View Test', () => {
configure({ adapter: new Adapter() });
Expand All @@ -20,4 +20,12 @@ describe('Added Integration Table View Test', () => {
expect(wrapper).toMatchSnapshot();
});
});

it('Renders added integration table view using dummy data when MDS is disabled', async () => {
const wrapper = mount(<AddedIntegrationsTable {...addedIntegrationDataWithoutMDS} />);

await waitFor(() => {
expect(wrapper).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,90 @@ export const addedIntegrationData: AddedIntegrationsTableProps = {
loading: false,
};

export const addedIntegrationDataWithoutMDS: AddedIntegrationsTableProps = {
setData: () => {},
http: httpClientMock,
data: {
hits: [
{
name: 'nginx',
templateName: 'nginx',
dataSource: { sourceType: 'logs', dataset: 'nginx', namespace: 'prod' },
creationDate: '2023-06-15T16:28:36.370Z',
status: 'active',
addedBy: 'admin',
assets: [
{
assetType: 'index-pattern',
assetId: '3fc41705-8a23-49f4-926c-2819e0d7306d',
status: 'available',
isDefaultAsset: false,
description: 'ss4o_logs-nginx-prod',
},
{
assetType: 'search',
assetId: 'a0415ddd-047d-4c02-8769-d14bfb70f525',
status: 'available',
isDefaultAsset: false,
description: '[NGINX Core Logs 1.0] Nginx Access Logs',
},
{
assetType: 'visualization',
assetId: 'a17cd453-fb2f-4c24-81db-aedfc8682829',
status: 'available',
isDefaultAsset: false,
description: '[NGINX Core Logs 1.0] Response codes over time',
},
{
assetType: 'search',
assetId: '3e47dfed-d9ff-4c1b-b425-04ffc8ed3fa9',
status: 'available',
isDefaultAsset: false,
description: '[NGINX Core Logs 1.0] Nginx Error Logs',
},
{
assetType: 'visualization',
assetId: '641c2a03-eead-4900-94ee-e12d2fef8383',
status: 'available',
isDefaultAsset: false,
description: '[NGINX Core Logs 1.0] Errors over time',
},
{
assetType: 'visualization',
assetId: 'ce61594d-8307-4358-9b7e-71101b3ed722',
status: 'available',
isDefaultAsset: false,
description: 'Data Volume',
},
{
assetType: 'visualization',
assetId: '452bd6e3-3b50-407f-88f2-c35a29c56051',
status: 'available',
isDefaultAsset: false,
description: 'Top Paths',
},
{
assetType: 'visualization',
assetId: '14a1ddab-08c1-4aba-ba3b-88bae36f7e50',
status: 'available',
isDefaultAsset: false,
description: 'Requests per Minute',
},
{
assetType: 'dashboard',
assetId: '179bad58-c840-4c6c-9fd8-1667c14bd03a',
status: 'available',
isDefaultAsset: true,
description: '[NGINX Core Logs 1.0] Overview',
},
],
id: 'ad7e6e30-0b99-11ee-b27c-c9863222e9bf',
},
],
},
loading: false,
};

export const testIntegrationInstanceData = {
data: {
id: 'ad7e6e30-0b99-11ee-b27c-c9863222e9bf',
Expand Down
35 changes: 31 additions & 4 deletions public/components/integrations/components/added_integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ import {
EuiTableFieldDataColumnType,
EuiText,
} from '@elastic/eui';
import React, { useEffect, useState } from 'react';
import truncate from 'lodash/truncate';
import { PanelTitle } from '../../trace_analytics/components/common/helper_functions';
import React, { useEffect, useState } from 'react';
import { DataSourceViewConfig } from '../../../../../../src/plugins/data_source_management/public';
import { ASSET_FILTER_OPTIONS } from '../../../../common/constants/integrations';
import { INTEGRATIONS_BASE } from '../../../../common/constants/shared';
import { dataSourceFilterFn } from '../../../../common/utils/shared';
import { useToast } from '../../../../public/components/common/toast';
import { DeleteModal } from '../../common/helpers/delete_modal';
import { PanelTitle } from '../../trace_analytics/components/common/helper_functions';
import { AddedIntegrationProps } from './integration_types';
import { useToast } from '../../../../public/components/common/toast';

export const IntegrationHealthBadge = ({ status }: { status?: string }) => {
switch (status) {
Expand All @@ -45,7 +47,14 @@ export const IntegrationHealthBadge = ({ status }: { status?: string }) => {
};

export function AddedIntegration(props: AddedIntegrationProps) {
const { http, integrationInstanceId, chrome } = props;
const {
http,
integrationInstanceId,
chrome,
dataSourceEnabled,
dataSourceManagement,
setActionMenu,
} = props;

const { setToast } = useToast();

Expand Down Expand Up @@ -74,6 +83,8 @@ export function AddedIntegration(props: AddedIntegrationProps) {
const [isModalVisible, setIsModalVisible] = useState(false);
const [modalLayout, setModalLayout] = useState(<EuiOverlayMask />);

const DataSourceMenu = dataSourceManagement?.ui?.getDataSourceMenu<DataSourceViewConfig>();

const activateDeleteModal = (integrationName?: string) => {
setModalLayout(
<DeleteModal
Expand Down Expand Up @@ -118,6 +129,22 @@ export function AddedIntegration(props: AddedIntegrationProps) {

return (
<EuiPageHeader style={{ justifyContent: 'spaceBetween' }}>
{dataSourceEnabled && (
<DataSourceMenu
setMenuMountPoint={setActionMenu}
componentType={'DataSourceView'}
componentConfig={{
activeOption: [
{
id: data?.references?.[0]?.id,
label: data?.references?.[0]?.name,
},
],
fullWidth: true,
dataSourceFilter: dataSourceFilterFn,
}}
/>
)}
<EuiSpacer size="m" />
<EuiPageHeaderSection style={{ width: '100%', justifyContent: 'space-between' }}>
<EuiPageContentHeaderSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
data: AddedIntegrationsList;
setData: React.Dispatch<React.SetStateAction<AddedIntegrationsList>>;
http: HttpStart;
dataSourceEnabled: string;
dataSourceEnabled: boolean;
}

export interface AddedIntegrationsList {
Expand All @@ -27,12 +27,13 @@
export interface AddedIntegrationType {
name: string;
templateName: string;
dataSource: any;

Check warning on line 30 in public/components/integrations/components/added_integration_overview_page.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
creationDate: string;
status: string;
assets: any[];

Check warning on line 33 in public/components/integrations/components/added_integration_overview_page.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
addedBy: string;
id: string;
references?: [];
}

export function AddedIntegrationOverviewPage(props: AddedIntegrationOverviewPageProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export function AddedIntegrationsTable(props: AddedIntegrationsTableProps) {
sortable: true,
truncateText: true,
render: (value, record) => (
<EuiText data-test-subj={`${record.templateName}IntegrationDescription`}>- -</EuiText>
<EuiText data-test-subj={`${record.templateName}IntegrationDescription`}>
{truncate(record.dataSourceMDSLabel || 'Local cluster', { length: 100 })}
</EuiText>
),
});
}
Expand Down Expand Up @@ -132,8 +134,17 @@ export function AddedIntegrationsTable(props: AddedIntegrationsTableProps) {
);
setIsModalVisible(true);
};

const integTemplateNames = [...new Set(props.data.hits.map((i) => i.templateName))].sort();
let mdsLabels;
if (dataSourceEnabled) {
mdsLabels = [
...new Set(
props.data.hits.flatMap((hit) =>
hit.references?.length > 0 ? hit.references.map((ref) => ref.name || 'Local cluster') : []
)
),
].sort();
}

const search = {
box: {
Expand All @@ -151,6 +162,21 @@ export function AddedIntegrationsTable(props: AddedIntegrationsTableProps) {
view: name,
})),
},
...(dataSourceEnabled
? [
{
type: 'field_value_selection' as const,
field: 'dataSourceMDSLabel',
name: 'Data Source Name',
multiSelect: false,
options: mdsLabels?.map((name) => ({
name,
value: name,
view: name,
})),
},
]
: []),
],
};

Expand All @@ -159,7 +185,17 @@ export function AddedIntegrationsTable(props: AddedIntegrationsTableProps) {
const templateName = integration.templateName;
const creationDate = integration.creationDate;
const name = integration.name;
return { id, templateName, creationDate, name, data: { templateName, name } };
const dataSourceMDSLabel = integration.references
? integration.references[0].name
: 'Local cluster';
return {
id,
templateName,
creationDate,
name,
data: { templateName, name },
dataSourceMDSLabel,
};
});

return (
Expand Down
Loading
Loading