Skip to content

Commit

Permalink
include dismissed warning data in file
Browse files Browse the repository at this point in the history
  • Loading branch information
IanLondon committed Jul 2, 2018
1 parent bdc1d90 commit 40b0288
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
12 changes: 9 additions & 3 deletions protocol-designer/src/dismiss/selectors.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
// @flow
import {createSelector} from 'reselect'
import {selectors as fileDataSelectors} from '../file-data'

// TODO: Ian 2018-07-02 split apart file-data concerns to avoid circular dependencies
// Eg, right now if you import {selectors as fileDataSelectors} from '../file-data',
// PD won't start, b/c of circular dependency when fileData/selectors/fileCreator
// imports getDismissedWarnings selector from 'dismiss/
import {warningsPerStep} from '../file-data/selectors/commands'

import {selectors as steplistSelectors} from '../steplist'
import type {BaseState, Selector} from '../types'
import type {CommandCreatorWarning} from '../step-generation'
import type {RootState, DismissedWarningState} from './reducers'

export const rootSelector = (state: BaseState): RootState => state.dismiss

const getDismissedWarnings: Selector<DismissedWarningState> = createSelector(
export const getDismissedWarnings: Selector<DismissedWarningState> = createSelector(
rootSelector,
s => s.dismissedWarnings
)
Expand All @@ -17,7 +23,7 @@ type WarningsPerStep = {[stepId: string | number]: Array<CommandCreatorWarning>}
/** Non-dismissed warnings for each step */
export const getVisibleWarningsPerStep: Selector<WarningsPerStep> = createSelector(
getDismissedWarnings,
fileDataSelectors.warningsPerStep,
warningsPerStep,
steplistSelectors.orderedSteps,
(dismissedWarnings, warningsPerStep, orderedSteps) => {
return orderedSteps.reduce(
Expand Down
5 changes: 4 additions & 1 deletion protocol-designer/src/file-data/selectors/fileCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {createSelector} from 'reselect'
import mapValues from 'lodash/mapValues'
import {fileMetadata} from './fileFields'
import {getInitialRobotState, robotStateTimeline} from './commands'
import {selectors as dismissSelectors} from '../../dismiss'
import {selectors as ingredSelectors} from '../../labware-ingred/reducers'
import {selectors as steplistSelectors} from '../../steplist/reducers'
import type {BaseState} from '../../types'
Expand All @@ -17,6 +18,7 @@ export const createFile: BaseState => ProtocolFile = createSelector(
fileMetadata,
getInitialRobotState,
robotStateTimeline,
dismissSelectors.getDismissedWarnings,
ingredSelectors.getIngredientGroups,
ingredSelectors.getIngredientLocations,
steplistSelectors.getSavedForms,
Expand All @@ -25,6 +27,7 @@ export const createFile: BaseState => ProtocolFile = createSelector(
fileMetadata,
initialRobotState,
_robotStateTimeline,
dismissedWarnings,
ingredients,
ingredLocations,
savedStepForms,
Expand Down Expand Up @@ -73,7 +76,7 @@ export const createFile: BaseState => ProtocolFile = createSelector(
initialRobotState.instruments,
(p: PipetteData): ?string => p.tiprackModel
),
// TODO IMMEDIATELY add dismissedWarnings after PR merge & rebase
dismissedWarnings,
ingredients,
ingredLocations,
savedStepForms,
Expand Down
5 changes: 3 additions & 2 deletions protocol-designer/src/file-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {DeckSlot, Mount} from '@opentrons/components'
import type {Command} from './step-generation/types'
import type {RootState as IngredRoot} from './labware-ingred/reducers'
import type {RootState as StepformRoot} from './steplist/reducers'
import type {RootState as DismissRoot} from './dismiss'

type MsSinceEpoch = number
type VersionString = string // eg '1.0.0'
Expand Down Expand Up @@ -41,11 +42,11 @@ export type ProtocolFile = {
// pipetteId to tiprackModel. may be unassigned
pipetteTiprackAssignments: {[pipetteId: string]: ?string},

dismissedWarnings: $PropertyType<DismissRoot, 'dismissedWarnings'>,

ingredients: $PropertyType<IngredRoot, 'ingredients'>,
ingredLocations: $PropertyType<IngredRoot, 'ingredLocations'>,

// dismissedWarnings: $PropertyType<DismissedRoot, 'dismissedWarnings'> // TODO IMMEDIATELY merge dismissed

savedStepForms: $PropertyType<StepformRoot, 'savedStepForms'>,
orderedSteps: $PropertyType<StepformRoot, 'orderedSteps'>
}
Expand Down

0 comments on commit 40b0288

Please sign in to comment.