Skip to content

Commit ed7498a

Browse files
committed
feat(matrix ui): don't show potentially confusing links for overwritten pact revisions
1 parent 679eec1 commit ed7498a

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

lib/pact_broker/ui/controllers/matrix.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'pact_broker/ui/controllers/base_controller'
2-
require 'pact_broker/ui/view_models/matrix_line'
2+
require 'pact_broker/ui/view_models/matrix_lines'
33
require 'pact_broker/matrix/parse_query'
44
require 'pact_broker/logging'
55
require 'haml'
@@ -29,7 +29,7 @@ class Matrix < Base
2929
errors = matrix_service.validate_selectors(selectors)
3030
if errors.empty?
3131
lines = matrix_service.find(selectors, options)
32-
locals[:lines] = lines.collect{ |line| PactBroker::UI::ViewDomain::MatrixLine.new(line) }
32+
locals[:lines] = PactBroker::UI::ViewDomain::MatrixLines.new(lines)
3333
else
3434
locals[:errors] = errors
3535
end
@@ -45,7 +45,7 @@ class Matrix < Base
4545
selectors = [{ pacticipant_name: params[:consumer_name] }, { pacticipant_name: params[:provider_name] } ]
4646
options = {latestby: 'cvpv', limit: 100}
4747
lines = matrix_service.find(selectors, options)
48-
lines = lines.collect{ |line| PactBroker::UI::ViewDomain::MatrixLine.new(line) }.sort
48+
lines = PactBroker::UI::ViewDomain::MatrixLines.new(lines)
4949
locals = {
5050
lines: lines,
5151
title: "The Matrix",

lib/pact_broker/ui/view_models/matrix_line.rb

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class MatrixLine
1212

1313
def initialize line
1414
@line = line
15+
@overwritten = false # true if the pact was revised and this revision is no longer the latest
1516
end
1617

1718
def provider_name
@@ -153,6 +154,14 @@ def verification_status_class
153154
else ''
154155
end
155156
end
157+
158+
def overwritten?
159+
@overwritten
160+
end
161+
162+
def overwritten= overwritten
163+
@overwritten = overwritten
164+
end
156165
end
157166
end
158167
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'pact_broker/ui/view_models/matrix_line'
2+
3+
module PactBroker
4+
module UI
5+
module ViewDomain
6+
class MatrixLines < Array
7+
8+
def initialize rows
9+
lines = rows.collect do | row |
10+
PactBroker::UI::ViewDomain::MatrixLine.new(row)
11+
end
12+
13+
super(lines.sort)
14+
15+
# Don't have a URL to view ovewritten pact revisions, so don't show a link for them until we do
16+
line_group_ids = []
17+
each do | line |
18+
line_group_id = [line.consumer_name, line.consumer_version_number, line.provider_name, line.provider_version_number]
19+
if line_group_ids.include?(line_group_id)
20+
line.overwritten = true
21+
else
22+
line_group_ids << line_group_id
23+
end
24+
end
25+
end
26+
end
27+
end
28+
end
29+
end

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@
114114
.tag.label.label-default
115115
= tag.name
116116
%td.pact-published{'data-sort-value' => line.pact_published_order}
117-
%a{href: line.pact_publication_date_url}
118-
= line.pact_publication_date
117+
- if !line.overwritten?
118+
%a{href: line.pact_publication_date_url}
119+
= line.pact_publication_date
120+
- else
121+
= "#{line.pact_publication_date} (overwritten)"
119122
%td.provider{'data-sort-value' => line.provider_name}
120123
%a{href: line.provider_name_url}
121124
= line.provider_name

0 commit comments

Comments
 (0)