2014-11-05 21:35 GMT+01:00
<richar...@googlemail.com>:
Am Mittwoch, 5. November 2014 18:05:14 UTC+1 schrieb Edwin Kempin:
Adding a new user preference is really that painful, lots of different places in the code need to be touched :(
To find all the places it's best to look at an old change that added such a preference, e.g. [1].
I guess everyone would be glad if this would be simpler, but nobody took the time to simplify it.
Yeah, thanks. I actually did it like that, but I still overlooked something at first.
Since I don't have many burning issues I want to tackle, I might think of a way to simplify the whole thing. I'm not very experienced with largish codebases, though, so I don't know if I will be successful. Any hint is welcome!
I guess this is not really an easy task.
We do have a similar problem with project configuration parameters, where also a lot of code places need to be
touched if a new parameter is introduced.
Nowadays plugins can extend the project configuration and here we have a really nice solution [1].
All a plugin needs to do is to define the parameter in a single place:
bind(ProjectConfigEntry.class)
.annotatedWith(Exports.named("enabled"))
.toInstance(new ProjectConfigEntry("Enable Greeting", true));
All the rest is automatic. We have a generic way to transport the parameters (type, name, value, etc) via REST
to the client and on client-side we have generic UI code in ProjectInfoScreen to render these parameters.
Something similar could be done for the Gerrit core project parameters and also for user preferences.
If to tackle this for user preferences we should probably at the same time also change how the user preferences
are persisted. At the moment they are stored in the database, but we already have a AllUsers repository with a
branch per user where some first user preferences are stored. So this would be a good chance to move
the old user preferences over to this new persistence.