Skip to content

Conversation

@zackspear
Copy link
Contributor

@zackspear zackspear commented Apr 1, 2025

For now just used in Dev Mode to help assist in testing webgui CSS changes.

  • Introduced a new UnraidThemeSwitcher component to allow users to change themes dynamically.
  • Updated nuxt.config.ts to register the new component.
  • Created ThemeSwitcher.ce.vue with functionality to handle theme changes and update the UI accordingly.

Summary by CodeRabbit

  • New Features
    • Introduced a theme switcher, allowing users to easily swap between available application themes.
    • Expanded the configuration to register the new theme switcher as a custom element for seamless integration.

- Introduced a new `UnraidThemeSwitcher` component to allow users to change themes dynamically.
- Updated `nuxt.config.ts` to register the new component.
- Created `ThemeSwitcher.ce.vue` with functionality to handle theme changes and update the UI accordingly.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 1, 2025

Walkthrough

This pull request introduces a new Vue component, ThemeSwitcher, to facilitate dynamic theme switching in the application. The component employs TypeScript, the Vue Composition API, and Pinia for managing reactive states, including theme lists and a submission flag. The handleThemeChange method processes theme updates by invoking a POST request via the WebguiUpdate service. Additionally, a new custom element configuration entry, UnraidThemeSwitcher, is added in the Nuxt configuration to register the component.

Changes

File(s) Change Summary
web/components/ThemeSwitcher.ce.vue Added a new Vue component that uses the Composition API and Pinia. Implements reactive state for devModeEnabled, themes, and submitting. Includes a dropdown for theme selection and a handleThemeChange method that processes updates via a POST request.
web/nuxt.config.ts Added a new custom element entry: UnraidThemeSwitcher mapped to the ThemeSwitcher.ce component, expanding the list of custom elements in the configuration.

Possibly related PRs

Suggested reviewers

  • pujitm
  • elibosley
  • mdatelle

Poem

In lines of code a change unfurls,
A switch that brightens user worlds.
Themes merge at every click,
With Vue and API doing the trick.
Code sings its tune like stars so bright 🚀✨!


📜 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 be94ccd and c27509f.

📒 Files selected for processing (1)
  • web/components/ThemeSwitcher.ce.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/components/ThemeSwitcher.ce.vue
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Build Web App
  • GitHub Check: Build API
  • GitHub Check: Cloudflare Pages

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

28-28: Consider making the theme list dynamic

The theme array is currently hard-coded with four themes. If themes are added or removed in the future, this component will need to be updated.

-const themes = ref<string[]>(['azure', 'black', 'gray', 'white']);
+// Consider fetching from an API or configuration
+const themes = ref<string[]>(['azure', 'black', 'gray', 'white']);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 48c6ad7 and be94ccd.

📒 Files selected for processing (2)
  • web/components/ThemeSwitcher.ce.vue (1 hunks)
  • web/nuxt.config.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Build Web App
  • GitHub Check: Build API
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (5)
web/nuxt.config.ts (1)

141-144: Proper registration of new ThemeSwitcher component

The custom element registration follows the existing pattern and naming conventions. This will make the theme switcher available as a custom element in the application.

web/components/ThemeSwitcher.ce.vue (4)

2-16: Clear integration instructions provided

The comment block provides clear instructions on how to integrate this component into the webGUI by modifying the PHP footer code. This is helpful for developers who need to implement the component.


31-61: Theme change handler implementation looks good

The handler properly checks if the theme has changed, manages submission state, and uses the WebguiUpdate service to apply the change. The error handling is implemented correctly.

One minor consideration: The page reload after theme change might interrupt user work. Is this the only way to apply theme changes, or could a less disruptive approach be considered?


65-79: Component is correctly hidden in production

Good job conditional rendering the component based on development mode. This ensures it's only visible when needed for testing.


82-86: Style imports follow application conventions

The component correctly imports the global UI styles and the main CSS file following the established pattern.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 1, 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/PR1304/dynamix.unraid.net.plg

Copy link
Member

@elibosley elibosley left a comment

Choose a reason for hiding this comment

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

Couple suggestions

- Added computed property `computedThemes` to dynamically handle theme options based on props.
- Updated template to use `computedThemes` instead of a static themes array.
- Removed unnecessary ref for `devModeEnabled` to simplify the code.
@zackspear zackspear marked this pull request as ready for review April 1, 2025 20:37
@zackspear zackspear requested a review from mdatelle as a code owner April 1, 2025 20:37
@elibosley
Copy link
Member

Flaky test killed this. Just ignore and merge with it failing

@zackspear zackspear merged commit e2d00dc into main Apr 1, 2025
7 of 8 checks passed
@zackspear zackspear deleted the feat/wc-switch-webgui-theme branch April 1, 2025 21:13
elibosley pushed a commit that referenced this pull request Apr 2, 2025
🤖 I have created a release *beep* *boop*
---


## [4.5.0](v4.4.1...v4.5.0)
(2025-04-02)


### Features

* add webgui theme switcher component
([#1304](#1304))
([e2d00dc](e2d00dc))
* api plugin system & offline versioned dependency vendoring
([#1252](#1252))
([9f492bf](9f492bf))
* **api:** add `unraid-api --delete` command
([#1289](#1289))
([2f09445](2f09445))
* basic array controls
([#1291](#1291))
([61fe696](61fe696))
* basic docker controls
([#1292](#1292))
([12eddf8](12eddf8))
* copy to webgui repo script docs + wc build options
([#1285](#1285))
([e54f189](e54f189))


### Bug Fixes

* additional url fixes
([4b2763c](4b2763c))
* **api:** redirect benign pnpm postinstall warning to log file
([#1290](#1290))
([7fb7849](7fb7849))
* **deps:** update dependency chalk to v5
([#1296](#1296))
([6bed638](6bed638))
* **deps:** update dependency diff to v7
([#1297](#1297))
([3c6683c](3c6683c))
* disable all config watchers
([#1306](#1306))
([5c1b435](5c1b435))
* extract callbacks to library
([#1280](#1280))
([2266139](2266139))
* OEM plugin issues ([#1288](#1288))
([d5a3d0d](d5a3d0d))
* replace files lost during pruning
([d0d2ff6](d0d2ff6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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