Skip to content

Commit

Permalink
select step on double click
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader committed Sep 29, 2024
1 parent 86b4df9 commit 46ac729
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export function ConnectedStepInfo(props: ConnectedStepInfoProps): JSX.Element {

const selectStep = (): ThunkAction<any> =>
dispatch(stepsActions.selectStep(stepId))
const selectStepOnDoubleClick = (): ThunkAction<any> =>
dispatch(stepsActions.selectStepOnDoubleClick(stepId))
const highlightStep = (): HoverOnStepAction =>
dispatch(stepsActions.hoverOnStep(stepId))
const unhighlightStep = (): HoverOnStepAction =>
Expand All @@ -74,9 +76,8 @@ export function ConnectedStepInfo(props: ConnectedStepInfoProps): JSX.Element {
stepId={stepId}
onMouseLeave={unhighlightStep}
selected={selected}
onClick={() => {
selectStep()
}}
onDoubleClick={selectStepOnDoubleClick}
onClick={selectStep}
hovered={hoveredStep === stepId && !hoveredSubstep}
onMouseEnter={highlightStep}
iconName={hasError || hasWarnings ? 'alert-circle' : iconName}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { useSelector } from 'react-redux'
import { useDispatch, useSelector } from 'react-redux'
import { createPortal } from 'react-dom'
import {
ALIGN_CENTER,
Expand All @@ -24,6 +24,8 @@ import { StepOverflowMenu } from './StepOverflowMenu'
import { capitalizeFirstLetterAfterNumber } from './utils'

import type { IconName } from '@opentrons/components'
import { cancelStepForm } from '../../../../steplist/actions'

Check failure on line 27 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/StepContainer.tsx

View workflow job for this annotation

GitHub Actions / js checks

'cancelStepForm' is defined but never used
import { ThunkDispatch } from '../../../../types'

Check failure on line 28 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/StepContainer.tsx

View workflow job for this annotation

GitHub Actions / js checks

All imports in the declaration are only used as types. Use `import type`

const STARTING_DECK_STATE = 'Starting deck state'
const FINAL_DECK_STATE = 'Final deck state'
Expand All @@ -34,6 +36,7 @@ export interface StepContainerProps {
stepId?: string
iconColor?: string
onClick?: (event: React.MouseEvent) => void
onDoubleClick?: (event: React.MouseEvent) => void
onMouseEnter?: (event: React.MouseEvent) => void
onMouseLeave?: (event: React.MouseEvent) => void
selected?: boolean
Expand All @@ -46,6 +49,7 @@ export function StepContainer(props: StepContainerProps): JSX.Element {
const {
stepId,
iconName,
onDoubleClick,
onMouseEnter,
onMouseLeave,
selected,
Expand All @@ -57,6 +61,7 @@ export function StepContainer(props: StepContainerProps): JSX.Element {
isStepAfterError = false,
} = props
const formData = useSelector(getUnsavedForm)
const dispatch = useDispatch<ThunkDispatch<any>>()

Check failure on line 64 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/StepContainer.tsx

View workflow job for this annotation

GitHub Actions / js checks

'dispatch' is assigned a value but never used
const [top, setTop] = React.useState<number>(0)
const menuRootRef = React.useRef<HTMLDivElement | null>(null)
const [stepOverflowMenu, setStepOverflowMenu] = React.useState<boolean>(false)
Expand Down Expand Up @@ -121,6 +126,7 @@ export function StepContainer(props: StepContainerProps): JSX.Element {
}}
>
<Btn
onDoubleClick={onDoubleClick}
onClick={onClick}
padding={SPACING.spacing12}
borderRadius={BORDERS.borderRadius8}
Expand Down
17 changes: 17 additions & 0 deletions protocol-designer/src/ui/steps/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ export const populateForm = (stepId: StepIdType): ThunkAction<any> => (
resetScrollElements()
}

export const selectStepOnDoubleClick = (
stepId: StepIdType
): ThunkAction<any> => (dispatch: ThunkDispatch<any>, getState: GetState) => {
const selectStepAction: SelectStepAction = {
type: 'SELECT_STEP',
payload: stepId,
}
dispatch(selectStepAction)
const state = getState()
const formData = { ...stepFormSelectors.getSavedStepForms(state)[stepId] }
dispatch({
type: 'POPULATE_FORM',
payload: formData,
})
resetScrollElements()
}

// NOTE(sa, 2020-12-11): this is a thunk so that we can populate the batch edit form with things later
export const selectMultipleSteps = (
stepIds: StepIdType[],
Expand Down

0 comments on commit 46ac729

Please sign in to comment.