-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add ODD modal for incompatible modules
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
Showing
11 changed files
with
546 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/src/organisms/IncompatibleModuleModal/IncompatibleModuleModalBody.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
) | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/organisms/IncompatibleModuleModal/IncompatibleModuleTakeover.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / js checks
|
||
import capitalize from 'lodash/capitalize' | ||
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} | ||
</> | ||
) | ||
} |
Oops, something went wrong.