]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
Beautify check counts in the patch list view
authorAli Alnubani <alialnu@mellanox.com>
Tue, 8 Jan 2019 12:38:47 +0000 (12:38 +0000)
committerStephen Finucane <stephen@that.guru>
Mon, 25 Feb 2019 11:11:53 +0000 (11:11 +0000)
This patch [1] adds colors to the checks in the patch list view.
The colors are set based on the check's priority, with FAILURE
having the highest priority, followed by WARNING, and then SUCCESS.
Only the check with the highest priority and non-zero count
will be colored. This is to make failures and warnings more visible.

The patch also [2] replaces zero counts with a '-' for
FAILUREs and WARNINGs.
The SUCCESS count will only be replaced by a '-'
when all other checks have zero counts too.

Suggested-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
htdocs/css/style.css
patchwork/templatetags/patch.py

index af2f0732eef937dc6d1d0b692252064ba932f4e2..c0f4561a126b6971bf3629716f6c5dd086cbed39 100644 (file)
@@ -236,6 +236,26 @@ table.patchmeta tr th, table.patchmeta tr td {
        text-decoration: underline;
 }
 
+.patchlistchecks {
+       display: inline-block;
+       border-radius: 7px;
+       min-width: 0.9em;
+       padding: 0 2px;
+       text-align: center;
+}
+
+.patchlistchecks.success {
+       background-color: #82ca9d;
+}
+
+.patchlistchecks.warning {
+       background-color: #ffc95e;
+}
+
+.patchlistchecks.fail {
+       background-color: #ff5555;
+}
+
 .checks .state {
        font-weight: bold;
        color: #ddd;
index 5d387a49c16bb522c642cdc39c25663048c63740..ea5a71de362fbf2b6936268bf5dbc8ce293a989b 100644 (file)
@@ -36,9 +36,29 @@ def patch_checks(patch):
     titles = ['Success', 'Warning', 'Fail']
     counts = patch.check_count
 
+    check_elements = []
+    use_color = True
+    for state in required[::-1]:
+        if counts[state]:
+            if use_color:
+                use_color = False
+                color = dict(Check.STATE_CHOICES).get(state)
+            else:
+                color = ''
+            count = str(counts[state])
+        else:
+            color = ''
+            count = '-'
+
+        check_elements.append(
+            '<span class="patchlistchecks {}">{}</span>'.format(
+                color, count))
+
+    check_elements.reverse()
+
     return mark_safe('<span title="%s">%s</span>' % (
         ' / '.join(titles),
-        ' '.join([str(counts[state]) for state in required])))
+        ''.join(check_elements)))
 
 
 @register.filter