Skip to content

Commit 2958ae8

Browse files
committed
feat(matrix ui): add links to all resources referenced in matrix
1 parent 611ab7e commit 2958ae8

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

lib/pact_broker/api/pact_broker_urls.rb

+20
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module PactBroker
44
module Api
55
module PactBrokerUrls
66

7+
# TODO make base_url the last and optional argument for all methods, defaulting to ''
8+
79
extend self
810

911
def pacticipants_url base_url
@@ -14,6 +16,14 @@ def pacticipant_url base_url, pacticipant
1416
"#{pacticipants_url(base_url)}/#{url_encode(pacticipant.name)}"
1517
end
1618

19+
def pacticipant_url_from_params params, base_url = ''
20+
[
21+
base_url,
22+
'pacticipants',
23+
url_encode(params.fetch(:pacticipant_name))
24+
].join("/")
25+
end
26+
1727
def latest_version_url base_url, pacticipant
1828
"#{pacticipant_url(base_url, pacticipant)}/versions/latest"
1929
end
@@ -26,6 +36,16 @@ def version_url base_url, version
2636
"#{pacticipant_url(base_url, version.pacticipant)}/versions/#{version.number}"
2737
end
2838

39+
def version_url_from_params params, base_url = ''
40+
[
41+
base_url,
42+
'pacticipants',
43+
url_encode(params.fetch(:pacticipant_name)),
44+
'versions',
45+
url_encode(params.fetch(:version_number)),
46+
].join("/")
47+
end
48+
2949
def pact_url base_url, pact
3050
"#{pactigration_base_url(base_url, pact)}/version/#{pact.consumer_version_number}"
3151
end

lib/pact_broker/ui/view_models/matrix_line.rb

+22-4
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,25 @@ def provider_name
1818
@line[:provider_name]
1919
end
2020

21+
def provider_name_url
22+
hal_browser_url(pacticipant_url_from_params(pacticipant_name: provider_name))
23+
end
24+
2125
def consumer_name
2226
@line[:consumer_name]
2327
end
2428

29+
def consumer_name_url
30+
hal_browser_url(pacticipant_url_from_params(pacticipant_name: consumer_name))
31+
end
32+
2533
def pact_version_sha
2634
@line[:pact_version_sha]
2735
end
2836

29-
# verification number
37+
# verification number, used in verification_url method
3038
def number
31-
@line[:number]
39+
@line[:verification_number]
3240
end
3341

3442
def consumer_name
@@ -40,7 +48,8 @@ def consumer_version_number
4048
end
4149

4250
def consumer_version_number_url
43-
pact_url_from_params('', @line)
51+
params = { pacticipant_name: consumer_name, version_number: consumer_version_number }
52+
hal_browser_url(version_url_from_params(params))
4453
end
4554

4655
def consumer_version_order
@@ -60,7 +69,8 @@ def provider_version_order
6069
end
6170

6271
def provider_version_number_url
63-
hal_browser_url(verification_url(self))
72+
params = { pacticipant_name: provider_name, version_number: provider_version_number }
73+
hal_browser_url(version_url_from_params(params))
6474
end
6575

6676
def provider_version_order
@@ -116,10 +126,18 @@ def verification_status
116126
# end
117127
end
118128

129+
def verification_status_url
130+
hal_browser_url(verification_url(self))
131+
end
132+
119133
def pact_publication_date
120134
relative_date(@line[:pact_created_at])
121135
end
122136

137+
def pact_publication_date_url
138+
pact_url_from_params('', @line)
139+
end
140+
123141
def relative_date date
124142
DateHelper.distance_of_time_in_words(date, DateTime.now) + " ago"
125143
end

lib/pact_broker/ui/views/matrix/show.haml

+8-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@
9797
- lines.each do | line |
9898
%tr
9999
%td.consumer{'data-sort-value' => line.consumer_name}
100-
= line.consumer_name
100+
%a{href: line.consumer_name_url}
101+
= line.consumer_name
101102
%td.consumer-version{'data-sort-value' => line.consumer_version_order}
102103
%div
103104
%a{href: line.consumer_version_number_url}
@@ -113,9 +114,11 @@
113114
.tag.label.label-default
114115
= tag.name
115116
%td.pact-published{'data-sort-value' => line.pact_published_order}
116-
= line.pact_publication_date
117+
%a{href: line.pact_publication_date_url}
118+
= line.pact_publication_date
117119
%td.provider{'data-sort-value' => line.provider_name}
118-
= line.provider_name
120+
%a{href: line.provider_name_url}
121+
= line.provider_name
119122
%td.provider-version{'data-sort-value' => line.provider_version_order}
120123
%div
121124
%a{href: line.provider_version_number_url}
@@ -131,4 +134,5 @@
131134
.tag.label.label-default
132135
= tag.name
133136
%td.verification-result{class: line.verification_status_class}
134-
= line.verification_status
137+
%a{href: line.verification_status_url}
138+
= line.verification_status

0 commit comments

Comments
 (0)