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

feat(app): usb connection and moam modal functionality in module setup #8257

Merged
merged 39 commits into from
Sep 3, 2021

Conversation

jerader
Copy link
Collaborator

@jerader jerader commented Aug 25, 2021

Overview

Closes ticket #8233

Changelog

  • add usb connection and connection status to module setup
  • add functionality to Proceed to Labware Setup CTA
  • add correct functionality to Multiple of a module (MoaM) modal to only show up if MoaM are in the uploaded protocol
  • address Emily's comment mentioned on PR feat(app): add module setup step to protocol setup #8224

Review requests

Risk assessment

low, below FF

@jerader jerader added the app Affects the `app` project label Aug 25, 2021
@codecov
Copy link

codecov bot commented Aug 25, 2021

Codecov Report

Merging #8257 (e8334fb) into edge (9d4274c) will increase coverage by 0.02%.
The diff coverage is 83.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge    #8257      +/-   ##
==========================================
+ Coverage   74.84%   74.86%   +0.02%     
==========================================
  Files        1680     1680              
  Lines       44642    44687      +45     
  Branches     4494     4515      +21     
==========================================
+ Hits        33414    33457      +43     
+ Misses      10465    10459       -6     
- Partials      763      771       +8     
Flag Coverage Δ
app 71.11% <83.01%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...s/ProtocolSetup/RunSetupCard/ModuleSetup/index.tsx 76.19% <77.14%> (-0.74%) ⬇️
...src/organisms/ProtocolSetup/RunSetupCard/index.tsx 90.90% <85.71%> (-4.33%) ⬇️
...tocolSetup/RunSetupCard/ModuleSetup/ModuleInfo.tsx 100.00% <100.00%> (+83.33%) ⬆️
...src/pages/Calibrate/CalibratePanel/PipetteList.tsx 83.87% <0.00%> (-0.75%) ⬇️
.../RunSetupCard/ModuleSetup/MultipleModulesModal.tsx 100.00% <0.00%> (+50.00%) ⬆️

@jerader jerader marked this pull request as ready for review August 26, 2021 13:51
@jerader jerader requested a review from a team as a code owner August 26, 2021 13:51
@jerader jerader requested review from b-cooper, shlokamin, smb2268 and emilywools and removed request for a team August 26, 2021 13:51
Copy link
Member

@shlokamin shlokamin left a comment

Choose a reason for hiding this comment

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

coming along!

i think your ModuleInfo tests need a bit of rework. i'd start by thinking about what exactly ModuleInfo's job is, and then craft your test cases from there. i.e. it('should display a warning icon when modules are not attached')

Comment on lines 28 to 29
"module_setup_step_description": "Plug in and power up the required module via the OT-2 USB Port. Place the module as shown in the deck map.",
"modules_setup_step_description": "Plug in and power up the required modules via the OT-2 USB Ports. Place the modules as shown in the deck map.",
Copy link
Member

Choose a reason for hiding this comment

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

do we need both of these?

Copy link
Member

Choose a reason for hiding this comment

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

if the extra is needed to pluralize, i18n can handle that for us i think: https://www.i18next.com/translation-function/plurals

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is something that Emily wanted to implement. She mentioned it in a comment on my last PR #8224

"no_usb_port_yet": "No USB Port Yet",
"usb_port_connected": "USB Port",
"hub_connected": "via hub",
"usb_port_connected_old": "USB Port Connected"
Copy link
Member

Choose a reason for hiding this comment

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

usb_port_connected_old makes this seem like we don't need it anymore. what is its purpose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If your robot server version is below 4.3, the usb and hub ports don't have a string (I double checked with my robot when it was version 4.0). So usb_port_connected_old is to support that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe making this title more descriptive, something like usb_port_connected_old_server_version could make this more clear

Comment on lines 140 to 146
<g>
<LabwareInfoOverlay
x={x}
y={y}
definition={labwareDef}
/>
</g>
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason you added a g tag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

