Skip to content

Commit

Permalink
feat(matrix ui): don't show potentially confusing links for overwritt…
Browse files Browse the repository at this point in the history
…en pact revisions
  • Loading branch information
bethesque committed Feb 4, 2018
1 parent 679eec1 commit ed7498a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/pact_broker/ui/controllers/matrix.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'pact_broker/ui/controllers/base_controller'
require 'pact_broker/ui/view_models/matrix_line'
require 'pact_broker/ui/view_models/matrix_lines'
require 'pact_broker/matrix/parse_query'
require 'pact_broker/logging'
require 'haml'
Expand Down Expand Up @@ -29,7 +29,7 @@ class Matrix < Base
errors = matrix_service.validate_selectors(selectors)
if errors.empty?
lines = matrix_service.find(selectors, options)
locals[:lines] = lines.collect{ |line| PactBroker::UI::ViewDomain::MatrixLine.new(line) }
locals[:lines] = PactBroker::UI::ViewDomain::MatrixLines.new(lines)
else
locals[:errors] = errors
end
Expand All @@ -45,7 +45,7 @@ class Matrix < Base
selectors = [{ pacticipant_name: params[:consumer_name] }, { pacticipant_name: params[:provider_name] } ]
options = {latestby: 'cvpv', limit: 100}
lines = matrix_service.find(selectors, options)
lines = lines.collect{ |line| PactBroker::UI::ViewDomain::MatrixLine.new(line) }.sort
lines = PactBroker::UI::ViewDomain::MatrixLines.new(lines)
locals = {
lines: lines,
title: "The Matrix",
Expand Down
9 changes: 9 additions & 0 deletions lib/pact_broker/ui/view_models/matrix_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MatrixLine

def initialize line
@line = line
@overwritten = false # true if the pact was revised and this revision is no longer the latest
end

def provider_name
Expand Down Expand Up @@ -153,6 +154,14 @@ def verification_status_class
else ''
end
end

def overwritten?
@overwritten
end

def overwritten= overwritten
@overwritten = overwritten
end
end
end
end
Expand Down
29 changes: 29 additions & 0 deletions lib/pact_broker/ui/view_models/matrix_lines.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'pact_broker/ui/view_models/matrix_line'

module PactBroker
module UI
module ViewDomain
class MatrixLines < Array

def initialize rows
lines = rows.collect do | row |
PactBroker::UI::ViewDomain::MatrixLine.new(row)
end

super(lines.sort)

# Don't have a URL to view ovewritten pact revisions, so don't show a link for them until we do
line_group_ids = []
each do | line |
line_group_id = [line.consumer_name, line.consumer_version_number, line.provider_name, line.provider_version_number]
if line_group_ids.include?(line_group_id)
line.overwritten = true
else
line_group_ids << line_group_id
end
end
end
end
end
end
end
7 changes: 5 additions & 2 deletions lib/pact_broker/ui/views/matrix/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@
.tag.label.label-default
= tag.name
%td.pact-published{'data-sort-value' => line.pact_published_order}
%a{href: line.pact_publication_date_url}
= line.pact_publication_date
- if !line.overwritten?
%a{href: line.pact_publication_date_url}
= line.pact_publication_date
- else
= "#{line.pact_publication_date} (overwritten)"
%td.provider{'data-sort-value' => line.provider_name}
%a{href: line.provider_name_url}
= line.provider_name
Expand Down

0 comments on commit ed7498a

Please sign in to comment.