You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now appconfig and user app configs are a bit weird to work with. I would like to discuss an idea I have to improve this. From all sides. What I often notice
the config requires a lot of boilerplate code each time
we have no default value assigned in a single place
we have no generic verification mechanism
we have no typehinting on the accepted and returned data
What I would propose is that we move to a more declarative mechanism. And then generate code. That does what we need to do. (values don't change that often anyway).
In example. We add a file usersettings.json in where we declare in some way that there is a user setting foo that is a bool, a setting bar that is an int and a setting foobar which is a string. We can also define default values just in 1 place.
We can then also set validation functions. There can be default ones (isBool, isIntInRange etc). And custom ones that require more custom logic.
We can then properly expose this via a generic OCS API (which we already do) but then with this file as backend. So that it flows trough the generic checks etc.
We can generate PHP code to use this in apps. So that there also the default value is always the same, we have proper types, the same sanity checks.
We could even create a js package that can work with the definitions. So that you don't set invalid values to begin with and already have client side validation as well that certain parameters need to be a certain type.
We add a file usersettings.json in where we declare in some way that there is a user setting
This would be available in both php and js?
I would love something like that yes! A global way of declaring this and a proper api to change user config
+1 for the general idea, but not sure if we should have an extra file for this, or merge into appinfo.xml
well that is just a choice of course. If we use it to generate code I'm all for a separate file. If we want to do it on the fly then info.xml is probably a good place.
Basically it boils down to. If you add a new config setting is it ok to tell people 'run these 2 commands' or does it all have to go automatically.
Activity
skjnldsv commentedon Dec 19, 2019
This would be available in both php and js?
I would love something like that yes! A global way of declaring this and a proper api to change user config
nickvergessen commentedon Jan 27, 2020
👍 for the general idea, but not sure if we should have an extra file for this, or merge into appinfo.xml
rullzer commentedon Jan 27, 2020
well that is just a choice of course. If we use it to generate code I'm all for a separate file. If we want to do it on the fly then info.xml is probably a good place.
Basically it boils down to. If you add a new config setting is it ok to tell people 'run these 2 commands' or does it all have to go automatically.