aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sb_builder/dashboard.py6
-rw-r--r--tests/test_gui.py7
2 files changed, 12 insertions, 1 deletions
diff --git a/sb_builder/dashboard.py b/sb_builder/dashboard.py
index 3280168..0d68d6f 100644
--- a/sb_builder/dashboard.py
+++ b/sb_builder/dashboard.py
@@ -33,6 +33,7 @@ STATUS = {"ok": "#0ca30c", "aborted": "#fab219", "bad": "#ec835a", "failed": "#d
"killed": "#fab219", "lost": "#ec835a"}
GAP = 2 # px of surface between bar segments
SPARK_POINTS = 60 # ~30 min at the default 30 s dashboard refresh
+TITLE_MAX = 90 # chars of a job title in Recent jobs
def upgrade_color(ts, now=None):
@@ -377,7 +378,10 @@ class Dashboard(QWidget):
if color:
icon = f'<span style="color:{color}">{icon}</span>'
dur = None if "start" not in j else j.get("end", time.time()) - j["start"]
- rows.append(f"<tr><td>{icon}&nbsp;</td><td>{html.escape(job_title(j))}&nbsp;&nbsp;</td>"
+ title = job_title(j)
+ if len(title) > TITLE_MAX: # a rich-text label never shrinks: cap it or it widens the window
+ title = title[:TITLE_MAX - 1] + "…"
+ rows.append(f"<tr><td>{icon}&nbsp;</td><td>{html.escape(title)}&nbsp;&nbsp;</td>"
f"<td>{j['status']}&nbsp;&nbsp;</td>"
f"<td>{fmt_time(j.get('start', j['created']))}&nbsp;&nbsp;</td>"
f"<td>{fmt_duration(dur)}</td></tr>")
diff --git a/tests/test_gui.py b/tests/test_gui.py
index aa6d681..ca415d3 100644
--- a/tests/test_gui.py
+++ b/tests/test_gui.py
@@ -461,6 +461,13 @@ class SmokeTest(unittest.TestCase):
self.assertIs(w.tabs.currentWidget(), w.packages_tab)
self.assertEqual([n for n, c in w.packages_tab.chips.items() if c.isChecked()], ["orphaned"])
+ def test_recent_jobs_caps_title(self):
+ w, _ = self.window()
+ w.dashboard.show_jobs([dict(JOB, args=["pkg"] * 100)])
+ text = w.dashboard.jobs_list.text()
+ self.assertIn("…", text)
+ self.assertNotIn("pkg " * 40, text)
+
def test_slackpkg_dot(self):
old = dict(STATS, slackpkg={"update": None, "upgrade": 1})
w, _ = self.window(stats=(old, None))