Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions runbot/controllers/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ def bundles_by_tag(self, bundle_tag_id=None, project=None, **kwargs):
if not project and projects:
project = projects[0]
bundles_by_team = defaultdict(list)
open_bundles_by_team = defaultdict(int)
nb_bundles = 0
nb_bundles_done = 0
for bundle in self.env['runbot.bundle'].search([('tag_ids', 'in', bundle_tag_id.id)]):
Expand All @@ -916,10 +917,13 @@ def bundles_by_tag(self, bundle_tag_id=None, project=None, **kwargs):
bundle_prs = bundle.branch_ids.filtered(lambda rec: rec.is_pr)
if any(bundle_prs) and not any(bundle_prs.mapped('alive')):
nb_bundles_done += 1
else:
open_bundles_by_team[bundle.team_id.name or 'No Team Defined'] += 1

qctx = {
'tag': bundle_tag_id,
'bundles_by_team': bundles_by_team,
'open_bundles_by_team': open_bundles_by_team,
'nb_bundles': nb_bundles,
'nb_bundles_done': nb_bundles_done,
}
Expand Down
23 changes: 23 additions & 0 deletions runbot/static/src/css/runbot.css
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,26 @@ code {
.log-details td {
padding-left: 20px;
}

/*
* Bundle by tag
*/
.o_team_bundle_grid {
display: grid;
/* menu | name (2/3 of free space) | tags | age | filler (1/3) */
grid-template-columns: max-content 2fr max-content max-content 1fr;
column-gap: .5rem;
align-items: center;
}

.o_team_bundle_grid > li {
display: contents;
}

.o_team_bundle_grid > li > button {
grid-column: 1; /* each bundle starts a new grid row, even if the previous one has no age badge */
}

.o_hide_done .o_team_bundle_grid > li:has(a.bundle-done) {
display: none;
}
29 changes: 29 additions & 0 deletions runbot/static/src/js/runbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,32 @@ document.addEventListener('DOMContentLoaded', function() {
});
}
});

// Expand/collapse all team sections at once.
document.addEventListener('DOMContentLoaded', function() {
const expandBtn = document.getElementById('toggleTeamsButton');
if (expandBtn) {
const bundleGrid = document.querySelector('.o_team_bundle_grid');
const container = bundleGrid.closest('.container-fluid');
expandBtn.addEventListener('click', function () {
const details = container.querySelectorAll('details');
const allOpen = Array.from(details).every(d => d.open);
details.forEach(d => d.open = !allOpen);
this.textContent = allOpen ? 'Expand all' : 'Collapse all';
});
}
});

// Show/hide done bundles, persisted across reloads.
document.addEventListener('DOMContentLoaded', function() {
const toggleHideDoneBtn = document.getElementById('toggleHideDoneButton');
if (toggleHideDoneBtn) {
const bundleGrid = document.querySelector('.o_team_bundle_grid');
const container = bundleGrid.closest('.container-fluid');
toggleHideDoneBtn.addEventListener('click', function () {
const hidden = container.classList.toggle('o_hide_done');
this.textContent = hidden ? 'Show done' : 'Hide done';
localStorage.setItem('runbot_hide_done_bundles', hidden ? '1' : '');
});
}
});
30 changes: 22 additions & 8 deletions runbot/templates/bundles_by_tag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@
<t t-set="link_title" t-value="'No PR yet'"/>
</t>
<t t-elif="not any(bundle.branch_ids.filtered(lambda rec: rec.is_pr).mapped('alive'))">
<t t-set="link_class" t-value="'link-success text-decoration-line-through'"/>
<t t-set="link_class" t-value="'link-success text-decoration-line-through bundle-done'"/>
<t t-set="link_title" t-value="'All PR are closed'"/>
<t t-set="done" t-value="True"/>
</t>
<t t-call="runbot.branch_github_menu">
<t t-set="btn_classes" t-value="'btn btn-link btn-ssm'"/>
</t>
<a t-out="bundle.description or bundle.name" t-attf-href="/runbot/bundle/{{bundle.id}}" t-att-class="link_class" t-att-title="link_title" target="_blank"/>
<a t-out="bundle.description or bundle.name" t-attf-href="/runbot/bundle/{{bundle.id}}" t-attf-class="text-truncate {{link_class}}" t-att-title="link_title" target="_blank"/>
<t t-set="other_tags" t-value="bundle.tag_ids.filtered(lambda rec: rec != tag)"/>
<t t-foreach="other_tags" t-as="other_tag">
<span class="badge rounded-pill text-bg-success"><t t-out="other_tag.name"/></span>
</t>
<span class="d-flex gap-1">
<t t-foreach="other_tags" t-as="other_tag">
<span class="badge text-bg-light border"><t t-out="other_tag.name"/></span>
</t>
</span>
<t t-if="not done">
<span t-attf-class="badge text-bg-info" data-toggle="tooltip" title="Last batch age">
<span t-attf-class="badge text-bg-info text-center" style="min-width: 4.5rem" data-toggle="tooltip" title="Last batch age">
<t t-out="bundle.last_batch._get_formated_age()"/>
</span>
</t>
Expand All @@ -33,11 +35,23 @@
<h1 class="text-capitalize">
<t t-out="tag.name"/>
<button type="button" class="btn btn-primary btn-ssm disabled"><t t-out="nb_bundles_done"/> / <t t-out="nb_bundles"/></button>
<button id="toggleTeamsButton" type="button" class="btn btn-secondary btn-ssm">Expand all</button>
<button id="toggleHideDoneButton" type="button" class="btn btn-secondary btn-ssm o_btn_toggle_done">Hide done</button>
</h1>
<t t-foreach="sorted(bundles_by_team.keys())" t-as="team">
<t t-set="team_bundles" t-value="bundles_by_team.get(team)"/>
<details t-att-open="bool(team_bundles) and ''"><summary t-out="team"/>
<ul>
<details>
<summary>
<span t-out="team"/>
<t t-set="open_bundles" t-value="open_bundles_by_team.get(team)"/>
<t t-if="open_bundles">
<span class="badge text-bg-light ms-1 border" title="Open bundles" t-out="open_bundles"/>
</t>
<t t-else="">
<span class="badge text-bg-success ms-1" title="Open bundles">All Done</span>
</t>
</summary>
<ul class="list-unstyled ps-4 mb-2 o_team_bundle_grid">
<t t-foreach="team_bundles" t-as="bundle">
<li><t t-call="runbot.bundle_tag_slot"/></li>
</t>
Expand Down