Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): refactor Flex pipette card to reference /instruments #14702

Merged
merged 4 commits into from
Mar 26, 2024

Conversation

smb2268
Copy link
Contributor

@smb2268 smb2268 commented Mar 20, 2024

fix RQA-2433

Overview

Currently, the pipette cards on the desktop app for Flex reference /pipettes while those on ODD reference /instruments. This has caused confusion because occasionally the pipettes would be visible on desktop but not ODD. Seth made a change in #14608 that makes the /instruments response report cached data like /pipettes does, which should have eliminated this discrepancy. This PR ensures that by using /instruments as the one source of truth for pipettes on Flex.

Test Plan

Smoke test pipette cards and all possible overflow menu actions for both Flex and OT-2 pipettes. This includes OT-2 pipette settings, attach, detach, and calibrate flows, drop tip wizard, and the about pipette menu.

Changelog

  1. Create new FlexPipetteCard and pull all Flex specific logic out of PipetteCard into here.
  2. Cleanup PipetteCard and PipetteOverflowMenu, removing all Flex logic which has been moved to FlexPipetteCard and some leftover OT-2 calibration logic that is no longer used since we only allow pipette cal from the calibration dashboard now.
  3. From InstrumentsAndModules only enable usePipettesQuery for OT-2 and useInstrumentsQuery for Flex. Display PipetteCard or FlexPipetteCard accordingly.
  4. Update all tests, refactoring some logic to bring them in line with our vitest best practices

Review requests

Look through the code - did I miss anything? And test this out if you can!

Risk assessment

Medium

@smb2268 smb2268 requested a review from a team as a code owner March 20, 2024 18:09
@smb2268 smb2268 requested review from brenthagen, jerader, ncdiehl11, sfoster1 and b-cooper and removed request for a team March 20, 2024 18:09
@smb2268 smb2268 self-assigned this Mar 20, 2024
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me!

transformOrigin="20% -10%"
/>
<Flex
alignItems={ALIGN_CENTER}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a separate bug, right? Like it's logically equivalent with the new transformOrigin at the standard viewpoint size, but it reflows better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this code wasn't hit previously because we weren't using InstrumentCard for pipettes - so I pulled the logic from what was actually being hit which lived here https://github.com/Opentrons/opentrons/blame/edge/app/src/organisms/Devices/PipetteCard/index.tsx#L261 and was recently updated by Nick to fix a styling bug

isEstopNotDisengaged,
}: FlexPipetteCardProps): JSX.Element {
const { t, i18n } = useTranslation(['device_details', 'shared'])
const host = useHost() as HostConfig
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to type this? isn't host already type HostConfig?

// this gives the instruments endpoint time to start reporting
// a good instrument
React.useEffect(() => {
if (attachedPipette?.ok === false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
if (attachedPipette?.ok === false) {
if (!attachedPipette?.ok) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be explicit -- we don't want to enter this if statement if attachedPipette is null or undefined, only if it does exist and ok is false

import { DropTipWizard } from '../../../DropTipWizard'

import type { PipetteData } from '@opentrons/api-client'
import { mockLeftSpecs } from '../../../../redux/pipettes/__fixtures__'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import can go higher

pipetteSpecs={pipetteModelSpecs}
mount={mount}
transform="scale(0.3)"
transformOrigin={'20% 52%'}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
transformOrigin={'20% 52%'}
transformOrigin="20% 52%"

Comment on lines 262 to 270
{attachedPipette?.ok && showAboutPipetteSlideout && (
<AboutPipetteSlideout
pipetteId={attachedPipette.serialNumber}
pipetteName={pipetteDisplayName ?? attachedPipette.instrumentName}
firmwareVersion={attachedPipette.firmwareVersion}
isExpanded={showAboutPipetteSlideout}
onCloseClick={() => setShowAboutPipetteSlideout(false)}
/>
)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, to keep the same pattern for easier readability:

Suggested change
{attachedPipette?.ok && showAboutPipetteSlideout && (
<AboutPipetteSlideout
pipetteId={attachedPipette.serialNumber}
pipetteName={pipetteDisplayName ?? attachedPipette.instrumentName}
firmwareVersion={attachedPipette.firmwareVersion}
isExpanded={showAboutPipetteSlideout}
onCloseClick={() => setShowAboutPipetteSlideout(false)}
/>
)}
{attachedPipette?.ok && showAboutPipetteSlideout ? (
<AboutPipetteSlideout
pipetteId={attachedPipette.serialNumber}
pipetteName={pipetteDisplayName ?? attachedPipette.instrumentName}
firmwareVersion={attachedPipette.firmwareVersion}
isExpanded={showAboutPipetteSlideout}
onCloseClick={() => setShowAboutPipetteSlideout(false)}
/>
) : null}

Copy link
Collaborator

@jerader jerader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm, just left some cleanup comments

@smb2268 smb2268 force-pushed the app_instrument-card-refactor branch from 8454264 to 5292830 Compare March 26, 2024 14:13
@smb2268 smb2268 merged commit fa38226 into edge Mar 26, 2024
20 checks passed
@smb2268 smb2268 deleted the app_instrument-card-refactor branch March 26, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants