-
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): add e-stop screen (#13010)
add e-stop screen
- Loading branch information
Showing
21 changed files
with
176 additions
and
30 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
39 changes: 39 additions & 0 deletions
39
app/src/pages/EmergencyStop/__tests__/EmergencyStop.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,39 @@ | ||
import * as React from 'react' | ||
|
||
import { renderWithProviders } from '@opentrons/components' | ||
|
||
import { i18n } from '../../../i18n' | ||
import { EmergencyStop } from '..' | ||
|
||
// const ESTOP_IMAGE_NAME = 'install_e_stop.png' | ||
const mockPush = jest.fn() | ||
jest.mock('react-router-dom', () => { | ||
const reactRouterDom = jest.requireActual('react-router-dom') | ||
return { | ||
...reactRouterDom, | ||
useHistory: () => ({ push: mockPush } as any), | ||
} | ||
}) | ||
|
||
const render = () => { | ||
return renderWithProviders(<EmergencyStop />, { | ||
i18nInstance: i18n, | ||
}) | ||
} | ||
|
||
describe('EmergencyStop', () => { | ||
// Note (kk:06/28/2023) commented test cases will be activated when added the function to check e-stop status | ||
|
||
it.todo( | ||
'should render text, image, and button when e-stop button is not connected' | ||
) | ||
|
||
it('should render text, icon, button when e-stop button is connected', () => { | ||
const [{ getByText, getByTestId, getByRole }] = render() | ||
getByTestId('EmergencyStop_connected_icon') | ||
getByText('E-stop successfully connected') | ||
expect(getByRole('button')).not.toBeDisabled() | ||
}) | ||
|
||
it.todo('should call a mock function when tapping continue button') | ||
}) |
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,99 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { useHistory } from 'react-router-dom' | ||
|
||
import { | ||
Icon, | ||
Flex, | ||
SPACING, | ||
COLORS, | ||
BORDERS, | ||
DIRECTION_COLUMN, | ||
JUSTIFY_CENTER, | ||
ALIGN_CENTER, | ||
TYPOGRAPHY, | ||
} from '@opentrons/components' | ||
|
||
import { StyledText } from '../../atoms/text' | ||
import { MediumButton } from '../../atoms/buttons' | ||
import { StepMeter } from '../../atoms/StepMeter' | ||
|
||
import estopImg from '../../assets/images/on-device-display/install_e_stop.png' | ||
|
||
export function EmergencyStop(): JSX.Element { | ||
const { i18n, t } = useTranslation(['device_settings', 'shared']) | ||
const history = useHistory() | ||
// Note (kk:06/28/2023) this IF is for test and it will be removed when the e-stop status check function | ||
// I will add the function soon | ||
const isEstopConnected = true | ||
|
||
return ( | ||
<> | ||
<StepMeter totalSteps={6} currentStep={4} /> | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
gridGap={SPACING.spacing32} | ||
paddingX={SPACING.spacing40} | ||
> | ||
<Flex | ||
paddingY={SPACING.spacing32} | ||
justifyContent={JUSTIFY_CENTER} | ||
alignItems={ALIGN_CENTER} | ||
> | ||
<StyledText as="h2" fontWeight={TYPOGRAPHY.fontWeightBold}> | ||
{t('install_e_stop')} | ||
</StyledText> | ||
</Flex> | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
padding={`${SPACING.spacing40} ${SPACING.spacing80}`} | ||
backgroundColor={ | ||
isEstopConnected ? COLORS.green3 : COLORS.darkBlack20 | ||
} | ||
borderRadius={BORDERS.borderRadiusSize3} | ||
alignItems={ALIGN_CENTER} | ||
> | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
gridGap={isEstopConnected ? SPACING.spacing32 : SPACING.spacing16} | ||
alignItems={ALIGN_CENTER} | ||
justifyContent={JUSTIFY_CENTER} | ||
height="13.5rem" | ||
> | ||
{isEstopConnected ? ( | ||
<> | ||
<Icon | ||
name="ot-check" | ||
size="3rem" | ||
color={COLORS.green2} | ||
data-testid="EmergencyStop_connected_icon" | ||
/> | ||
<StyledText as="h3" fontWeight={TYPOGRAPHY.fontWeightSemiBold}> | ||
{t('e_stop_connected')} | ||
</StyledText> | ||
</> | ||
) : ( | ||
<> | ||
<img src={estopImg} height="116px" alt="E-stop button" /> | ||
<StyledText | ||
as="h3" | ||
fontWeight={TYPOGRAPHY.fontWeightSemiBold} | ||
color={COLORS.darkBlack70} | ||
textAlign={TYPOGRAPHY.textAlignCenter} | ||
> | ||
{t('e_stop_not_connected')} | ||
</StyledText> | ||
</> | ||
)} | ||
</Flex> | ||
</Flex> | ||
<MediumButton | ||
flex="1" | ||
buttonText={i18n.format(t('shared:continue'), 'capitalize')} | ||
disabled={!isEstopConnected} | ||
onClick={() => history.push('/robot-settings/rename-robot')} | ||
/> | ||
</Flex> | ||
</> | ||
) | ||
} |
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
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.