From 8cb25c62957ee7a8565b98b67fd2830b53eb5cd1 Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Tue, 26 Nov 2024 13:53:30 +0100 Subject: [PATCH] [IMP] runbot: show state in favicon Until now the favicon was handled by the `/favicon.ico` route made available by `website`. This commit adds the different favicons and logic to be able to display the state of the current page through it. --- runbot/controllers/frontend.py | 7 ++++++- runbot/models/batch.py | 10 ++++++++++ runbot/static/src/img/icon_killed.png | Bin 0 -> 1213 bytes runbot/static/src/img/icon_killed.svg | 8 ++++++++ runbot/static/src/img/icon_ko.png | Bin 0 -> 1002 bytes runbot/static/src/img/icon_ko.svg | 8 ++++++++ runbot/static/src/img/icon_ok.png | Bin 0 -> 1012 bytes runbot/static/src/img/icon_ok.svg | 8 ++++++++ runbot/static/src/img/icon_skipped.png | Bin 0 -> 1012 bytes runbot/static/src/img/icon_skipped.svg | 8 ++++++++ runbot/static/src/img/icon_warn.png | Bin 0 -> 1016 bytes runbot/static/src/img/icon_warn.svg | 8 ++++++++ runbot/templates/utils.xml | 20 ++++++++++++++++++++ 13 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 runbot/static/src/img/icon_killed.png create mode 100644 runbot/static/src/img/icon_killed.svg create mode 100644 runbot/static/src/img/icon_ko.png create mode 100644 runbot/static/src/img/icon_ko.svg create mode 100644 runbot/static/src/img/icon_ok.png create mode 100644 runbot/static/src/img/icon_ok.svg create mode 100644 runbot/static/src/img/icon_skipped.png create mode 100644 runbot/static/src/img/icon_skipped.svg create mode 100644 runbot/static/src/img/icon_warn.png create mode 100644 runbot/static/src/img/icon_warn.svg diff --git a/runbot/controllers/frontend.py b/runbot/controllers/frontend.py index eada071d..af0ae038 100644 --- a/runbot/controllers/frontend.py +++ b/runbot/controllers/frontend.py @@ -64,6 +64,8 @@ def route(routes, **kw): response.qcontext['nb_build_errors'] = nb_build_errors response.qcontext['nb_assigned_errors'] = nb_assigned_errors response.qcontext['nb_team_errors'] = nb_team_errors + if 'page_info_state' not in response.qcontext: + response.qcontext['page_info_state'] = 'ok' return response return response_wrap return decorator @@ -215,6 +217,7 @@ class Runbot(Controller): 'pager': pager, 'project': bundle.project_id, 'title': 'Bundle %s' % bundle.name, + 'page_info_state': bundle.last_batch._get_global_result(), } return request.render('runbot.bundle', context) @@ -239,7 +242,8 @@ class Runbot(Controller): context = { 'batch': batch, 'project': batch.bundle_id.project_id, - 'title': 'Batch %s (%s)' % (batch.id, batch.bundle_id.name) + 'title': 'Batch %s (%s)' % (batch.id, batch.bundle_id.name), + 'page_info_state': batch._get_global_result(), } return request.render('runbot.batch', context) @@ -330,6 +334,7 @@ class Runbot(Controller): 'project': build.params_id.trigger_id.project_id, 'title': 'Build %s' % build.id, 'siblings': siblings, + 'page_info_state': build.global_result, # following logic is not the most efficient but good enough 'prev_ko': next((b for b in reversed(siblings) if b.id < build.id and b.global_result != 'ok'), Build), 'prev_bu': next((b for b in reversed(siblings) if b.id < build.id), Build), diff --git a/runbot/models/batch.py b/runbot/models/batch.py index 5df699d5..22a5a754 100644 --- a/runbot/models/batch.py +++ b/runbot/models/batch.py @@ -57,6 +57,16 @@ class Batch(models.Model): def _get_formated_age(self): return s2human_long(self.age) + def _get_global_result(self): + """Returns the worst result from the related builds and logs""" + self.ensure_one() + batch_result = 'warn' if any(log.level != 'INFO' for log in self.log_ids) else 'ok' + if self.state == 'skipped': + batch_result = 'skipped' + return self.env['runbot.build']._get_worst_result([ + batch_result, *self.slot_ids.build_id.mapped('global_result'), + ]) + def _url(self): self.ensure_one() return "/runbot/batch/%s" % self.id diff --git a/runbot/static/src/img/icon_killed.png b/runbot/static/src/img/icon_killed.png new file mode 100644 index 0000000000000000000000000000000000000000..fb70bc3ffdcc908ebb76c164007e7d546af25ad2 GIT binary patch literal 1213 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGojKx9jP7LeL$-HD>U@7->aSW-5 zdpjpE@3sL?+vU$Hw%&$35xX{v+&@JpRx!#_?1#s#7bx6hj@FgA!X%s$WK z!H~du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pnTZMHaftK*hJTFieSv!e6~5;I P%OeI)S3j3^P6 + + + + diff --git a/runbot/static/src/img/icon_ko.png b/runbot/static/src/img/icon_ko.png new file mode 100644 index 0000000000000000000000000000000000000000..7268fdd78b3205db5d66971ccc6ba90eb3db9109 GIT binary patch literal 1002 zcmVPx&q)9|URCr$PoH0%wF%X59A}KvxF{)BXEEmAj$za07r z2nh-(5)H!AX0!WyJoEgIZN0x;+v9!Tz8Tx>a&UKh`)A@WOo0Oe2-E&KFagBsPXNLC z69553D-ax?HGlwu6$lPb2M|E80>Rs2w;B-JpQkTkBJ$JspVQNe*h%!9;sWK>3z);>qg->?^&tR=$PX7+lU8hvdI?Bv7~KM> zA^IAa!%rWlnh>A>v`?TX2k%SxIgFYRAOL=UJu9|<$xTIwzI4O8Z|9oKRouo6;Qr!j zy1%?G4lEtEAS5SAUYDQNS*A%SJH7q#xytIv4dB*enkWn~9 zH{@=(S`C<6bl0mUy}T8%1lM#5S}Ran5PAiGazPabtmVh8cZhlgAdWz|fB+mt0pWrw z0M?$2(Na+2=3Na{0WjYwrY}~uUf}IH1tHQ0O{8Ygzy?5 zVtL+T*mVOvKtP-axl)h-uzVep+>yHh&)8ZAdfIu@kHmHZu%?Wh_(>R#!#v{V`fBH& z8wUa)7sPWN@ezn8{<5#6%{RwKu+Np62Viv=T67r?DSVn=7XZAqW)1^!e1L@84FFUs zLgj80gl+(!QW0Y9juIcX3PMgOHx^=P+EN;9<<_uE&+%WybxM( zLAL-9MY#nRbPd1@p#>Lo55RLGO8~hwr}Db>=$ZhO0_U1}3NqqIIXAyu*M~?!p0gqX z@H{@VzShkd0e}El(hzF^Nc=QR>0i%UI2j$L23YC<0e~G)S_h)@f0xJ6yO@>KffkP%dH?_b literal 0 HcmV?d00001 diff --git a/runbot/static/src/img/icon_ko.svg b/runbot/static/src/img/icon_ko.svg new file mode 100644 index 00000000..d6dd181d --- /dev/null +++ b/runbot/static/src/img/icon_ko.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/runbot/static/src/img/icon_ok.png b/runbot/static/src/img/icon_ok.png new file mode 100644 index 0000000000000000000000000000000000000000..971d0bf8697b890821a0f34af819f891bf031cba GIT binary patch literal 1012 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGojKx9jP7LeL$-HD>U|#3x;uum9 z_jayr-W>yh)~B;~6m!WZ`3opd4Q8`+*~P$i=cz#3=^b2igx@I299Xx<{RD4P4>Qvy zrF9)#FV)e%o4etC(y|EIhWEdJKg_GI51BhnVGZAb_SNS-*WKi531#&7 z_|I^ze7L#ihOBv8v>2xSKHggHx#P8e{0rC0P==t({tU^ws~i*LRx?hRUFTE6$gnGp zlfn4>I_A}#4R^i>-{59Y;F=~Df82+Ifx#j3S0EQtM}F{>W%8nl3=I9>w{MVow~M3t zi21ju4ojs2+I8G7kLT?_&GDhc_VIIO-5l?7&IMauY}+PyJ(Z;*xc_bm_fc~T=WxLW zf&H!b>Sa3bGB`Z>du`AD)gn`NUzg9`a3h-k^6OVhOaUv8U;Mi78n5+*xxt?qq6F%B z&Ryf5zWe(I^~|%(4qN8Po$v2;UAt&DTf?c}rVIc;Y&o(Fd%15}G35U$%s-YZ$#Cd5Yr@JyZvW&b{#N8q*(Sr-@ntcGMh}DZwIgYF zrYSox$lU9eSf$hxaM7@x!QzNBPbinuiWf7SV<$MT_-zlliiW&OVSQ{#$Iih^V>W3 z^^J)WtL9pMk6X*}JjUf+uVlx6S<$U~?(-f{`;a&9DHBJ5b63bP0l+XkKA^^08 literal 0 HcmV?d00001 diff --git a/runbot/static/src/img/icon_ok.svg b/runbot/static/src/img/icon_ok.svg new file mode 100644 index 00000000..e11c0a16 --- /dev/null +++ b/runbot/static/src/img/icon_ok.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/runbot/static/src/img/icon_skipped.png b/runbot/static/src/img/icon_skipped.png new file mode 100644 index 0000000000000000000000000000000000000000..a21e8930134f405b6748ae9916f5b85e632d8d99 GIT binary patch literal 1012 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGojKx9jP7LeL$-HD>U|#3x;uum9 z_jZnN-W3Od*14Z2>{e(wqLS{ofuV3(iiMAvp|l=zR*UlLtM68=tFleqem`fE$EvvB zzhnMQoV&AnX8r$}KRA^O+!+(!{AUez(5dI*c;?S2BH*iFG5~zhdr)9Vy$zdPVHV z+u!{!@BXz7acTPh_4M;Rhfl}k?f0x-cYk+p9wXSwY+4em{@2b7L7d7s++CFZ@#y3-e?P5y9AaX~4wio&IZY;&*Q(vOed z(XeH~wB8R~8MgeMmAcvbZ)J81Twro#Qu00Usrs$xq$%b-3~O09JHi;W@--NxG&~qP z_B>?q2)Mwsr_z~gh2u-b1C!0yH0WyVWy!fa+oRH%Tf=c;!-ej_xo-7C zF{Y?bZSx!cTujVo{Hd)IbngO_*ZEvkg?Y{aFaIiP=0`9_^Pg2!2xGjqN0If)y@(ee zXU}1HSt_`NA^%@ z`laESxeJ98Ds%5xGp;?bWY4v_oh=58Vn60_dQ`sNE^9J*(Mjti4B9ok6NGNe14hRJ z+n>2_7hY0ST>tsNbq@O}4EjK+tqsvnWZf8;+`1d0pSE&cU~)X@QF*EU+4B94&pg}r z6fg=2sPObMl-zsAdgWi>`Q7DH{Elq@w}~&4{d3;p*LDevQ|fDbzRrrS&Ykz^+0U`z5Vw(Ys-Zn<*7^)I2B^78M!uWZVm}zU|GDEll8_;M=ec;ri=GlnBKfmm@2|> zFeBfIv8-%@7gs~V7W0J+*47@XtPTdZW(PFPm0dE4NkQVRuf~CMd_kU!0zKc_^oe9hqL>gTe~DWM4f*?6z) literal 0 HcmV?d00001 diff --git a/runbot/static/src/img/icon_skipped.svg b/runbot/static/src/img/icon_skipped.svg new file mode 100644 index 00000000..392c9841 --- /dev/null +++ b/runbot/static/src/img/icon_skipped.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/runbot/static/src/img/icon_warn.png b/runbot/static/src/img/icon_warn.png new file mode 100644 index 0000000000000000000000000000000000000000..8f09168245959f838c92d992a7184bbc5b2c766c GIT binary patch literal 1016 zcmaKrYfO`O7{#Ce3#>PwU4Q|lK!cf=joSnqE;?E$fd)b7h!#PpW&uhkc5;yhTsxpR zidG~cpqn65&`!!tGFk!KC_xB!iW3d`LI>GUxsMd6#o_m5AI|wD=i5onDUFSZup`sS z0ARJdOPC#Xuph|ma{Lk=tu*y!i30S2FguPzm< zp{fsG5UHgLPu5S0p4BFHY6$}>Kb?o{&c$0BRmz{62iSayKHo@Xma+K+8Rs3EF_`{r zY1gkvvA>Pyi4=wiMm5q_$3`?QzGqtX+IN>K=(SLSX15@9N_xG@Xs0~@WoAOLF)Z#R zco_Xg%imxdD|0xn=%J0S`&ThJ16$6Pt~gFu3(j;UmTJwyp$hZ*I&d_)<@Rg zyCMVqlr0?-3f;lg=zN6j4r5^>LbG?Ej~cOFZ@2d19iAOZ^~<)kwX*M~CV-iv3y7n@~AU0i6MdIR9rxvcU_R-)ZEgyNABSfg2vfX$ln-{tJ9)v#J09 literal 0 HcmV?d00001 diff --git a/runbot/static/src/img/icon_warn.svg b/runbot/static/src/img/icon_warn.svg new file mode 100644 index 00000000..9074f5f3 --- /dev/null +++ b/runbot/static/src/img/icon_warn.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/runbot/templates/utils.xml b/runbot/templates/utils.xml index 33acd1aa..ad48381c 100644 --- a/runbot/templates/utils.xml +++ b/runbot/templates/utils.xml @@ -19,6 +19,26 @@ + + + + + + + + + + + + + + + + + + + +