Theme selector in the UI

Now that it will be possible to install and update plugins via the palette, I would love to see the theme selector in the editor settings in Node-RED 4.0.

From the user's perspective, it would be weird to be able to install a theme plugin using the palette and then have to edit settings.js to configure it.

Yeah, where would you put it? Settings/View/View ?

The initial idea was to put it below the language selector.

@knolleary @Steve-Mcl why is the selector commented out?

@GogoVega you can get some context on that from the last bit of this stream.

For me the theme should be in userSettings - currently it is in settings, its a problem because the editor cannot write to .node-red/settings file.

Not sure that is quite correct? In fact, it was discovered not so long ago that you couldn't STOP the editor from being able to update settings.js I believe.

However, you need to restart Node-RED for the settings to be reloaded.

Whilst you are technically correct, you are also wrong. As a point of principle, the node-red runtime cannot write back to the runtime settings object as the storage API that abstracts away whether it is a local file or not does not provide a means to do so. No feature added to the core of node-red will rely on writing back to that object (which may or may not be a file).

The storage API does provide an api for storing user settings - this is what is used to store the options that are made in the editor (grid size etc). This would be entirely the right place to store a users choice of theme and not worth any discussion because that's how it works.

The main issue with this feature remains the one that stopped us implementing it long ago when themes were first introduced. The way the editor loads the current theme means it is loaded long before we know who the user is that is accessing the editor. By the time we know who the user is, it is too late to change the theme already loaded in the editor. I suspect this is the point I make at the end of the video @mbonani referenced.

So to have theme selection in the UI will require a fairly fundamental change to the way themes are loaded. Hence why this seemingly easy feature request has not been done to date.

Yes, that's what I read in the code. I spent a few hours trying to find a simple way to modify the runtime settings without success.

We should separate the theme.context() part: when loading the editor, the editorApp only returns the defaultContext. Then add a part to editorApp which retrieves the connected user and sends the plugin themes. I don't really see where we could insert this part :thinking:

Along the same lines, would it be interesting to create a node/plugin filter for the palette installer?

Note: the catalog will need a new property.