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): add wifi disconnect #5028

Closed
wants to merge 29 commits into from
Closed

Conversation

iansolano
Copy link
Contributor

@iansolano iansolano commented Feb 19, 2020

overview

Refactors select network functionality on robot settings screen. Handles disconnect, connect, and joining of wifi networks.

changelog

review requests

@iansolano iansolano added WIP DO NOT MERGE Indicates a PR should not be merged, even if there's a shiny green merge button available labels Feb 19, 2020
@iansolano iansolano requested review from a team as code owners February 19, 2020 20:13
@codecov
Copy link

codecov bot commented Feb 26, 2020

Codecov Report

Merging #5028 into edge will increase coverage by 0.24%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge    #5028      +/-   ##
==========================================
+ Coverage   68.86%   69.10%   +0.24%     
==========================================
  Files        1082     1090       +8     
  Lines       36045    36158     +113     
==========================================
+ Hits        24822    24988     +166     
+ Misses      11223    11170      -53     
Impacted Files Coverage Δ
...omponents/RobotSettings/SelectNetwork/constants.js 100.00% <0.00%> (ø)
app/src/networking/epic/disconnectEpic.js 100.00% <0.00%> (ø)
...Settings/SelectNetwork/SelectNetworkModal/index.js 100.00% <0.00%> (ø)
...SelectNetworkModal/ConnectDisconnectModal/utils.js 33.33% <0.00%> (ø)
...obotSettings/SelectNetwork/SelectSsid/constants.js 100.00% <0.00%> (ø)
...SelectNetworkModal/ConnectDisconnectModal/index.js 50.00% <0.00%> (ø)
...Settings/SelectNetwork/SelectNetworkModal/utils.js 16.66% <0.00%> (ø)
...rc/components/RobotSettings/SelectNetwork/hooks.js 100.00% <0.00%> (ø)
...rc/components/RobotSettings/SelectNetwork/utils.js 90.00% <0.00%> (ø)
components/src/forms/Select.js 93.33% <0.00%> (+6.66%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3713002...5c9424e. Read the comment docs.

@iansolano iansolano force-pushed the app_add-wifi-disconnect branch 2 times, most recently from 2e43469 to 14ac643 Compare February 26, 2020 21:52
Copy link
Contributor

@mcous mcous left a comment

Choose a reason for hiding this comment

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

Batch of comments. Haven't gotten to the big components yet, so more incoming tomorrow

@iansolano iansolano added the robot-svcs Falls under the purview of the Robot Services squad (formerly CPX, Core Platform Experience). label Feb 27, 2020
@iansolano iansolano changed the title [WIP] feat(app): add wifi disconnect feat(app): add wifi disconnect Feb 27, 2020
@iansolano iansolano added DO NOT MERGE Indicates a PR should not be merged, even if there's a shiny green merge button available and removed DO NOT MERGE Indicates a PR should not be merged, even if there's a shiny green merge button available WIP labels Feb 27, 2020
Copy link
Contributor

@mcous mcous left a comment

Choose a reason for hiding this comment

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

Lot of comments in this one, but the only two that are important to tackle in this PR before merging are:

  • "Join other" and "Disconnect" need to be in groups to get group separators
  • "Disconnect" should not be an option if the robot isn't on Wi-Fi

The rest of my comments are important, but addressing them before we switch to the better actions / state will result in unnecessary churn, so please resist the temptation

}

const SELECT_ACTIONS_OPTIONS = [
{ value: JOIN_OTHER_VALUE },
Copy link
Contributor

Choose a reason for hiding this comment

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

The { options: [{value: JOIN_OTHER_VALUE}] } was intentional and created an option group rather than a simple option. Removing the group wrapper causes the list to render incorrectly, without the separator

This build:

Screen Shot 2020-02-27 at 5 05 13 PM

Production:

Screen Shot 2020-02-27 at 5 05 01 PM

if (showWifiDisconnect) {
return list
.map(({ ssid }) => ({ value: ssid }))
.concat(SELECT_ACTIONS_OPTIONS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Per screens, "disconnect" should be in its own group at the beginning of the list. We don't have to address in this PR, but adding this comment because it relates to the option group comment above

Screen Shot 2020-02-27 at 5 07 12 PM

(Ignore incorrect background color + various other wrong stuff in screens)

failure,
modalOpen,
ssid,
previousSsid,
Copy link
Contributor

Choose a reason for hiding this comment

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

previousSsid seems entirely redundant with the presence of networkingType or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, it can go away once we fix up the handler, which will be made even easier by splitting up the onChange work

const [networkingType, setNetworkingType] = useState<NetworkingType | null>(
null
)
const [securityType, setSecurityType] = useState<WifiSecurityType | null>(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is only a concern when joining an unknown network; I don't think it needs to be up here

const [securityType, setSecurityType] = useState<WifiSecurityType | null>(
null
)
const [modalOpen, setModalOpen] = useState<boolean>(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems redundant when networkingType is a thing

app/src/pages/Robots/index.js Outdated Show resolved Hide resolved
app/src/components/RobotSettings/SelectNetwork/index.js Outdated Show resolved Hide resolved
app/src/components/RobotSettings/SelectNetwork/index.js Outdated Show resolved Hide resolved
app/src/networking/epic/__tests__/wifiListEpic.test.js Outdated Show resolved Hide resolved
getActiveSsid(): ?string {
const activeNetwork = find(this.props.list, 'active')
return activeNetwork && activeNetwork.ssid
setSsid(currentSsid)
Copy link
Contributor

Choose a reason for hiding this comment

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

The fact that one handler sets all these different things is a red flag. At most I think we need two pieces of state:

  • Current action: connect, disconnect, join other, null (close modal)
  • Network to join (if action is connect)

Disconnect needs to hang on to the active network so it can display proper copy after it's no longer marked "active" in state, but that should be local to whatever DisconnectModal we write

Copy link
Contributor Author

Choose a reason for hiding this comment

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

💯

@mcous
Copy link
Contributor

mcous commented Mar 25, 2020

Closing in favor of #5234 and #5280. Those PRs were both created from this branch, which is now safe to delete

@mcous mcous closed this Mar 25, 2020
@mcous mcous deleted the app_add-wifi-disconnect branch May 6, 2020 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DO NOT MERGE Indicates a PR should not be merged, even if there's a shiny green merge button available robot-svcs Falls under the purview of the Robot Services squad (formerly CPX, Core Platform Experience).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants