Skip to content

Commit

Permalink
feat(index): show tag names as slugs
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Feb 7, 2018
1 parent 9a21e10 commit 117c89b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 35 deletions.
18 changes: 8 additions & 10 deletions lib/pact_broker/ui/view_models/index_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@ def provider_version_number
PactBroker::Versions::AbbreviateNumber.call(@relationship.provider_version_number)
end

def tag_names
latest_overall = @relationship.latest? ? "latest & " : ""
@relationship.tag_names.any? ? " (#{latest_overall}latest #{@relationship.tag_names.join(', ')}) ": " (latest) "
def latest?
@relationship.latest?
end

def verification_tag_names
if @relationship.latest_verification_latest_tags.any?
tag_names = @relationship.latest_verification_latest_tags.collect(&:name)
" (latest #{tag_names.join(', ')})"
else
""
end
def consumer_version_latest_tag_names
@relationship.tag_names
end

def provider_version_latest_tag_names
@relationship.latest_verification_latest_tags.collect(&:name)
end

def consumer_group_url
Expand Down
22 changes: 15 additions & 7 deletions lib/pact_broker/ui/views/index/show-with-tags.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@
Consumer
%span.glyphicon.glyphicon-sort.relationships-sort
%th.consumer-version-number
Version
Consumer<br>Version
%span.glyphicon.glyphicon-sort.relationships-sort
%th.pact{ style: 'width: 40px' }
%th.provider
Provider
%span.glyphicon.glyphicon-sort.relationships-sort
%th.provider-version-number
Version
Provider<br>Version
%span.glyphicon.glyphicon-sort.relationships-sort
%th
Published
%span.glyphicon.glyphicon-sort.relationships-sort
%th
Webhook<br>status
%th
Last<br>verified
%span.glyphicon.glyphicon-sort.relationships-sort
%tbody

- index_items.each do | index_item |
Expand All @@ -45,9 +47,14 @@
%a{:href => index_item.consumer_group_url }
= index_item.consumer_name
%td.consumer-version-number
= index_item.consumer_version_number
%span{style: 'color:gray'}
= index_item.tag_names
%div
= index_item.consumer_version_number
- if index_item.latest?
.tag.label.label-success
latest
- index_item.consumer_version_latest_tag_names.each do | tag_name |
.tag.label.label-primary
= tag_name
%td.pact
%span.pact
%a{ href: index_item.pact_url, title: "View pact" }
Expand All @@ -58,8 +65,9 @@
= index_item.provider_name
%td.provider-version-number
= index_item.provider_version_number
%span{style: 'color:gray'}
= index_item.verification_tag_names
- index_item.provider_version_latest_tag_names.each do | tag_name |
.tag.label.label-primary
= tag_name
%td
= index_item.publication_date_of_latest_pact.gsub("about ", "")
%td{ class: index_item.webhook_status }
Expand Down
11 changes: 10 additions & 1 deletion public/stylesheets/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}

table#relationships {
table-layout: fixed;
/*table-layout: fixed;*/
}

table#relationships td,
Expand Down Expand Up @@ -105,3 +105,12 @@ span.pact:hover svg path, span.pact-matrix:hover svg path {
#top-left-menu li{
list-style: none;
}

table#relationships .label {
word-wrap: break-word;
white-space: normal;
}

div.tag {
display: inline-block;
}
28 changes: 11 additions & 17 deletions spec/lib/pact_broker/ui/view_models/index_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,24 @@ module ViewDomain
end
end

describe "tag_names" do
context "when the pact is the overall latest and it has no tag names" do
its(:tag_names) { is_expected.to eq " (latest) " }
describe "latest?" do
context "when the pact is the overall latest" do
its(:latest?) { is_expected.to be true }
end

context "when the pact is the overall latest and also has tag names" do
let(:tags) { ["master", "prod"] }
its(:tag_names) { is_expected.to eq " (latest & latest master, prod) " }
end

context "when the pact is not the latest and has tag names" do
context "when the pact is not the latest" do
let(:latest) { false }
let(:tags) { ["master", "prod"] }
its(:tag_names) { is_expected.to eq " (latest master, prod) " }
its(:latest?) { is_expected.to be false }
end
end

describe "verification_tag_names" do
its(:verification_tag_names) { is_expected.to eq " (latest dev, prod)"}
describe "consumer_version_latest_tag_names" do
let(:tags) { ["master", "prod"] }
its(:consumer_version_latest_tag_names) { is_expected.to eq ["master", "prod"] }
end

context "when there are no tags" do
let(:latest_verification_latest_tags) { [] }
its(:verification_tag_names) { is_expected.to eq "" }
end
describe "provider_version_latest_tag_names" do
its(:provider_version_latest_tag_names) { is_expected.to eq ["dev", "prod"] }
end

describe "<=>" do
Expand Down

0 comments on commit 117c89b

Please sign in to comment.