Skip to content

Commit

Permalink
WIP odd run commands list
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Aug 6, 2024
1 parent 4d8b384 commit 130750f
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 8 deletions.
8 changes: 2 additions & 6 deletions app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { useDownloadRunLog } from '../hooks'

import type { RunError, RunCommandErrors } from '@opentrons/api-client'
import type { LegacyModalProps } from '../../../molecules/LegacyModal'
import { RunCommandError } from '@opentrons/shared-data'

/**
* This modal is for Desktop app
Expand Down Expand Up @@ -126,17 +125,14 @@ export function RunFailedModal({
{commandErrorList?.pageLength} errors
</LegacyStyledText>
<Flex css={ERROR_MESSAGE_STYLE}>
{commandErrorList?.data.map((error: RunCommandError, index) => {
{commandErrorList?.data.map((error: RunError, index) => {
return (
<LegacyStyledText
as="p"
textAlign={TYPOGRAPHY.textAlignLeft}
key={index}
>
{t('error_info', {
errorCode: error.errorCode,
errorType: error.detail
})}
{error.errorCode}: {error.detail}
</LegacyStyledText>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,27 @@ import { SmallButton } from '../../../atoms/buttons'
import { Modal } from '../../../molecules/Modal'

import type { ModalHeaderBaseProps } from '../../../molecules/Modal/types'
import type { RunError } from '@opentrons/api-client'
import type { RunCommandErrors, RunError } from '@opentrons/api-client'

interface RunFailedModalProps {
runId: string
setShowRunFailedModal: (showRunFailedModal: boolean) => void
errors?: RunError[]
commandErrorList?: RunCommandErrors
}

export function RunFailedModal({
runId,
setShowRunFailedModal,
errors,
commandErrorList
}: RunFailedModalProps): JSX.Element | null {
const { t, i18n } = useTranslation(['run_details', 'shared', 'branded'])
const navigate = useNavigate()
const { stopRun } = useStopRunMutation()
const [isCanceling, setIsCanceling] = React.useState(false)

if (errors == null || errors.length === 0) return null
if ((errors == null || errors.length === 0) && (commandErrorList == null || commandErrorList.data.length === 0)) return null
const modalHeader: ModalHeaderBaseProps = {
title: t('run_failed_modal_title'),
}
Expand All @@ -60,6 +62,10 @@ export function RunFailedModal({
},
})
}
if (
highestPriorityError != null &&
(commandErrorList == null || commandErrorList?.data?.length === 0)
) {
return (
<Modal
header={modalHeader}
Expand Down Expand Up @@ -122,6 +128,70 @@ export function RunFailedModal({
</Modal>
)
}
else{
return (
<Modal
header={modalHeader}
onOutsideClick={() => {
setShowRunFailedModal(false)
}}
>
<Flex
flexDirection={DIRECTION_COLUMN}
gridGap={SPACING.spacing40}
width="100%"
css={css`
word-break: break-all;
`}
>
<Flex
flexDirection={DIRECTION_COLUMN}
gridGap={SPACING.spacing16}
alignItems={ALIGN_FLEX_START}
>
<LegacyStyledText as="p" fontWeight={TYPOGRAPHY.fontWeightBold}>
{commandErrorList?.pageLength} errors
</LegacyStyledText>
<Flex
width="100%"
flexDirection={DIRECTION_COLUMN}
gridGap={SPACING.spacing8}
maxHeight="11rem"
backgroundColor={COLORS.grey35}
borderRadius={BORDERS.borderRadius8}
padding={`${SPACING.spacing16} ${SPACING.spacing20}`}
>
<Flex flexDirection={DIRECTION_COLUMN} css={SCROLL_BAR_STYLE}>
{commandErrorList?.data.map((error: RunError, index) => {
return (
<LegacyStyledText as="p" textAlign={TYPOGRAPHY.textAlignLeft} key={index}>
{error.errorCode}: {error.detail}
</LegacyStyledText>
)})}
</Flex>
</Flex>
<LegacyStyledText
as="p"
textAlign={TYPOGRAPHY.textAlignLeft}
css={css`
word-break: break-word;
`}
>
{t('branded:contact_information')}
</LegacyStyledText>
</Flex>
<SmallButton
width="100%"
buttonType="alert"
buttonText={i18n.format(t('shared:close'), 'capitalize')}
onClick={handleClose}
disabled={isCanceling}
/>
</Flex>
</Modal>
)
}
}

const SCROLL_BAR_STYLE = css`
overflow-y: ${OVERFLOW_AUTO};
Expand Down
10 changes: 10 additions & 0 deletions app/src/pages/RunSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
useProtocolQuery,
useInstrumentsQuery,
useDeleteRunMutation,
useAllRunCommandErrorsQuery,
} from '@opentrons/react-api-client'

import { LargeButton } from '../../atoms/buttons'
Expand Down Expand Up @@ -145,6 +146,14 @@ export function RunSummary(): JSX.Element {
localRobot?.serverHealth?.serialNumber ??
null

const { data: commandErrorList } = useAllRunCommandErrorsQuery(runId, null, {
enabled:
runStatus != null &&
// @ts-expect-error runStatus expected to possibly not be terminal
RUN_STATUSES_TERMINAL.includes(runStatus) &&
isRunCurrent,
})

let headerText = t('run_complete_splash')
if (runStatus === RUN_STATUS_FAILED) {
headerText = t('run_failed_splash')
Expand Down Expand Up @@ -321,6 +330,7 @@ export function RunSummary(): JSX.Element {
runId={runId}
setShowRunFailedModal={setShowRunFailedModal}
errors={runRecord?.data.errors}
commandErrorList={commandErrorList}
/>
) : null}
<Flex
Expand Down

0 comments on commit 130750f

Please sign in to comment.