Issue 2685: custom images for label scores
Status:  Accepted
Owner: ----
Project Member Reported by zaro0508, May 27, 2014
Gerrit shows an 'X' for the lowest score and a check mark for the highest score on vote labels.  I would like to override those images with my own.  It would be great if there was a setting to allow setting custom images for those scores.  
May 27, 2014
#1 dborowitz@google.com
Is this just for custom skinning purposes or do you think there's a better choice that would benefit anyone?
Jul 27, 2014
Project Member #2 zaro0508
I'm not sure what you mean by better choice.  I'll explain our use case to clarify.  

We are using Gerrit 2.8 and have created a label called "Work In Progress" (WIP) with votes -1,0,+1.  When someone sets a change to WIP the 'X' icon appears which freaks users out because it's the same icon to indicate  "do not accept".  Therefore I was thinking a way to fix this problem is to allow the Gerrit admin to set the dislike icon to something different.  Maybe as a per label gerrit.config setting? 


Jul 28, 2014
Project Member #3 David.Os...@gmail.com
Even more interesting approach to be able to provide custom images per label per vote category, so to stay with OpenStack use case, to be able to provide different images for different labels for the same vote category: 

* reject_verify.png (vote=-1)
* reject_wip.png (vote=-1)
* reject_codereview.png (vote=-2)


Jul 28, 2014
Project Member #4 David.Os...@gmail.com
How about to optionally extend the label section with icon/mage definition

[label "Verified"]
       function = MaxWithBlock
       value = -1 Fails
       value =  0 No score
       value = +1 Verified
       image = -1 rejected_verify.png
       image = +1 approved_verify.png

[label "WIP"]
       function = MaxWithBlock
       value = -1 WIP
       value =  0 No score
       value = +1 Approved
       image = -1 rejected_wip.png
       image = +1 approved_wip.png

Then we would parse it and upload it to the client side with existing or new config request?

Status: AwaitingInformation
Jul 28, 2014
#5 dborowitz@google.com
Khai, I was asking two things:
1. Do you have a better image we should use as the default for every label?
2. Do you think we should include a broader range of options in Gerrit, as opposed to making it arbitrarily extensible? (Independent of how it's configured.)

Sounds like the answer to (1) is no. (2) I don't feel strongly about either way, assuming admins can just drop images in /static or something.

As a thought experiment, I wonder if this can be done entirely in CSS, no project.config necessary. Say each icon has a class "vote-Label-Name-1" and we use a CSS background-image default that can be overridden. (Now that I've written this I feel like I made a similar suggestion before but can't dig it up.)
Aug 24, 2014
Project Member #6 zaro0508
I wasn't thinking of anything broader for this feature but since you mentioned the CSS approach it would be neat if we could configure in CSS for all images :)   However I also think scoping this issue to just to vote labels would be better.  I'm not sure how this would be implemented though.  If there's already something similar in code could you please point me to it?
Status: Accepted
Mar 18, 2015
Project Member #7 zaro0508
I was able to figure out how to replace the icons using the a custom theme and javascript.  It would have been easier if the html contained ids for objects though.  In any case this problem is solved.  My files are attached to help the next person do the same.

GerritSiteHeader.html
77 bytes   View   Download
replace_icon.js
2.1 KB   View   Download
Owner: zaro0508
Mar 18, 2015
Project Member #8 zaro0508
Files were created for Gerrit 2.9.4 tested on Chrome Version 41.0.2272.89 (64-bit)
Mar 24, 2015
Project Member #9 zaro0508
(No comment was entered for this change.)
Owner: ---
Apr 10, 2015
#10 oswald.b...@gmx.de
here's a use case i'm trying to implement:

-1: "I would prefer this is not merged as is", advisory, non-sticky
-2: "This shall not be merged as is", blocking, non-sticky
-3: "This shall not be merged [at all]", blocking, sticky

i've written a prolog rule that correctly turns both -2 and -3 into rejections.
the visual effect is a tad sub-optimal, though: -2 is not the minimal score, so the hard-coded logic does not recognize it as a rejection, with two consequences:

- it is shown as a numerical value. i'd want it to be the big fat X, while -3 would be illustrated with ... let's say a cul-de-sac sign. this would be nicely covered by the proposal in comment #4, afaict. if somebody considers it too limiting, prolog could start looking for an icon_rule predicate ...

- it does not override an approval, so the wrong icon altogether is shown. this is the problem that lead me to create Issue 3288.