Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): Remove 'opentrons-' prefix in robot displayNames #2459

Merged
merged 2 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/components/ConnectPanel/RobotListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {RobotItemProps} from './RobotItem'
export function RobotListItem (props: RobotItemProps) {
const {
name,
displayName,
local,
status,
connected,
Expand All @@ -35,7 +36,7 @@ export function RobotListItem (props: RobotItemProps) {
childClassName={styles.notification}
/>

<p className={styles.link_text}>{name}</p>
<p className={styles.link_text}>{displayName}</p>

{connectable ? (
<ToggleButton
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/ConnectPanel/UnreachableRobotItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import RobotLink from './RobotLink'
import styles from './styles.css'

export default function UnreachableRobotItem (props: UnreachableRobot) {
const {name} = props
const {displayName} = props
return (
<li className={styles.robot_group}>
<HoverTooltip
Expand All @@ -27,7 +27,7 @@ export default function UnreachableRobotItem (props: UnreachableRobot) {
className={styles.robot_item_icon}
disabled
/>
<p className={styles.link_text}>{name}</p>
<p className={styles.link_text}>{displayName}</p>
</RobotLink>
)}
</HoverTooltip>
Expand Down
6 changes: 1 addition & 5 deletions app/src/components/SessionHeader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import {getProtocolFilename} from '../../protocol'
export default connect(mapStateToProps)(SessionHeader)

function SessionHeader (props) {
return (
<Link to='/upload'>
{props.sessionName}
</Link>
)
return <Link to="/upload">{props.sessionName}</Link>
}

function mapStateToProps (state) {
Expand Down
103 changes: 63 additions & 40 deletions app/src/discovery/__tests__/selectors.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
// discovery selectors tests
import * as discovery from '..'

const makeFullyUp = (name, ip, status = null, connected = null) => ({
const makeFullyUp = (
name,
displayName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wasn't thinking when you showed this to me earlier. These helpers pull double duty as both state inputs and selector expected outputs. Since displayName is a selector output, we should tack it on at the end and default it to null like status and connected

ip,
status = null,
connected = null
) => ({
name,
displayName,
ip,
local: false,
ok: true,
Expand All @@ -14,8 +21,15 @@ const makeFullyUp = (name, ip, status = null, connected = null) => ({
connected,
})

const makeConnectable = (name, ip, status = null, connected = null) => ({
const makeConnectable = (
name,
displayName,
ip,
status = null,
connected = null
) => ({
name,
displayName,
ip,
local: false,
ok: true,
Expand All @@ -25,8 +39,9 @@ const makeConnectable = (name, ip, status = null, connected = null) => ({
connected,
})

const makeAdvertising = (name, ip, status = null) => ({
const makeAdvertising = (name, displayName, ip, status = null) => ({
name,
displayName,
ip,
local: false,
ok: false,
Expand All @@ -35,8 +50,9 @@ const makeAdvertising = (name, ip, status = null) => ({
status,
})

const makeServerUp = (name, ip, advertising, status = null) => ({
const makeServerUp = (name, displayName, ip, advertising, status = null) => ({
name,
displayName,
ip,
advertising,
local: false,
Expand All @@ -46,8 +62,9 @@ const makeServerUp = (name, ip, advertising, status = null) => ({
status,
})

const makeUnreachable = (name, ip, status = null) => ({
const makeUnreachable = (name, displayName, ip, status = null) => ({
name,
displayName,
ip,
local: false,
ok: false,
Expand Down Expand Up @@ -76,15 +93,15 @@ describe('discovery selectors', () => {
state: {
discovery: {
robotsByName: {
foo: [makeConnectable('foo', '10.0.0.1')],
bar: [makeFullyUp('bar', '10.0.0.2')],
foo: [makeConnectable('foo', 'foo', '10.0.0.1')],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting display name in the state means our selector isn't necessarily being tested, because the selector doesn't have to add anything to the object for the test to pass

bar: [makeFullyUp('bar', 'bar', '10.0.0.2')],
},
},
robot: {connection: {connectedTo: 'bar'}},
},
expected: [
makeConnectable('foo', '10.0.0.1', 'connectable', false),
makeFullyUp('bar', '10.0.0.2', 'connectable', true),
makeConnectable('foo', 'foo', '10.0.0.1', 'connectable', false),
makeFullyUp('bar', 'bar', '10.0.0.2', 'connectable', true),
],
},
{
Expand All @@ -94,31 +111,33 @@ describe('discovery selectors', () => {
discovery: {
robotsByName: {
foo: [
makeConnectable('foo', '10.0.0.1'),
makeConnectable('foo', '10.0.0.2'),
makeServerUp('foo', '10.0.0.3', false),
makeAdvertising('foo', '10.0.0.4', false),
makeConnectable('foo', 'foo', '10.0.0.1'),
makeConnectable('foo', 'foo', '10.0.0.2'),
makeServerUp('foo', 'foo', '10.0.0.3', false),
makeAdvertising('foo', 'foo', '10.0.0.4', false),
],
},
},
robot: {connection: {connectedTo: 'foo'}},
},
expected: [makeConnectable('foo', '10.0.0.1', 'connectable', true)],
expected: [
makeConnectable('foo', 'foo', '10.0.0.1', 'connectable', true),
],
},
{
name: 'getReachableRobots grabs robots with serverUp or advertising',
selector: discovery.getReachableRobots,
state: {
discovery: {
robotsByName: {
foo: [makeServerUp('foo', '10.0.0.1', false)],
bar: [makeAdvertising('bar', '10.0.0.2')],
foo: [makeServerUp('foo', 'foo', '10.0.0.1', false)],
bar: [makeAdvertising('bar', 'bar', '10.0.0.2')],
},
},
},
expected: [
makeServerUp('foo', '10.0.0.1', false, 'reachable'),
makeAdvertising('bar', '10.0.0.2', 'reachable'),
makeServerUp('foo', 'foo', '10.0.0.1', false, 'reachable'),
makeAdvertising('bar', 'bar', '10.0.0.2', 'reachable'),
],
},
{
Expand All @@ -128,14 +147,14 @@ describe('discovery selectors', () => {
discovery: {
robotsByName: {
foo: [
makeServerUp('foo', '10.0.0.1', true),
makeServerUp('foo', '10.0.0.1', false),
makeAdvertising('foo', '10.0.0.2'),
makeServerUp('foo', 'foo', '10.0.0.1', true),
makeServerUp('foo', 'foo', '10.0.0.1', false),
makeAdvertising('foo', 'foo', '10.0.0.2'),
],
},
},
},
expected: [makeServerUp('foo', '10.0.0.1', true, 'reachable')],
expected: [makeServerUp('foo', 'foo', '10.0.0.1', true, 'reachable')],
},
{
name: 'getReachableRobots does not grab connectable robots',
Expand All @@ -144,18 +163,18 @@ describe('discovery selectors', () => {
discovery: {
robotsByName: {
foo: [
makeConnectable('foo', '10.0.0.1'),
makeServerUp('foo', '10.0.0.2', true),
makeConnectable('foo', 'foo', '10.0.0.1'),
makeServerUp('foo', 'foo', '10.0.0.2', true),
],
bar: [
makeConnectable('bar', '10.0.0.3'),
makeServerUp('bar', '10.0.0.4', false),
makeConnectable('bar', 'bar', '10.0.0.3'),
makeServerUp('bar', 'bar', '10.0.0.4', false),
],
baz: [
makeConnectable('baz', '10.0.0.5'),
makeAdvertising('baz', '10.0.0.6'),
makeConnectable('baz', 'baz', '10.0.0.5'),
makeAdvertising('baz', 'baz', '10.0.0.6'),
],
qux: [makeFullyUp('qux', '10.0.0.7')],
qux: [makeFullyUp('qux', 'baz', '10.0.0.7')],
},
},
},
Expand All @@ -165,9 +184,13 @@ describe('discovery selectors', () => {
name: 'getUnreachableRobots grabs robots with no ip',
selector: discovery.getUnreachableRobots,
state: {
discovery: {robotsByName: {foo: [{name: 'foo', ip: null}]}},
discovery: {
robotsByName: {foo: [{name: 'foo', displayName: 'foo', ip: null}]},
},
},
expected: [{name: 'foo', ip: null, status: 'unreachable'}],
expected: [
{name: 'foo', displayName: 'foo', ip: null, status: 'unreachable'},
],
},
{
name: 'getUnreachableRobots grabs robots with IP but no responses',
Expand All @@ -176,13 +199,13 @@ describe('discovery selectors', () => {
discovery: {
robotsByName: {
foo: [
makeUnreachable('foo', '10.0.0.1'),
makeUnreachable('foo', '10.0.0.2'),
makeUnreachable('foo', 'foo', '10.0.0.1'),
makeUnreachable('foo', 'foo', '10.0.0.2'),
],
},
},
},
expected: [makeUnreachable('foo', '10.0.0.1', 'unreachable')],
expected: [makeUnreachable('foo', 'foo', '10.0.0.1', 'unreachable')],
},
{
name: "getUnreachableRobots won't grab connectable/reachable robots",
Expand All @@ -191,18 +214,18 @@ describe('discovery selectors', () => {
discovery: {
robotsByName: {
foo: [
makeServerUp('foo', '10.0.0.1', true),
makeUnreachable('foo', '10.0.0.2'),
makeServerUp('foo', 'foo', '10.0.0.1', true),
makeUnreachable('foo', 'foo', '10.0.0.2'),
],
bar: [
makeServerUp('bar', '10.0.0.3', false),
makeServerUp('bar', 'bar', '10.0.0.3', false),
makeUnreachable('bar', '10.0.0.4'),
],
baz: [
makeAdvertising('bar', '10.0.0.5'),
makeUnreachable('baz', '10.0.0.6'),
makeAdvertising('bar', 'bar', '10.0.0.5'),
makeUnreachable('baz', 'baz', '10.0.0.6'),
],
qux: [makeConnectable('qux', '10.0.0.7')],
qux: [makeConnectable('qux', 'qux', '10.0.0.7')],
},
},
},
Expand Down
17 changes: 14 additions & 3 deletions app/src/discovery/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,28 @@ const getGroupedRobotsMap: GetGroupedRobotsMap = createSelector(
mapValues(robotsMap, services => {
const servicesWithStatus = services.map(s => {
const resolved = maybeGetResolved(s)
const displayName = makeDisplayName(s)
if (resolved) {
if (isConnectable(resolved)) return {...s, status: CONNECTABLE}
if (isReachable(resolved)) return {...s, status: REACHABLE}
if (isConnectable(resolved)) {
return {...s, status: CONNECTABLE, displayName}
}
if (isReachable(resolved)) {
return {...s, status: REACHABLE, displayName}
}
}
return {...s, status: UNREACHABLE}
return {...s, status: UNREACHABLE, displayName}
})

return groupBy(servicesWithStatus, 'status')
})
)

function makeDisplayName (robot: Service) {
const {name} = robot
const displayName = name.replace('opentrons-', '')
return displayName
}

export const getConnectableRobots: GetConnectableRobots = createSelector(
getGroupedRobotsMap,
robotSelectors.getConnectedRobotName,
Expand Down
2 changes: 2 additions & 0 deletions app/src/discovery/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type UnreachableStatus = 'unreachable'
// service with a known IP address
export type ResolvedRobot = {
...$Exact<Service>,
displayName: string,
ip: $NonMaybeType<$PropertyType<Service, 'ip'>>,
local: $NonMaybeType<$PropertyType<Service, 'local'>>,
ok: $NonMaybeType<$PropertyType<Service, 'ok'>>,
Expand All @@ -34,6 +35,7 @@ export type ReachableRobot = {
// robot with an unknown IP
export type UnreachableRobot = {
...$Exact<Service>,
displayName: string,
status: UnreachableStatus,
}

Expand Down
21 changes: 12 additions & 9 deletions app/src/pages/Robots/InstrumentSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ export default function InstrumentSettingsPage (props: Props) {
robot,
match: {path, url},
} = props
const titleBarProps = {title: robot.name}
const titleBarProps = {title: robot.displayName}

return (
<React.Fragment>
<Page titleBarProps={titleBarProps}>
<InstrumentSettings {...robot} />
</Page>
<Switch>
<Route path={`${path}/pipettes`} render={(props) => (
<ChangePipette {...props} robot={robot} parentUrl={url} />
)} />
</Switch>
<Page titleBarProps={titleBarProps}>
<InstrumentSettings {...robot} />
</Page>
<Switch>
<Route
path={`${path}/pipettes`}
render={props => (
<ChangePipette {...props} robot={robot} parentUrl={url} />
)}
/>
</Switch>
</React.Fragment>
)
}
2 changes: 1 addition & 1 deletion app/src/pages/Robots/RobotSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function RobotSettingsPage (props: Props) {
match: {path, url},
} = props

const titleBarProps = {title: robot.name}
const titleBarProps = {title: robot.displayName}
const updateUrl = `${url}/${UPDATE_FRAGMENT}`
const calibrateDeckUrl = `${url}/${CALIBRATE_DECK_FRAGMENT}`
const resetUrl = `${url}/${RESET_FRAGMENT}`
Expand Down