-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add error callout on watch details page #36139
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,21 +16,20 @@ import { | |
EuiTitle, | ||
EuiButtonEmpty, | ||
EuiToolTip, | ||
EuiCallOut, | ||
} from '@elastic/eui'; | ||
import { loadWatchDetail, ackWatchAction } from '../../../lib/api'; | ||
import { getPageErrorCode, WatchStatus } from '../../../components'; | ||
import { PAGINATION } from '../../../../common/constants'; | ||
|
||
const WatchDetailUi = ({ watchId }: { watchId: string }) => { | ||
const pagination = { | ||
initialPageSize: 10, | ||
pageSizeOptions: [10, 50, 100], | ||
}; | ||
|
||
const { error, data: watchDetail, isLoading } = loadWatchDetail(watchId); | ||
|
||
const [actionStatuses, setActionStatuses] = useState<any[]>([]); | ||
const [isActionStatusLoading, setIsActionStatusLoading] = useState<boolean>(false); | ||
|
||
const actionErrors = watchDetail && watchDetail.watchErrors.actionErrors; | ||
|
||
useEffect( | ||
() => { | ||
if (watchDetail) { | ||
|
@@ -134,6 +133,34 @@ const WatchDetailUi = ({ watchId }: { watchId: string }) => { | |
|
||
<EuiSpacer size="s" /> | ||
|
||
{actionErrors && ( | ||
<EuiCallOut | ||
title={i18n.translate('xpack.watcher.sections.watchDetail.actionErrorsCalloutTitle', { | ||
defaultMessage: 'This watch contains action errors.', | ||
})} | ||
color="danger" | ||
iconType="cross" | ||
> | ||
{Object.keys(actionErrors).map((action: string) => ( | ||
<Fragment key={action}> | ||
<EuiText size="xs"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<h4>{action}</h4> | ||
<ul> | ||
{actionErrors[action].map( | ||
(actionError: { message: string }, errorIndex: number) => ( | ||
<li key={`action-error-${errorIndex}`}>{actionError.message}</li> | ||
) | ||
)} | ||
</ul> | ||
</EuiText> | ||
<EuiSpacer size="s" /> | ||
</Fragment> | ||
))} | ||
</EuiCallOut> | ||
)} | ||
|
||
<EuiSpacer size="s" /> | ||
|
||
<EuiTitle size="s"> | ||
<h2> | ||
<FormattedMessage | ||
|
@@ -149,7 +176,7 @@ const WatchDetailUi = ({ watchId }: { watchId: string }) => { | |
items={actionStatuses} | ||
itemId="id" | ||
columns={columns} | ||
pagination={pagination} | ||
pagination={PAGINATION} | ||
sorting={true} | ||
loading={isLoading} | ||
message={ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import { BaseAction } from './base_action'; | ||
import { ACTION_TYPES, ERROR_CODES } from '../../../common/constants'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { get } from 'lodash'; | ||
|
||
export class JiraAction extends BaseAction { | ||
constructor(props, errors) { | ||
|
@@ -72,9 +73,9 @@ export class JiraAction extends BaseAction { | |
const { errors } = this.validateJson(json.actionJson); | ||
|
||
Object.assign(props, { | ||
projectKey: json.actionJson.jira.fields.project.key, | ||
issueType: json.actionJson.jira.fields.issuetype.name, | ||
summary: json.actionJson.jira.fields.summary, | ||
projectKey: get(json, 'actionJson.jira.fields.project.key'), | ||
issueType: get(json, 'actionJson.jira.fields.issuetype.name'), | ||
summary: get(json, 'actionJson.jira.fields.summary'), | ||
}); | ||
|
||
const action = new JiraAction(props, errors); | ||
|
@@ -98,7 +99,32 @@ export class JiraAction extends BaseAction { | |
json.jira = {}; | ||
} | ||
|
||
if (!json.jira.fields.project.key) { | ||
if (!json.jira.fields) { | ||
errors.push({ | ||
code: ERROR_CODES.ERR_PROP_MISSING, | ||
message: i18n.translate('xpack.watcher.models.jiraAction.actionJsonJiraFieldsPropertyMissingBadRequestMessage', { | ||
defaultMessage: 'json argument must contain an {actionJsonJiraFieldsKey} property', | ||
values: { | ||
actionJsonJiraProjectKey: 'actionJson.jira.fields' | ||
} | ||
}), | ||
}); | ||
return { errors }; | ||
} | ||
|
||
if (!json.jira.fields.project) { | ||
errors.push({ | ||
code: ERROR_CODES.ERR_PROP_MISSING, | ||
message: i18n.translate('xpack.watcher.models.jiraAction.actionJsonJiraProjectPropertyMissingBadRequestMessage', { | ||
defaultMessage: 'json argument must contain an {actionJsonJiraProject} property', | ||
values: { | ||
actionJsonJiraProject: 'actionJson.jira.fields.project' | ||
} | ||
}), | ||
}); | ||
} | ||
|
||
if (json.jira.fields.project && !json.jira.fields.project.key) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can imagine a user getting frustrated if they fix This comment applies to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point :) Fixed! |
||
errors.push({ | ||
code: ERROR_CODES.ERR_PROP_MISSING, | ||
message: i18n.translate('xpack.watcher.models.jiraAction.actionJsonJiraProjectKeyPropertyMissingBadRequestMessage', { | ||
|
@@ -110,7 +136,19 @@ export class JiraAction extends BaseAction { | |
}); | ||
} | ||
|
||
if (!json.jira.fields.issuetype.name) { | ||
if (!json.jira.fields.issuetype) { | ||
errors.push({ | ||
code: ERROR_CODES.ERR_PROP_MISSING, | ||
message: i18n.translate('xpack.watcher.models.jiraAction.actionJsonJiraIssueTypePropertyMissingBadRequestMessage', { | ||
defaultMessage: 'json argument must contain an {actionJsonJiraIssueTypeKey} property', | ||
values: { | ||
actionJsonJiraIssueTypeKey: 'actionJson.jira.fields.issuetype' | ||
} | ||
}), | ||
}); | ||
} | ||
|
||
if (json.jira.fields.issuetype && !json.jira.fields.issuetype.name) { | ||
errors.push({ | ||
code: ERROR_CODES.ERR_PROP_MISSING, | ||
message: i18n.translate('xpack.watcher.models.jiraAction.actionJsonJiraIssueTypePropertyMissingBadRequestMessage', { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice call! I think this is a big improvement over the modal. Is it possible for there to be a lot of actions, and they could all have errors? In this case, the callout would become very tall, and it would be difficult to correlate an error in the callout with a row in the actions table.
If you agree, then I think a more usable solution would be to make each "Config error" status a link which, when clicked, opens a flyout containing a danger callout like this one, except it only contains the errors for that specific action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought of that as well. That's a good point.
Latest changes: