Skip to content

Commit 0d53909

Browse files
committed
feat(matrix): show pact version SHA in popup text, and highlight pact publications with the same pact version
1 parent 49fd500 commit 0d53909

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

lib/pact_broker/ui/view_models/matrix_line.rb

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def pact_version_sha
3737
@line.pact_version_sha
3838
end
3939

40+
def pact_version_sha_message
41+
"The highlighted pact(s) have content that has a SHA of #{pact_version_sha}"
42+
end
43+
4044
# verification number, used in verification_url method
4145
def number
4246
@line.verification_number

lib/pact_broker/ui/views/matrix/show.haml

+2-7
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
%a{href: tag.url}
120120
.tag.label.label-default
121121
= tag.name
122-
%td.pact-published{'data-sort-value' => line.pact_published_order, "data-toggle": "tooltip"}
122+
%td.pact-published{'data-sort-value' => line.pact_published_order, "data-toggle": "tooltip", "title": line.pact_version_sha_message, "data-placement": "right", "data-pact-version-sha": line.pact_version_sha}
123123
%a{href: line.pact_publication_date_url}
124124
- if options.all_rows_checked
125125
= "#{line.pact_publication_date} (revision #{line.pact_revision_number})"
@@ -146,16 +146,11 @@
146146
%a{href: tag.url}
147147
.tag.label.label-default
148148
= tag.name
149-
%td.verification-result{class: line.verification_status_class, "title": line.pre_verified_message, "data-toggle": "tooltip"}
149+
%td.verification-result{class: line.verification_status_class, "title": line.pre_verified_message, "data-toggle": "tooltip", "data-placement": "left"}
150150
%a{href: line.verification_status_url}
151151
- if options.all_rows_checked && line.number
152152
= "#{line.verification_status} (number #{line.number})"
153153
- else
154154
= line.verification_status
155155
- if line.pre_verified_message
156156
%span.glyphicon.glyphicon-time.pre-verified-icon{"aria-hidden": true}
157-
158-
:javascript
159-
$(document).ready(function(){
160-
initializeClipper(".clippable");
161-
});

public/javascripts/matrix.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,26 @@ function disableFieldsThatShouldNotBeSubmitted() {
5353
$('.version-selectorizor').prop('disabled', 'disabled');
5454
}
5555

56+
function highlightPactPublicationsWithSameContent(td) {
57+
const pactVersionSha = $(td).data('pact-version-sha');
58+
$('*[data-pact-version-sha="' + pactVersionSha +'"]').addClass('bg-info');
59+
}
60+
61+
function unHighlightPactPublicationsWithSameContent(td, event) {
62+
var destinationElement = $(event.toElement || event.relatedTarget);
63+
// Have to use mouseout instead of mouseleave, because the tooltip is a child
64+
// of the td, and the mouseleave will consider that hovering over the tooltip
65+
// does not count as leaving. Unfortunately, if you then leave the tooltip,
66+
// the div gets removed without firing the mouseleave event, so the cells remain
67+
// highlighted.
68+
// The tooltip needs to be a child of the td so that we can style the one showing
69+
// the SHA so that it's wide enough to fit the SHA in.
70+
if (!$(td).find('a').is(destinationElement)) {
71+
const pactVersionSha = $(td).data('pact-version-sha');
72+
$('*[data-pact-version-sha="' + pactVersionSha +'"]').removeClass('bg-info');
73+
}
74+
}
75+
5676
$(document).ready(function(){
5777
$('.version-selectorizor').change(handleSelectorizorChanged);
5878
$('.version-selectorizor').each(function(){ showApplicableTextBoxes($(this)); });
@@ -65,6 +85,11 @@ $(document).ready(function(){
6585
});
6686

6787
$('[data-toggle="tooltip"]').each(function(index, el){
68-
$(el).tooltip({container: $(el)});
88+
$(el).tooltip({container: $(el)})
6989
});
90+
91+
initializeClipper('.clippable');
92+
93+
$('td.pact-published').mouseover(function(event) { highlightPactPublicationsWithSameContent(this) });
94+
$('td.pact-published').mouseout(function(event) { unHighlightPactPublicationsWithSameContent(this, event)});
7095
});

public/stylesheets/matrix.css

+5
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ div.tag {
2323
span.pre-verified-icon {
2424
color: #337ab7;
2525
}
26+
27+
/* Need to make the tooltip wide enough to show the full SHA */
28+
td.pact-published .tooltip-inner {
29+
max-width: 300px;
30+
}

0 commit comments

Comments
 (0)