-
Notifications
You must be signed in to change notification settings - Fork 175
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
Conversation
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this 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')
"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.", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
<g> | ||
<LabwareInfoOverlay | ||
x={x} | ||
y={y} | ||
definition={labwareDef} | ||
/> | ||
</g> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
backgroundColor={C_BLUE} | ||
{...linkProps} | ||
{...targetProps} | ||
backgroundColor={C_BLUE} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😬
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 |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
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
<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> |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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?
7fc52de
to
2c3581f
Compare
hey Jethary! looking good! Here are some things I noticed:
|
@emilywools - this will be fixed when we have the SVGs 😄
|
There was a problem hiding this 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
There was a problem hiding this 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' |
There was a problem hiding this comment.
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
- Builtin Node.js modules (import fs from 'fs')
- External npm modules (import * as React from 'react')
- Opentrons modules (import { THERMOCYCLER } from '@opentrons/shared-data')
- Parent relative modules (import { SomeParentComponent } from '../../parent')
- Sibling relative modules (import { SomeSiblingComponent } from './sibling')
- 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" |
There was a problem hiding this comment.
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> | ||
) : ( |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! 🚀
Shlok is OOO for a few weeks and I got other dev reviews
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
Overview
Closes ticket #8233
Changelog
Proceed to Labware Setup
CTAReview requests
usbPort
info, if user has a robot where the server version is below 4.3, rather than displaying what port or hub number the module is connected by, it will sayUSB Port Connected
. Note: the Opentrons-dev bot does not have usbPort info so you should seeUSB Port Connected
.Risk assessment
low, below FF