Skip to content

Commit

Permalink
feat(app): add ODD modal for incompatible modules
Browse files Browse the repository at this point in the history
This is a blocking modal takeover that pops when you have incompatible
modules (as determined by the machine) connected to your flex, and goes
away when you remove them.

Closes RSQ-6
  • Loading branch information
sfoster1 committed May 6, 2024
1 parent 1e55300 commit 289e32a
Show file tree
Hide file tree
Showing 11 changed files with 546 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/src/App/OnDeviceDisplayApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { OnDeviceLocalizationProvider } from '../LocalizationProvider'
import { ToasterOven } from '../organisms/ToasterOven'
import { MaintenanceRunTakeover } from '../organisms/TakeoverModal'
import { FirmwareUpdateTakeover } from '../organisms/FirmwareUpdateModal/FirmwareUpdateTakeover'
import { IncompatibleModuleTakeover } from '../organisms/IncompatibleModuleModal/IncompatibleModuleTakeover'
import { EstopTakeover } from '../organisms/EmergencyStop'
import { ConnectViaEthernet } from '../pages/ConnectViaEthernet'
import { ConnectViaUSB } from '../pages/ConnectViaUSB'
Expand Down Expand Up @@ -179,6 +180,7 @@ export const OnDeviceDisplayApp = (): JSX.Element => {
) : (
<>
<EstopTakeover />
<IncompatibleModuleTakeover />
<MaintenanceRunTakeover>
<FirmwareUpdateTakeover />
<NiceModal.Provider>
Expand Down
4 changes: 4 additions & 0 deletions app/src/assets/localization/en/incompatible_modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"incompatible_modules_attached": "incompatible module detected",
"remove_before_running_protocol": "Remove the following hardware before running a protocol:"
}
2 changes: 2 additions & 0 deletions app/src/assets/localization/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import robot_controls from './robot_controls.json'
import run_details from './run_details.json'
import top_navigation from './top_navigation.json'
import error_recovery from './error_recovery.json'
import incompatible_modules from './incompatible_modules.json'

export const en = {
shared,
Expand Down Expand Up @@ -58,4 +59,5 @@ export const en = {
run_details,
top_navigation,
error_recovery,
incompatible_modules,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as React from 'react'
import { useTranslation, Trans } from 'react-i18next'
import capitalize from 'lodash/capitalize'
import {
DIRECTION_COLUMN,
Flex,
SPACING,
StyledText,
TYPOGRAPHY,
OVERFLOW_SCROLL,

} from '@opentrons/components'
import {
getModuleDisplayName
} from '@opentrons/shared-data'
import type { AttachedModule } from '@opentrons/api-client'
import { Modal } from '../../molecules/Modal'
import { ListItem } from '../../atoms/ListItem'
import type { ModalHeaderBaseProps } from '../../molecules/Modal/types'

export interface IncompatibleModuleModalBodyProps {
modules: AttachedModule[]
}

export function IncompatibleModuleModalBody(
props: IncompatibleModuleModalBodyProps
): JSX.Element {
const { t } = useTranslation('incompatible_modules')
const incompatibleModuleHeader: ModalHeaderBaseProps = {
title: capitalize(t('incompatible_modules_attached')),
}
const { modules } = props
return (
<Modal header={incompatibleModuleHeader}>
<Flex flexDirection={DIRECTION_COLUMN} width="100%">
<StyledText as="p" marginBottom={SPACING.spacing32} >
<Trans t={t} i18nKey="remove_before_running_protocol" />
</StyledText>
<Flex overflowY={OVERFLOW_SCROLL} flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing8} maxHeight='196px'>
{...modules.map(module => (
<ListItem key={module.id} type="noActive">
<StyledText as="p" key={module.id} fontWeight={TYPOGRAPHY.fontWeightSemiBold}>
{getModuleDisplayName(module.moduleModel)}
</StyledText>
</ListItem>
))}
</Flex>
</Flex>
</Modal>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as React from 'react'
import { createPortal } from 'react-dom'
import { useTranslation, Trans } from 'react-i18next'

Check failure on line 3 in app/src/organisms/IncompatibleModuleModal/IncompatibleModuleTakeover.tsx

View workflow job for this annotation

GitHub Actions / js checks

'useTranslation' is defined but never used

Check failure on line 3 in app/src/organisms/IncompatibleModuleModal/IncompatibleModuleTakeover.tsx

View workflow job for this annotation

GitHub Actions / js checks

'Trans' is defined but never used
import capitalize from 'lodash/capitalize'

Check failure on line 4 in app/src/organisms/IncompatibleModuleModal/IncompatibleModuleTakeover.tsx

View workflow job for this annotation

GitHub Actions / js checks

'capitalize' is defined but never used
import { IncompatibleModuleModalBody } from './IncompatibleModuleModalBody'
import { getTopPortalEl } from '../../App/portal'
import { useIncompatibleModulesAttached } from './hooks'

const POLL_INTERVAL_MS = 5000

export function IncompatibleModuleTakeover(): JSX.Element {
const incompatibleModules = useIncompatibleModulesAttached({
refetchInterval: POLL_INTERVAL_MS,
})
return (
<>
{incompatibleModules.length !== 0
? createPortal(
<IncompatibleModuleModalBody modules={incompatibleModules} />,
getTopPortalEl()
)
: null}
</>
)
}
Loading

0 comments on commit 289e32a

Please sign in to comment.