Skip to content

Commit

Permalink
refactor(protocol-designer): rename selectors to start with "get" (#2720
Browse files Browse the repository at this point in the history
)

Closes #2591
  • Loading branch information
IanLondon authored Nov 28, 2018
1 parent e3aaf58 commit 172b952
Show file tree
Hide file tree
Showing 57 changed files with 228 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default connect(mapStateToProps, null, mergeProps)(FileSidebar)
function mapStateToProps (state: BaseState): SP & MP {
const protocolName = fileDataSelectors.getFileMetadata(state)['protocol-name'] || 'untitled'
const fileData = fileDataSelectors.createFile(state)
const canDownload = selectors.currentPage(state) !== 'file-splash'
const canDownload = selectors.getCurrentPage(state) !== 'file-splash'

return {
downloadData: (canDownload)
Expand All @@ -34,8 +34,8 @@ function mapStateToProps (state: BaseState): SP & MP {
}
: null,
// Ignore clicking 'CREATE NEW' button in these cases
_canCreateNew: !selectors.newProtocolModal(state),
_hasUnsavedChanges: loadFileSelectors.hasUnsavedChanges(state),
_canCreateNew: !selectors.getNewProtocolModal(state),
_hasUnsavedChanges: loadFileSelectors.getHasUnsavedChanges(state),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type DP = {
type SP = $Diff<Props, DP> & {_labwareId: ?string}

function mapStateToProps (state: BaseState): SP {
const labwareData = labwareIngredSelectors.getSelectedContainer(state)
const labwareData = labwareIngredSelectors.getSelectedLabware(state)
assert(labwareData, 'Expected labware data to exist in connected labware details card')

const props = (labwareData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type SP = {
function mapStateToProps (state: BaseState): SP {
return {
slot: labwareIngredSelectors.selectedAddLabwareSlot(state) || null,
permittedTipracks: pipetteSelectors.permittedTipracks(state),
permittedTipracks: pipetteSelectors.getPermittedTipracks(state),
}
}

Expand Down
6 changes: 3 additions & 3 deletions protocol-designer/src/components/LiquidPlacementForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type SP = $Diff<Props, DP> & {
function mapStateToProps (state: BaseState): SP {
const selectedWells = Object.keys(wellSelectionSelectors.getSelectedWells(state))

const _labwareId = labwareIngredSelectors.getSelectedContainerId(state)
const liquidLocations = labwareIngredSelectors.getIngredientLocations(state)
const _labwareId = labwareIngredSelectors.getSelectedLabwareId(state)
const liquidLocations = labwareIngredSelectors.getLiquidsByLabwareId(state)
const _selectionHasLiquids = Boolean(
_labwareId &&
liquidLocations[_labwareId] &&
Expand All @@ -45,7 +45,7 @@ function mapStateToProps (state: BaseState): SP {
commonSelectedVolume: wellContentsSelectors.getSelectedWellsCommonVolume(state),
liquidSelectionOptions: labwareIngredSelectors.getLiquidSelectionOptions(state),
showForm: selectedWells.length > 0,
selectedWellsMaxVolume: wellContentsSelectors.selectedWellsMaxVolume(state),
selectedWellsMaxVolume: wellContentsSelectors.getSelectedWellsMaxVolume(state),

_labwareId,
_selectedWells: selectedWells,
Expand Down
6 changes: 3 additions & 3 deletions protocol-designer/src/components/LiquidPlacementModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class LiquidPlacementModal extends React.Component<Props, State> {
}

const mapStateToProps = (state: BaseState): SP => {
const containerId = selectors.getSelectedContainerId(state)
const containerId = selectors.getSelectedLabwareId(state)
const selectedWells = wellSelectionSelectors.getSelectedWells(state)
if (containerId === null) {
console.error('LiquidPlacementModal: No labware is selected, and no labwareId was given to LiquidPlacementModal')
Expand All @@ -83,11 +83,11 @@ const mapStateToProps = (state: BaseState): SP => {
}
}

const labware = selectors.getLabware(state)[containerId]
const labware = selectors.getLabwareById(state)[containerId]
let wellContents: ContentsByWell = {}

// selection for deck setup: shows initial state of liquids
wellContents = wellContentsSelectors.wellContentsAllLabware(state)[containerId]
wellContents = wellContentsSelectors.getWellContentsAllLabware(state)[containerId]

return {
selectedWells,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const SettingsSidebar = (props: SP & DP) => (
)

const STP = (state: BaseState): SP => ({
currentPage: selectors.currentPage(state),
currentPage: selectors.getCurrentPage(state),
})

const DTP = (dispatch: ThunkDispatch<*>): DP => ({
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/components/SettingsPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const SettingsPage = (props: SP) => {
}

const STP = (state: BaseState): SP => ({
currentPage: selectors.currentPage(state),
currentPage: selectors.getCurrentPage(state),
})

export default connect(STP)(SettingsPage)
4 changes: 3 additions & 1 deletion protocol-designer/src/components/StepEditForm/ButtonRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const ButtonRow = (props: Props) => {
)
}

const STP = (state: BaseState): SP => ({ canSave: selectors.currentFormCanBeSaved(state) })
const STP = (state: BaseState): SP => ({
canSave: selectors.getCurrentFormCanBeSaved(state),
})

const DTP = (dispatch: ThunkDispatch<*>): DP => ({
onCancel: () => dispatch(actions.cancelStepForm()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function mapStateToProps (state: BaseState, ownProps: OP): SP {
const formData = steplistSelectors.getUnsavedForm(state)

const pipetteId = formData ? formData[pipetteFieldName] : null
const pipette = pipetteId && pipetteSelectors.pipettesById(state)[pipetteId]
const pipette = pipetteId && pipetteSelectors.getPipettesById(state)[pipetteId]
const pipetteConfig = pipette && getPipetteNameSpecs(pipette.model)
const pipetteDisplayName = pipetteConfig ? pipetteConfig.displayName : 'pipette'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const mapStateToProps = (state: BaseState, ownProps: OP): SP => {
alerts: dismissSelectors.getFormWarningsForSelectedStep(state),
})

const errors = steplistSelectors.formLevelErrors(state)
const errors = steplistSelectors.getFormLevelErrors(state)
const filteredErrors = getVisibleAlerts({
focusedField,
dirtyFields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const FormSection = (props: FormSectionProps) => {
}

const FormSectionSTP = (state: BaseState, ownProps: OP) => ({
collapsed: steplistSelectors.formSectionCollapse(state)[ownProps.sectionName],
collapsed: steplistSelectors.getFormSectionCollapsed(state)[ownProps.sectionName],
})
const FormSectionDTP = (dispatch: ThunkDispatch<*>, ownProps: OP) => ({
onCollapseToggle: () => dispatch(collapseFormSection(ownProps.sectionName)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const mapSTP = (state: BaseState, ownProps: OP): SP => {

let wellHeightMM = null
if (formData && formData[labwareFieldName]) {
const labwareById = labwareIngredsSelectors.getLabware(state)
const labwareById = labwareIngredsSelectors.getLabwareById(state)
const labware = labwareById[formData[labwareFieldName]]
const labwareDef = labware && labware.type && getLabware(labware.type)
if (labwareDef) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ class WellSelectionModal extends React.Component<Props, State> {
function mapStateToProps (state: BaseState, ownProps: OP): SP {
const {pipetteId, labwareId} = ownProps

const allLabware = selectors.getLabware(state)
const allLabware = selectors.getLabwareById(state)
const labware = labwareId && allLabware && allLabware[labwareId]
const allWellContentsForSteps = wellContentsSelectors.allWellContentsForSteps(state)
const allWellContentsForSteps = wellContentsSelectors.getAllWellContentsForSteps(state)

const stepId = steplistSelectors.getSelectedStepId(state)
// TODO: Ian 2018-07-31 replace with util function, "findIndexOrNull"?
const orderedSteps = steplistSelectors.orderedSteps(state)
const orderedSteps = steplistSelectors.getOrderedSteps(state)
const timelineIdx = orderedSteps.findIndex(id => id === stepId)
const allWellContentsForStep = allWellContentsForSteps[timelineIdx]
const formData = steplistSelectors.getUnsavedForm(state)
const ingredNames = selectors.getLiquidNamesById(state)

return {
initialSelectedWells: formData ? formData[ownProps.name] : [],
pipette: pipetteId ? pipetteSelectors.equippedPipettes(state)[pipetteId] : null,
pipette: pipetteId ? pipetteSelectors.getEquippedPipettes(state)[pipetteId] : null,
wellContents: labware && allWellContentsForStep ? allWellContentsForStep[labware.id] : {},
containerType: labware ? labware.type : 'missing labware',
ingredNames,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const mapStateToProps = (state: BaseState, ownProps: OP): SP => {
const formData = steplistSelectors.getUnsavedForm(state)
const pipetteId = formData && formData[ownProps.pipetteFieldName]
const selectedWells = formData ? formData[ownProps.name] : []
const pipetteData = pipetteId && pipetteSelectors.pipettesById(state)[pipetteId]
const pipetteData = pipetteId && pipetteSelectors.getPipettesById(state)[pipetteId]
const isMulti = pipetteData && (pipetteData.channels > 1)

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type PipetteFieldSP = {pipetteOptions: Options, getHydratedPipette: (string) =>
type PipetteFieldDP = {updateDisposalVolume: (?mixed) => void}
type PipetteFieldProps = PipetteFieldOP & PipetteFieldSP & PipetteFieldDP
const PipetteFieldSTP = (state: BaseState, ownProps: PipetteFieldOP): PipetteFieldSP => ({
pipetteOptions: pipetteSelectors.equippedPipetteOptions(state),
pipetteOptions: pipetteSelectors.getEquippedPipetteOptions(state),
getHydratedPipette: (value) => hydrateField(state, ownProps.name, value),
})
const PipetteFieldDTP = (dispatch: ThunkDispatch<*>): PipetteFieldDP => ({
Expand Down
4 changes: 2 additions & 2 deletions protocol-designer/src/components/StepEditForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class StepEditForm extends React.Component<Props, StepEditFormState> {
}

const mapStateToProps = (state: BaseState): SP => ({
formData: selectors.formData(state),
isNewStep: selectors.isNewStepForm(state),
formData: selectors.getUnsavedForm(state),
isNewStep: selectors.getIsNewStepForm(state),
})

const mapDispatchToProps = (dispatch: ThunkDispatch<*>): DP => ({
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/components/alerts/TimelineAlerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type MP = {
*/

function mapStateToProps (state: BaseState): SP {
const timeline = fileDataSelectors.robotStateTimeline(state)
const timeline = fileDataSelectors.getRobotStateTimeline(state)
const errors = timeline.errors || []
const warnings = dismissSelectors.getTimelineWarningsForSelectedStep(state)
const _stepId = steplistSelectors.getSelectedStepId(state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ class BrowseLabwareModal extends React.Component<Props> {

function mapStateToProps (state: BaseState): SP {
const labwareId = selectors.getDrillDownLabwareId(state)
const allLabware = selectors.getLabware(state)
const allLabware = selectors.getLabwareById(state)
const labware = labwareId && allLabware ? allLabware[labwareId] : null
const allWellContents = wellContentsSelectors.lastValidWellContents(state)
const allWellContents = wellContentsSelectors.getLastValidWellContents(state)
const wellContents = labwareId && allWellContents ? allWellContents[labwareId] : {}
const ingredNames = selectors.getLiquidNamesById(state)
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class EditPipettesModal extends React.Component<Props, State> {
}

const mapSTP = (state: BaseState): SP => {
const pipetteData = pipetteSelectors.pipettesForEditPipettes(state)
const pipetteData = pipetteSelectors.getPipettesForEditPipettes(state)
return {
initialLeft: pipetteData.find(i => i.mount === 'left'),
initialRight: pipetteData.find(i => i.mount === 'right'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function StartingDeckStateTerminalItem (props: Props) {

function mapStateToProps (state: BaseState): Props {
// since default-trash counts as 1, labwareCount <= 1 means "user did not add labware"
const noLabware = Object.keys(labwareIngredsSelectors.getLabware(state)).length <= 1
const noLabware = Object.keys(labwareIngredsSelectors.getLabwareById(state)).length <= 1
return {showHint: noLabware}
}

Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/containers/Alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function Alerts (props: Props) {
}

function mapStateToProps (state: BaseState): SP {
const timeline = fileDataSelectors.robotStateTimeline(state)
const timeline = fileDataSelectors.getRobotStateTimeline(state)
const errors = timeline.errors || []
const warnings = dismissSelectors.getTimelineWarningsForSelectedStep(state)
const _stepId = steplistSelectors.getSelectedStepId(state)
Expand Down
4 changes: 2 additions & 2 deletions protocol-designer/src/containers/ConnectedDeckSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ type Props = {

const mapStateToProps = (state: BaseState): StateProps => ({
selectedTerminalItemId: steplistSelectors.getSelectedTerminalItemId(state),
ingredSelectionMode: Boolean(selectors.getSelectedContainer(state)),
ingredSelectionMode: Boolean(selectors.getSelectedLabware(state)),
drilledDown: !!selectors.getDrillDownLabwareId(state),
_moveLabwareMode: !!selectors.slotToMoveFrom(state),
_moveLabwareMode: !!selectors.getSlotToMoveFrom(state),
})

const mapDispatchToProps = (dispatch: ThunkDispatch<*>): DispatchProps => ({
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/containers/ConnectedFilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type DP = {
}

const mapStateToProps = (state: BaseState): SP => {
const pipetteData = pipetteSelectors.pipettesForInstrumentGroup(state)
const pipetteData = pipetteSelectors.getPipettesForInstrumentGroup(state)
return {
_values: fileSelectors.fileFormValues(state),
isFormAltered: fileSelectors.isUnsavedMetadatFormAltered(state),
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/containers/ConnectedMainPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ function MainPanel (props: Props) {

function mapStateToProps (state: BaseState): Props {
return {
page: selectors.currentPage(state),
page: selectors.getCurrentPage(state),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import type {BaseState, ThunkDispatch} from '../types'

function mapStateToProps (state: BaseState) {
const formModalData = selectors.formModalData(state)
const formModalData = selectors.getFormModalData(state)
return {
hideModal: formModalData === null,
formData: formModalData,
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/containers/ConnectedNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Nav (props: Props) {

function mapStateToProps (state: BaseState) {
return {
currentPage: selectors.currentPage(state),
currentPage: selectors.getCurrentPage(state),
currentProtocolExists: fileSelectors.getCurrentProtocolExists(state),
}
}
Expand Down
4 changes: 2 additions & 2 deletions protocol-designer/src/containers/ConnectedNewFileModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type DP = {

function mapStateToProps (state: BaseState): SP {
return {
hideModal: !selectors.newProtocolModal(state),
_hasUnsavedChanges: loadFileSelectors.hasUnsavedChanges(state),
hideModal: !selectors.getNewProtocolModal(state),
_hasUnsavedChanges: loadFileSelectors.getHasUnsavedChanges(state),
}
}

Expand Down
4 changes: 2 additions & 2 deletions protocol-designer/src/containers/ConnectedSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function Sidebar (props: Props) {
}

function mapStateToProps (state: BaseState): Props {
const page = selectors.currentPage(state)
const liquidPlacementMode = !!labwareIngredSelectors.getSelectedContainer(state)
const page = selectors.getCurrentPage(state)
const liquidPlacementMode = !!labwareIngredSelectors.getSelectedLabware(state)

return {
page,
Expand Down
4 changes: 2 additions & 2 deletions protocol-designer/src/containers/ConnectedStepItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type DP = $Diff<$Diff<Props, SP>, OP>

function mapStateToProps (state: BaseState, ownProps: OP): SP {
const {stepId} = ownProps
const allSteps = steplistSelectors.allSteps(state)
const allSteps = steplistSelectors.getAllSteps(state)

const hoveredSubstep = steplistSelectors.getHoveredSubstep(state)
const hoveredStep = steplistSelectors.getHoveredStepId(state)
Expand All @@ -62,7 +62,7 @@ function mapStateToProps (state: BaseState, ownProps: OP): SP {
// user is not hovering on substep.
hovered: (hoveredStep === stepId) && !hoveredSubstep,

getLabware: (labwareId: ?string) => labwareId ? labwareIngredSelectors.getLabware(state)[labwareId] : null,
getLabware: (labwareId: ?string) => labwareId ? labwareIngredSelectors.getLabwareById(state)[labwareId] : null,
ingredNames: labwareIngredSelectors.getLiquidNamesById(state),
}
}
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/containers/ConnectedStepList.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type DP = $Diff<Props, SP>

function mapStateToProps (state: BaseState): SP {
return {
orderedSteps: steplistSelectors.orderedSteps(state),
orderedSteps: steplistSelectors.getOrderedSteps(state),
}
}

Expand Down
8 changes: 4 additions & 4 deletions protocol-designer/src/containers/ConnectedTitleBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ function TitleWithIcon (props: TitleWithIconProps) {
}

function mapStateToProps (state: BaseState): SP {
const _page = selectors.currentPage(state)
const _page = selectors.getCurrentPage(state)
const fileName = fileDataSelectors.protocolName(state)
const selectedStep = steplistSelectors.getSelectedStep(state)
const selectedTerminalId = steplistSelectors.getSelectedTerminalItemId(state)
const labware = labwareIngredSelectors.getSelectedContainer(state)
const labware = labwareIngredSelectors.getSelectedLabware(state)
const labwareNames = labwareIngredSelectors.getLabwareNames(state)
const labwareNickname = labware && labware.id && labwareNames[labware.id]
const drilledDownLabwareId = labwareIngredSelectors.getDrillDownLabwareId(state)
const liquidPlacementMode = !!labwareIngredSelectors.getSelectedContainer(state)
const liquidPlacementMode = !!labwareIngredSelectors.getSelectedLabware(state)
const wellSelectionLabwareKey = steplistSelectors.getWellSelectionLabwareKey(state)

switch (_page) {
Expand Down Expand Up @@ -90,7 +90,7 @@ function mapStateToProps (state: BaseState): SP {
subtitle = END_TERMINAL_TITLE
if (drilledDownLabwareId) {
backButtonLabel = 'Deck'
const drilledDownLabware = labwareIngredSelectors.getLabware(state)[drilledDownLabwareId]
const drilledDownLabware = labwareIngredSelectors.getLabwareById(state)[drilledDownLabwareId]
title = drilledDownLabware && drilledDownLabware.name
subtitle = drilledDownLabware && humanizeLabwareType(drilledDownLabware.type)
}
Expand Down
Loading

0 comments on commit 172b952

Please sign in to comment.