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 all commits
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
113 changes: 99 additions & 14 deletions app/src/discovery/__tests__/selectors.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// discovery selectors tests
import * as discovery from '..'

const makeFullyUp = (name, ip, status = null, connected = null) => ({
const makeFullyUp = (
name,
ip,
status = null,
connected = null,
displayName = null
) => ({
name,
ip,
local: false,
Expand All @@ -12,9 +18,16 @@ const makeFullyUp = (name, ip, status = null, connected = null) => ({
serverHealth: {},
status,
connected,
displayName,
})

const makeConnectable = (name, ip, status = null, connected = null) => ({
const makeConnectable = (
name,
ip,
status = null,
connected = null,
displayName = null
) => ({
name,
ip,
local: false,
Expand All @@ -23,19 +36,27 @@ const makeConnectable = (name, ip, status = null, connected = null) => ({
health: {},
status,
connected,
displayName,
})

const makeAdvertising = (name, ip, status = null) => ({
const makeAdvertising = (name, ip, status = null, displayName = null) => ({
name,
ip,
local: false,
ok: false,
serverOk: false,
advertising: true,
status,
displayName,
})

const makeServerUp = (name, ip, advertising, status = null) => ({
const makeServerUp = (
name,
ip,
advertising,
status = null,
displayName = null
) => ({
name,
ip,
advertising,
Expand All @@ -44,16 +65,18 @@ const makeServerUp = (name, ip, advertising, status = null) => ({
serverOk: true,
serverHealth: {},
status,
displayName,
})

const makeUnreachable = (name, ip, status = null) => ({
const makeUnreachable = (name, ip, status = null, displayName = null) => ({
name,
ip,
local: false,
ok: false,
serverOk: false,
advertising: false,
status,
displayName,
})

describe('discovery selectors', () => {
Expand Down Expand Up @@ -83,8 +106,8 @@ describe('discovery selectors', () => {
robot: {connection: {connectedTo: 'bar'}},
},
expected: [
makeConnectable('foo', '10.0.0.1', 'connectable', false),
makeFullyUp('bar', '10.0.0.2', 'connectable', true),
makeConnectable('foo', '10.0.0.1', 'connectable', false, 'foo'),
makeFullyUp('bar', '10.0.0.2', 'connectable', true, 'bar'),
],
},
{
Expand All @@ -103,7 +126,9 @@ describe('discovery selectors', () => {
},
robot: {connection: {connectedTo: 'foo'}},
},
expected: [makeConnectable('foo', '10.0.0.1', 'connectable', true)],
expected: [
makeConnectable('foo', '10.0.0.1', 'connectable', true, 'foo'),
],
},
{
name: 'getReachableRobots grabs robots with serverUp or advertising',
Expand All @@ -117,8 +142,8 @@ describe('discovery selectors', () => {
},
},
expected: [
makeServerUp('foo', '10.0.0.1', false, 'reachable'),
makeAdvertising('bar', '10.0.0.2', 'reachable'),
makeServerUp('foo', '10.0.0.1', false, 'reachable', 'foo'),
makeAdvertising('bar', '10.0.0.2', 'reachable', 'bar'),
],
},
{
Expand All @@ -135,7 +160,7 @@ describe('discovery selectors', () => {
},
},
},
expected: [makeServerUp('foo', '10.0.0.1', true, 'reachable')],
expected: [makeServerUp('foo', '10.0.0.1', true, 'reachable', 'foo')],
},
{
name: 'getReachableRobots does not grab connectable robots',
Expand Down Expand Up @@ -165,9 +190,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', ip: null}]},
},
},
expected: [{name: 'foo', ip: null, status: 'unreachable'}],
expected: [
{name: 'foo', ip: null, status: 'unreachable', displayName: 'foo'},
],
},
{
name: 'getUnreachableRobots grabs robots with IP but no responses',
Expand All @@ -182,7 +211,7 @@ describe('discovery selectors', () => {
},
},
},
expected: [makeUnreachable('foo', '10.0.0.1', 'unreachable')],
expected: [makeUnreachable('foo', '10.0.0.1', 'unreachable', 'foo')],
},
{
name: "getUnreachableRobots won't grab connectable/reachable robots",
Expand All @@ -208,6 +237,62 @@ describe('discovery selectors', () => {
},
expected: [],
},
{
name: 'display name removes opentrons- from connectable robot names',
selector: discovery.getConnectableRobots,
state: {
discovery: {
robotsByName: {
'opentrons-foo': [makeConnectable('opentrons-foo', '10.0.0.1')],
'opentrons-bar': [makeFullyUp('opentrons-bar', '10.0.0.2')],
},
},
robot: {connection: {connectedTo: 'opentrons-bar'}},
},
expected: [
makeConnectable(
'opentrons-foo',
'10.0.0.1',
'connectable',
false,
'foo'
),
makeFullyUp('opentrons-bar', '10.0.0.2', 'connectable', true, 'bar'),
],
},
{
name: 'display name removes opentrons- from reachable robot names',
selector: discovery.getReachableRobots,
state: {
discovery: {
robotsByName: {
'opentrons-foo': [makeServerUp('opentrons-foo', '10.0.0.1', false)],
'opentrons-bar': [makeAdvertising('opentrons-bar', '10.0.0.2')],
},
},
},
expected: [
makeServerUp('opentrons-foo', '10.0.0.1', false, 'reachable', 'foo'),
makeAdvertising('opentrons-bar', '10.0.0.2', 'reachable', 'bar'),
],
},
{
name: 'display name removes opentrons- from unreachable robot names',
selector: discovery.getUnreachableRobots,
state: {
discovery: {
robotsByName: {'opentrons-foo': [{name: 'opentrons-foo', ip: null}]},
},
},
expected: [
{
name: 'opentrons-foo',
ip: null,
status: 'unreachable',
displayName: 'foo',
},
],
},
]

SPECS.forEach(spec => {
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