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

refactor(app): Allow app to request buildroot update token #3765

Merged
merged 1 commit into from
Jul 23, 2019
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
1 change: 1 addition & 0 deletions app-shell/src/buildroot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function registerBuildrootUpdate(dispatch: Dispatch) {
.then(
(): BuildrootAction => ({
type: 'buildroot:PREMIGRATION_DONE',
payload: robot.name,
})
)
.catch(
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/RobotSettings/InformationCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ function makeMapStateToProps(): (state: State, ownProps: OP) => SP {

return (state, ownProps) => {
const version = getRobotApiVersion(ownProps.robot) || 'Unknown'

return {
version,
updateInfo: getUpdateInfo(state, ownProps.robot),
buildrootUpdateAvailable:
version && getBuildrootUpdateAvailable(state, version),
buildrootUpdateAvailable: getBuildrootUpdateAvailable(state, version),
__buildRootEnabled: Boolean(
getConfig(state).devInternal?.enableBuildRoot
),
Expand Down
8 changes: 5 additions & 3 deletions app/src/discovery/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
Robot,
ReachableRobot,
UnreachableRobot,
ViewableRobot,
AnyRobot,
ConnectableStatus,
ReachableStatus,
Expand All @@ -43,7 +44,7 @@ type GetConnectableRobots = Selector<State, void, Array<Robot>>
type GetReachableRobots = Selector<State, void, Array<ReachableRobot>>
type GetUnreachableRobots = Selector<State, void, Array<UnreachableRobot>>
type GetAllRobots = Selector<State, void, Array<AnyRobot>>
type GetLiveRobots = Selector<State, void, Array<Robot | ReachableRobot>>
type GetLiveRobots = Selector<State, void, Array<ViewableRobot>>
type GetConnectedRobot = Selector<State, void, ?Robot>

export const CONNECTABLE: ConnectableStatus = 'connectable'
Expand Down Expand Up @@ -150,6 +151,7 @@ export const getRobotFirmwareVersion = (robot: AnyRobot): ?string =>
(robot.health && robot.health.fw_version) ||
(robot.serverHealth && robot.serverHealth.smoothieVersion)

// TODO(mc, 2019-07-19): replace with selector(s) in app/src/shell/buildroot
export const getRobotBuildrootStatus = (
robot: AnyRobot
): BuildrootStatus | null => {
Expand All @@ -161,14 +163,14 @@ export const getRobotBuildrootStatus = (
// migration capable proceed to step 2 automatically
if (
robot.serverHealth.capabilities &&
robot.serverHealth.capabilities['buildroot-migration']
robot.serverHealth.capabilities['buildrootMigration']
) {
return 'migrating'
}
// robot is already on buildroot and capable of receiving normal buildroot updates
if (
robot.serverHealth.capabilities &&
robot.serverHealth.capabilities['buildroot-update']
robot.serverHealth.capabilities['buildrootUpdate']
) {
return 'buildroot'
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/epic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
// root application epic
import { combineEpics } from 'redux-observable'
import { robotApiEpic } from './robot-api'
import { buildrootUpdateEpic } from './shell'

export default combineEpics(robotApiEpic)
export default combineEpics(robotApiEpic, buildrootUpdateEpic)
4 changes: 2 additions & 2 deletions app/src/pages/Robots/RobotSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import ResetRobotModal from '../../components/RobotSettings/ResetRobotModal'

import type { ContextRouter } from 'react-router'
import type { State, Dispatch, Error } from '../../types'
import type { ViewableRobot, BuildrootStatus } from '../../discovery'
import type { ShellUpdateState } from '../../shell'
import type { ViewableRobot } from '../../discovery'
import type { ShellUpdateState, BuildrootStatus } from '../../shell'

type WithRouterOP = {|
robot: ViewableRobot,
Expand Down
2 changes: 2 additions & 0 deletions app/src/robot-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
export * from './types'
export * from './resources'
export * from './hooks'
export * from './http'
export * from './utils'

export { robotApiReducer } from './reducer'
2 changes: 1 addition & 1 deletion app/src/robot-api/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const createBaseRobotApiEpic = (
ofType(type),
switchMap<RobotApiAction, _, _>(a =>
// `any` typed to recast strictly-typed `meta` of RobotApiRequest
// to loosly-typed `meta` of RobotApi(Request|Response)Action
// to loosely-typed `meta` of RobotApi(Request|Response)Action
makeRobotApiRequest(a.payload, (a: any).meta)
)
)
Expand Down
121 changes: 0 additions & 121 deletions app/src/shell/__tests__/buildroot.test.js

This file was deleted.

109 changes: 0 additions & 109 deletions app/src/shell/buildroot.js

This file was deleted.

33 changes: 33 additions & 0 deletions app/src/shell/buildroot/__tests__/actions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as actions from '../actions'

describe('app/shell/buildroot action creators', () => {
const SPECS = [
{
name: 'buildroot:SET_UPDATE_SEEN',
creator: actions.setBuildrootUpdateSeen,
args: [],
expected: { type: 'buildroot:SET_UPDATE_SEEN' },
},
{
name: 'buildroot:START_PREMIGRATION',
creator: actions.startBuildrootPremigration,
args: [{ name: 'robot', ip: '10.10.0.0', port: 31950 }],
expected: {
type: 'buildroot:START_PREMIGRATION',
payload: { name: 'robot', ip: '10.10.0.0', port: 31950 },
meta: { shell: true },
},
},
{
name: 'buildroot:UNEXPECTED_ERROR',
creator: actions.unexpectedBuildrootError,
args: [],
expected: { type: 'buildroot:UNEXPECTED_ERROR' },
},
]

SPECS.forEach(spec => {
const { name, creator, args, expected } = spec
test(name, () => expect(creator(...args)).toEqual(expected))
})
})
Loading