-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app): Disable run start button if missing modules (#3994)
Closes #2676
- Loading branch information
Showing
14 changed files
with
180 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 27 additions & 44 deletions
71
app/src/components/InstrumentSettings/AttachedModulesCard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,47 @@ | ||
// @flow | ||
// attached modules container card | ||
import * as React from 'react' | ||
import { connect } from 'react-redux' | ||
import { useDispatch, useSelector } from 'react-redux' | ||
|
||
import { Card, IntervalWrapper } from '@opentrons/components' | ||
import { Card, useInterval } from '@opentrons/components' | ||
import { fetchModules, getModulesState } from '../../robot-api' | ||
import ModulesCardContents from './ModulesCardContents' | ||
import { getConfig } from '../../config' | ||
|
||
import type { State, Dispatch } from '../../types' | ||
import type { Module } from '../../robot-api' | ||
import type { Robot } from '../../discovery' | ||
|
||
type OP = {| robot: Robot |} | ||
|
||
type SP = {| | ||
modules: Array<Module>, | ||
__tempControlsEnabled: boolean, | ||
|} | ||
|
||
type DP = {| fetchModules: () => mixed |} | ||
|
||
type Props = { ...OP, ...SP, ...DP } | ||
type Props = {| robot: Robot |} | ||
|
||
const TITLE = 'Modules' | ||
const POLL_MODULE_INTERVAL_MS = 5000 | ||
|
||
export default connect<Props, OP, SP, DP, State, Dispatch>( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(AttachedModulesCard) | ||
export default function AttachedModulesCard(props: Props) { | ||
const { robot } = props | ||
const dispatch = useDispatch<Dispatch>() | ||
|
||
function AttachedModulesCard(props: Props) { | ||
return ( | ||
<IntervalWrapper | ||
interval={POLL_MODULE_INTERVAL_MS} | ||
refresh={props.fetchModules} | ||
> | ||
<Card title={TITLE} column> | ||
<ModulesCardContents | ||
modules={props.modules} | ||
robot={props.robot} | ||
showControls={props.__tempControlsEnabled} | ||
/> | ||
</Card> | ||
</IntervalWrapper> | ||
const modules = useSelector((state: State) => | ||
getModulesState(state, robot.name) | ||
) | ||
const __tempControlsEnabled = Boolean( | ||
useSelector(getConfig).devInternal?.tempdeckControls | ||
) | ||
} | ||
|
||
function mapStateToProps(state: State, ownProps: OP): SP { | ||
return { | ||
modules: getModulesState(state, ownProps.robot.name), | ||
__tempControlsEnabled: Boolean( | ||
getConfig(state).devInternal?.tempdeckControls | ||
), | ||
} | ||
} | ||
// this component may be mounted if the robot is not currently connected, so | ||
// GET /modules ourselves instead of relying on the poll while connected epic | ||
useInterval( | ||
() => dispatch(fetchModules(robot)), | ||
POLL_MODULE_INTERVAL_MS, | ||
true | ||
) | ||
|
||
function mapDispatchToProps(dispatch: Dispatch, ownProps: OP): DP { | ||
return { | ||
fetchModules: () => dispatch(fetchModules(ownProps.robot)), | ||
} | ||
return ( | ||
<Card title={TITLE} column> | ||
<ModulesCardContents | ||
robot={robot} | ||
modules={modules} | ||
showControls={__tempControlsEnabled} | ||
/> | ||
</Card> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.