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): Show connect modules modal when session modules detected #1897

Merged
merged 5 commits into from
Jul 20, 2018

Conversation

Kadee80
Copy link
Contributor

@Kadee80 Kadee80 commented Jul 19, 2018

overview

This PR closes #1738 and checks of a few boxes in #1737

changelog

  • feat(app): Show connect modules modal when session modules detected
  • refactor(app): refactor app specific modal

review requests

Modal prompt will only show if modules flag is true: make dev OT_APP_MODULES=1

Modal Prompt will only show if state.robot.session.modulesBySlot contains SessionModule object(s)

  • To simulate modules required by the protocol:
    • Uncomment lines 344-351 in app/src/robot/api-client/client.js
  • To simulate modules actually attached:
    • Comment out line 113 in app/src/pages/Calibrate/Labware.js
    • Replace with const actualModules = [{name: 'magdeck'}] or {name: 'tempdeck'} or both

Expected behavior:

  • If modules are enabled and protocol requires module(s), module review modal shows
  • If actual modules do not match protocol modules, show a warning
    • Clicking the "Check for Modules" button sends a GET /modules
  • If actual modules are a superset of protocol modules, show a success
    • Clicking "Continue to Labware" takes you to the labware review modal

Todo in upcoming PR: show the deckmap in the module review modal

@Kadee80 Kadee80 added feature Ticket is a feature request / PR introduces a feature app Affects the `app` project labels Jul 19, 2018
@Kadee80 Kadee80 requested a review from mcous July 19, 2018 19:08
@codecov
Copy link

codecov bot commented Jul 19, 2018

Codecov Report

Merging #1897 into edge will decrease coverage by 0.1%.
The diff coverage is 15.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge    #1897      +/-   ##
==========================================
- Coverage   33.22%   33.12%   -0.11%     
==========================================
  Files         401      403       +2     
  Lines        6562     6588      +26     
==========================================
+ Hits         2180     2182       +2     
- Misses       4382     4406      +24
Impacted Files Coverage Δ
app/src/http-api-client/modules.js 100% <ø> (ø) ⬆️
app/src/components/modals/Modal.js 0% <ø> (ø)
...pp/src/components/CalibrateLabware/ConfirmModal.js 0% <ø> (ø) ⬆️
app/src/robot/reducer/session.js 100% <ø> (ø) ⬆️
app/src/components/ConnectModulesModal/Prompt.js 0% <0%> (ø)
app/src/components/ReviewDeckModal/index.js 0% <0%> (ø) ⬆️
app/src/pages/Calibrate/Pipettes.js 0% <0%> (ø) ⬆️
app/src/pages/Calibrate/Labware.js 0% <0%> (ø) ⬆️
app/src/components/modals/index.js 0% <0%> (ø) ⬆️
...mponents/InstrumentSettings/AttachedModulesCard.js 0% <0%> (ø) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cf1b4d...2b7eb3e. Read the comment docs.

Copy link
Contributor

@mcous mcous left a comment

Choose a reason for hiding this comment

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

Going to push fixups directly to this branch

export type StateModule = {
// resource ID
_id: number,
// slot module is installed in
slot: Slot,
// name identifier of the module
type: 'magdeck' | 'tempdeck',
name: ModuleType
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

}

// TODO (ka 2018-7-19): type this more specifically
function getNames (array: Array<any> | []): Array<string> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this work?

function getNames (array: ?Array<{name: string}>): Array<string> {

// TODO (ka 2018-7-19): type this more specifically
function getNames (array: Array<any> | []): Array<string> {
const names = array
? array.map((m) => { return m.name }).sort()
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer m => m.name to m => { return m.name } and also is the sort necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sort isnt neccesary, its left over from another half baked idea

return names
}

function compareNames (a: Array<StateModule>, b: Array<?Module> | null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the type for b be ?Array<Module>?

@@ -132,13 +132,15 @@ export type Labware = StateLabware & {

export type LabwareType = 'tiprack' | 'labware'

export type ModuleType = 'magdeck' | 'tempdeck'

export type StateModule = {
Copy link
Contributor

Choose a reason for hiding this comment

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

In hindsight, StateModule is a bad name. We should probably rename it to SessionModule

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renaming now

@@ -4,11 +4,11 @@ import type {Module} from '../../http-api-client'
import ModuleItem, {NoModulesMessage} from '../ModuleItem'

type Props = {
modules: Array<Module>,
modules: Array<?Module>,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be ?Array<Module>. If the array exists, it is definitely comprised of Modules, but the array may not exist.

(The type as written says the array definitely exists and is comprised of either Modules or null/undefineds)

@@ -21,7 +21,7 @@ export type Module = {
}

type FetchModulesResponse = {
modules: Array<Module>,
modules: Array<?Module>,
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is incorrect and should be reverted. The API will never respond with [..., null, ...]

modules: Array<StateModule>,
actualModules: ?Array<Module>,
actualModules: Array<?Module>,
Copy link
Contributor

Choose a reason for hiding this comment

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

?Array<Module>

Copy link
Contributor

@mcous mcous left a comment

Choose a reason for hiding this comment

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

🐇

@mcous
Copy link
Contributor

mcous commented Jul 20, 2018

Note that when we merge this: it does not close #1737 and the commit message should be amended accordingly. It does appear to close #1738

Copy link
Contributor

@IanLondon IanLondon left a comment

Choose a reason for hiding this comment

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

works! couldn't break it

displayName: 'Magnetic Bead Module'
}
]
// TODO(mc, 2018-07-19): remove this testing code when API returns modules
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is gonna be toggled in development for much longer, maybe it should be under a feature flag instead of commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats a good idea! We can do that in an upcoming PR. This ones already too big

@Kadee80 Kadee80 merged commit 8306130 into edge Jul 20, 2018
@mcous mcous deleted the app_review-modules-logic branch August 6, 2018 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Affects the `app` project feature Ticket is a feature request / PR introduces a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modules: Check for Module
3 participants