Skip to content

Commit 5d285e9

Browse files
committed
feat(ui): display repository URL on the pacticipant relationships page
https://pact.canny.io/feature-requests/p/display-repo-url-for-provider-and-consumer-in-broker-ui
1 parent 58dea9a commit 5d285e9

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

lib/pact_broker/test/test_data_builder.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def create_tag_with_hierarchy pacticipant_name, pacticipant_version, tag_name
111111

112112
def create_pacticipant pacticipant_name, params = {}
113113
params.delete(:comment)
114-
@pacticipant = PactBroker::Domain::Pacticipant.create({ :name => pacticipant_name }.merge(params))
114+
@pacticipant = PactBroker::Domain::Pacticipant.create({ :name => pacticipant_name, repository_url: "https://github.com/example-organization/#{pacticipant_name}" }.merge(params))
115115
self
116116
end
117117

lib/pact_broker/ui/controllers/groups.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ class Groups < Base
1010
include PactBroker::Services
1111

1212
get ":name" do
13+
pacticipant = pacticipant_service.find_pacticipant_by_name(params[:name])
1314
erb :'groups/show.html', {
14-
locals: {
15-
csv_path: "/groups/#{params[:name]}.csv",
16-
pacticipant_name: params[:name]}
15+
locals: {
16+
csv_path: "/groups/#{params[:name]}.csv",
17+
pacticipant_name: params[:name],
18+
repository_url: pacticipant&.repository_url
19+
}
1720
}, {
1821
layout: 'layouts/main'
1922
}

lib/pact_broker/ui/views/groups/show.html.erb

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<% require 'sanitize' %>
2+
13
<!DOCTYPE html>
24
<html lang="en">
35
<head>
@@ -30,6 +32,19 @@ body{
3032
</head>
3133
<body>
3234
<h1>Network graph of <%= pacticipant_name %> relationships</h1>
35+
36+
<% if repository_url %>
37+
<p>Repository URL:
38+
39+
<%
40+
repository_link = "<a href='#{repository_url}'>#{escape_html(repository_url)}</a>"
41+
%>
42+
43+
<%= Sanitize.fragment(repository_link, Sanitize::Config::BASIC) %>
44+
45+
<% end %>
46+
47+
3348
<script type="text/javascript">
3449
var windowWidth, windowHeight, svg;
3550

pact_broker.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Gem::Specification.new do |gem|
6363
gem.add_runtime_dependency 'dry-logic', '0.4.2' # Later version cases ArgumentError: wrong number of arguments
6464
gem.add_runtime_dependency 'table_print', '~> 1.5'
6565
gem.add_runtime_dependency 'semantic_logger', '~> 4.3'
66+
gem.add_runtime_dependency 'sanitize', '~> 5.1'
6667

6768
gem.add_development_dependency 'pact', '~>1.14'
6869
gem.add_development_dependency 'rspec-pact-matchers', '~>0.1'

0 commit comments

Comments
 (0)