Skip to content
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

[Metrics UI] Fix Alert Preview Error design #71005

Merged
merged 8 commits into from
Jul 20, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiCallOut,
EuiOverlayMask,
EuiModal,
EuiModalHeader,
EuiModalHeaderTitle,
EuiModalBody,
EuiAccordion,
EuiCodeBlock,
EuiLink,
EuiText,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -61,9 +57,6 @@ export const AlertPreview: React.FC<Props> = (props) => {
const [previewResult, setPreviewResult] = useState<
(AlertPreviewSuccessResponsePayload & Record<string, any>) | null
>(null);
const [isErrorModalVisible, setIsErrorModalVisible] = useState<boolean>(false);
const onOpenModal = useCallback(() => setIsErrorModalVisible(true), [setIsErrorModalVisible]);
const onCloseModal = useCallback(() => setIsErrorModalVisible(false), [setIsErrorModalVisible]);

const onSelectPreviewLookbackInterval = useCallback((e) => {
setPreviewLookbackInterval(e.target.value);
Expand Down Expand Up @@ -271,33 +264,32 @@ export const AlertPreview: React.FC<Props> = (props) => {
iconType="alert"
>
{previewError.body && (
<FormattedMessage
id="xpack.infra.metrics.alertFlyout.alertPreviewErrorDesc"
defaultMessage="Try again later, or {viewTheError}."
values={{
viewTheError: <EuiLink onClick={onOpenModal}>view the error</EuiLink>,
}}
/>
<>
<FormattedMessage
id="xpack.infra.metrics.alertFlyout.alertPreviewErrorDesc"
defaultMessage="Please try again later or see details for more information."
/>
<EuiSpacer size={'s'} />
<EuiAccordion
id="alertErrorDetailsAccordion"
buttonContent={
<>
<EuiText size="s">
<FormattedMessage
id="xpack.infra.metrics.alertFlyout.errorDetails"
defaultMessage="Details"
/>
</EuiText>
</>
}
>
<EuiSpacer size={'s'} />
<EuiCodeBlock>{previewError.body.message}</EuiCodeBlock>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add <EuiSpacer size={'s'} /> before the codeblock so that there is space between the codeblock and accordion toggle. You may need to wrap this in a fragment.

</EuiAccordion>
</>
)}
</EuiCallOut>
)}
{isErrorModalVisible && (
<EuiOverlayMask>
<EuiModal onClose={onCloseModal}>
<EuiModalHeader>
<EuiModalHeaderTitle>
<FormattedMessage
id="xpack.infra.metrics.alertFlyout.alertPreviewErrorModalTitle"
defaultMessage="Alert preview error"
/>
</EuiModalHeaderTitle>
</EuiModalHeader>
<EuiModalBody>
<EuiCodeBlock>{previewError.body.message}</EuiCodeBlock>
</EuiModalBody>
</EuiModal>
</EuiOverlayMask>
)}
</>
)}
</>
Expand Down