Add support for configuring WiFi devices#292
Conversation
* Extend the NetworkClient to retrieve the list of access points.
* It is just a draft and it does not work yet.
f443dc3 to
95e655e
Compare
It will encapsulate needed logic to create a connection object from given data before call to #addConnection method. Co-Authored-By: Knut Anderssen <kanderssen@suse.com>
93f2892 to
b1f1dff
Compare
e492b22 to
181adbc
Compare
| import { Dropdown, DropdownToggle } from "@patternfly/react-core"; | ||
| import { EOS_MORE_VERT as MenuIcon } from "eos-icons-react"; | ||
|
|
||
| export default function KebabMenu({ items, position = "right", id = Date.now(), ...props }) { |
There was a problem hiding this comment.
I guess it might happen that you get the same id twice, right?
There was a problem hiding this comment.
Yes, it could happen. However, it's difficult. Anyway, ideally the consumer will provide a better id, this is just the default/fallback value. I could change it for something like parseInt(Date.now() * Math.random()) if you think it worth it.
|
|
||
| const security_options = [ | ||
| { value: "", label: "None" }, | ||
| { value: "wpa-psk", label: "WPA & WPA2 Personal" } |
There was a problem hiding this comment.
I wonder if we should rely on SecurityProtocols. We do not need to fix it know, but we should review it along with other enums. Especially when translations come into play.
There was a problem hiding this comment.
In this case we missed a class enum for adding things like the label for example.
There was a problem hiding this comment.
Yes, that's true. My point is that using a "wpa-psk" looks fragile. But let's address it later.
|
|
||
| const securityFrom = (supported) => { | ||
| if (supported.includes("WPA2")) | ||
| return "wpa-psk"; |
There was a problem hiding this comment.
Same as above: we are using an ad-hoc string when we already have an enum for this.
There was a problem hiding this comment.
Similar to above and it also shows that is very related to the adapter... so maybe it should be declared there.
There was a problem hiding this comment.
Sure it should not be declared here :-) but as said before, we can live with this.
web/src/WifiSelector.jsx
Outdated
| }; | ||
|
|
||
| const renderFilteredNetworks = (networks) => { | ||
| return networks.map(n => { |
There was a problem hiding this comment.
Please, use a meaningful name. For a small function, is perfectly fine, but this one has around 60 lines :-)
web/src/WifiSelector.jsx
Outdated
|
|
||
| return ( | ||
| <Popup isOpen={isOpen} height="large" title="Connect to a Wi-Fi network"> | ||
| { renderFilteredNetworks(networksFromValues(networks)) } |
There was a problem hiding this comment.
Why not use a proper component? OK, I know, components are functions, but I would expect to have something like Networks and HiddenNetworkForm. Do you need to share all that state between them?
In any case, about the renderFilteredNetworks, does that function do any filtering? If that's not the case, I do not think you need to mention that in the name. It isn't very clear.
There was a problem hiding this comment.
Imo, you're right.
Somehow, we forget to extract this to small components after so many changes to get the Wi-Fi selector working. I have tried to improve the situation a bit, but I fear a better improvement/re-organization must wait until next iterations in the network area.
What is more, I'd like to create a custom SelectionList component (Wi-Fi and Product selector are quite similar, though) and reorganize not only that part, but the whole src/ directory.
Hope, however, it looks good/acceptable enough for now.
| // Do not include networks without SSID | ||
| if (!ap.ssid || ap.ssid === "") return networks; | ||
| // Do not include "duplicates" | ||
| if (knownSsids.includes(ap.ssid)) return networks; |
There was a problem hiding this comment.
What about filtering networks you cannot configure? For instance, we cannot set up a WEP network, right? Alternatively, we could show them, but we should not allow trying to connect.
bf1fc5a to
4119dbe
Compare
4119dbe to
b89c9a7
Compare
imobachgs
left a comment
There was a problem hiding this comment.
It looks much better now. Just a few suggestions, but feel free to ignore them.
Problem
In #260 we added basic support for configuring the network, the idea is to extend it supporting also wireless devices.
Solution
We have added support for configuring WiFi networks at least allowing the user to connect to a network without security or using WPA-PSK authentication as well as configuring a Hidden network.
Testing
Screenshots
Click to show/hide some screenshots