Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
404efd5
extract issues summary widget into edition partials
MattBudz Jun 29, 2026
c3c449e
merge develop to pick up crass 1.0.7 security update
MattBudz Jun 29, 2026
1fa82a2
extract shared tags accordion into a sub-partial
MattBudz Jun 29, 2026
f3ed086
move chart data to controller; set attributes on #issue-chart
MattBudz Jun 29, 2026
9635184
fix RuboCop ExtraSpacing violations in projects_controller
MattBudz Jun 29, 2026
2b8d3b8
use each over for..in for tag iteration
MattBudz Jul 15, 2026
52eac9f
extract tag grouping into a shared IssuesGrouping concern
MattBudz Jul 15, 2026
498db39
Merge remote-tracking branch 'origin/develop' into dashboard/extract-…
MattBudz Jul 15, 2026
fa855c9
rename IssuesGrouping to IssuesDimensionGrouping
MattBudz Jul 16, 2026
26abf01
add issues_summary route and controller
MattBudz Jul 16, 2026
e02447e
lazy-load the issues-summary widget via a turbo frame
MattBudz Jul 16, 2026
7f05c34
stop eagerly computing issue grouping in ProjectsController#show
MattBudz Jul 16, 2026
d7dde6d
add request spec for Projects::IssuesSummaryController
MattBudz Jul 16, 2026
67a9606
fix pre-existing RuboCop spacing offenses in routes.rb
MattBudz Jul 16, 2026
bc1ee96
initialize the issues chart on turbo:frame-load, not turbo:load
MattBudz Jul 17, 2026
df2b89b
add feature spec covering the lazy-loaded issues chart
MattBudz Jul 17, 2026
5f13e76
break out of the issues-summary frame when opening an issue
MattBudz Jul 17, 2026
d180a34
simplify build_all_tags_grouping with Hash.new(0)
MattBudz Jul 17, 2026
d4bab36
extract a colors array in initIssuesChart
MattBudz Jul 17, 2026
605e6ee
fix stray double space in colored_icon_for_model
MattBudz Jul 17, 2026
80ab8ed
drop manual alignment padding in initIssuesChart data variables
MattBudz Jul 17, 2026
4bec4b1
Merge branch 'develop' into dashboard/extract-issues-summary-edition-…
MattBudz Jul 21, 2026
3dbb787
match combobox options by attribute value instead of a raw selector
MattBudz Jul 21, 2026
adaa6c1
Merge remote-tracking branch 'origin/dashboard/extract-issues-summary…
MattBudz Jul 21, 2026
9f88530
Merge branch 'develop' into dashboard/extract-issues-summary-edition-…
MattBudz Aug 3, 2026
0fe97cd
move issues chart legend below chart, wrap horizontally
MattBudz Aug 3, 2026
51446af
Merge branch 'develop' into dashboard/extract-issues-summary-edition-…
MattBudz Aug 4, 2026
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
25 changes: 14 additions & 11 deletions app/assets/javascripts/hera/modules/combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,7 @@ class ComboBox {
// ==========================================================================

setInitialSelection() {
let $initialOption = this.$comboboxOptions.filter(
`[data-value="${this.$target.val()}"]`,
);
let $initialOption = this.filterByDataValue(this.$comboboxOptions, 'value', this.$target.val());

if (!$initialOption.length) {
if (this.isMultiSelect) {
Expand Down Expand Up @@ -506,10 +504,8 @@ class ComboBox {

updateMultiSelectUI($options) {
$options.forEach(($option) => {
if (
this.$combobox.find(`[data-option-value="${$option.data('value')}"]`)
.length
) {
const $existingTags = this.$combobox.find('[data-behavior~=combobox-multi-option]');
if (this.filterByDataValue($existingTags, 'option-value', $option.data('value')).length) {
return;
}

Expand Down Expand Up @@ -543,17 +539,15 @@ class ComboBox {
if (this.isMultiSelect) {
const currentValues = this.$target.val() || [];
currentValues.forEach((value) => {
const $option = this.$comboboxOptions.filter(`[data-value="${value}"]`);
const $option = this.filterByDataValue(this.$comboboxOptions, 'value', value);
if ($option.length) {
$options.push($option);
}
});
this.$comboboxOptions.removeClass('selected');
this.$combobox.find('[data-behavior~=combobox-multi-option]').remove();
} else {
$options = this.$comboboxOptions.filter(
`[data-value="${this.$target.val()}"]`,
);
$options = this.filterByDataValue(this.$comboboxOptions, 'value', this.$target.val());
}

this.updateComboboxUI($options);
Expand All @@ -563,6 +557,15 @@ class ComboBox {
// Utilities
// ==========================================================================

// Matches by exact attribute value instead of building a CSS attribute
// selector, so values containing quotes or other selector metacharacters
// (eg. option labels sourced from user-editable field names) can't break
// or escape the match.
filterByDataValue($elements, dataKey, value) {
const attr = `data-${dataKey}`;
return $elements.filter((_, el) => el.getAttribute(attr) === String(value));
}

showMenu() {
this.$comboboxMenu.css('display', 'block');
this.$combobox.attr('aria-expanded', 'true');
Expand Down
192 changes: 99 additions & 93 deletions app/assets/javascripts/hera/pages/projects/issues_chart.js
Original file line number Diff line number Diff line change
@@ -1,95 +1,101 @@
document.addEventListener('turbo:load', function(){
var $dataElement = $('#issues-summary-data'),
$chartElement = $('#issue-chart');

if ($dataElement.length && $chartElement.find('svg').length == 0) {
var margin = {top: 20, bottom: 30},
width = 354;
height = 180 - margin.top - margin.bottom;

var x = d3.scaleBand().rangeRound([0, width]);

var y = d3.scaleLinear()
.range([height, 0]);

var xAxis = d3.axisBottom(x)
.tickSize(0);

var svg = d3.select('#issue-chart').append('svg')
.attr('width', width)
.attr('height', height + margin.top + margin.bottom)
.append('g')
.attr('transform', 'translate(0,' + margin.top + ')');

// --------------------------------------------------------- Data variables
var tags = $dataElement.data('tags');
var issuesByTag = $dataElement.data('issues-count');
var highest = 0;
var data = [];
var x_domain = [];

for (var key in tags){
issuesCount = issuesByTag[key];
highest = issuesCount > highest ? issuesCount : highest
data.push({letter: tags[key][0], frequency: issuesCount});
x_domain.push(tags[key][0]);
}
data.push({letter: 'N/A', frequency: issuesByTag['unassigned']})
x_domain.push('N/A');

var highest_y = Math.max(highest, issuesByTag['unassigned']);
// -------------------------------------------------------- /Data variables

x.domain(x_domain);

y.domain([0, highest_y]);

d3.selection.prototype.last = function() {
return d3.select(
this.nodes()[this.size() - 1]
);
};

x_axis = svg.append('g')
.attr('class', 'x axis')
.attr('transform', 'translate(0,' + height + ')')
.call(xAxis);
x_axis.selectAll("text").style("fill", "inherit");
x_axis.selectAll("path").style("stroke", "none");
x_axis.selectAll("text").last().classed("untagged", true);

var bars = svg.append('g');

bars.selectAll('rect')
.data(data)
.enter().append('rect')
.attr('class', 'bar' )
.attr('x', function(d) { return x(d.letter); })
.attr('width', x.bandwidth())
.attr('y', function(d) { return y(d.frequency); })
.attr('height', function(d) { return height - y(d.frequency); });


bars.selectAll('text')
.data(data)
.enter().append('text')
.attr('x', function(d, i) { return x(d.letter) + x.bandwidth()/2; })
.attr('y', function(d) { return y(d.frequency);})
.attr('dy', -5)
.attr('text-anchor', 'middle')
.attr('class', 'counter' )
.text(function(d) {return d.frequency;});

var i = 0;
for( var key in tags ){
$($('.tick')[i]).attr('fill', tags[key][1]);
$($('.bar')[i]).attr('fill', tags[key][1]);
$($('.counter')[i]).attr('fill', tags[key][1]);
i++;
}

$($('.tick')[i]).addClass('untagged');
$($('.bar')[i]).addClass('untagged');
$($('.counter')[i]).addClass('untagged');
function initIssuesChart() {
const $chartElement = $('[data-behavior~=issue-chart]');

if (!$chartElement.length || $chartElement.find('svg').length > 0) { return; }

const margin = { top: 20, bottom: 0 };
const width = 354;
const height = 180 - margin.top - margin.bottom;

const x = d3.scaleBand().rangeRound([0, width]);
const y = d3.scaleLinear().range([height, 0]);

const container = d3.select('[data-behavior~=issue-chart]');

const svg = container.append('svg')
.attr('width', width)
.attr('height', height + margin.top + margin.bottom)
.append('g')
.attr('transform', `translate(0,${margin.top})`);

// --------------------------------------------------------- Data variables
const tags = $chartElement.data('tags') || {};
const issuesByTag = $chartElement.data('issues-count') || {};
let highest = 0;
const data = [];
const x_domain = [];
const colors = [];

Object.keys(tags).forEach(key => {
const issuesCount = issuesByTag[key] || 0;
highest = issuesCount > highest ? issuesCount : highest;
data.push({ letter: tags[key][0], frequency: issuesCount });
x_domain.push(tags[key][0]);
colors.push(tags[key][1]);
});

const unassignedCount = issuesByTag['unassigned'] || 0;
data.push({ letter: 'N/A', frequency: unassignedCount });
x_domain.push('N/A');

const highest_y = Math.max(highest, unassignedCount);
// -------------------------------------------------------- /Data variables

x.domain(x_domain);
y.domain([0, highest_y]);

const bars = svg.append('g');

bars.selectAll('rect')
.data(data)
.enter().append('rect')
.attr('class', 'bar')
.attr('x', d => x(d.letter))
.attr('width', x.bandwidth())
.attr('y', d => y(d.frequency))
.attr('height', d => height - y(d.frequency));

bars.selectAll('text')
.data(data)
.enter().append('text')
.attr('x', d => x(d.letter) + x.bandwidth() / 2)
.attr('y', d => y(d.frequency))
.attr('dy', -5)
.attr('text-anchor', 'middle')
.attr('class', 'counter')
.text(d => d.frequency);

colors.forEach((color, i) => {
$($('.bar')[i]).attr('fill', color);
$($('.counter')[i]).attr('fill', color);
});

$($('.bar')[colors.length]).addClass('untagged');
$($('.counter')[colors.length]).addClass('untagged');

buildLegend(container, data, colors);
}

function buildLegend(container, data, colors) {
const legend = container.append('ul').attr('class', 'issue-chart-legend');

const item = legend.selectAll('li')
.data(data)
.enter().append('li')
.attr('class', (_, i) => i === colors.length ? 'legend-item untagged' : 'legend-item')
.attr('title', d => d.letter);

item.append('span')
.attr('class', 'legend-swatch')
.style('background-color', (_, i) => colors[i] || null);

item.append('span')
.attr('class', 'legend-label')
.text(d => d.letter);
}

document.addEventListener('turbo:frame-load', e => {
if (e.target.id === 'issues-summary') {
initIssuesChart();
}
});
49 changes: 45 additions & 4 deletions app/assets/stylesheets/hera/views/projects.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,60 @@ body.projects {
}

#issue-chart {
display: flex;
justify-content: center;
align-items: center;
display: flex;
flex-direction: column;
gap: 0.75rem;

.bar.untagged,
.counter.untagged,
.tick.untagged {
.counter.untagged {
fill: var(--untagged-color);
}

svg text {
font-size: 14px;
}

.issue-chart-legend {
display: flex;
flex-wrap: wrap;
gap: 0.5rem 1rem;
justify-content: center;
list-style: none;
margin: 0;
padding: 0;

.legend-item {
align-items: center;
display: flex;
gap: 0.5rem;

&.untagged {
.legend-swatch {
background-color: var(--untagged-color);
}

.legend-label {
color: var(--untagged-color);
}
}
}

.legend-label {
color: var(--text-default);
max-width: 12rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.legend-swatch {
border-radius: 50%;
flex-shrink: 0;
height: 0.75rem;
width: 0.75rem;
}
}
}

#issues-accordion {
Expand Down
29 changes: 29 additions & 0 deletions app/controllers/concerns/issues_dimension_grouping.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module IssuesDimensionGrouping
private

def build_all_tags_grouping
@count_by_tag = Hash.new(0)
@issues_by_tag = Hash.new { |h, k| h[k] = [] }
@tag_names = @tags.map do |tag|
[tag.name, [tag.display_name, tag.color]]
end.to_h

@issues.each do |issue|
if issue.tags.empty?
@issues_by_tag[:unassigned] << issue
@count_by_tag[:unassigned] += 1
else
issue.tags.each do |tag|
@issues_by_tag[tag.name] << issue
@count_by_tag[tag.name] += 1
end
end
end

@chart_data = {
dimension: 'tags',
tags: @tag_names.to_json,
issues_count: @count_by_tag.to_json
}
end
end
11 changes: 11 additions & 0 deletions app/controllers/projects/issues_summary_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Projects::IssuesSummaryController < AuthenticatedController
include IssuesDimensionGrouping
include ProjectScoped

def show
@issues = current_project.issues.includes(:tags).sort
@tags = current_project.tags

build_all_tags_grouping
end
end
Loading
Loading