Skip to content

Commit

Permalink
banner colors and warnings/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Aug 8, 2024
1 parent 9bc4866 commit 5d20145
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
4 changes: 3 additions & 1 deletion app/src/assets/localization/en/run_details.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"end_step_time": "End",
"error_info": "Error {{errorCode}}: {{errorType}}",
"error_type": "Error: {{errorType}}",
"error_details": "Error details",
"failed_step": "Failed step",
"final_step": "Final Step",
"ignore_stored_data": "Ignore stored data",
Expand Down Expand Up @@ -144,5 +145,6 @@
"view_analysis_error_details": "View <errorLink>error details</errorLink>",
"view_current_step": "View current step",
"view_error": "View error",
"view_error_details": "View error details"
"view_error_details": "View error details",
"warning_details": "Warning details"
}
1 change: 0 additions & 1 deletion app/src/molecules/Modal/ModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function ModalHeader(props: ModalHeaderBaseProps): JSX.Element {
color={iconColor}
size="2rem"
alignSelf={ALIGN_CENTER}
marginRight={SPACING.spacing16}
/>
) : null}
<LegacyStyledText
Expand Down
25 changes: 15 additions & 10 deletions app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ export function ProtocolRunHeader({
setShowRunFailedModal={setShowRunFailedModal}
highestPriorityError={highestPriorityError}
commandErrorList={commandErrorList}
runStatus={runStatus}

Check failure on line 348 in app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx

View workflow job for this annotation

GitHub Actions / js checks

Type 'RunStatus | null' is not assignable to type 'RunStatus'.
/>
) : null}
<Flex
Expand Down Expand Up @@ -660,9 +661,8 @@ function ActionButton(props: ActionButtonProps): JSX.Element {
)
const [showIsShakingModal, setShowIsShakingModal] = React.useState(false)
const isSetupComplete =
isCalibrationComplete &&
isModuleCalibrationComplete &&
missingModuleIds.length === 0
// isCalibrationComplete &&
isModuleCalibrationComplete && missingModuleIds.length === 0
const isRobotOnWrongVersionOfSoftware = ['upgrade', 'downgrade'].includes(
useSelector((state: State) => {
return getRobotUpdateDisplayInfo(state, robotName)
Expand Down Expand Up @@ -899,7 +899,8 @@ function TerminalRunBanner(props: TerminalRunProps): JSX.Element | null {
isRunCurrent,
} = props
const { t } = useTranslation('run_details')

const completedWithErrors =
commandErrorList?.data != null && commandErrorList.data.length > 0
const handleRunSuccessClick = (): void => {
handleClearClick()
}
Expand All @@ -926,15 +927,20 @@ function TerminalRunBanner(props: TerminalRunProps): JSX.Element | null {

const buildErrorBanner = (): JSX.Element => {
return (
<Banner type="error" iconMarginLeft={SPACING.spacing4}>
<Banner
type={runStatus === RUN_STATUS_SUCCEEDED ? 'warning' : 'error'}
iconMarginLeft={SPACING.spacing4}
>
<Flex justifyContent={JUSTIFY_SPACE_BETWEEN} width="100%">
<LegacyStyledText>
{highestPriorityError != null
? t('error_info', {
errorType: highestPriorityError?.errorType,
errorCode: highestPriorityError?.errorCode,
})
: 'Run completed with errors.'}
: `Run completed with ${
runStatus === RUN_STATUS_SUCCEEDED ? 'warnings' : 'errors'
}.`}
</LegacyStyledText>

<LinkButton
Expand All @@ -951,14 +957,13 @@ function TerminalRunBanner(props: TerminalRunProps): JSX.Element | null {
if (
runStatus === RUN_STATUS_SUCCEEDED &&
isRunCurrent &&
!isResetRunLoading
!isResetRunLoading &&
!completedWithErrors
) {
return buildSuccessBanner()
} else if (
highestPriorityError != null ||
(commandErrorList?.data != null &&
commandErrorList.data.length > 0 &&
!isResetRunLoading)
(completedWithErrors && !isResetRunLoading)
) {
return buildErrorBanner()
} else {
Expand Down
13 changes: 11 additions & 2 deletions app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ import {
import { LegacyModal } from '../../../molecules/LegacyModal'
import { useDownloadRunLog } from '../hooks'

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

Expand All @@ -45,6 +50,7 @@ interface RunFailedModalProps {
setShowRunFailedModal: (showRunFailedModal: boolean) => void
highestPriorityError?: RunError | null
commandErrorList?: RunCommandErrors | null
runStatus: RunStatus
}

export function RunFailedModal({
Expand All @@ -53,13 +59,16 @@ export function RunFailedModal({
setShowRunFailedModal,
highestPriorityError,
commandErrorList,
runStatus,
}: RunFailedModalProps): JSX.Element | null {
const { i18n, t } = useTranslation(['run_details', 'shared', 'branded'])
const modalProps: LegacyModalProps = {
type: 'error',
type: runStatus === RUN_STATUS_SUCCEEDED ? 'warning' : 'error',
title:
commandErrorList == null || commandErrorList?.data.length === 0
? t('run_failed_modal_title')
: runStatus === RUN_STATUS_SUCCEEDED
? t('warning_details')
: t('error_details'),
onClose: () => {
setShowRunFailedModal(false)
Expand Down

0 comments on commit 5d20145

Please sign in to comment.