From 9c83c6d45a9bc7e7b865ecffbbb05bb85b37bb17 Mon Sep 17 00:00:00 2001 From: Josh McVey Date: Tue, 10 Sep 2024 16:59:18 -0500 Subject: [PATCH] chore(cherrypick): 16208 to chore_release-8.0.0 (#16232) ## Cherrypick in #16208 Co-authored-by: Seth Foster --- .../ChooseRobotToRunProtocolSlideout.test.tsx | 19 ++---- .../index.tsx | 58 +++++++++++-------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/app/src/organisms/ChooseRobotToRunProtocolSlideout/__tests__/ChooseRobotToRunProtocolSlideout.test.tsx b/app/src/organisms/ChooseRobotToRunProtocolSlideout/__tests__/ChooseRobotToRunProtocolSlideout.test.tsx index 057533ce778..2f726984699 100644 --- a/app/src/organisms/ChooseRobotToRunProtocolSlideout/__tests__/ChooseRobotToRunProtocolSlideout.test.tsx +++ b/app/src/organisms/ChooseRobotToRunProtocolSlideout/__tests__/ChooseRobotToRunProtocolSlideout.test.tsx @@ -320,7 +320,7 @@ describe('ChooseRobotToRunProtocolSlideout', () => { runCreatedAt: '2022-05-11T13:33:51.012179+00:00', } when(vi.mocked(useOffsetCandidatesForAnalysis)) - .calledWith(storedProtocolDataFixture.mostRecentAnalysis, '127.0.0.1') + .calledWith(storedProtocolDataFixture.mostRecentAnalysis, null) .thenReturn([mockOffsetCandidate]) vi.mocked(getConnectableRobots).mockReturnValue([ mockConnectableRobot, @@ -333,7 +333,7 @@ describe('ChooseRobotToRunProtocolSlideout', () => { }) expect(vi.mocked(useCreateRunFromProtocol)).toHaveBeenCalledWith( expect.any(Object), - { hostname: '127.0.0.1' }, + null, [ { vector: mockOffsetCandidate.vector, @@ -369,11 +369,8 @@ describe('ChooseRobotToRunProtocolSlideout', () => { runCreatedAt: '2022-05-11T13:33:51.012179+00:00', } when(vi.mocked(useOffsetCandidatesForAnalysis)) - .calledWith(storedProtocolDataFixture.mostRecentAnalysis, '127.0.0.1') + .calledWith(storedProtocolDataFixture.mostRecentAnalysis, null) .thenReturn([mockOffsetCandidate]) - when(vi.mocked(useOffsetCandidatesForAnalysis)) - .calledWith(storedProtocolDataFixture.mostRecentAnalysis, 'otherIp') - .thenReturn([]) vi.mocked(getConnectableRobots).mockReturnValue([ mockConnectableRobot, { ...mockConnectableRobot, name: 'otherRobot', ip: 'otherIp' }, @@ -393,10 +390,9 @@ describe('ChooseRobotToRunProtocolSlideout', () => { }) fireEvent.click(proceedButton) fireEvent.click(screen.getByRole('button', { name: 'Confirm values' })) - expect(vi.mocked(useCreateRunFromProtocol)).nthCalledWith( - 3, + expect(vi.mocked(useCreateRunFromProtocol)).toHaveBeenLastCalledWith( expect.any(Object), - { hostname: '127.0.0.1' }, + null, [ { vector: mockOffsetCandidate.vector, @@ -405,11 +401,6 @@ describe('ChooseRobotToRunProtocolSlideout', () => { }, ] ) - expect(vi.mocked(useCreateRunFromProtocol)).toHaveBeenLastCalledWith( - expect.any(Object), - { hostname: 'otherIp' }, - [] - ) }) it('disables proceed button if no available robots', () => { diff --git a/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx b/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx index 0b145340852..38d39a1e031 100644 --- a/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx +++ b/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx @@ -16,7 +16,10 @@ import { SPACING, useHoverTooltip, } from '@opentrons/components' -import { useUploadCsvFileMutation } from '@opentrons/react-api-client' +import { + useUploadCsvFileMutation, + ApiHostProvider, +} from '@opentrons/react-api-client' import { Tooltip } from '../../atoms/Tooltip' import { getRobotUpdateDisplayInfo } from '../../redux/robot-update' @@ -46,11 +49,23 @@ interface ChooseRobotToRunProtocolSlideoutProps extends StyleProps { showSlideout: boolean } +interface ChooseRobotToRunProtocolSlideoutComponentProps + extends ChooseRobotToRunProtocolSlideoutProps { + selectedRobot: Robot | null + setSelectedRobot: (robot: Robot | null) => void +} + export function ChooseRobotToRunProtocolSlideoutComponent( - props: ChooseRobotToRunProtocolSlideoutProps + props: ChooseRobotToRunProtocolSlideoutComponentProps ): JSX.Element | null { const { t } = useTranslation(['protocol_details', 'shared', 'app_settings']) - const { storedProtocolData, showSlideout, onCloseClick } = props + const { + storedProtocolData, + showSlideout, + onCloseClick, + selectedRobot, + setSelectedRobot, + } = props const navigate = useNavigate() const [shouldApplyOffsets, setShouldApplyOffsets] = React.useState( true @@ -62,7 +77,6 @@ export function ChooseRobotToRunProtocolSlideoutComponent( mostRecentAnalysis, } = storedProtocolData const [currentPage, setCurrentPage] = React.useState(1) - const [selectedRobot, setSelectedRobot] = React.useState(null) const { trackCreateProtocolRunEvent } = useTrackCreateProtocolRunEvent( storedProtocolData, selectedRobot?.name ?? '' @@ -83,19 +97,10 @@ export function ChooseRobotToRunProtocolSlideoutComponent( const offsetCandidates = useOffsetCandidatesForAnalysis( mostRecentAnalysis, - selectedRobot?.ip ?? null + null ) - const { uploadCsvFile } = useUploadCsvFileMutation( - {}, - selectedRobot != null - ? { - hostname: selectedRobot.ip, - requestor: - selectedRobot?.ip === OPENTRONS_USB ? appShellRequestor : undefined, - } - : null - ) + const { uploadCsvFile } = useUploadCsvFileMutation() const { createRunFromProtocolSource, @@ -121,13 +126,7 @@ export function ChooseRobotToRunProtocolSlideoutComponent( }) }, }, - selectedRobot != null - ? { - hostname: selectedRobot.ip, - requestor: - selectedRobot?.ip === OPENTRONS_USB ? appShellRequestor : undefined, - } - : null, + null, shouldApplyOffsets ? offsetCandidates.map(({ vector, location, definitionUri }) => ({ vector, @@ -360,5 +359,18 @@ export function ChooseRobotToRunProtocolSlideoutComponent( export function ChooseRobotToRunProtocolSlideout( props: ChooseRobotToRunProtocolSlideoutProps ): JSX.Element | null { - return + const [selectedRobot, setSelectedRobot] = React.useState(null) + return ( + + + + ) }