Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'

Expand Down Expand Up @@ -133,6 +133,13 @@ export function ProtocolRunSetup({
const noLwOffsetsInRun =
useSelector(selectTotalCountLocationSpecificOffsets(runId)) === 0 && isFlex

// A separate app can apply offsets. We need to update the missing steps as a side effect.
useEffect(() => {
if (flexOffsetsApplied) {
dispatch(updateRunSetupStepsComplete(runId, { [LPC_STEP_KEY]: true }))
}
}, [flexOffsetsApplied])

const offsetsConfirmed = isFlex
? flexOffsetsApplied && !missingSteps.includes(LPC_STEP_KEY)
: !missingSteps.includes(LPC_STEP_KEY)
Expand Down Expand Up @@ -266,9 +273,6 @@ export function ProtocolRunSetup({
<SetupLabwarePositionCheck
{...{ runId, robotName, robotType }}
setOffsetsConfirmed={confirmed => {
dispatch(
updateRunSetupStepsComplete(runId, { [LPC_STEP_KEY]: confirmed })
)
if (confirmed) {
dispatch(appliedOffsetsToRun(runId))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
import { useToaster } from '/app/organisms/ToasterOven'
import { useLPCDisabledReason } from '/app/resources/runs'
import {
selectAreOffsetsApplied,
selectIsAnyNecessaryDefaultOffsetMissing,
selectLabwareOffsetsToAddToRun,
selectTotalCountNonHardCodedLSOffsets,
Expand All @@ -31,6 +30,7 @@ export interface LPCSetupFlexBtnsProps extends SetupLabwarePositionCheckProps {

export function LPCSetupFlexBtns({
setOffsetsConfirmed,
offsetsConfirmed,
launchLPC,
runId,
robotName,
Expand All @@ -41,7 +41,6 @@ export function LPCSetupFlexBtns({
const isNecessaryDefaultOffsetMissing = useSelector(
selectIsAnyNecessaryDefaultOffsetMissing(runId)
)
const offsetsConfirmed = useSelector(selectAreOffsetsApplied(runId))
const [runLPCTargetProps, runLPCTooltipProps] = useHoverTooltip({
placement: TOOLTIP_BOTTOM,
})
Expand Down Expand Up @@ -79,6 +78,16 @@ export function LPCSetupFlexBtns({
}
}

const runLPCDisabledTooltipText = (): string | null => {
if (lpcDisabledReason != null) {
return lpcDisabledReason
} else if (offsetsConfirmed) {
return t('offsets_already_applied')
} else {
return null
}
}

const onApplyOffsets = (): void => {
if (!isApplyOffsets && lwOffsetsForRun != null) {
setIsApplyingOffsets(true)
Expand All @@ -103,12 +112,14 @@ export function LPCSetupFlexBtns({
onClick={launchLPC}
id="LabwareSetup_checkLabwarePositionsButton"
{...runLPCTargetProps}
disabled={lpcDisabledReason !== null}
disabled={lpcDisabledReason !== null || offsetsConfirmed}
>
{t('run_labware_position_check')}
</SecondaryButton>
{lpcDisabledReason !== null ? (
<Tooltip tooltipProps={runLPCTooltipProps}>{lpcDisabledReason}</Tooltip>
{lpcDisabledReason !== null || offsetsConfirmed ? (
<Tooltip tooltipProps={runLPCTooltipProps}>
{runLPCDisabledTooltipText()}
</Tooltip>
) : null}
<PrimaryButton
onClick={onApplyOffsets}
Expand Down
Loading