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): Remove ssid parameter from OnDeviceRouteParams #11930

Merged
merged 39 commits into from
Jan 31, 2023

Conversation

koji
Copy link
Contributor

@koji koji commented Dec 27, 2022

Overview

This PR removes :ssid from routers and passes ssid as a prop and move a couple of components from pages to organisms.
ConnectViaWifi renders components conditionally.

changeState: null => DisplayWifiList
changeState: !null && showSelectAuthenticationType: true => SelectAuthenticationType
changeState: !null && showSelectAuthenticationType: false => SetWifiCred
After tapping Connect button in SetWifiCred, ConnectViaWifi checks requestState

requestState.status pending => ConnectingNetwork
requestState.status success => SucceededToConnect
requestState.status failure => FailedToConnect

This PR also fixes UI diff between current edge and mid-fi design.

Changelog

  • remove :ssid from routers
  • remove 2 routes (set-wifi-cred and connected-network-info ) from OnDeviceDisplayApp
  • Update Wifi Connection screens to align with the mid-fi design
  • ConnectResult component changes into FailedToConnect component

Review requests

  • make -C app-shell push-ot3 host=dev_kit_ip_address and wifi auto connection process works as expected

Risk assessment

low

@codecov
Copy link

codecov bot commented Dec 27, 2022

Codecov Report

Merging #11930 (ee7098f) into edge (da72cfb) will increase coverage by 0.34%.
The diff coverage is 84.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #11930      +/-   ##
==========================================
+ Coverage   73.72%   74.06%   +0.34%     
==========================================
  Files        1439     2195     +756     
  Lines       47598    60734   +13136     
  Branches     2987     6464    +3477     
