Skip to content

Commit

Permalink
Update use_response_actions_log_table.tsx
Browse files Browse the repository at this point in the history
review change (@dasansol92)
  • Loading branch information
ashokaditya committed Oct 28, 2022
1 parent e67bf36 commit be87496
Showing 1 changed file with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,35 @@ export const useResponseActionsLogTable = ({
};
});

const getOutputContent = () => {
if (isExpired) {
return OUTPUT_MESSAGES.hasExpired(command);
}

if (!isCompleted) {
return OUTPUT_MESSAGES.isPending(command);
}

if (!wasSuccessful) {
return OUTPUT_MESSAGES.hasFailed(command);
}

if (!isGetFileCommand) {
return OUTPUT_MESSAGES.wasSuccessful(command);
} else {
return (
<>
{OUTPUT_MESSAGES.wasSuccessful(command)}
<ResponseActionFileDownloadLink
action={item}
textSize="xs"
data-test-subj={getTestId('getFileDownloadLink')}
/>
</>
);
}
};

const outputList = [
{
title: (
Expand All @@ -179,28 +208,7 @@ export const useResponseActionsLogTable = ({
description: (
// codeblock for output
<StyledEuiCodeBlock data-test-subj={getTestId('details-tray-output')}>
{isExpired ? (
OUTPUT_MESSAGES.hasExpired(command)
) : isCompleted ? (
wasSuccessful ? (
isGetFileCommand ? (
<>
{OUTPUT_MESSAGES.wasSuccessful(command)}
<ResponseActionFileDownloadLink
action={item}
textSize="xs"
data-test-subj={getTestId('getFileDownloadLink')}
/>
</>
) : (
OUTPUT_MESSAGES.wasSuccessful(command)
)
) : (
OUTPUT_MESSAGES.hasFailed(command)
)
) : (
OUTPUT_MESSAGES.isPending(command)
)}
{getOutputContent()}
</StyledEuiCodeBlock>
),
},
Expand Down

0 comments on commit be87496

Please sign in to comment.