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

Add view single document and surrounding documents #6831

Merged
merged 12 commits into from
Jul 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { DocumentViewTableAndJson } from '../wazuh-discover/components/document-
import DiscoverDataGridAdditionalControls from '../wazuh-discover/components/data-grid-additional-controls';
import './wazuh-data-grid.scss';
import { wzDiscoverRenderColumns } from '../wazuh-discover/render-columns';
import DocDetailsHeader from '../wazuh-discover/components/doc-details-header';

export const MAX_ENTRIES_PER_QUERY = 10000;

Expand Down Expand Up @@ -180,7 +181,10 @@ const WazuhDataGrid = (props: tWazuhDataGridProps) => {
<EuiFlyout onClose={() => setInspectedHit(undefined)} size='m'>
<EuiFlyoutHeader>
<EuiTitle>
<h2>Document Details</h2>
<DocDetailsHeader
doc={inspectedHit}
indexPattern={indexPattern}
/>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiLink } from '@elastic/eui';
import { RedirectAppLinks } from '../../../../../../../src/plugins/opensearch_dashboards_react/public';
import { getCore } from '../../../../kibana-services';
import NavigationService from '../../../../react-services/navigation-service';

const DocDetailsHeader = ({ doc, indexPattern }) => {
return (
<EuiFlexGroup>
<EuiFlexItem>
<EuiTitle>
<h2>Document Details</h2>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
<EuiFlexGroup>
<EuiFlexItem>
<RedirectAppLinks application={getCore().application}>
<EuiLink
href={NavigationService.getInstance().getUrlForApp('discover', {
path: `#/context/${indexPattern?.id}/${doc?._id}`,
})}
target='_blank'
rel='noopener noreferrer'
external
>
View surrounding documents
</EuiLink>
</RedirectAppLinks>
</EuiFlexItem>
<EuiFlexItem>
<RedirectAppLinks application={getCore().application}>
<EuiLink
href={NavigationService.getInstance().getUrlForApp('discover', {
path: `#/doc/${indexPattern?.id}/${doc?._index}?id=${doc?._id}`,
})}
target='_blank'
rel='noopener noreferrer'
external
>
View single document
</EuiLink>
</RedirectAppLinks>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexGroup>
);
};

export default DocDetailsHeader;
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
import DiscoverDataGridAdditionalControls from './components/data-grid-additional-controls';
import { wzDiscoverRenderColumns } from './render-columns';
import { WzSearchBar } from '../search-bar';
import DocDetailsHeader from './components/doc-details-header';

export const MAX_ENTRIES_PER_QUERY = 10000;

Expand Down Expand Up @@ -267,9 +268,10 @@ const WazuhDiscoverComponent = (props: WazuhDiscoverProps) => {
{inspectedHit && (
<EuiFlyout onClose={() => setInspectedHit(undefined)} size='m'>
<EuiFlyoutHeader>
<EuiTitle>
<h2>Document Details</h2>
</EuiTitle>
<DocDetailsHeader
doc={inspectedHit}
indexPattern={dataSource?.indexPattern}
/>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiFlexGroup direction='column'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import { useReportingCommunicateSearchContext } from '../../../common/hooks/use-
import { wzDiscoverRenderColumns } from '../../../common/wazuh-discover/render-columns';
import { WzSearchBar } from '../../../common/search-bar';

import DocDetailsHeader from '../../../common/wazuh-discover/components/doc-details-header';

const plugins = getPlugins();

const DashboardByRenderer = plugins.dashboard.DashboardContainerByValueRenderer;
Expand Down Expand Up @@ -332,9 +334,10 @@ const DashboardTH: React.FC = () => {
{inspectedHit && (
<EuiFlyout onClose={() => setInspectedHit(undefined)} size='m'>
<EuiFlyoutHeader>
<EuiTitle>
<h2>Document details</h2>
</EuiTitle>
<DocDetailsHeader
doc={inspectedHit}
indexPattern={dataSource?.indexPattern}
/>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiFlexGroup direction='column'>
Expand Down
Loading