Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierM committed Aug 18, 2021
1 parent f917c86 commit 6096d8a
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useKibana } from '../../lib/kibana';
import { SourcererScopeName } from '../../store/sourcerer/model';
import { useIsExperimentalFeatureEnabled } from '../../hooks/use_experimental_features';
import { DEFAULT_COLUMN_MIN_WIDTH } from '../../../timelines/components/timeline/body/constants';
import type { EntityType } from '../../../../../timelines/common';

export interface OwnProps {
end: string;
Expand Down Expand Up @@ -63,13 +64,15 @@ const defaultAlertsFilters: Filter[] = [
interface Props {
timelineId: TimelineIdLiteral;
endDate: string;
entityType?: EntityType;
startDate: string;
pageFilters?: Filter[];
}

const AlertsTableComponent: React.FC<Props> = ({
timelineId,
endDate,
entityType = 'alerts',
startDate,
pageFilters = [],
}) => {
Expand Down Expand Up @@ -107,7 +110,7 @@ const AlertsTableComponent: React.FC<Props> = ({
defaultModel={alertsDefaultModel}
defaultCellActions={defaultCellActions}
end={endDate}
entityType="alerts"
entityType={entityType}
id={timelineId}
renderCellValue={DefaultCellRenderer}
rowRenderers={defaultRowRenderers}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const AlertsViewComponent: React.FC<AlertsComponentsProps> = ({
timelineId,
deleteQuery,
endDate,
entityType,
filterQuery,
indexNames,
pageFilters,
Expand Down Expand Up @@ -74,6 +75,7 @@ const AlertsViewComponent: React.FC<AlertsComponentsProps> = ({
<AlertsTable
timelineId={timelineId}
endDate={endDate}
entityType={entityType}
startDate={startDate}
pageFilters={pageFilters}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { Filter } from '../../../../../../../src/plugins/data/public';
import type { EntityType } from '../../../../../timelines/common';
import { TimelineIdLiteral } from '../../../../common/types/timeline';
import { HostsComponentsQueryProps } from '../../../hosts/pages/navigation/types';
import { NetworkComponentQueryProps } from '../../../network/pages/navigation/types';
Expand All @@ -23,5 +24,6 @@ export interface AlertsComponentsProps
stackByOptions?: MatrixHistogramOption[];
defaultFilters?: Filter[];
defaultStackByOption?: MatrixHistogramOption;
entityType?: EntityType;
indexNames: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useGlobalFullScreen } from '../../containers/use_full_screen';
import { useIsExperimentalFeatureEnabled } from '../../hooks/use_experimental_features';
import { SourcererScopeName } from '../../store/sourcerer/model';
import { useSourcererScope } from '../../containers/sourcerer';
import { EntityType } from '../../../../../timelines/common';
import type { EntityType } from '../../../../../timelines/common';
import { TGridCellAction } from '../../../../../timelines/common/types';
import { DetailsPanel } from '../../../timelines/components/side_panel';
import { CellValueElementProps } from '../../../timelines/components/timeline/cell_rendering';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const HostAlertsQueryTabBody = React.memo((alertsProps: AlertsComponentQu

return (
<AlertsView
entityType="events"
timelineId={TimelineId.hostsPageExternalAlerts}
{...rest}
pageFilters={hostPageFilters}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const filterNetworkData: Filter[] = [

export const NetworkAlertsQueryTabBody = React.memo((alertsProps: NetworkComponentQueryProps) => (
<AlertsView
entityType="events"
timelineId={TimelineId.networkPageExternalAlerts}
{...alertsProps}
pageFilters={filterNetworkData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ const EventRenderedFlexItem = styled(EuiFlexItem)`
}
`;

const ActionsContainer = styled.div`
display: flex;
align-items: center;
div div:first-child div.siemEventsTable__tdContent {
margin-left: ${({ theme }) => theme.eui.paddingSizes.m};
}
`;

// Fix typing issue with EuiBasicTable and styled
type BasicTableType = ComponentType<EuiBasicTableProps<TimelineItem>>;

Expand Down Expand Up @@ -113,25 +121,31 @@ const EventRenderedViewComponent = ({
name: ActionTitle,
truncateText: false,
hideForMobile: false,
// eslint-disable-next-line react/display-name
render: (name: unknown, item: unknown) => {
const alertId = get(item, '_id');
const rowIndex = events.findIndex((evt) => evt._id === alertId);
return leadingControlColumns.length > 0
? leadingControlColumns.map((action) => {
const getActions = action.rowCellRender as (
props: EuiDataGridCellValueElementProps
) => React.ReactNode;
return getActions({
columnId: 'actions',
isDetails: false,
isExpandable: false,
isExpanded: false,
rowIndex,
setCellProps: () => null,
});
})
: null;
return (
<ActionsContainer>
{leadingControlColumns.length > 0
? leadingControlColumns.map((action) => {
const getActions = action.rowCellRender as (
props: EuiDataGridCellValueElementProps
) => React.ReactNode;
return getActions({
columnId: 'actions',
isDetails: false,
isExpandable: false,
isExpanded: false,
rowIndex,
setCellProps: () => null,
});
})
: null}
</ActionsContainer>
);
},
width: '120px',
},
{
field: 'ecs.@timestamp',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ const SummaryViewSelectorComponent = ({ viewSelected, onViewChange }: SummaryVie
>
<ContainerEuiSelectable>
<EuiSelectable
aria-label="Basic example"
options={options}
onChange={onChangeSelectable}
renderOption={renderOption}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ const TGridIntegratedComponent: React.FC<TGridIntegratedProps> = ({
<UpdatedFlexItem grow={false} show={!loading}>
{!resolverIsShowing(graphEventId) && additionalFilters}
</UpdatedFlexItem>
{tGridEventRenderedViewEnabled && (
{tGridEventRenderedViewEnabled && entityType === 'alerts' && (
<UpdatedFlexItem grow={false} show={!loading}>
<SummaryViewSelector viewSelected={tableView} onViewChange={setTableView} />
</UpdatedFlexItem>
Expand Down

0 comments on commit 6096d8a

Please sign in to comment.