Skip to content

Commit

Permalink
update to failure portion
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Sebastian <paulstn@amazon.com>
  • Loading branch information
paulstn committed Oct 18, 2023
1 parent c34d7f0 commit 102e158
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions public/components/QueryResults/async_query_body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { EuiFlexGroup, EuiText, EuiLoadingSpinner, EuiButton, EuiIcon } from '@elastic/eui';
import {
EuiFlexGroup,
EuiText,
EuiLoadingSpinner,
EuiButton,
EuiIcon,
EuiModal,
EuiModalBody,
EuiModalFooter,
EuiModalHeader,
EuiModalHeaderTitle,
} from '@elastic/eui';
import { AsyncQueryLoadingStatus } from '../../../common/types';
import React from 'react';
import React, { useState } from 'react';

interface AsyncQueryBodyProps {
asyncLoadingStatus: AsyncQueryLoadingStatus;
Expand All @@ -15,9 +26,28 @@ interface AsyncQueryBodyProps {

export function AsyncQueryBody(props: AsyncQueryBodyProps) {
const { asyncLoadingStatus, cancelAsyncQuery, asyncQueryError } = props;
const [isModalVisible, setIsModalVisible] = useState(false);

// TODO: implement query failure display
// TODO: implement query cancellation
const closeModal = () => setIsModalVisible(false);
const showModal = () => setIsModalVisible(true);

let modal;
if (isModalVisible) {
modal = (
<EuiModal onClose={closeModal}>
<EuiModalHeader>
<EuiModalHeaderTitle>Error</EuiModalHeaderTitle>
</EuiModalHeader>
<EuiModalBody>{asyncQueryError}</EuiModalBody>

<EuiModalFooter>
<EuiButton onClick={closeModal} fill>
Close
</EuiButton>
</EuiModalFooter>
</EuiModal>
);
}

return (
<EuiFlexGroup direction="column" alignItems="center">
Expand All @@ -27,15 +57,17 @@ export function AsyncQueryBody(props: AsyncQueryBodyProps) {
<EuiText>
<h3>Query failed</h3>
</EuiText>
<EuiText>error: {asyncQueryError}</EuiText>
<EuiText>The query failed to execute and the operation could not be complete.</EuiText>
<EuiButton onClick={() => showModal()}>View error details</EuiButton>
{modal}
</>
) : (
<>
<EuiLoadingSpinner size="l" />
<EuiText>
<h3>Query running</h3>
</EuiText>
<EuiText>status: {asyncLoadingStatus}</EuiText>
<EuiText>Status: {asyncLoadingStatus}</EuiText>
<EuiButton onClick={cancelAsyncQuery}>Cancel</EuiButton>
</>
)}
Expand Down

0 comments on commit 102e158

Please sign in to comment.