==========================================
+ Hits        35091    44985    +9894     
- Misses      12052    14221    +2169     
- Partials      455     1528    +1073     
Flag Coverage Δ
app 72.48% <84.55%> (+26.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
app/src/App/OnDeviceDisplayApp.tsx 44.44% <ø> (ø)
...p/src/organisms/SetupNetwork/ConnectingNetwork.tsx 100.00% <ø> (ø)
...rganisms/SetupNetwork/SelectAuthenticationType.tsx 61.90% <61.90%> (ø)
app/src/pages/OnDeviceDisplay/ConnectViaWifi.tsx 82.69% <82.69%> (ø)
app/src/organisms/SetupNetwork/SetWifiCred.tsx 83.33% <83.33%> (ø)
.../src/organisms/SetupNetwork/SucceededToConnect.tsx 91.66% <91.66%> (ø)
app/src/organisms/SetupNetwork/DisplayWifiList.tsx 100.00% <100.00%> (ø)
app/src/organisms/SetupNetwork/FailedToConnect.tsx 100.00% <100.00%> (ø)
app/src/organisms/SetupNetwork/SearchNetwork.tsx 100.00% <100.00%> (ø)
...ons_hardware/hardware_control/move_group_runner.py 82.77% <0.00%> (-5.90%) ⬇️
... and 771 more

@koji koji marked this pull request as ready for review December 27, 2022 22:25
@koji koji requested a review from a team as a code owner December 27, 2022 22:25
return (
<>
{isShowSetWifiCred ? (
<SetWifiCred ssid={ssid} />
Copy link
Contributor

Choose a reason for hiding this comment

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

SetWifiCred is the parent of this component - nesting an instance of the parent here potentially creates multiple instances of SetWifiCred all the way down:

Screen Shot 2023-01-06 at 1 44 54 PM

Probably SelectWifiNetwork should manage switching back to SetWifiCred instead

Comment on lines 28 to 31
const [isShowSetWifiCred, setIsShowSetWifiCred] = React.useState<boolean>(
false
)
const [selectedSsid, setSelectedSsid] = React.useState<string>('')
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to use a single local state value, string | null, here?

</SecondaryButton>
<PrimaryButton
flex="1"
onClick={() => history.push('/network-setup/wifi')}
Copy link
Contributor

Choose a reason for hiding this comment

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

this push now points to the page the app is on, so doesn't make any change.

Copy link
Contributor

Choose a reason for hiding this comment

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

same issue with history.push('/network-setup/wifi') in SetWifiCred and ConnectedNetworkInfo components

@koji koji changed the title refactor(app): Remove ssid parameter from routes refactor(app): Remove ssid parameter from OnDeviceRouteParams Jan 12, 2023
@koji koji marked this pull request as draft January 12, 2023 16:52
@koji koji marked this pull request as ready for review January 19, 2023 18:50
Copy link
Contributor

@brenthagen brenthagen left a comment

Choose a reason for hiding this comment

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

a few comments to consider - overall a big improvement in page/component structure 👍

Comment on lines +140 to +142
React.useEffect(() => {
dispatch(Networking.fetchWifiList(robotName))
}, [dispatch, robotName])
Copy link
Contributor

Choose a reason for hiding this comment

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

with the interval below, is this useEffect necessary?

setChangeState,
}: SelectAuthenticationTypeProps): JSX.Element {
const { t } = useTranslation(['device_settings', 'shared'])
const [isWpaTapped, setIsWpaTapped] = React.useState<boolean>(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

this local state is duplicating selectedAuthType from the parent - should pass that in as a prop instead and delete this useState

Comment on lines 160 to 163
React.useEffect(() => {
// a user selects none as authType
if (selectedSsid !== '' && selectedAuthType === 'none') {
const network = list.find((nw: WifiNetwork) => nw.ssid === selectedSsid)
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this useEffect is causing issues on the SelectAuthenticationType screen - if i select "None" the connect request is made immediately, and if it fails, it fails silently. i don't see the failure until clicking "Next". instead, it seems more in line with what i expect to make the request on clicking "Next".

Related, if i select "None" then switch back to "WPA2 Personal" and click "Next", I get the failure screen without being prompted to enter a password. this is also unexpected.

instead of fixing now, we could make a bug ticket in order to get this large PR merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will make a ticket for this

Comment on lines +55 to +58
React.useEffect(() => {
dispatch(fetchStatus(robotName))
dispatch(fetchWifiList(robotName))
}, [robotName, dispatch])
Copy link
Contributor

Choose a reason for hiding this comment

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

similar question, is the useEffect necessary with the intervals above? (and can those two be a single useInterval?

Comment on lines 10 to 11
// import { DisplayWifiList } from '../DisplayWifiList'
// import { SetWifiCred } from '../SetWifiCred'
Copy link
Contributor

Choose a reason for hiding this comment

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

some leftover comments

Comment on lines 31 to 34
// const mockDisplayWifiList = DisplayWifiList as jest.MockedFunction<
// typeof DisplayWifiList
// >
// const mockSetWifiCred = SetWifiCred as jest.MockedFunction<typeof SetWifiCred>
Copy link
Contributor

Choose a reason for hiding this comment

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

some leftover comments

Comment on lines 56 to 57
// mockDisplayWifiList.mockReturnValue(<div>Mock DisplayList</div>)
// mockSetWifiCred.mockReturnValue(<div>Mock SetWifiCred</div>)
Copy link
Contributor

Choose a reason for hiding this comment

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

some leftover comments

setPassword('')
}

const renderScreen = (): JSX.Element | null => {
Copy link
Contributor

Choose a reason for hiding this comment

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

it's just a matter of code style/preference, but these nested conditionals are tough to reason about (and could cause bugs). some options here:

  • use a switch statement
  • use useReducer
  • lift the nested conditions to a single flat level, like:
} else if (changeState.ssid != null && currentRequestState === null) {

instead of

    } else if (changeState.ssid != null) {
      if (currentRequestState === null) {

@koji
Copy link
Contributor Author

koji commented Jan 30, 2023

  • address the last comment
  • test this branch with a dev kit

@koji koji merged commit 4774d49 into edge Jan 31, 2023
y3rsh added a commit that referenced this pull request Feb 7, 2023
* edge: (116 commits)
  feat(system-server): add sqlite database and barebones HTTP server (#12085)
  feat(ot3): add enableOT3FirmwareUpdates feature flag to gate firmware update functionality. (#12102)
  feat(app): add bare bones hardware section to protocol details (#12099)
  feat(app): Support failed calibrations in the calibration wizard (#12092)
  refactor(docs): clean up Versioning page (#12084)
  refactor(robot-server): Make run and protocol limits configurable at launch (#12094)
  feat(app): add robotServerVersion to display the current robot software version (#12096)
  fix(hardware): do not track tip motor positions (#12093)
  feat(engine): allow calibrateGripper command to save calibration data (#12046)
  feat(app, api-client, react-api-client): delete POC TLC calibration data from overflow menu (#12075)
  fix(api): actually update OT3 instrument calibration offset in cache instrument (#12089)
  fix(robot-server): correct the data returned from instruments endpoint (#12067)
  feat(api): add thermocycler plate lift to hardware controller (#12068)
  fix(app): reference moduleId from result not params (#12077)
  feat(app): create ODD protocol setup page (#12071)
  refactor(api): Deprecate presses and increment args when using PAPI pick_up_tip (#12079)
  fix(ot3): handle multiple responses for a tip action request (#12083)
  refactor(api): touch tip implementation for PAPIv2 engine core (#12053)
  refactor(app): Remove ssid parameter from OnDeviceRouteParams (#11930)
  fix(api): fix broken test in the api hardware controller (#12080)
  ...
@koji koji deleted the refactor-remove-ssid-parameter-from-routes branch June 17, 2023 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants