-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol-designer): deleting staging area also deletes 4th colum… (
- Loading branch information
Showing
13 changed files
with
329 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
.../organisms/ConfirmDeleteStagingAreaModal/__tests__/ConfirmDeleteStagingAreaModal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { fireEvent, screen } from '@testing-library/react' | ||
import { describe, it, beforeEach, vi, expect } from 'vitest' | ||
import { renderWithProviders } from '../../../__testing-utils__' | ||
import { i18n } from '../../../assets/localization' | ||
import { ConfirmDeleteStagingAreaModal } from '..' | ||
import type { ComponentProps } from 'react' | ||
|
||
const render = ( | ||
props: ComponentProps<typeof ConfirmDeleteStagingAreaModal> | ||
) => { | ||
return renderWithProviders(<ConfirmDeleteStagingAreaModal {...props} />, { | ||
i18nInstance: i18n, | ||
})[0] | ||
} | ||
|
||
describe('ConfirmDeleteStagingAreaModal', () => { | ||
let props: ComponentProps<typeof ConfirmDeleteStagingAreaModal> | ||
|
||
beforeEach(() => { | ||
props = { | ||
onClose: vi.fn(), | ||
onConfirm: vi.fn(), | ||
} | ||
}) | ||
it('renders the text and buttons work as expected', () => { | ||
render(props) | ||
screen.getByText('This staging area slot has labware') | ||
screen.getByText( | ||
'The staging area slot that you are about to delete has labware placed on it. If you make these changes to your protocol starting deck, the labware will be deleted as well.' | ||
) | ||
fireEvent.click(screen.getByText('Cancel')) | ||
expect(props.onClose).toHaveBeenCalled() | ||
fireEvent.click(screen.getByText('Continue')) | ||
expect(props.onConfirm).toHaveBeenCalled() | ||
}) | ||
}) |
58 changes: 58 additions & 0 deletions
58
protocol-designer/src/organisms/ConfirmDeleteStagingAreaModal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { useTranslation } from 'react-i18next' | ||
import { createPortal } from 'react-dom' | ||
import { | ||
Flex, | ||
JUSTIFY_END, | ||
Modal, | ||
PrimaryButton, | ||
SecondaryButton, | ||
SPACING, | ||
StyledText, | ||
} from '@opentrons/components' | ||
import { getTopPortalEl } from '../../components/portals/TopPortal' | ||
import { HandleEnter } from '../../atoms/HandleEnter' | ||
|
||
interface ConfirmDeleteStagingAreaModalProps { | ||
onClose: () => void | ||
onConfirm: () => void | ||
} | ||
export function ConfirmDeleteStagingAreaModal( | ||
props: ConfirmDeleteStagingAreaModalProps | ||
): JSX.Element { | ||
const { onClose, onConfirm } = props | ||
const { t, i18n } = useTranslation(['create_new_protocol', 'shared']) | ||
|
||
return createPortal( | ||
<HandleEnter onEnter={onConfirm}> | ||
<Modal | ||
zIndexOverlay={11} | ||
title={t('staging_area_has_labware')} | ||
type="info" | ||
onClose={onClose} | ||
footer={ | ||
<Flex | ||
justifyContent={JUSTIFY_END} | ||
gridGap={SPACING.spacing8} | ||
padding={SPACING.spacing24} | ||
> | ||
<SecondaryButton | ||
onClick={() => { | ||
onClose() | ||
}} | ||
> | ||
{t('shared:cancel')} | ||
</SecondaryButton> | ||
<PrimaryButton onClick={onConfirm}> | ||
{i18n.format(t('shared:continue'), 'capitalize')} | ||
</PrimaryButton> | ||
</Flex> | ||
} | ||
> | ||
<StyledText desktopStyle="bodyDefaultRegular"> | ||
{t('staging_area_will_delete_labware')} | ||
</StyledText> | ||
</Modal> | ||
</HandleEnter>, | ||
getTopPortalEl() | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.