Skip to content

Commit a86010e

Browse files
committed
feat(matrix): update 'pre-verifed' pop up text, and add icon to indicate when a pact is pre-verified
1 parent 5556b81 commit a86010e

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

lib/pact_broker/locale/en.yml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ en:
1313
pact_broker:
1414
messages:
1515
response_body_hidden: For security purposes, the response details are not logged. To enable response logging, configure the webhook_host_whitelist property. See /doc/webhooks#whitelist for more information.
16+
matrix:
17+
pre_verified: This pact was "pre-verified" as it has identical content to a previously verified pact.
1618
webhooks:
1719
parameters:
1820
pactbroker:

lib/pact_broker/test/test_data_builder.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def create_pact params = {}
203203
def republish_same_pact params = {}
204204
params.delete(:comment)
205205
last_pact_version = PactBroker::Pacts::PactVersion.order(:id).last
206-
create_pact json_content: last_pact_version.content
206+
create_pact pact_version_sha: last_pact_version.sha, json_content: last_pact_version.content, created_at: params[:created_at]
207207
self
208208
end
209209

lib/pact_broker/ui/view_models/matrix_line.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
require 'pact_broker/date_helper'
44
require 'pact_broker/ui/view_models/matrix_tag'
55
require 'pact_broker/versions/abbreviate_number'
6+
require 'pact_broker/messages'
67

78
module PactBroker
89
module UI
910
module ViewDomain
1011
class MatrixLine
1112
include PactBroker::Api::PactBrokerUrls
13+
include PactBroker::Messages
1214

1315
def initialize line
1416
@line = line
@@ -114,7 +116,7 @@ def <=> other
114116
(self.orderable_fields <=> other.orderable_fields) * -1
115117
end
116118

117-
def pseudo_branch_verification_status
119+
def verification_status
118120
if @line.verification_executed_at
119121
DateHelper.distance_of_time_in_words(@line.verification_executed_at, DateTime.now) + " ago"
120122
else
@@ -163,9 +165,9 @@ def overwritten= overwritten
163165
@overwritten = overwritten
164166
end
165167

166-
def inherited_verification_message
168+
def pre_verified_message
167169
if @line.verification_executed_at && @line.pact_created_at > @line.verification_executed_at
168-
"The verification date is before the pact publication date because this verification has been inherited from a previously verified pact with identical content."
170+
message("messages.matrix.pre_verified")
169171
end
170172
end
171173
end

lib/pact_broker/ui/view_models/matrix_tag.rb

+6-8
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,26 @@ class MatrixTag
99

1010
include PactBroker::Api::PactBrokerUrls
1111

12+
attr_reader :name, :pacticipant_name, :version_number
13+
1214
def initialize params
13-
@params = params
1415
@name = params[:name]
16+
@pacticipant_name = params[:pacticipant_name]
1517
@version_number = params[:version_number]
1618
@created_at = params[:created_at]
1719
@latest = !!params[:latest]
1820
end
1921

20-
def name
21-
@params[:name]
22-
end
23-
2422
def tooltip
2523
if @latest
26-
"Version #{@version_number} is the latest version with tag #{@name}. Tag created #{relative_date(@created_at)}."
24+
"This is the latest version of #{pacticipant_name} with tag \"#{@name}\". Tag created #{relative_date(@created_at)}."
2725
else
28-
"Tag created #{relative_date(@created_at)}."
26+
"Tag created #{relative_date(@created_at)}. A more recent version of #{pacticipant_name} with tag \"#{name}\" exists."
2927
end
3028
end
3129

3230
def url
33-
hal_browser_url("/pacticipants/#{ERB::Util.url_encode(@params[:pacticipant_name])}/versions/#{@params[:version_number]}/tags/#{@params[:name]}")
31+
hal_browser_url("/pacticipants/#{ERB::Util.url_encode(pacticipant_name)}/versions/#{ERB::Util.url_encode(version_number)}/tags/#{ERB::Util.url_encode(name)}")
3432
end
3533

3634
def relative_date date

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

+6-4
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, "title": line.inherited_verification_message, "data-toggle": "tooltip"}
122+
%td.pact-published{'data-sort-value' => line.pact_published_order, "data-toggle": "tooltip"}
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,12 +146,14 @@
146146
%a{href: tag.url}
147147
.tag.label.label-default
148148
= tag.name
149-
%td.verification-result{class: line.verification_status_class, "title": line.inherited_verification_message, "data-toggle": "tooltip"}
149+
%td.verification-result{class: line.verification_status_class, "title": line.pre_verified_message, "data-toggle": "tooltip"}
150150
%a{href: line.verification_status_url}
151151
- if options.all_rows_checked && line.number
152-
= "#{line.pseudo_branch_verification_status} (number #{line.number})"
152+
= "#{line.verification_status} (number #{line.number})"
153153
- else
154-
= line.pseudo_branch_verification_status
154+
= line.verification_status
155+
- if line.pre_verified_message
156+
%span.glyphicon.glyphicon-time.pre-verified-icon{"aria-hidden": true}
155157

156158
:javascript
157159
$(document).ready(function(){

public/stylesheets/matrix.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ div.tag-parent {
1818

1919
div.tag {
2020
display: inline-block;
21-
}
21+
}
22+
23+
span.pre-verified-icon {
24+
color: #337ab7;
25+
}

0 commit comments

Comments
 (0)