Skip to content

Commit 117c89b

Browse files
committed
feat(index): show tag names as slugs
1 parent 9a21e10 commit 117c89b

File tree

4 files changed

+44
-35
lines changed

4 files changed

+44
-35
lines changed

lib/pact_broker/ui/view_models/index_item.rb

+8-10
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,16 @@ def provider_version_number
3030
PactBroker::Versions::AbbreviateNumber.call(@relationship.provider_version_number)
3131
end
3232

33-
def tag_names
34-
latest_overall = @relationship.latest? ? "latest & " : ""
35-
@relationship.tag_names.any? ? " (#{latest_overall}latest #{@relationship.tag_names.join(', ')}) ": " (latest) "
33+
def latest?
34+
@relationship.latest?
3635
end
3736

38-
def verification_tag_names
39-
if @relationship.latest_verification_latest_tags.any?
40-
tag_names = @relationship.latest_verification_latest_tags.collect(&:name)
41-
" (latest #{tag_names.join(', ')})"
42-
else
43-
""
44-
end
37+
def consumer_version_latest_tag_names
38+
@relationship.tag_names
39+
end
40+
41+
def provider_version_latest_tag_names
42+
@relationship.latest_verification_latest_tags.collect(&:name)
4543
end
4644

4745
def consumer_group_url

lib/pact_broker/ui/views/index/show-with-tags.haml

+15-7
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,23 @@
2222
Consumer
2323
%span.glyphicon.glyphicon-sort.relationships-sort
2424
%th.consumer-version-number
25-
Version
25+
Consumer<br>Version
2626
%span.glyphicon.glyphicon-sort.relationships-sort
2727
%th.pact{ style: 'width: 40px' }
2828
%th.provider
2929
Provider
3030
%span.glyphicon.glyphicon-sort.relationships-sort
3131
%th.provider-version-number
32-
Version
32+
Provider<br>Version
3333
%span.glyphicon.glyphicon-sort.relationships-sort
3434
%th
3535
Published
36+
%span.glyphicon.glyphicon-sort.relationships-sort
3637
%th
3738
Webhook<br>status
3839
%th
3940
Last<br>verified
41+
%span.glyphicon.glyphicon-sort.relationships-sort
4042
%tbody
4143

4244
- index_items.each do | index_item |
@@ -45,9 +47,14 @@
4547
%a{:href => index_item.consumer_group_url }
4648
= index_item.consumer_name
4749
%td.consumer-version-number
48-
= index_item.consumer_version_number
49-
%span{style: 'color:gray'}
50-
= index_item.tag_names
50+
%div
51+
= index_item.consumer_version_number
52+
- if index_item.latest?
53+
.tag.label.label-success
54+
latest
55+
- index_item.consumer_version_latest_tag_names.each do | tag_name |
56+
.tag.label.label-primary
57+
= tag_name
5158
%td.pact
5259
%span.pact
5360
%a{ href: index_item.pact_url, title: "View pact" }
@@ -58,8 +65,9 @@
5865
= index_item.provider_name
5966
%td.provider-version-number
6067
= index_item.provider_version_number
61-
%span{style: 'color:gray'}
62-
= index_item.verification_tag_names
68+
- index_item.provider_version_latest_tag_names.each do | tag_name |
69+
.tag.label.label-primary
70+
= tag_name
6371
%td
6472
= index_item.publication_date_of_latest_pact.gsub("about ", "")
6573
%td{ class: index_item.webhook_status }

public/stylesheets/index.css

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313

1414
table#relationships {
15-
table-layout: fixed;
15+
/*table-layout: fixed;*/
1616
}
1717

1818
table#relationships td,
@@ -105,3 +105,12 @@ span.pact:hover svg path, span.pact-matrix:hover svg path {
105105
#top-left-menu li{
106106
list-style: none;
107107
}
108+
109+
table#relationships .label {
110+
word-wrap: break-word;
111+
white-space: normal;
112+
}
113+
114+
div.tag {
115+
display: inline-block;
116+
}

spec/lib/pact_broker/ui/view_models/index_item_spec.rb

+11-17
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,24 @@ module ViewDomain
114114
end
115115
end
116116

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

122-
context "when the pact is the overall latest and also has tag names" do
123-
let(:tags) { ["master", "prod"] }
124-
its(:tag_names) { is_expected.to eq " (latest & latest master, prod) " }
125-
end
126-
127-
context "when the pact is not the latest and has tag names" do
122+
context "when the pact is not the latest" do
128123
let(:latest) { false }
129-
let(:tags) { ["master", "prod"] }
130-
its(:tag_names) { is_expected.to eq " (latest master, prod) " }
124+
its(:latest?) { is_expected.to be false }
131125
end
132126
end
133127

134-
describe "verification_tag_names" do
135-
its(:verification_tag_names) { is_expected.to eq " (latest dev, prod)"}
128+
describe "consumer_version_latest_tag_names" do
129+
let(:tags) { ["master", "prod"] }
130+
its(:consumer_version_latest_tag_names) { is_expected.to eq ["master", "prod"] }
131+
end
136132

137-
context "when there are no tags" do
138-
let(:latest_verification_latest_tags) { [] }
139-
its(:verification_tag_names) { is_expected.to eq "" }
140-
end
133+
describe "provider_version_latest_tag_names" do
134+
its(:provider_version_latest_tag_names) { is_expected.to eq ["dev", "prod"] }
141135
end
142136

143137
describe "<=>" do

0 commit comments

Comments
 (0)