Skip to content

Commit

Permalink
Changes due to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Oct 2, 2020
1 parent f90de57 commit c8b8572
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ import { fold } from 'fp-ts/lib/Either';
import { pick } from 'lodash';
import { alertStateSchema, AlertingFrameworkHealth } from '../../../../alerts/common';
import { BASE_ALERT_API_PATH } from '../constants';
import {
Alert,
AlertType,
AlertWithoutId,
AlertTaskState,
AlertInstanceSummary,
} from '../../types';
import { Alert, AlertType, AlertUpdates, AlertTaskState, AlertInstanceSummary } from '../../types';

export async function loadAlertTypes({ http }: { http: HttpSetup }): Promise<AlertType[]> {
return await http.get(`${BASE_ALERT_API_PATH}/list_alert_types`);
Expand Down Expand Up @@ -142,7 +136,7 @@ export async function createAlert({
}: {
http: HttpSetup;
alert: Omit<
AlertWithoutId,
AlertUpdates,
'createdBy' | 'updatedBy' | 'muteAll' | 'mutedInstanceIds' | 'executionStatus'
>;
}): Promise<Alert> {
Expand All @@ -157,7 +151,7 @@ export async function updateAlert({
id,
}: {
http: HttpSetup;
alert: Pick<AlertWithoutId, 'throttle' | 'name' | 'tags' | 'schedule' | 'params' | 'actions'>;
alert: Pick<AlertUpdates, 'throttle' | 'name' | 'tags' | 'schedule' | 'params' | 'actions'>;
id: string;
}): Promise<Alert> {
return await http.put(`${BASE_ALERT_API_PATH}/alert/${id}`, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {
EuiFilterSelectItem,
EuiHealth,
} from '@elastic/eui';
import { AlertExecutionStatusValues } from '../../../../../../alerts/common';
import {
AlertExecutionStatuses,
AlertExecutionStatusValues,
} from '../../../../../../alerts/common';

interface AlertStatusFilterProps {
selectedStatuses: string[];
Expand Down Expand Up @@ -59,7 +62,7 @@ export const AlertStatusFilter: React.FunctionComponent<AlertStatusFilterProps>
}
>
<div className="euiFilterSelect__items">
{[...AlertExecutionStatusValues].sort().map((item: string) => {
{[...AlertExecutionStatusValues].sort().map((item: AlertExecutionStatuses) => {
const healthColor = getHealthColor(item);
return (
<EuiFilterSelectItem
Expand All @@ -85,7 +88,7 @@ export const AlertStatusFilter: React.FunctionComponent<AlertStatusFilterProps>
);
};

export function getHealthColor(status: string) {
export function getHealthColor(status: AlertExecutionStatuses) {
switch (status) {
case 'active':
return 'primary';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ export const AlertsList: React.FunctionComponent = () => {
title={
<FormattedMessage
id="xpack.triggersActionsUI.sections.alertsList.attentionBannerTitle"
defaultMessage="There is {totalStausesError} {totalStausesError, plural, one {{singleTitle}} other {# {multipleTitle}}} with an error."
defaultMessage="Found {totalStausesError} {totalStausesError, plural, one {{singleTitle}} other {# {multipleTitle}}} with an error."
values={{
totalStausesError: alertsStatusesTotal.error,
singleTitle: 'alert',
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/triggers_actions_ui/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export interface AlertType {

export type SanitizedAlertType = Omit<AlertType, 'apiKey'>;

export type AlertWithoutId = Omit<Alert, 'id' | 'executionStatus'>;
export type AlertUpdates = Omit<Alert, 'id' | 'executionStatus'>;

export interface AlertTableItem extends Alert {
alertType: AlertType['name'];
Expand Down

0 comments on commit c8b8572

Please sign in to comment.