Skip to content

Commit

Permalink
address the review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Saxena <[email protected]>
  • Loading branch information
riysaxen-amzn committed Jun 25, 2024
1 parent 501bfaa commit 7bd5683
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
formatRuleType,
renderTime,
} from '../../../../utils/helpers';
import { IndexPatternsService, OpenSearchService, DetectorsService } from '../../../../services';
import { parseAlertSeverityToOption } from '../../../CreateDetector/components/ConfigureAlerts/utils/helpers';
import { NotificationsStart } from 'opensearch-dashboards/public';
import { DataStore } from '../../../../store/DataStore';
Expand Down
16 changes: 7 additions & 9 deletions public/pages/Alerts/containers/Alerts/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export interface AlertsState {
dateFormat: string;
widgetEmptyMessage: React.ReactNode | undefined;
widgetEmptyCorrelationMessage: React.ReactNode | undefined;
tab: string;
tab: 'detector findings' | 'correlations'; // Union type for tab
}

const groupByOptions = [
Expand All @@ -107,7 +107,6 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
static contextType = CoreServicesContext;
private abortControllers: AbortController[] = [];


constructor(props: AlertsProps) {
super(props);

Expand All @@ -134,7 +133,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
dateFormat: timeUnits.dateFormat,
widgetEmptyMessage: undefined,
widgetEmptyCorrelationMessage: undefined,
tab: 'findings'
tab: 'detector findings'
};
}

Expand Down Expand Up @@ -232,15 +231,15 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
};

private renderVisAsPerTab() {
if (this.state.tab === "findings") {
if (this.state.tab === "detector findings") {
renderVisualization(this.generateVisualizationSpec(this.state.filteredAlerts), 'alerts-view');
} else {
renderVisualization(this.generateCorrelationVisualizationSpec(this.state.filteredCorrelationAlerts), 'alerts-view');
}
}

private getAlertsAsPerTab() {
if (this.state.tab === "findings") {
if (this.state.tab === "detector findings") {
this.abortPendingGetAlerts();
const abortController = new AbortController();
this.abortControllers.push(abortController);
Expand Down Expand Up @@ -838,7 +837,6 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
alertItem={flyoutCorrelationData.alertItem}
onClose={this.onCorrelationFlyoutClose}
onAcknowledge={this.onAcknowledgeCorrelationAlert}
indexPatternService={this.props.indexPatternService}
/>
)}
<EuiFlexGroup direction="column">
Expand Down Expand Up @@ -891,12 +889,12 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
</EuiFlexItem>
<EuiFlexItem>
<ContentPanel title={'Alerts'} actions={[
this.state.tab === 'findings'
this.state.tab === 'detector findings'
? this.createAcknowledgeControl()
: this.createAcknowledgeControlForCorrelations()
]}>
<EuiTabs>
<EuiTab onClick={() => this.setState({ tab: 'findings' })} isSelected={this.state.tab === 'findings'}>
<EuiTab onClick={() => this.setState({ tab: 'detector findings' })} isSelected={this.state.tab === 'detector findings'}>
Findings
</EuiTab>
<EuiTab onClick={() => this.setState({ tab: 'correlations' })} isSelected={this.state.tab === 'correlations'}>
Expand All @@ -908,7 +906,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
</EuiToolTip>
</EuiTab>
</EuiTabs>
{this.state.tab === 'findings' && (
{this.state.tab === 'detector findings' && (
// Content for the "Findings" tab
<EuiInMemoryTable
columns={this.getColumns()}
Expand Down
13 changes: 5 additions & 8 deletions public/pages/Correlations/containers/CreateCorrelationRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,22 @@ import {
CorrelationRuleAction,
CorrelationRuleModel,
CorrelationRuleQuery,
CorrelationRuleTrigger,
DataSourceProps,
} from '../../../../types';
import { BREADCRUMBS, NOTIFICATIONS_HREF, OS_NOTIFICATION_PLUGIN, ROUTES } from '../../../utils/constants';
import { CoreServicesContext } from '../../../components/core_services';
import { RouteComponentProps, useParams } from 'react-router-dom';
import { validateName } from '../../../utils/validation';
import { FieldMappingService, IndexService } from '../../../services';
import { FieldMappingService, IndexService, OpenSearchService, NotificationsService } from '../../../services';
import { errorNotificationToast, getDataSources, getLogTypeOptions, getPlugins } from '../../../utils/helpers';
import { severityOptions } from '../../../pages/Alerts/utils/constants';
import _ from 'lodash';
import { NotificationChannelOption, NotificationChannelTypeOptions } from '../../CreateDetector/components/ConfigureAlerts/models/interfaces';
import { getEmptyAlertCondition, getNotificationChannels, parseAlertSeverityToOption, parseNotificationChannelsToOptions } from '../../CreateDetector/components/ConfigureAlerts/utils/helpers';
import { NotificationsCallOut } from '../../../../public/components/NotificationsCallOut';
import { BrowserServices } from '../../../../public/models/interfaces';
import { ExperimentalBanner } from '../components/ExperimentalBanner';
import { ALERT_SEVERITY_OPTIONS } from '../../CreateDetector/components/ConfigureAlerts/utils/constants';
import uuid from 'uuid';
import { randomUUID } from 'crypto';

export interface CreateCorrelationRuleProps extends DataSourceProps {
indexService: IndexService;
Expand All @@ -69,7 +66,8 @@ export interface CreateCorrelationRuleProps extends DataSourceProps {
{ rule: CorrelationRuleModel; isReadOnly: boolean }
>['history'];
notifications: NotificationsStart | null;
services: BrowserServices;
notificationsService: NotificationsService
opensearchService: OpenSearchService
}

export interface CorrelationOption {
Expand Down Expand Up @@ -199,14 +197,13 @@ export const CreateCorrelationRule: React.FC<CreateCorrelationRuleProps> = (

useEffect(() => {
const setInitalNotificationValues = async () => {
const { services } = props;
const plugins = await getPlugins(services.opensearchService);
const plugins = await getPlugins(props.opensearchService);
if (plugins) {
setHasNotificationPlugin(plugins.includes(OS_NOTIFICATION_PLUGIN));
}
};
const setNotificationChannelValues = async () => {
const channels = await getNotificationChannels(props.services.notificationsService);
const channels = await getNotificationChannels(props.notificationsService);
const parsedChannels = parseNotificationChannelsToOptions(channels);
setNotificationChannels(parsedChannels);
setLoadingNotifications(false);
Expand Down
6 changes: 4 additions & 2 deletions public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,8 @@ export default class Main extends Component<MainProps, MainState> {
fieldMappingService={services?.fieldMappingService}
notifications={core?.notifications}
dataSource={selectedDataSource}
services={services}
notificationsService={services?.notificationsService}
opensearchService={services?.opensearchService}
/>
)}
/>
Expand All @@ -663,7 +664,8 @@ export default class Main extends Component<MainProps, MainState> {
fieldMappingService={services?.fieldMappingService}
notifications={core?.notifications}
dataSource={selectedDataSource}
services={services}
notificationsService={services?.notificationsService}
opensearchService={services?.opensearchService}
/>
)}
/>
Expand Down

0 comments on commit 7bd5683

Please sign in to comment.