-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): create and wire up Not Configured modal (#13751)
closes RAUT-699
- Loading branch information
Showing
7 changed files
with
152 additions
and
4 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
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
76 changes: 76 additions & 0 deletions
76
app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/NotConfiguredModal.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,76 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { useUpdateDeckConfigurationMutation } from '@opentrons/react-api-client/src/deck_configuration' | ||
import { | ||
Flex, | ||
DIRECTION_COLUMN, | ||
TYPOGRAPHY, | ||
SPACING, | ||
JUSTIFY_SPACE_BETWEEN, | ||
COLORS, | ||
BORDERS, | ||
ALIGN_CENTER, | ||
} from '@opentrons/components' | ||
import { FixtureLoadName, getFixtureDisplayName } from '@opentrons/shared-data' | ||
import { TertiaryButton } from '../../../../atoms/buttons/TertiaryButton' | ||
import { Portal } from '../../../../App/portal' | ||
import { LegacyModal } from '../../../../molecules/LegacyModal' | ||
import { StyledText } from '../../../../atoms/text' | ||
|
||
interface NotConfiguredModalProps { | ||
onCloseClick: () => void | ||
requiredFixture: FixtureLoadName | ||
cutout: string | ||
} | ||
|
||
export const NotConfiguredModal = ( | ||
props: NotConfiguredModalProps | ||
): JSX.Element => { | ||
const { onCloseClick, cutout, requiredFixture } = props | ||
const { t, i18n } = useTranslation(['protocol_setup', 'shared']) | ||
const { updateDeckConfiguration } = useUpdateDeckConfigurationMutation() | ||
|
||
const handleUpdateDeck = (): void => { | ||
updateDeckConfiguration({ | ||
fixtureLocation: cutout, | ||
loadName: requiredFixture, | ||
}) | ||
onCloseClick() | ||
} | ||
|
||
return ( | ||
<Portal level="top"> | ||
<LegacyModal | ||
title={ | ||
<StyledText as="h3" fontWeight={TYPOGRAPHY.fontWeightSemiBold}> | ||
{t('add_fixture', { | ||
fixtureName: getFixtureDisplayName(requiredFixture), | ||
})} | ||
</StyledText> | ||
} | ||
onClose={onCloseClick} | ||
width="27.75rem" | ||
> | ||
<Flex flexDirection={DIRECTION_COLUMN}> | ||
<StyledText as="p">{t('add_fixture_to_deck')}</StyledText> | ||
<Flex paddingTop={SPACING.spacing16} flexDirection={DIRECTION_COLUMN}> | ||
<Flex | ||
padding={`${SPACING.spacing8} ${SPACING.spacing16}`} | ||
backgroundColor={COLORS.medGreyEnabled} | ||
borderRadius={BORDERS.radiusSoftCorners} | ||
alignItems={ALIGN_CENTER} | ||
justifyContent={JUSTIFY_SPACE_BETWEEN} | ||
> | ||
<StyledText as="p" fontWeight={TYPOGRAPHY.fontWeightSemiBold}> | ||
{getFixtureDisplayName(requiredFixture)} | ||
</StyledText> | ||
<TertiaryButton onClick={handleUpdateDeck}> | ||
{i18n.format(t('add'), 'capitalize')} | ||
</TertiaryButton> | ||
</Flex> | ||
</Flex> | ||
</Flex> | ||
</LegacyModal> | ||
</Portal> | ||
) | ||
} |
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
43 changes: 43 additions & 0 deletions
43
...rc/organisms/Devices/ProtocolRun/SetupModuleAndDeck/__tests__/NotConfiguredModal.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,43 @@ | ||
import * as React from 'react' | ||
import { renderWithProviders } from '@opentrons/components' | ||
import { TRASH_BIN_LOAD_NAME } from '@opentrons/shared-data' | ||
import { useUpdateDeckConfigurationMutation } from '@opentrons/react-api-client/src/deck_configuration' | ||
import { i18n } from '../../../../../i18n' | ||
import { NotConfiguredModal } from '../NotConfiguredModal' | ||
|
||
jest.mock('@opentrons/react-api-client/src/deck_configuration') | ||
|
||
const mockUseUpdateDeckConfigurationMutation = useUpdateDeckConfigurationMutation as jest.MockedFunction< | ||
typeof useUpdateDeckConfigurationMutation | ||
> | ||
|
||
const render = (props: React.ComponentProps<typeof NotConfiguredModal>) => { | ||
return renderWithProviders(<NotConfiguredModal {...props} />, { | ||
i18nInstance: i18n, | ||
})[0] | ||
} | ||
|
||
describe('NotConfiguredModal', () => { | ||
let props: React.ComponentProps<typeof NotConfiguredModal> | ||
const mockUpdate = jest.fn() | ||
beforeEach(() => { | ||
props = { | ||
onCloseClick: jest.fn(), | ||
cutout: 'B3', | ||
requiredFixture: TRASH_BIN_LOAD_NAME, | ||
} | ||
mockUseUpdateDeckConfigurationMutation.mockReturnValue({ | ||
updateDeckConfiguration: mockUpdate, | ||
} as any) | ||
}) | ||
it('renders the correct text and button works as expected', () => { | ||
const { getByText, getByRole } = render(props) | ||
getByText('Add Trash Bin to deck configuration') | ||
getByText( | ||
'Add this fixture to your deck configuration. It will be referenced during protocol analysis.' | ||
) | ||
getByText('Trash Bin') | ||
getByRole('button', { name: 'Add' }).click() | ||
expect(mockUpdate).toHaveBeenCalled() | ||
}) | ||
}) |
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