whoops. idk how this got added back. removing it now.

Comment on lines 164 to 172
backgroundColor={C_BLUE}
{...linkProps}
{...targetProps}
backgroundColor={C_BLUE}
Copy link
Member

Choose a reason for hiding this comment

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

how come you switched this ordering?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

some weirdness probably occurred when i rebased this to my last PR. i'll change it back 😬

Comment on lines 35 to 39
export const ModuleInfo = (props: ModuleInfoProps): JSX.Element => {
const { x, y, orientation, moduleModel } = props
export function ModuleInfo(props: ModuleInfoProps): JSX.Element {
const { x, y, orientation, moduleModel, usbPort, hubPort, isAttached } = props
Copy link
Member

Choose a reason for hiding this comment

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

how come you changed this from a function expression to a function declaration? we normally stick to function expressions when we can

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function

import { ModuleInfo } from '../ModuleInfo'
import { when } from 'jest-when'

jest.mock('../ModuleInfo')
Copy link
Member

Choose a reason for hiding this comment

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

this test should be testing ModuleInfo right? we don't actually want to mock it, we only want to mock the dependencies of ModuleInfo that we need to

}
})

it('should render no modules connected', () => {
Copy link
Member

Choose a reason for hiding this comment

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

this test isn't actually making any assertion, so it will always pass. what should module info be actually be doing?

the test name says it should not render any modules, but i dont think the ModuleInfo component has any concept of "modules", it just takes in info about a particular module and then renders some text and an icon depending on that info it loooks like

}
})

