Skip to content

Commit

Permalink
fix(app): Fix run cancel redirection, pipette path copy (#16166)
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 authored Aug 29, 2024
1 parent f0d3ab3 commit a989cb8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/src/assets/localization/en/quick_transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"pipette_path": "Pipette path",
"pipette_path_multi_aspirate": "Multi-aspirate",
"pipette_path_multi_dispense": "Multi-dispense",
"pipette_path_multi_dispense_volume_blowout": "Multi-dispense, {{volume}} disposal volume, blowout into {{blowOutLocation}}",
"pipette_path_multi_dispense_volume_blowout": "Multi-dispense, {{volume}} disposal volume, blowout {{blowOutLocation}}",
"pipette_path_single": "Single transfers",
"pre_wet_tip": "Pre-wet tip",
"quick_transfer": "Quick transfer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,8 @@ export function ConfirmCancelRunModal({
isLoading: isDismissing,
} = useDismissCurrentRunMutation({
onSettled: () => {
if (isQuickTransfer && protocolId != null) {
if (isQuickTransfer) {
deleteRun(runId)
navigate(`/quick-transfer/${protocolId}`)
} else if (isQuickTransfer) {
deleteRun(runId)
navigate('/quick-transfer')
} else if (protocolId != null) {
navigate(`/protocols/${protocolId}`)
} else {
navigate('/protocols')
}
},
})
Expand Down Expand Up @@ -97,6 +89,15 @@ export function ConfirmCancelRunModal({
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_ACTION.CANCEL })
if (!isActiveRun) {
dismissCurrentRun(runId)
if (isQuickTransfer && protocolId != null) {
navigate(`/quick-transfer/${protocolId}`)
} else if (isQuickTransfer) {
navigate('/quick-transfer')
} else if (protocolId != null) {
navigate(`/protocols/${protocolId}`)
} else {
navigate('/protocols')
}
}
}
}, [runStatus])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ describe('ConfirmCancelRunModal', () => {

expect(mockDismissCurrentRun).toHaveBeenCalled()
expect(mockTrackProtocolRunEvent).toHaveBeenCalled()
expect(mockNavigate).toHaveBeenCalledWith('/protocols')
})

it('when quick transfer run is stopped, the run is dismissed and the modal closes if the run is not yet active', () => {
props = {
...props,
isActiveRun: false,
isQuickTransfer: true,
}
when(useRunStatus).calledWith(RUN_ID).thenReturn(RUN_STATUS_STOPPED)
render(props)

expect(mockDismissCurrentRun).toHaveBeenCalled()
expect(mockTrackProtocolRunEvent).toHaveBeenCalled()
expect(mockNavigate).toHaveBeenCalledWith('/quick-transfer')
})

it('when run is stopped, the run is not dismissed if the run is active', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react'
import isEqual from 'lodash/isEqual'
import { useTranslation } from 'react-i18next'
import { createPortal } from 'react-dom'
import {
Expand Down Expand Up @@ -197,7 +198,10 @@ export function BlowOut(props: BlowOutProps): JSX.Element {
{blowOutLocationItems.map(blowOutLocationItem => (
<RadioButton
key={blowOutLocationItem.description}
isSelected={blowOutLocation === blowOutLocationItem.location}
isSelected={
isEqual(blowOutLocation, blowOutLocationItem.location) ||
blowOutLocation === blowOutLocationItem.location
}
onChange={() => {
setBlowOutLocation(
blowOutLocationItem.location as BlowOutLocation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react'
import isEqual from 'lodash/isEqual'
import { useTranslation } from 'react-i18next'
import { createPortal } from 'react-dom'
import {
Expand Down Expand Up @@ -218,7 +219,10 @@ export function PipettePath(props: PipettePathProps): JSX.Element {
{blowOutLocationItems.map(option => (
<RadioButton
key={option.description}
isSelected={blowOutLocation === option.location}
isSelected={
isEqual(blowOutLocation, option.location) ||
blowOutLocation === option.location
}
onChange={() => {
setBlowOutLocation(option.location)
}}
Expand Down

0 comments on commit a989cb8

Please sign in to comment.