diff --git a/lib/pact_broker/api/pact_broker_urls.rb b/lib/pact_broker/api/pact_broker_urls.rb index a3a5bd30d..bf1406557 100644 --- a/lib/pact_broker/api/pact_broker_urls.rb +++ b/lib/pact_broker/api/pact_broker_urls.rb @@ -76,7 +76,7 @@ def new_verification_url pact, number, base_url ].join('/') end - def verification_url verification, base_url + def verification_url verification, base_url = '' [ base_url, 'pacts', 'provider', url_encode(verification.provider_name), 'consumer', url_encode(verification.consumer_name), diff --git a/lib/pact_broker/ui/view_models/matrix_line.rb b/lib/pact_broker/ui/view_models/matrix_line.rb index 9a7b47107..aef5c70dd 100644 --- a/lib/pact_broker/ui/view_models/matrix_line.rb +++ b/lib/pact_broker/ui/view_models/matrix_line.rb @@ -13,14 +13,51 @@ def initialize line @line = line end + def provider_name + @line[:provider_name] + end + + def consumer_name + @line[:consumer_name] + end + + def pact_version_sha + @line[:pact_version_sha] + end + + # verification number + def number + @line[:number] + end + def consumer_version_number @line[:consumer_version_number] end + def consumer_version_number_url + pact_url_from_params('', @line) + end + + def consumer_version_order + @line[:consumer_version_order] + end + def provider_version_number @line[:provider_version] end + def provider_version_number_url + hal_browser_url(verification_url(self)) + end + + def provider_version_order + if @line[:execution_date] + @line[:execution_date].to_time.to_i + else + 0 + end + end + def verification_status case @line[:success] when true then "Verified" diff --git a/lib/pact_broker/ui/views/matrix/show.haml b/lib/pact_broker/ui/views/matrix/show.haml index ab696b28f..afd9cbcf6 100644 --- a/lib/pact_broker/ui/views/matrix/show.haml +++ b/lib/pact_broker/ui/views/matrix/show.haml @@ -8,7 +8,7 @@ .container %h1.page-header = title - %table.table.table-bordered.table-striped{id: 'relationships'} + %table.table.table-bordered.table-striped{id: 'matrix'} %thead %th.consumer = "#{consumer_name} version" @@ -18,13 +18,25 @@ %span.glyphicon.glyphicon-sort.sort %th.verification-result Verification + %span.glyphicon.glyphicon-sort.sort %tbody - lines.each do | line | %tr - %td.consumer-version - = line.consumer_version_number - %td.provider - = line.provider_version_number + %td.consumer-version{'data-sort-value' => line.consumer_version_order} + %a{href: line.consumer_version_number_url} + = line.consumer_version_number + %td.provider{'data-sort-value' => line.provider_version_order} + %a{href: line.provider_version_number_url} + = line.provider_version_number %td.verification-result{class: line.verification_status_class} = line.verification_status +:javascript + $(function(){ + $("#matrix").tablesorter({ + textExtraction : function(node, table, cellIndex){ + n = $(node); + return n.attr('data-sort-value') || n.text(); + } + }); + });