From d037b4676c494b2a3ad9ffcd98eb0f54a7c45a85 Mon Sep 17 00:00:00 2001 From: Jethary Date: Wed, 13 Mar 2024 11:56:20 -0400 Subject: [PATCH] put behind ff --- .../__tests__/ChooseRobotSlideout.test.tsx | 4 +- .../organisms/ChooseRobotSlideout/index.tsx | 4 +- .../ChooseRobotToRunProtocolSlideout.test.tsx | 3 + .../index.tsx | 92 ++++++++++++------- 4 files changed, 67 insertions(+), 36 deletions(-) diff --git a/app/src/organisms/ChooseRobotSlideout/__tests__/ChooseRobotSlideout.test.tsx b/app/src/organisms/ChooseRobotSlideout/__tests__/ChooseRobotSlideout.test.tsx index d6664c61226..524c59d4f06 100644 --- a/app/src/organisms/ChooseRobotSlideout/__tests__/ChooseRobotSlideout.test.tsx +++ b/app/src/organisms/ChooseRobotSlideout/__tests__/ChooseRobotSlideout.test.tsx @@ -18,6 +18,7 @@ import { mockReachableRobot, mockUnreachableRobot, } from '../../../redux/discovery/__fixtures__' +import { useFeatureFlag } from '../../../redux/config' import { getNetworkInterfaces } from '../../../redux/networking' import { ChooseRobotSlideout } from '..' import { useNotifyService } from '../../../resources/useNotifyService' @@ -26,7 +27,7 @@ vi.mock('../../../redux/discovery') vi.mock('../../../redux/robot-update') vi.mock('../../../redux/networking') vi.mock('../../../resources/useNotifyService') - +vi.mock('../../../redux/config') const render = (props: React.ComponentProps) => { return renderWithProviders( @@ -42,6 +43,7 @@ const mockSetSelectedRobot = vi.fn() describe('ChooseRobotSlideout', () => { beforeEach(() => { + vi.mocked(useFeatureFlag).mockReturnValue(true) vi.mocked(getConnectableRobots).mockReturnValue([mockConnectableRobot]) vi.mocked(getUnreachableRobots).mockReturnValue([mockUnreachableRobot]) vi.mocked(getReachableRobots).mockReturnValue([mockReachableRobot]) diff --git a/app/src/organisms/ChooseRobotSlideout/index.tsx b/app/src/organisms/ChooseRobotSlideout/index.tsx index 5c768bdb12f..152939001c5 100644 --- a/app/src/organisms/ChooseRobotSlideout/index.tsx +++ b/app/src/organisms/ChooseRobotSlideout/index.tsx @@ -44,6 +44,7 @@ import type { SlideoutProps } from '../../atoms/Slideout' import type { UseCreateRun } from '../../organisms/ChooseRobotToRunProtocolSlideout/useCreateRunFromProtocol' import type { State, Dispatch } from '../../redux/types' import type { Robot } from '../../redux/discovery/types' +import { useFeatureFlag } from '../../redux/config' interface RobotIsBusyAction { type: 'robotIsBusy' @@ -116,6 +117,7 @@ export function ChooseRobotSlideout( showIdleOnly = false, multiSlideout, } = props + const enableRunTimeParametersFF = useFeatureFlag('enableRunTimeParameters') const dispatch = useDispatch() const isScanning = useSelector((state: State) => getScanning(state)) @@ -306,7 +308,7 @@ export function ChooseRobotSlideout( const pageTwoBody = TODO - return multiSlideout != null ? ( + return multiSlideout != null && enableRunTimeParametersFF ? ( @@ -70,6 +72,7 @@ describe('ChooseRobotToRunProtocolSlideout', () => { mockTrackCreateProtocolRunEvent = vi.fn( () => new Promise(resolve => resolve({})) ) + vi.mocked(useFeatureFlag).mockReturnValue(true) vi.mocked(getRobotUpdateDisplayInfo).mockReturnValue({ autoUpdateAction: '', autoUpdateDisabledReason: null, diff --git a/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx b/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx index dbb5f7196b1..6edbefbe4f1 100644 --- a/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx +++ b/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx @@ -18,6 +18,7 @@ import { import { getRobotUpdateDisplayInfo } from '../../redux/robot-update' import { OPENTRONS_USB } from '../../redux/discovery' import { appShellRequestor } from '../../redux/shell/remote' +import { useFeatureFlag } from '../../redux/config' import { useTrackCreateProtocolRunEvent } from '../Devices/hooks' import { ApplyHistoricOffsets } from '../ApplyHistoricOffsets' import { useOffsetCandidatesForAnalysis } from '../ApplyHistoricOffsets/hooks/useOffsetCandidatesForAnalysis' @@ -53,6 +54,7 @@ export function ChooseRobotToRunProtocolSlideoutComponent( srcFiles, mostRecentAnalysis, } = storedProtocolData + const enableRunTimeParametersFF = useFeatureFlag('enableRunTimeParameters') const [currentPage, setCurrentPage] = React.useState(1) const [selectedRobot, setSelectedRobot] = React.useState(null) const { trackCreateProtocolRunEvent } = useTrackCreateProtocolRunEvent( @@ -143,6 +145,24 @@ export function ChooseRobotToRunProtocolSlideoutComponent( ? mostRecentAnalysis?.robotType ?? null : null + const singlePageButtonWithoutFF = ( + + {isCreatingRun ? ( + + ) : ( + t('shared:proceed_to_setup') + )} + + ) + return ( - {currentPage === 1 ? ( - <> - - setCurrentPage(2)} - width="100%" - disabled={ - isCreatingRun || - selectedRobot == null || - isSelectedRobotOnDifferentSoftwareVersion - } - > - {t('shared:continue_to_param')} - - + {enableRunTimeParametersFF ? ( + currentPage === 1 ? ( + <> + + setCurrentPage(2)} + width="100%" + disabled={ + isCreatingRun || + selectedRobot == null || + isSelectedRobotOnDifferentSoftwareVersion + } + > + {t('shared:continue_to_param')} + + + ) : ( + + setCurrentPage(1)} width="50%"> + {t('shared:change_robot')} + + + {isCreatingRun ? ( + + ) : ( + t('shared:confirm_values') + )} + + + ) ) : ( - - setCurrentPage(1)} width="50%"> - {t('shared:change_robot')} - - - {isCreatingRun ? ( - - ) : ( - t('shared:confirm_values') - )} - - + singlePageButtonWithoutFF )} }