Skip to content

Conversation

@zackspear
Copy link
Contributor

@zackspear zackspear commented Apr 2, 2025

  • enhances pnpm sync-webgui-repo to include Unraid UI build + sync options
  • changed the dev intended ThemeSwitcher to use local / session storage

Summary by CodeRabbit

  • New Features

    • The theme switcher now respects your saved preferences, ensuring a more personalized interface.
    • The component build and synchronization process has been enhanced with new options for UI components and clearer feedback during operations.
    • New computed properties added for better state management in account and purchase functionalities.
  • Bug Fixes

    • Improved error handling and logging during the component build process.

…cesses

- Changed the import of chalk to use dynamic import for better compatibility.
- Updated paths for web components and UI components in the sync functions.
- Enhanced error handling and success messages during the build and sync processes for both web and UI components.
- Modified the menu options to reflect the new functionality for building and syncing UI components.

This refactor improves the overall structure and clarity of the code, ensuring better maintainability and user experience.
- Replaced `devModeEnabled` with `enableThemeSwitcher` to control the visibility of the theme switcher based on session and local storage values.
- This change enhances user experience by allowing theme switching to persist across sessions.

This refactor improves the functionality of the theme switcher component, ensuring it behaves as expected based on user preferences.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 2, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes update several components of the project. In the theme switcher, a new constant based on storage checks replaces the previous devModeEnabled flag, altering the display logic of the theme switcher. The repository synchronization script transitions to asynchronous imports, updates constants for build paths, and introduces new functions for handling UI component builds and synchronization. Enhanced logging and error handling accompany these modifications. Additionally, computed properties are added to account and purchase stores, improving data handling in various actions.

Changes

File(s) Change Summary
web/components/ThemeSwitcher.ce.vue Removed devModeEnabled; added storageKey and enableThemeSwitcher constants to check session/local storage for rendering the theme switcher.
web/scripts/sync-webgui-repo.js Changed to asynchronous import for chalk; removed old constants and added new ones (API_WEB_BUILD_PATH, API_UI_BUILD_PATH, WEBGUI_BASE_PATH, WEBGUI_WEB_SUBPATH, WEBGUI_UI_SUBPATH); updated control flow and logging; added handleUiComponentBuild and handleUiComponentSync methods.
web/store/account.ts Added sendType computed property from callbackStore.sendType for use in multiple action functions, enhancing data sent without altering fundamental logic.
web/store/purchase.ts Introduced new computed properties (serverPurchasePayload, inIframe, sendType) in usePurchaseStore, replacing direct store references and enhancing reactivity while passing sendType.value in various actions.
plugin/plugins/dynamix.unraid.net.plg Added two new file paths to FILES_TO_RESTORE and preserveFilesDirs arrays in the installation script, enhancing restoration and preservation logic for important files.

Poem

In lines of code, a tale unfolds,
A theme switcher now checks storages old and new.
With async calls and paths redefined,
Our script syncs both web and UI, true!
Cheers to changes, crisp and bright—coding magic in plain sight!
🚀✨


📜 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 77c9cb4 and ac315ef.

📒 Files selected for processing (1)
  • plugin/plugins/dynamix.unraid.net.plg (2 hunks)

🪧 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (7)
web/components/ThemeSwitcher.ce.vue (1)

37-38: Use a single source of truth or name to unify usage and reduce confusion.
These lines introduce a new storage key and boolean logic by checking both sessionStorage and localStorage. Consider whether you actually need both or if you should prioritize one. If a user toggles local storage but not session storage, this code still evaluates true. If that’s acceptable, then this is fine as is.

web/scripts/sync-webgui-repo.js (6)

7-10: Handle potential import errors for chalk.
Using dynamic import without error handling can fail silently if the module is missing or incompatible, causing runtime errors later. Consider wrapping this in a try-catch or checking if chalk is loaded successfully.


290-301: Enhance logging for build process flow.
The new build logic uses an async child process and logs upon success or failure. Consider adding more detail or structured logs to quickly troubleshoot build failures, such as build duration or environment info.


304-331: Consolidate duplicate build logic.
The UI build code mirrors the web build code. If they share a common structure, you could introduce a helper to handle the repetitive steps, letting you pass in different commands or directories.


363-385: Abstract common code between web and UI sync.
This sync function is almost identical to handleWebComponentSync(). Consolidating them into a single function with parameters for each subpath can reduce maintenance overhead.


571-571: Avoid infinite loop risk.
While a while (true) menu loop is functional, consider a do-while with a defined exit condition to reduce the chance of unexpected infinite loops if the user input is unhandled.


577-581: Menu clarity improvement.
The new menu options are clear, but consider unifying them under a single “Build & Sync” sub-menu or grouping them logically to reduce confusion for new contributors.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3911be3 and 3f8d3fb.

📒 Files selected for processing (2)
  • web/components/ThemeSwitcher.ce.vue (2 hunks)
  • web/scripts/sync-webgui-repo.js (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build Web App
  • GitHub Check: Test API
  • GitHub Check: Build API
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
web/components/ThemeSwitcher.ce.vue (1)

77-77: Ensure consistent fallback behavior for theme selection.
Currently, the theme switcher is shown if enableThemeSwitcher is true in storage. If no storage values exist, it remains hidden. Double-check you have an intended default or fallback to avoid confusion if neither storage is set.

web/scripts/sync-webgui-repo.js (3)

184-194: Confirm chalk availability before logging with color.
These logs rely on chalk.default; if the async import fails or doesn’t complete in time, the calls may throw an error. Verify that chalk is loaded and fallback to plain console logs if not.


334-361: Validate removal of existing directories is deliberate.
The script forcefully removes previous web component directories before copying new ones, which can lead to data loss if invoked accidentally. Confirm that wiping the entire directory is the intended approach. Optionally, prompt the user before deletion or back up old builds.


583-583: Validate numeric input.
Relying solely on user-entered numeric strings can cause hidden issues if a user enters characters or out-of-range options. Confirm that your validation or fallback logic adequately covers these cases.

…vation-code-extractor.php correctly (#1320)

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1209867047971138
@elibosley elibosley merged commit df16822 into main Apr 3, 2025
5 of 7 checks passed
@elibosley elibosley deleted the fix/webgui-sync-script-with-ui-components-build branch April 3, 2025 13:17
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2025

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL:

https://preview.dl.unraid.net/unraid-api/tag/PR1318/dynamix.unraid.net.plg

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.

3 participants