From d883da08d8ae2fac21454b970bffa5c9af9c32f5 Mon Sep 17 00:00:00 2001 From: Jethary Date: Tue, 19 Mar 2024 10:42:12 -0400 Subject: [PATCH] plug in ResetValueModal --- .../__tests__/ProtocolSetupParameters.test.tsx | 13 +++++++++++++ app/src/organisms/ProtocolSetupParameters/index.tsx | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/src/organisms/ProtocolSetupParameters/__tests__/ProtocolSetupParameters.test.tsx b/app/src/organisms/ProtocolSetupParameters/__tests__/ProtocolSetupParameters.test.tsx index 326fdc27920..e2c4992b199 100644 --- a/app/src/organisms/ProtocolSetupParameters/__tests__/ProtocolSetupParameters.test.tsx +++ b/app/src/organisms/ProtocolSetupParameters/__tests__/ProtocolSetupParameters.test.tsx @@ -59,4 +59,17 @@ describe('ProtocolSetupParameters', () => { fireEvent.click(screen.getByRole('button', { name: 'Confirm values' })) expect(props.setSetupScreen).toHaveBeenCalled() }) + it('renders the reset values modal', () => { + render(props) + fireEvent.click( + screen.getByRole('button', { name: 'Restore default values' }) + ) + screen.getByText( + 'This will discard any changes you have made. All parameters will have their default values.' + ) + const title = screen.getByText('Reset parameter values?') + fireEvent.click(screen.getByRole('button', { name: 'Go back' })) + expect(title).not.toBeInTheDocument() + // TODO(jr, 3/19/24): wire up the confirm button + }) }) diff --git a/app/src/organisms/ProtocolSetupParameters/index.tsx b/app/src/organisms/ProtocolSetupParameters/index.tsx index 28dee8d82b3..ac3403dd740 100644 --- a/app/src/organisms/ProtocolSetupParameters/index.tsx +++ b/app/src/organisms/ProtocolSetupParameters/index.tsx @@ -10,6 +10,7 @@ import { import { ProtocolSetupStep, SetupScreens } from '../../pages/ProtocolSetup' import { useMostRecentCompletedAnalysis } from '../LabwarePositionCheck/useMostRecentCompletedAnalysis' import { ChildNavigation } from '../ChildNavigation' +import { ResetValuesModal } from './ResetValuesModal' import type { RunTimeParameter } from '@opentrons/shared-data' @@ -157,6 +158,9 @@ export function ProtocolSetupParameters({ const { t, i18n } = useTranslation('protocol_setup') const history = useHistory() const mostRecentAnalysis = useMostRecentCompletedAnalysis(runId) + const [resetValuesModal, showResetValuesModal] = React.useState( + false + ) const handleConfirmValues = (): void => { setSetupScreen('prepare to run') @@ -194,6 +198,10 @@ export function ProtocolSetupParameters({ return ( <> + {resetValuesModal ? ( + showResetValuesModal(false)} /> + ) : null} + history.goBack()} @@ -202,7 +210,7 @@ export function ProtocolSetupParameters({ secondaryButtonProps={{ buttonType: 'tertiaryLowLight', buttonText: t('restore_default'), - onClick: () => console.log('TODO: wire this up!'), + onClick: () => showResetValuesModal(true), }} />