Skip to content

Commit

Permalink
address the comments
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Saxena <riysaxen@amazon.com>
  • Loading branch information
riysaxen-amzn committed Jun 24, 2024
1 parent 78dae49 commit fa9c6ef
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import {
import { parseAlertSeverityToOption } from '../../../CreateDetector/components/ConfigureAlerts/utils/helpers';
import { NotificationsStart } from 'opensearch-dashboards/public';
import { DataStore } from '../../../../store/DataStore';
import { CorrelationAlertColumns, Finding } from '../../../../../types';
import { CorrelationAlertTableItem, Finding } from '../../../../../types';

export interface CorrelationAlertFlyoutProps {
alertItem: CorrelationAlertColumns;
alertItem: CorrelationAlertTableItem;
notifications: NotificationsStart;
onClose: () => void;
onAcknowledge: (selectedItems: CorrelationAlertColumns[]) => void;
onAcknowledge: (selectedItems: CorrelationAlertTableItem[]) => void;
}

export interface CorrelationAlertFlyoutState {
Expand Down
30 changes: 15 additions & 15 deletions public/pages/Alerts/containers/Alerts/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import {
import { NotificationsStart } from 'opensearch-dashboards/public';
import { match, RouteComponentProps, withRouter } from 'react-router-dom';
import { ChartContainer } from '../../../../components/Charts/ChartContainer';
import { AlertItem, CorrelationAlertColumns, DataSourceProps, DateTimeFilter, Detector } from '../../../../../types';
import { AlertItem, CorrelationAlertTableItem, DataSourceProps, DateTimeFilter, Detector } from '../../../../../types';
import { DurationRange } from '@elastic/eui/src/components/date_picker/types';
import { DataStore } from '../../../../store/DataStore';

Expand All @@ -80,13 +80,13 @@ export interface AlertsState {
groupBy: string;
recentlyUsedRanges: DurationRange[];
selectedItems: AlertItem[];
correlatedItems: CorrelationAlertColumns[];
correlatedItems: CorrelationAlertTableItem[];
alerts: AlertItem[];
correlationAlerts: CorrelationAlertColumns[];
correlationAlerts: CorrelationAlertTableItem[];
flyoutData?: { alertItem: AlertItem };
flyoutCorrelationData?: { alertItem: CorrelationAlertColumns };
flyoutCorrelationData?: { alertItem: CorrelationAlertTableItem };
alertsFiltered: boolean;
filteredCorrelationAlerts: CorrelationAlertColumns[];
filteredCorrelationAlerts: CorrelationAlertTableItem[];
filteredAlerts: AlertItem[];
detectors: { [key: string]: Detector };
loading: boolean;
Expand Down Expand Up @@ -328,7 +328,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
];
}

getCorrelationColumns(): EuiBasicTableColumn<CorrelationAlertColumns>[] {
getCorrelationColumns(): EuiBasicTableColumn<CorrelationAlertTableItem>[] {
return [
{
field: 'start_time',
Expand All @@ -349,7 +349,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
name: 'Correlation Rule Name',
sortable: true,
dataType: 'string',
render: (correlationRulename: string, alertItem: CorrelationAlertColumns) => (
render: (correlationRulename: string, alertItem: CorrelationAlertTableItem) => (
<EuiLink onClick={() => this.setCorrelationFlyout(alertItem)}>{correlationRulename}</EuiLink>
),
},
Expand Down Expand Up @@ -380,7 +380,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
sortable: false,
actions: [
{
render: (alertItem: CorrelationAlertColumns) => {
render: (alertItem: CorrelationAlertTableItem) => {
const disableAcknowledge = alertItem.state !== ALERT_STATE.ACTIVE;
return (
<EuiToolTip
Expand All @@ -399,7 +399,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
},
},
{
render: (alertItem: CorrelationAlertColumns) => (
render: (alertItem: CorrelationAlertTableItem) => (
<EuiToolTip content={'View details'}>
<EuiButtonIcon
aria-label={'View details'}
Expand All @@ -418,7 +418,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
this.setState({ flyoutData: alertItem ? { alertItem } : undefined });
}

setCorrelationFlyout(alertItem?: CorrelationAlertColumns): void {
setCorrelationFlyout(alertItem?: CorrelationAlertTableItem): void {
this.setState({ flyoutCorrelationData: alertItem ? { alertItem } : undefined });
}

Expand Down Expand Up @@ -452,7 +452,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
});
}

generateCorrelationVisualizationSpec(alerts: CorrelationAlertColumns[]) {
generateCorrelationVisualizationSpec(alerts: CorrelationAlertTableItem[]) {
const visData = alerts.map((alert) => {
const time = new Date(alert.start_time);
time.setMilliseconds(0);
Expand Down Expand Up @@ -632,7 +632,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
this.setState({ selectedItems });
};

onCorrelationSelectionChange = (correlatedItems: CorrelationAlertColumns[]) => {
onCorrelationSelectionChange = (correlatedItems: CorrelationAlertTableItem[]) => {
this.setState({ correlatedItems });
};

Expand Down Expand Up @@ -674,7 +674,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
this.onRefresh();
};

onAcknowledgeCorrelationAlert = async (selectedItems: CorrelationAlertColumns[] = []) => {
onAcknowledgeCorrelationAlert = async (selectedItems: CorrelationAlertTableItem[] = []) => {
const { correlationService, notifications } = this.props;
let successCount = 0;
try {
Expand Down Expand Up @@ -806,9 +806,9 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
selectableMessage: (selectable) => (selectable ? '' : DISABLE_ACKNOWLEDGED_ALERT_HELP_TEXT),
};

const correlationSelection: EuiTableSelectionType<CorrelationAlertColumns> = {
const correlationSelection: EuiTableSelectionType<CorrelationAlertTableItem> = {
onSelectionChange: this.onCorrelationSelectionChange,
selectable: (item: CorrelationAlertColumns) => item.state === ALERT_STATE.ACTIVE,
selectable: (item: CorrelationAlertTableItem) => item.state === ALERT_STATE.ACTIVE,
selectableMessage: (selectable) => (selectable ? '' : DISABLE_ACKNOWLEDGED_ALERT_HELP_TEXT),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,12 @@ export const CreateCorrelationRule: React.FC<CreateCorrelationRuleProps> = (
>
{createForm(queries, touched, errors, props)}
</ContentPanel>
<ExperimentalBanner />
<EuiSpacer size="l" />
<ContentPanel
panelStyles={{ paddingLeft: 10, paddingRight: 10 }}
hideHeaderBorder
>
<ExperimentalBanner />
<EuiTitle size="m">
<h2>Alert Trigger </h2>
</EuiTitle>
Expand Down
2 changes: 1 addition & 1 deletion types/Alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export interface CorrelationAlertItem {
acknowledged_time: string | null;
}

export interface CorrelationAlertColumns extends CorrelationAlertItem{
export interface CorrelationAlertTableItem extends CorrelationAlertItem{
correlation_rule_categories: string[];
}

Expand Down

0 comments on commit fa9c6ef

Please sign in to comment.