Skip to content

Commit

Permalink
feat(matrix): update 'pre-verifed' pop up text, and add icon to indic…
Browse files Browse the repository at this point in the history
…ate when a pact is pre-verified
  • Loading branch information
bethesque committed Nov 20, 2019
1 parent 5556b81 commit a86010e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
2 changes: 2 additions & 0 deletions lib/pact_broker/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ en:
pact_broker:
messages:
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.
matrix:
pre_verified: This pact was "pre-verified" as it has identical content to a previously verified pact.
webhooks:
parameters:
pactbroker:
Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/test/test_data_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def create_pact params = {}
def republish_same_pact params = {}
params.delete(:comment)
last_pact_version = PactBroker::Pacts::PactVersion.order(:id).last
create_pact json_content: last_pact_version.content
create_pact pact_version_sha: last_pact_version.sha, json_content: last_pact_version.content, created_at: params[:created_at]
self
end

Expand Down
8 changes: 5 additions & 3 deletions lib/pact_broker/ui/view_models/matrix_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
require 'pact_broker/date_helper'
require 'pact_broker/ui/view_models/matrix_tag'
require 'pact_broker/versions/abbreviate_number'
require 'pact_broker/messages'

module PactBroker
module UI
module ViewDomain
class MatrixLine
include PactBroker::Api::PactBrokerUrls
include PactBroker::Messages

def initialize line
@line = line
Expand Down Expand Up @@ -114,7 +116,7 @@ def <=> other
(self.orderable_fields <=> other.orderable_fields) * -1
end

def pseudo_branch_verification_status
def verification_status
if @line.verification_executed_at
DateHelper.distance_of_time_in_words(@line.verification_executed_at, DateTime.now) + " ago"
else
Expand Down Expand Up @@ -163,9 +165,9 @@ def overwritten= overwritten
@overwritten = overwritten
end

def inherited_verification_message
def pre_verified_message
if @line.verification_executed_at && @line.pact_created_at > @line.verification_executed_at
"The verification date is before the pact publication date because this verification has been inherited from a previously verified pact with identical content."
message("messages.matrix.pre_verified")
end
end
end
Expand Down
14 changes: 6 additions & 8 deletions lib/pact_broker/ui/view_models/matrix_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,26 @@ class MatrixTag

include PactBroker::Api::PactBrokerUrls

attr_reader :name, :pacticipant_name, :version_number

def initialize params
@params = params
@name = params[:name]
@pacticipant_name = params[:pacticipant_name]
@version_number = params[:version_number]
@created_at = params[:created_at]
@latest = !!params[:latest]
end

def name
@params[:name]
end

def tooltip
if @latest
"Version #{@version_number} is the latest version with tag #{@name}. Tag created #{relative_date(@created_at)}."
"This is the latest version of #{pacticipant_name} with tag \"#{@name}\". Tag created #{relative_date(@created_at)}."
else
"Tag created #{relative_date(@created_at)}."
"Tag created #{relative_date(@created_at)}. A more recent version of #{pacticipant_name} with tag \"#{name}\" exists."
end
end

def url
hal_browser_url("/pacticipants/#{ERB::Util.url_encode(@params[:pacticipant_name])}/versions/#{@params[:version_number]}/tags/#{@params[:name]}")
hal_browser_url("/pacticipants/#{ERB::Util.url_encode(pacticipant_name)}/versions/#{ERB::Util.url_encode(version_number)}/tags/#{ERB::Util.url_encode(name)}")
end

def relative_date date
Expand Down
10 changes: 6 additions & 4 deletions lib/pact_broker/ui/views/matrix/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
%a{href: tag.url}
.tag.label.label-default
= tag.name
%td.pact-published{'data-sort-value' => line.pact_published_order, "title": line.inherited_verification_message, "data-toggle": "tooltip"}
%td.pact-published{'data-sort-value' => line.pact_published_order, "data-toggle": "tooltip"}
%a{href: line.pact_publication_date_url}
- if options.all_rows_checked
= "#{line.pact_publication_date} (revision #{line.pact_revision_number})"
Expand All @@ -146,12 +146,14 @@
%a{href: tag.url}
.tag.label.label-default
= tag.name
%td.verification-result{class: line.verification_status_class, "title": line.inherited_verification_message, "data-toggle": "tooltip"}
%td.verification-result{class: line.verification_status_class, "title": line.pre_verified_message, "data-toggle": "tooltip"}
%a{href: line.verification_status_url}
- if options.all_rows_checked && line.number
= "#{line.pseudo_branch_verification_status} (number #{line.number})"
= "#{line.verification_status} (number #{line.number})"
- else
= line.pseudo_branch_verification_status
= line.verification_status
- if line.pre_verified_message
%span.glyphicon.glyphicon-time.pre-verified-icon{"aria-hidden": true}

:javascript
$(document).ready(function(){
Expand Down
6 changes: 5 additions & 1 deletion public/stylesheets/matrix.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ div.tag-parent {

div.tag {
display: inline-block;
}
}

span.pre-verified-icon {
color: #337ab7;
}

0 comments on commit a86010e

Please sign in to comment.