add config option controlling which theme option(s) are available in the UI

Bug #1960358 reported by Garrett Neugent
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard Charm
Triaged
Wishlist
Unassigned

Bug Description

BootStack has a customer who has a custom theme uploaded as a resource. However, we are unable to remove the other themes (Ubuntu, Default, Material) from the Horizon UI. These themes exist under /usr/share/openstack-dashboard/openstack_dashboard/themes, but have hard coded imports, and throw errors if the directories are removed.

reference: https://pastebin.canonical.com/p/JPxQXtqCJ6/

It would be great if these could be added as a charm config option, like "loaded-themes", or something similar.

Thanks for your time!

Revision history for this message
Billy Olsen (billy-olsen) wrote :

How were the directories removed? the code doesn't remove the directories today so I suspect this is operator action.

Practically speaking, this should probably be something to the effect of 'enabled-themes' which identify which particular themes are enabled for the openstack dashboard.

Changed in charm-openstack-dashboard:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
Nobuto Murata (nobuto) wrote :

Yeah I think it's about this logic:
https://github.com/openstack/charm-openstack-dashboard/blob/82897f8f5fde0ef2c639b18a2499d2f033ce37c5/templates/stein/local_settings.py#L912-L940

The quickest hack in this specific case is to set the custom theme as the default then "hide" the theme selection menu in the custom theme itself like the following:

$ git diff
diff --git a/custom-theme/static/_styles.scss b/custom-theme/static/_styles.scss
index e69de29..d474a4e 100644
--- a/custom-theme/static/_styles.scss
+++ b/custom-theme/static/_styles.scss
@@ -0,0 +1,3 @@
+.dropdown-menu.theme-picker {
+ display: none;
+}

Revision history for this message
Nobuto Murata (nobuto) wrote :

It's not beautiful, but it does the trick.

Revision history for this message
Billy Olsen (billy-olsen) wrote :

Looking at the code, I have a clarifying question...

Is the user attempting to only allow their custom theme to be displayed? Or is the user interested in having the custom theme as the default theme and still allowing other themes?

Removing the themes from the filesystem is not really the right way to go about this, as a custom theme may depend on the default theme (and can indeed import pieces from that theme).

Revision history for this message
Nobuto Murata (nobuto) wrote :

In this specific customer usecase, they would like to have the custom theme as the default and don't want to let users change the theme to other ones.

I agree that we shouldn't delete anything from the file system but to use AVAILABLE_THEMES to tweak the list of the themes to be displayed. In fact, the theme here has "@import "/themes/default/variables";" statement so if the default theme is deleted from the filesystem, Horizon gives 503.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.