Skip to content

Commit

Permalink
put behind ff
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader committed Mar 13, 2024
1 parent 49afcf0 commit d037b46
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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<typeof ChooseRobotSlideout>) => {
return renderWithProviders(
<StaticRouter>
Expand All @@ -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])
Expand Down
4 changes: 3 additions & 1 deletion app/src/organisms/ChooseRobotSlideout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -116,6 +117,7 @@ export function ChooseRobotSlideout(
showIdleOnly = false,
multiSlideout,
} = props
const enableRunTimeParametersFF = useFeatureFlag('enableRunTimeParameters')
const dispatch = useDispatch<Dispatch>()
const isScanning = useSelector((state: State) => getScanning(state))

Expand Down Expand Up @@ -306,7 +308,7 @@ export function ChooseRobotSlideout(

const pageTwoBody = <Flex>TODO</Flex>

return multiSlideout != null ? (
return multiSlideout != null && enableRunTimeParametersFF ? (
<MultiSlideout
isExpanded={isExpanded}
onCloseClick={onCloseClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getUnreachableRobots,
startDiscovery,
} from '../../../redux/discovery'
import { useFeatureFlag } from '../../../redux/config'
import { getRobotUpdateDisplayInfo } from '../../../redux/robot-update'
import {
mockConnectableRobot,
Expand All @@ -44,6 +45,7 @@ vi.mock('../../../redux/config')
vi.mock('../useCreateRunFromProtocol')
vi.mock('../../ApplyHistoricOffsets/hooks/useOffsetCandidatesForAnalysis')
vi.mock('../../../resources/useNotifyService')
vi.mock('../../../redux/config')

const render = (
props: React.ComponentProps<typeof ChooseRobotToRunProtocolSlideout>
Expand All @@ -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,
Expand Down
92 changes: 58 additions & 34 deletions app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -53,6 +54,7 @@ export function ChooseRobotToRunProtocolSlideoutComponent(
srcFiles,
mostRecentAnalysis,
} = storedProtocolData
const enableRunTimeParametersFF = useFeatureFlag('enableRunTimeParameters')
const [currentPage, setCurrentPage] = React.useState<number>(1)
const [selectedRobot, setSelectedRobot] = React.useState<Robot | null>(null)
const { trackCreateProtocolRunEvent } = useTrackCreateProtocolRunEvent(
Expand Down Expand Up @@ -143,6 +145,24 @@ export function ChooseRobotToRunProtocolSlideoutComponent(
? mostRecentAnalysis?.robotType ?? null
: null

const singlePageButtonWithoutFF = (
<PrimaryButton
disabled={
isCreatingRun ||
selectedRobot == null ||
isSelectedRobotOnDifferentSoftwareVersion
}
width="100%"
onClick={handleProceed}
>
{isCreatingRun ? (
<Icon name="ot-spinner" spin size={SIZE_1} />
) : (
t('shared:proceed_to_setup')
)}
</PrimaryButton>
)

return (
<ChooseRobotSlideout
multiSlideout={{ currentPage }}
Expand All @@ -156,41 +176,45 @@ export function ChooseRobotToRunProtocolSlideoutComponent(
})}
footer={
<Flex flexDirection={DIRECTION_COLUMN}>
{currentPage === 1 ? (
<>
<ApplyHistoricOffsets
offsetCandidates={offsetCandidates}
shouldApplyOffsets={shouldApplyOffsets}
setShouldApplyOffsets={setShouldApplyOffsets}
commands={mostRecentAnalysis?.commands ?? []}
labware={mostRecentAnalysis?.labware ?? []}
modules={mostRecentAnalysis?.modules ?? []}
/>
<PrimaryButton
onClick={() => setCurrentPage(2)}
width="100%"
disabled={
isCreatingRun ||
selectedRobot == null ||
isSelectedRobotOnDifferentSoftwareVersion
}
>
{t('shared:continue_to_param')}
</PrimaryButton>
</>
{enableRunTimeParametersFF ? (
currentPage === 1 ? (
<>
<ApplyHistoricOffsets
offsetCandidates={offsetCandidates}
shouldApplyOffsets={shouldApplyOffsets}
setShouldApplyOffsets={setShouldApplyOffsets}
commands={mostRecentAnalysis?.commands ?? []}
labware={mostRecentAnalysis?.labware ?? []}
modules={mostRecentAnalysis?.modules ?? []}
/>
<PrimaryButton
onClick={() => setCurrentPage(2)}
width="100%"
disabled={
isCreatingRun ||
selectedRobot == null ||
isSelectedRobotOnDifferentSoftwareVersion
}
>
{t('shared:continue_to_param')}
</PrimaryButton>
</>
) : (
<Flex gridGap={SPACING.spacing8} flexDirection={DIRECTION_ROW}>
<SecondaryButton onClick={() => setCurrentPage(1)} width="50%">
{t('shared:change_robot')}
</SecondaryButton>
<PrimaryButton width="50%" onClick={handleProceed}>
{isCreatingRun ? (
<Icon name="ot-spinner" spin size={SIZE_1} />
) : (
t('shared:confirm_values')
)}
</PrimaryButton>
</Flex>
)
) : (
<Flex gridGap={SPACING.spacing8} flexDirection={DIRECTION_ROW}>
<SecondaryButton onClick={() => setCurrentPage(1)} width="50%">
{t('shared:change_robot')}
</SecondaryButton>
<PrimaryButton width="50%" onClick={handleProceed}>
{isCreatingRun ? (
<Icon name="ot-spinner" spin size={SIZE_1} />
) : (
t('shared:confirm_values')
)}
</PrimaryButton>
</Flex>
singlePageButtonWithoutFF
)}
</Flex>
}
Expand Down

0 comments on commit d037b46

Please sign in to comment.