Skip to content

Commit c860450

Browse files
committed
Conditionally show Details column
Only when there's something to show
1 parent 24e99cf commit c860450

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed

pkg/networkmanager/network-main.jsx

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const NetworkPage = ({ privileged, operationInProgress, usage_monitor, pl
3737
const managed = [];
3838
const unmanaged = [];
3939
const plot_ifaces = [];
40+
let hasDetails = false;
4041

4142
interfaces.forEach(iface => {
4243
function hasGroup(iface) {
@@ -89,22 +90,25 @@ export const NetworkPage = ({ privileged, operationInProgress, usage_monitor, pl
8990
if (dev?.DeviceType === '802-11-wireless') {
9091
// Count only non-hidden networks (ones with SSID)
9192
const networkCount = dev.AccessPoints?.filter(ap => ap.Ssid).length || 0;
92-
detailsColumn = (
93-
<Flex columnGap={{ default: 'columnGapSm' }}>
94-
{networkCount > 0 && (
95-
<FlexItem>
96-
<Label status="info">
97-
{cockpit.format(cockpit.ngettext("$0 network", "$0 networks", networkCount), networkCount)}
98-
</Label>
99-
</FlexItem>
100-
)}
101-
{dev.ActiveAccessPoint?.Ssid && (
102-
<FlexItem>
103-
<Label status="success" icon={<ConnectedIcon />}>{dev.ActiveAccessPoint?.Ssid}</Label>
104-
</FlexItem>
105-
)}
106-
</Flex>
107-
);
93+
if (networkCount > 0 || dev.ActiveAccessPoint?.Ssid) {
94+
hasDetails = true;
95+
detailsColumn = (
96+
<Flex columnGap={{ default: 'columnGapSm' }}>
97+
{networkCount > 0 && (
98+
<FlexItem>
99+
<Label status="info">
100+
{cockpit.format(cockpit.ngettext("$0 network", "$0 networks", networkCount), networkCount)}
101+
</Label>
102+
</FlexItem>
103+
)}
104+
{dev.ActiveAccessPoint?.Ssid && (
105+
<FlexItem>
106+
<Label status="success" icon={<ConnectedIcon />}>{dev.ActiveAccessPoint?.Ssid}</Label>
107+
</FlexItem>
108+
)}
109+
</Flex>
110+
);
111+
}
108112
}
109113
row.columns.push({ title: detailsColumn });
110114

@@ -194,11 +198,11 @@ export const NetworkPage = ({ privileged, operationInProgress, usage_monitor, pl
194198
<ListingTable aria-label={_("Managed interfaces")}
195199
variant='compact'
196200
columns={[
197-
{ title: _("Name"), header: true, props: { width: 15 } },
198-
{ title: _("IP address"), props: { width: 35 } },
199-
{ title: _("Sending"), props: { width: 15 } },
200-
{ title: _("Receiving"), props: { width: 15 } },
201-
{ title: _("Details"), props: { width: 20 } },
201+
{ title: _("Name"), header: true, props: { width: hasDetails ? 15 : 25 } },
202+
{ title: _("IP address"), props: { width: hasDetails ? 35 : 25 } },
203+
{ title: _("Sending"), props: { width: hasDetails ? 15 : 25 } },
204+
{ title: _("Receiving"), props: { width: hasDetails ? 15 : 25 } },
205+
...(hasDetails ? [{ title: _("Details"), props: { width: 20 } }] : []),
202206
]}
203207
rows={managed} />
204208
</Card>
@@ -210,11 +214,11 @@ export const NetworkPage = ({ privileged, operationInProgress, usage_monitor, pl
210214
<ListingTable aria-label={_("Unmanaged interfaces")}
211215
variant='compact'
212216
columns={[
213-
{ title: _("Name"), header: true, props: { width: 15 } },
214-
{ title: _("IP address"), props: { width: 35 } },
215-
{ title: _("Sending"), props: { width: 15 } },
216-
{ title: _("Receiving"), props: { width: 15 } },
217-
{ title: _("Details"), props: { width: 20 } },
217+
{ title: _("Name"), header: true, props: { width: hasDetails ? 15 : 25 } },
218+
{ title: _("IP address"), props: { width: hasDetails ? 35 : 25 } },
219+
{ title: _("Sending"), props: { width: hasDetails ? 15 : 25 } },
220+
{ title: _("Receiving"), props: { width: hasDetails ? 15 : 25 } },
221+
...(hasDetails ? [{ title: _("Details"), props: { width: 20 } }] : []),
218222
]}
219223
rows={unmanaged} />
220224
</Card>}

test/verify/check-networkmanager-wifi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ wpa_passphrase=hidden99""")
269269
self.wait_for_iface_setting("Status", "Not available")
270270
b.wait_not_present("table[aria-label='Available networks']")
271271
b.click("#network-interface nav a:contains('Networking')")
272-
b.wait_text(f"tr[data-interface='{self.iface}'] [data-label='Details']", "")
272+
b.wait_not_present(f"tr[data-interface='{self.iface}'] [data-label='Details']")
273273

274274
m.execute("nmcli radio wifi on")
275275
# in theory, NM will now connect to OpenNet automatically; however, kill switch messes up

0 commit comments

Comments
 (0)