Skip to content

refactor(web): network connection form UX (part 4)#3351

Merged
dgdavid merged 8 commits intoenhance-network-connection-formfrom
network-tanstack-form-part4
Apr 1, 2026
Merged

refactor(web): network connection form UX (part 4)#3351
dgdavid merged 8 commits intoenhance-network-connection-formfrom
network-tanstack-form-part4

Conversation

@dgdavid
Copy link
Copy Markdown
Contributor

@dgdavid dgdavid commented Mar 31, 2026

This PR continues the network connection form reimplementation, built on top of #3349. It adds edit mode, fixes how the form derives the IP method when editing, and introduces a not-found empty state.

Edit mode

ConnectionForm is split into NewConnectionForm and EditConnectionForm, both delegating to a shared ConnectionFormContent. When a route id param is present, the form pre-populates from the existing connection: IP mode, addresses, gateways, DNS servers, and search domains are all restored. The connection name field is not shown: it cannot be changed and the name is already visible in the breadcrumb.

localhost_8080_ (24)

Not-found empty state

When the connection id from the route does not match any known connection, EditConnectionForm renders a ConnectionNotFound empty state page instead of crashing.

localhost_8080_ (26)

Postponed for follow-up PRs

  • Auto-generated connection name.
  • Evaluate if it "Advanced" mode must be shown when config has no method but system already has addresses.

Notes for reviewers

Changelog entry postponed f r the final PR from the feature branch against master.

dgdavid added 5 commits March 31, 2026 20:45
Previously both fields defaulted to ConnectionMethod.AUTO, causing a
connection saved without an explicit method to round-trip as "auto",
making every edited connection appear as "Advanced" in the form instead
of "Automatic".

  - Remove the AUTO default so absence of a method is represented as undefined
  - Mark APIConnection.method4/method6 optional to reflect the backend may omit them
  - toApi(): omit the fields when undefined
  - fromApi(): assign as explicit own properties so object spreading when
    merging config and system connections overrides system's "auto" correctly
Splits ConnectionForm into NewConnectionForm and EditConnectionForm.
EditConnectionForm reads the connection from system state and
pre-populates form fields via connectionToFormValues, so the user sees
the current values when editing an existing connection.
When editing a connection, merge config and system connections giving
precedence to config. This ensures the form reflects what the user
explicitly saved: e.g. a connection with no method4 in config (the user
chose "Automatic", meaning "do not put method in the config") correctly
shows as Automatic instead of Advanced, which Agama backend or
NetworkManager might report for automatic connections.
This prevents users changing the connection id, which is not fully
supported at backend side yet.
The commit also extracts the Page shell to ConnectionForm and please
linter.
@dgdavid dgdavid requested a review from teclator March 31, 2026 21:22
…emoval

WiredConnectionDetails now shows "None set" when method4/method6 is
undefined, and the test mock explicitly sets AUTO to represent a DHCP
connection.

IpSettingsForm tests are skipped since the component is
pending deletion.
Comment on lines +62 to +67
// TODO: evaluate whether this page and WiredConnectionDetails should merge config
// and system connections (like EditConnectionForm does) so that displayed values
// reflect what the user actually configured. Currently useConnections reads from
// the proposal source, which always reports e.g. method4: "auto" even when the
// config has no method set. If merging is not adopted here, ConnectionForm should
// be made consistent and drop its own merge too.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@teclator

We were discussing this morning in a meeting the counterpart of this for properly displaying the right values when editing a connection. Maybe I missunderstood you, but I solved it by merging config and system documents, prioritizing the firtst one (see relevant commit if interested on it).

Later, I realized that fixing some stuff for it in current types (which are supposed to change too) made some other components fail, like the one in charge of displaying the details. It is using the proposal document.

Hence, this comment in the code.

I guess we should put some order in all of this. Meanwhile, I will continue ahead with the network connection form re-implementation, which is almost done as you can see. IMHO, this kind of decisions shouldn't block this feature branch, but being addressed as another PR instead.

Please, be aware of this concern.

Improvement suggested in code review.
Copy link
Copy Markdown
Contributor

@ancorgs ancorgs left a comment

Choose a reason for hiding this comment

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

LGTM

@dgdavid dgdavid merged commit 478d120 into enhance-network-connection-form Apr 1, 2026
4 checks passed
@dgdavid dgdavid deleted the network-tanstack-form-part4 branch April 1, 2026 11:50
dgdavid added a commit that referenced this pull request Apr 7, 2026
A continuation of network connection form reimplementation, built on top
of #3351.

It prefills connection name when creating a new connection with a value
based based on the connection type and the selected binding:

- Any device: connection type only, no suffix. E.g., "Ethernet"
- Chosen by name: connection type and device name. E.g.,
"Ethernet enp1s0"
- Chosen by MAC: connection type and device MAC address. E.g.,
"Ethernet 001122334455" (colons stripped)

The name updates reactively as the user changes the binding or device
selection. Once the user manually edits the Name field, auto-filling
stops.

If the base name is already taken by an existing connection, a numeric
suffix is appended (`Ethernet 2`, `Ethernet 3`, etc).


Interesting reading:

*
https://tanstack.dev/form/latest/docs/framework/react/guides/basic-concepts#field-state
@imobachgs imobachgs mentioned this pull request Apr 14, 2026
imobachgs added a commit that referenced this pull request Apr 14, 2026
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