Skip to content

File manager: add UD shares to top level user shares#2147

Merged
limetech merged 2 commits into
unraid:masterfrom
bergware:master
Apr 11, 2025
Merged

File manager: add UD shares to top level user shares#2147
limetech merged 2 commits into
unraid:masterfrom
bergware:master

Conversation

@bergware

@bergware bergware commented Apr 11, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Introduced a new CSS file for styling textarea elements, ensuring a consistent look and feel.
  • Refactor

    • Adjusted the logic for displaying file shares in dropdown menus to show only relevant directories.
    • Streamlined how top-level and user-specific directories are handled, enhancing the browsing experience for available shares.
  • Style

    • Simplified the styling of the <textarea> element by removing inline CSS properties.

@coderabbitai

coderabbitai Bot commented Apr 11, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes adjust the directory structure handling in the FileTree.php file. Two new variables, $topdir and $userdir, are introduced with values /mnt/ and /mnt/user/, respectively. The $udShares array is modified to remove the 'addons' entry, leaving only 'disks' and 'remotes'. Conditional logic is updated to compare the current directory against these new variables and, when matching $userdir, iterates over shares to add unassigned devices. These modifications alter how file shares are displayed based on the directory context.

Changes

File Path Change Summary
emhttp/.../FileTree.php Modified the is_low function: added variables $topdir (/mnt/) and $userdir (/mnt/user/), removed 'addons' from $udShares (now ['disks','remotes']), and updated directory conditional logic.
emhttp/.../SMBExtras.page Modified <textarea> element: removed inline style attributes for simplified styling.
emhttp/.../SMBExtras.css Added new CSS file SMBExtras.css with styles for textarea elements, specifying non-resizable and font-family as "bitstream".

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant FileTree

    Caller->>FileTree: Call is_low(rootdir)
    alt rootdir equals $topdir
        FileTree->>FileTree: Exclude folder from dropdown
    else rootdir equals $userdir
        FileTree->>FileTree: Iterate over udShares
        FileTree->>FileTree: Check directory existence under $topdir
        FileTree->>FileTree: Add unassigned shares
    end
    FileTree->>Caller: Return updated share list
Loading

Poem

Oh, I hopped through lines of code so bright,
Tweaking paths beneath the digital light.
With $topdir and $userdir in my hop,
I rearranged shares without a stop.
A bunny’s touch in every bit and byte,
Celebrating changes in the coding night!
🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 65995e2 and b727b10.

📒 Files selected for processing (2)
  • emhttp/plugins/dynamix/SMBExtras.page (1 hunks)
  • emhttp/plugins/dynamix/sheets/SMBExtras.css (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • emhttp/plugins/dynamix/sheets/SMBExtras.css
  • emhttp/plugins/dynamix/SMBExtras.page

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@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/include/FileTree.php (1)

88-93: Functionality added to display unassigned devices in user directory view.

The implementation correctly adds unassigned devices top-level shares when browsing the user directory. The code:

  1. Checks if the current directory is /mnt/user/
  2. Iterates through $udShares array ('disks' and 'remotes')
  3. Adds them to the directory listing if they exist under /mnt/

Consider adding error handling for potential permission issues when accessing these directories.

if ($rootdir === $userdir) {
  // add unassigned devices top level shares
- foreach ($udShares as $name) if (is_dir($topdir.$name)) {
+ foreach ($udShares as $name) {
+   $path = $topdir.$name;
+   if (is_dir($path) && is_readable($path)) {
    echo "<li class='directory collapsed'>$checkbox<a href='#' rel=\"{$topdir}{$name}/\">$name</a></li>";
+   }
  }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f07f46 and 65995e2.

📒 Files selected for processing (1)
  • emhttp/plugins/dynamix/include/FileTree.php (2 hunks)
🔇 Additional comments (3)
emhttp/plugins/dynamix/include/FileTree.php (3)

48-49: Good variable extraction for path constants.

Using dedicated variables for the directory paths improves code maintainability and readability.


82-82: Clean path reference update.

Good refactoring to use the $topdir variable instead of hardcoding the path in the condition.


56-56:

Details

❓ Verification inconclusive

Verify removal of 'addons' from unassigned device shares.

The $udShares array has been modified to only include 'disks' and 'remotes', removing 'addons'. Make sure this aligns with the desired behavior for unassigned devices top-level shares.


🏁 Script executed:

#!/bin/bash
# Check the structure under /mnt/ to verify if 'disks' and 'remotes' directories exist
# This helps confirm the array changes are appropriate

echo "Checking for directories in /mnt/"
ls -la /mnt/ 2>/dev/null | grep -E "disks|remotes|addons" || echo "Directories not found"

Length of output: 177


Confirm Removal of "addons" from Unassigned Device Shares

The $udShares array in emhttp/plugins/dynamix/include/FileTree.php (line 56) now only includes "disks" and "remotes", with "addons" removed as intended. The shell script check on /mnt/ returning “Directories not found” confirms that none of the directories (including "addons") are present in the test environment. Please verify in an environment where these mounts are populated that the removal aligns with the desired behavior for unassigned device shares.

@limetech limetech merged commit 6486409 into unraid:master Apr 11, 2025
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