-
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(app): add Jupyter Notebook button to robot's Advanced Settings (#…
- Loading branch information
Showing
7 changed files
with
263 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// @flow | ||
import * as React from 'react' | ||
|
||
import { SecondaryBtn, Link } from '@opentrons/components' | ||
import { useTrackEvent } from '../../analytics' | ||
import { TitledControl } from '../TitledControl' | ||
|
||
import type { StyleProps } from '@opentrons/components' | ||
|
||
// TODO(mc, 2020-09-09): i18n | ||
const OPEN = 'Open' | ||
const JUPYTER_NOTEBOOK = 'Jupyter Notebook' | ||
const OPEN_JUPYTER_DESCRIPTION = ( | ||
<> | ||
Open the{' '} | ||
<Link external href="https://jupyter.org/"> | ||
Jupyter Notebook | ||
</Link>{' '} | ||
running on this OT-2 in your web browser. (Experimental feature! See{' '} | ||
<Link | ||
external | ||
href="https://docs.opentrons.com/v2/new_advanced_running.html#jupyter-notebook" | ||
> | ||
documentation | ||
</Link>{' '} | ||
for more details.) | ||
</> | ||
) | ||
|
||
const EVENT_JUPYTER_OPEN = { name: 'jupyterOpen', properties: {} } | ||
|
||
export type OpenJupyterControlProps = {| | ||
robotIp: string, | ||
...StyleProps, | ||
|} | ||
|
||
export function OpenJupyterControl(props: OpenJupyterControlProps): React.Node { | ||
const { robotIp, ...styleProps } = props | ||
const href = `http://${robotIp}:48888` | ||
const trackEvent = useTrackEvent() | ||
|
||
return ( | ||
<TitledControl | ||
{...styleProps} | ||
title={JUPYTER_NOTEBOOK} | ||
description={OPEN_JUPYTER_DESCRIPTION} | ||
control={ | ||
<SecondaryBtn | ||
onClick={() => trackEvent(EVENT_JUPYTER_OPEN)} | ||
as={Link} | ||
href={href} | ||
width="9rem" | ||
external | ||
> | ||
{OPEN} | ||
</SecondaryBtn> | ||
} | ||
/> | ||
) | ||
} |
47 changes: 47 additions & 0 deletions
47
app/src/components/RobotSettings/__tests__/AdvancedSettingsCard.test.js
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,47 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import { BORDER_SOLID_LIGHT } from '@opentrons/components' | ||
import { mountWithStore } from '@opentrons/components/__utils__' | ||
|
||
import * as RobotSettings from '../../../robot-settings' | ||
import { mockConnectableRobot } from '../../../discovery/__fixtures__' | ||
import { AdvancedSettingsCard } from '../AdvancedSettingsCard' | ||
import { OpenJupyterControl } from '../OpenJupyterControl' | ||
|
||
import type { State } from '../../../types' | ||
|
||
jest.mock('react-router-dom', () => ({ Link: 'a' })) | ||
jest.mock('../../../analytics') | ||
jest.mock('../../../robot-settings/selectors') | ||
jest.mock('../../../shell/robot-logs/selectors') | ||
|
||
const getRobotSettings: JestMockFn< | ||
[State, string], | ||
$Call<typeof RobotSettings.getRobotSettings, State, string> | ||
> = RobotSettings.getRobotSettings | ||
|
||
// TODO(mc, 2020-09-09): flesh out these tests | ||
describe('RobotSettings > AdvancedSettingsCard', () => { | ||
const render = (robot = mockConnectableRobot) => { | ||
const resetUrl = `/robots/${robot.name}/reset` | ||
return mountWithStore( | ||
<AdvancedSettingsCard robot={robot} resetUrl={resetUrl} /> | ||
) | ||
} | ||
|
||
beforeEach(() => { | ||
getRobotSettings.mockReturnValue([]) | ||
}) | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks() | ||
}) | ||
|
||
it('should render an OpenJupyterControl', () => { | ||
const { wrapper } = render() | ||
const openJupyter = wrapper.find(OpenJupyterControl) | ||
|
||
expect(openJupyter.prop('robotIp')).toBe(mockConnectableRobot.ip) | ||
expect(openJupyter.prop('borderBottom')).toBe(BORDER_SOLID_LIGHT) | ||
}) | ||
}) |
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.