From a86010e52267a2c68d2c89fa9caefb15331ae4f8 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 20 Nov 2019 17:10:31 +1100 Subject: [PATCH] feat(matrix): update 'pre-verifed' pop up text, and add icon to indicate when a pact is pre-verified --- lib/pact_broker/locale/en.yml | 2 ++ lib/pact_broker/test/test_data_builder.rb | 2 +- lib/pact_broker/ui/view_models/matrix_line.rb | 8 +++++--- lib/pact_broker/ui/view_models/matrix_tag.rb | 14 ++++++-------- lib/pact_broker/ui/views/matrix/show.haml | 10 ++++++---- public/stylesheets/matrix.css | 6 +++++- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/lib/pact_broker/locale/en.yml b/lib/pact_broker/locale/en.yml index 2c4643907..7e420a18d 100644 --- a/lib/pact_broker/locale/en.yml +++ b/lib/pact_broker/locale/en.yml @@ -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: diff --git a/lib/pact_broker/test/test_data_builder.rb b/lib/pact_broker/test/test_data_builder.rb index 00c819cb4..03665a484 100644 --- a/lib/pact_broker/test/test_data_builder.rb +++ b/lib/pact_broker/test/test_data_builder.rb @@ -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 diff --git a/lib/pact_broker/ui/view_models/matrix_line.rb b/lib/pact_broker/ui/view_models/matrix_line.rb index 23239c523..992cbe5ef 100644 --- a/lib/pact_broker/ui/view_models/matrix_line.rb +++ b/lib/pact_broker/ui/view_models/matrix_line.rb @@ -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 @@ -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 @@ -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 diff --git a/lib/pact_broker/ui/view_models/matrix_tag.rb b/lib/pact_broker/ui/view_models/matrix_tag.rb index 74083c06c..c4f1bbf3a 100644 --- a/lib/pact_broker/ui/view_models/matrix_tag.rb +++ b/lib/pact_broker/ui/view_models/matrix_tag.rb @@ -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 diff --git a/lib/pact_broker/ui/views/matrix/show.haml b/lib/pact_broker/ui/views/matrix/show.haml index 737e6535a..dd61eb2f4 100644 --- a/lib/pact_broker/ui/views/matrix/show.haml +++ b/lib/pact_broker/ui/views/matrix/show.haml @@ -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})" @@ -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(){ diff --git a/public/stylesheets/matrix.css b/public/stylesheets/matrix.css index 7f8a05480..3895df8bd 100644 --- a/public/stylesheets/matrix.css +++ b/public/stylesheets/matrix.css @@ -18,4 +18,8 @@ div.tag-parent { div.tag { display: inline-block; -} \ No newline at end of file +} + +span.pre-verified-icon { + color: #337ab7; +}