Skip to content

Commit

Permalink
displaying the backend error message to the Alerting Page
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Saxena <[email protected]>
  • Loading branch information
riysaxen-amzn committed Feb 20, 2024
1 parent 7837a99 commit c8fab2b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
42 changes: 41 additions & 1 deletion public/pages/Alerts/containers/Alerts/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import {
EuiTitle,
EuiToolTip,
EuiEmptyPrompt,
EuiModal,
EuiModalHeader,
EuiModalHeaderTitle,
EuiModalBody,
EuiModalFooter,
EuiIcon,
} from '@elastic/eui';
import { FieldValueSelectionFilterConfigType } from '@elastic/eui/src/components/search_bar/filters/field_value_selection_filter';
import dateMath from '@elastic/datemath';
Expand Down Expand Up @@ -84,6 +90,7 @@ export interface AlertsState {
timeUnit: TimeUnit;
dateFormat: string;
widgetEmptyMessage: React.ReactNode | undefined;
isModalVisible: boolean;
}

const groupByOptions = [
Expand Down Expand Up @@ -116,6 +123,7 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
timeUnit: timeUnits.timeUnit,
dateFormat: timeUnits.dateFormat,
widgetEmptyMessage: undefined,
isModalVisible: false,
};
}

Expand Down Expand Up @@ -199,7 +207,39 @@ export class Alerts extends Component<AlertsProps, AlertsState> {
name: 'Status',
sortable: true,
dataType: 'string',
render: (status) => (status ? capitalizeFirstLetter(status) : DEFAULT_EMPTY_DATA),
render: (status, alertItem) => {
if (status === 'ERROR') {
const isModalVisible = this.state.isModalVisible;
return (
<React.Fragment>
<EuiLink onClick={() => this.setState({ isModalVisible: true })}>
{capitalizeFirstLetter(status)}
</EuiLink>

{isModalVisible && (
<EuiModal onClose={() => this.setState({ isModalVisible: false })}>
<EuiModalHeader>
<EuiModalHeaderTitle>{capitalizeFirstLetter(status)}</EuiModalHeaderTitle>
</EuiModalHeader>

<EuiModalBody>
<EuiIcon type="alert" size="l" />
<p>{alertItem.error_message}</p>
</EuiModalBody>

<EuiModalFooter>
<EuiButton onClick={() => this.setState({ isModalVisible: false })}>
Close
</EuiButton>
</EuiModalFooter>
</EuiModal>
)}
</React.Fragment>
);
} else {
return <span>{status}</span>;
}
},
},
{
field: 'severity',
Expand Down
1 change: 1 addition & 0 deletions server/models/interfaces/Alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface AlertItem {
trigger_name: string;
detector_id: string;
state: string;
error_message: string | null;
severity: string;
finding_ids: string[];
last_notification_time: string;
Expand Down
1 change: 1 addition & 0 deletions types/Alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface AlertItem {
trigger_name: string;
detector_id: string;
state: string;
error_message: string | null;
severity: string;
finding_ids: string[];
last_notification_time: string;
Expand Down

0 comments on commit c8fab2b

Please sign in to comment.