it('should render modules connected on a robot server 4.3 or higher', () => {
Copy link
Member

Choose a reason for hiding this comment

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

same deal here, this test isn't making any assertions

Comment on lines 136 to 172
<ModuleViz
x={x}
y={y}
orientation={orientation}
moduleType={getModuleType(moduleModel)}
/>
<ModuleInfo
x={x}
y={y}
moduleModel={moduleModel}
orientation={orientation}
isAttached={attached}
usbPort={null}
hubPort={null}
/>
</React.Fragment>
) : (
<React.Fragment
key={`LabwareSetup_Module_${moduleModel}_${x}${y}`}
>
<ModuleViz
x={x}
y={y}
orientation={orientation}
moduleType={getModuleType(moduleModel)}
/>
<ModuleInfo
x={x}
y={y}
moduleModel={moduleModel}
orientation={orientation}
isAttached={attached}
usbPort={null}
hubPort={null}
/>
</React.Fragment>
Copy link
Member

Choose a reason for hiding this comment

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

same comment earlier about conditionally rendering Icon twice, you can render these components once and change what props you pass in depending on whether modulesByPort is empty or not

const ROBOT_CALIBRATION_STEP_KEY = 'robot_calibration_step' as const
const LABWARE_SETUP_KEY = 'labware_setup_step' as const

let MODULE_SETUP_KEY = 'module_setup_step'
Copy link
Member

Choose a reason for hiding this comment

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

how come this isn't a const too?

@jerader jerader force-pushed the app_module-usb-connection-step branch from 7fc52de to 2c3581f Compare August 30, 2021 13:38
@emilywools
Copy link

hey Jethary! looking good! Here are some things I noticed:

  1. can you add a space between the end of the sentence and the link in the MoaM modal:?

Screen Shot 2021-08-30 at 1 25 52 PM

2. the green successfully connected icon should have a check mark in it instead of a ! 3. The two temp modules are overlapping each other a little bit. Will this be resolved when we have the SVGs?

Screen Shot 2021-08-30 at 1 29 00 PM

@jerader
Copy link
Collaborator Author

jerader commented Aug 30, 2021

@emilywools - this will be fixed when we have the SVGs 😄

  1. The two temp modules are overlapping each other a little bit. Will this be resolved when we have the SVGs?
Screen Shot 2021-08-30 at 1 29 00 PM

Copy link

@emilywools emilywools left a comment

Choose a reason for hiding this comment

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

sounds good! looks good to me

@jerader jerader requested a review from shlokamin August 31, 2021 13:02
Copy link
Contributor

@smb2268 smb2268 left a comment

Choose a reason for hiding this comment

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

Looking really good overall, Jethary! I l just left a few comments that can help DRY things up.

expandLabwareSetupStep: () => void
}
import type { State, Dispatch } from '../../../../redux/types'
import type { AttachedModule } from '../../../../redux/modules/types'
Copy link
Contributor

Choose a reason for hiding this comment

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

Pasting a comment Shlok left on my PR since it's relevant here and he explained it well! #8182 (comment):

nit: we unfortunately have a pattern of imports we follow that is not enforced by a linter
basically we usually do

  1. Builtin Node.js modules (import fs from 'fs')
  2. External npm modules (import * as React from 'react')
  3. Opentrons modules (import { THERMOCYCLER } from '@opentrons/shared-data')
  4. Parent relative modules (import { SomeParentComponent } from '../../parent')
  5. Sibling relative modules (import { SomeSiblingComponent } from './sibling')
  6. type imports (import type {Whatever} from './types')

"no_usb_port_yet": "No USB Port Yet",
"usb_port_connected": "USB Port",
"hub_connected": "via hub",
"usb_port_connected_old": "USB Port Connected"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe making this title more descriptive, something like usb_port_connected_old_server_version could make this more clear

hubPort={null}
/>
</React.Fragment>
) : (
Copy link
Contributor

Choose a reason for hiding this comment

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

There aren't any differences between what you're returning here if attached is true vs false. If the variation between them is handled with different prop inputs than you can remove this ternary!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

omg that ternary is for no reason, thank you for noticing this!

moduleModel={moduleModel}
orientation={orientation}
isAttached={attached}
usbPort={port}
Copy link
Contributor

Choose a reason for hiding this comment

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

For this ternary, it looks like the only difference between having attached be true or false is what you're passing for usbPort. To make this DRY you can remove the larger ternary and do this instead:

<React.Fragment
  key={`LabwareSetup_Module_${moduleModel}_${x}${y}`}
>
  <ModuleViz
    x={x}
    y={y}
    orientation={orientation}
    moduleType={getModuleType(moduleModel)}
  />
  <ModuleInfo
    x={x}
    y={y}
    moduleModel={moduleModel}
    orientation={orientation}
    isAttached={attached}
    usbPort={attached === true ? port : null}
    hubPort={attached === true ? port : null}
  />
</React.Fragment>

orientation={orientation}
isAttached={attached}
usbPort={port}
hubPort={port}
Copy link
Contributor

@smb2268 smb2268 Sep 1, 2021

Choose a reason for hiding this comment

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

I'm not familiar with usbPort vs hubPort - we're passing in the string port for both, are they always the same thing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On the robot, there are 2 or 4 usb ports (depending on if you have the OT-2 or the OT-2-R) If your robot has 2 usb ports which is the more common robot of the 2 and if you need to connect all 3 modules, you'll need to connect a hub that has more usb ports attached to it. port is the same in my code because your module is either connected via usb or hub and const port = module.usbPort.hub || module.usbPort.port. Hope this clears things up!

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha yes that makes sense - thanks for explaining!!

Copy link
Contributor

@smb2268 smb2268 left a comment

Choose a reason for hiding this comment

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

lgtm! 🚀

@jerader jerader dismissed shlokamin’s stale review September 1, 2021 18:13

Shlok is OOO for a few weeks and I got other dev reviews

Copy link
Contributor

@b-cooper b-cooper left a comment

Choose a reason for hiding this comment

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

🚢

@jerader jerader merged commit da516da into edge Sep 3, 2021
@jerader jerader deleted the app_module-usb-connection-step branch September 3, 2021 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Affects the `app` project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants