Skip to content

Fix: PHP Warnings & Share/Device prev/next buttons on narrow screens#2373

Merged
limetech merged 3 commits into
unraid:masterfrom
Squidly271:navbuttons
Sep 17, 2025
Merged

Fix: PHP Warnings & Share/Device prev/next buttons on narrow screens#2373
limetech merged 3 commits into
unraid:masterfrom
Squidly271:navbuttons

Conversation

@Squidly271

@Squidly271 Squidly271 commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Style

    • Improved placement and styling of previous/next navigation buttons in tabbed views.
    • Buttons align right on larger screens and flow naturally on smaller screens for better responsiveness.
    • Navigation controls now render within the tabs container for consistent layout on Device and Share pages.
  • Bug Fixes

    • Resolved inconsistent positioning of navigation controls in tabbed layouts.
    • Hardened handling of WireGuard network labels to avoid errors when config files are missing or malformed.
    • Added safety checks to VLAN/network handling to prevent undefined-index errors.

@coderabbitai

coderabbitai Bot commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Add conditional .menuNavButtonsTabbed class for prev/next nav in tabbed mode, move injection target from .tabs to .tabs-container for tabbed/multi-sheet paths, add CSS positioning and responsive override, harden WireGuard config reading when building Docker network labels, and guard VLAN driver access in DockerClient to avoid undefined index notices.

Changes

Cohort / File(s) Summary
Tabbed nav injection logic
emhttp/plugins/dynamix/DeviceInfo.page, emhttp/plugins/dynamix/Share.page
Add conditional class menuNavButtonsTabbed when $tabbed is truthy. Change append target for nav controls from .tabs to .tabs-container in tabbed and multi-sheet code paths.
CSS for tabbed buttons
emhttp/plugins/dynamix/styles/default-base.css
Add .menuNavButtonsTabbed (position: absolute; right: 0) and a responsive override @media (max-width: 1024px) to set position: relative; right: auto.
WireGuard label hardening
emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php
Guard reading /etc/wireguard/$network.conf with is_file(...) ? file(...) : [] and use a safe check for the second line (($conf[1][0]??'') == '#') before appending description; avoid errors when file or lines are missing.
VLAN driver guard
emhttp/plugins/dynamix.docker.manager/include/DockerClient.php
Add isset($driver[$netName]) check before comparing driver type to prevent undefined index notices when network driver entry is absent.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant S as Server (PHP)
  participant B as Browser JS
  participant D as DOM

  U->>S: Request Device/Share page
  S-->>U: HTML (nav span includes `menuNavButtonsTabbed` if $tabbed)
  U->>B: load scripts
  B->>B: evaluate sheet count / $tabbed flag
  alt tabbed / multi-sheet
    B->>D: append(prevNextCtrl) to .tabs-container
    Note right of D #add8e6: nav element has class `menuNavButtonsTabbed`
  else not tabbed
    B->>D: append(prevNextCtrl) to .tabs
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I’m a rabbit in the DOM so spry,
Tabs align and buttons fly.
Right on wide screens I take my stand,
I flow back down when view is bland.
Tiny guards and tweaks — hop, all is tidy! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately and concisely reflects the primary changes in the patch: fixes for PHP warnings (guarding file/array accesses) and adjustments to Share/Device prev/next button behavior on narrow screens (HTML/JS target change plus new responsive CSS). It is specific to the modified areas and clearly communicates the main intent of the changeset.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12ab3df and 04882c3.

📒 Files selected for processing (1)
  • emhttp/plugins/dynamix.docker.manager/include/DockerClient.php (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Squidly271
PR: unraid/webgui#0
File: :0-0
Timestamp: 2025-05-31T05:10:13.120Z
Learning: Squidly271 prefers not to receive CodeRabbit reviews or feedback while PRs are in draft status. Only provide reviews after PRs are moved out of draft.
🔇 Additional comments (1)
emhttp/plugins/dynamix.docker.manager/include/DockerClient.php (1)

1007-1014: Good guard against undefined index on network drivers.

Adding isset($driver[$netName]) prevents notices when a network entry is missing. Looks correct and low-risk.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Sep 17, 2025

Copy link
Copy Markdown

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2025.09.17.0140
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2373/webgui-pr-2373.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates

📝 Modified Files:

Click to expand file list
emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php
emhttp/plugins/dynamix.docker.manager/include/DockerClient.php
emhttp/plugins/dynamix/DeviceInfo.page
emhttp/plugins/dynamix/Share.page
emhttp/plugins/dynamix/sheets/ShareEdit.css
emhttp/plugins/dynamix/styles/default-base.css

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2025.09.17.0140, or run:

plugin remove webgui-pr-2025.09.17.0140

🤖 This comment is automatically generated and will be updated with each new push to this PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
emhttp/plugins/dynamix/styles/default-base.css (1)

232-241: Reserve space and ensure stacking for absolute nav; consider adding top and z-index.

Absolute positioning without reserving space can overlap the last tab; also, without an explicit stacking context it may sit under other elements.

Apply this diff to improve robustness:

 .menuNavButtonsTabbed {
   position: absolute;
   right: 0;
+  top: 0;
+  z-index: 1; /* keep buttons above tabs */
 }
 @media (max-width: 1024px) {
   .menuNavButtonsTabbed {
     position: relative;
     right: auto;
   }
 }

Additionally, add right padding to the tabs container when the buttons are present so last tabs remain clickable:

/* outside the changed hunk */
.tabs-container.hasMenuNavButtons { padding-right: 64px; } /* ~2 icon buttons + gap */

Note: If you prefer avoiding a new class, we could use :has, but adding a class is safer for older engines.

Please confirm the last tab remains fully clickable when many tabs overflow on desktop and that no overlap occurs at widths just above 1024px.

emhttp/plugins/dynamix/Share.page (1)

61-64: Also mark the container to reserve space for the absolute buttons.

Chaining a class onto the container lets CSS add padding-right to avoid covering the last tab.

Apply this diff:

-  const target = <?= $tabbed ? '".tabs-container"' : '".title:first .right"' ?>;
-  $(target).append(prevNextButtons);
+  const target = <?= $tabbed ? '".tabs-container"' : '".title:first .right"' ?>;
+  $(target).append(prevNextButtons)<?= $tabbed ? '.addClass("hasMenuNavButtons")' : '' ?>;

Please verify on shares with many tabs that the last tab isn’t occluded at desktop widths.

emhttp/plugins/dynamix/DeviceInfo.page (2)

1935-1938: Class injection LGTM; minor a11y nit (optional).

The conditional menuNavButtonsTabbed is correct. Optional: add aria-labels on the chevron buttons to complement title for screen readers.

Example:

-  var ctrl  = "<span class='inline-flex flex-row items-center gap-2<?= $tabbed ? ' menuNavButtonsTabbed' : ''?>'><span class='waitmsg fa fa-circle-o-notch fa-span fa-fw' style='display:none;'></span><a href='/<?=$path?>?name=<?=$prev?>' title='_(previous device)_'>";
-      ctrl += "<button type='button' onclick='this.disabled=true;$(\".waitmsg\").show();'><i class='fa fa-chevron-left fa-fw'></i></button></a>";
-      ctrl += "<a href='/<?=$path?>?name=<?=$next?>' title='_(next device)_'><button type='button' onclick='this.disabled=true;$(\".waitmsg\").show();'><i class='fa fa-chevron-right fa-fw'></i></button></a></span>";
+  var ctrl  = "<span class='inline-flex flex-row items-center gap-2<?= $tabbed ? ' menuNavButtonsTabbed' : ''?>'><span class='waitmsg fa fa-circle-o-notch fa-span fa-fw' style='display:none;'></span><a href='/<?=$path?>?name=<?=$prev?>' title='_(previous device)_' aria-label='_(previous device)_'>";
+      ctrl += "<button type='button' aria-hidden='true' onclick='this.disabled=true;$(\".waitmsg\").show();'><i class='fa fa-chevron-left fa-fw'></i></button></a>";
+      ctrl += "<a href='/<?=$path?>?name=<?=$next?>' title='_(next device)_' aria-label='_(next device)_'><button type='button' aria-hidden='true' onclick='this.disabled=true;$(\".waitmsg\").show();'><i class='fa fa-chevron-right fa-fw'></i></button></a></span>";

1939-1943: Append target switch LGTM; add container class to prevent tab overlap.

Adds consistency with Share.page and enables CSS padding-right.

Apply this diff:

-  $('.tabs-container').append(ctrl);
+  $('.tabs-container').append(ctrl).addClass('hasMenuNavButtons');

Please confirm device tabs remain fully clickable on desktop when overflowing and that behavior matches Share.page.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ada892e and eb43127.

📒 Files selected for processing (3)
  • emhttp/plugins/dynamix/DeviceInfo.page (1 hunks)
  • emhttp/plugins/dynamix/Share.page (2 hunks)
  • emhttp/plugins/dynamix/styles/default-base.css (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Squidly271
PR: unraid/webgui#0
File: :0-0
Timestamp: 2025-05-31T05:10:13.120Z
Learning: Squidly271 prefers not to receive CodeRabbit reviews or feedback while PRs are in draft status. Only provide reviews after PRs are moved out of draft.
📚 Learning: 2025-09-05T19:26:36.587Z
Learnt from: zackspear
PR: unraid/webgui#2354
File: emhttp/plugins/dynamix/ShareEdit.page:0-0
Timestamp: 2025-09-05T19:26:36.587Z
Learning: In emhttp/plugins/dynamix/ShareEdit.page, the clone-settings div was moved outside the form element and both are wrapped in a div.relative container to prevent event bubbling issues while maintaining proper positioning.

Applied to files:

  • emhttp/plugins/dynamix/Share.page
🔇 Additional comments (1)
emhttp/plugins/dynamix/Share.page (1)

49-58: Class injection LGTM.
The conditional addition of menuNavButtonsTabbed is correct and localized to tabbed mode.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php (1)

1097-1098: Avoid undefined offset and string-offset warnings when line 2 is missing.

($conf[1][0] ?? '') still indexes $conf[1] before ??, which can emit warnings if the file has fewer than 2 lines or the second line is empty. Guard with isset() and use strncmp() (or str_starts_with() on PHP 8+) to avoid string-offset access.

Apply this diff:

-    $conf = is_file("/etc/wireguard/$network.conf") ? file("/etc/wireguard/$network.conf") : [];
-    if ( ($conf[1][0]??'')=='#') $name .= ' -- '.compress(trim(substr($conf[1],1)));
+    $conf = is_file("/etc/wireguard/$network.conf") ? file("/etc/wireguard/$network.conf") : [];
+    if (isset($conf[1]) && strncmp($conf[1], '#', 1) === 0) {
+      $name .= ' -- ' . compress(trim(substr($conf[1], 1)));
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb43127 and 12ab3df.

📒 Files selected for processing (1)
  • emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Squidly271
PR: unraid/webgui#0
File: :0-0
Timestamp: 2025-05-31T05:10:13.120Z
Learning: Squidly271 prefers not to receive CodeRabbit reviews or feedback while PRs are in draft status. Only provide reviews after PRs are moved out of draft.
🧬 Code graph analysis (1)
emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php (1)
emhttp/plugins/dynamix/include/Helpers.php (1)
  • compress (235-237)

@Squidly271 Squidly271 changed the title Fix: Share/Device prev/next buttons on narrow screens Fix: PHP Warnings & Share/Device prev/next buttons on narrow screens Sep 17, 2025
@limetech limetech merged commit 71abe53 into unraid:master Sep 17, 2025
2 checks passed
@Squidly271 Squidly271 deleted the navbuttons branch September 17, 2025 04:38
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