From 5d285e95705b089781b02789b0e10321221ef0f5 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 27 Feb 2020 14:57:20 +1100 Subject: [PATCH] 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 --- lib/pact_broker/test/test_data_builder.rb | 2 +- lib/pact_broker/ui/controllers/groups.rb | 9 ++++++--- lib/pact_broker/ui/views/groups/show.html.erb | 15 +++++++++++++++ pact_broker.gemspec | 1 + 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/pact_broker/test/test_data_builder.rb b/lib/pact_broker/test/test_data_builder.rb index 3cc429531..7226edc1c 100644 --- a/lib/pact_broker/test/test_data_builder.rb +++ b/lib/pact_broker/test/test_data_builder.rb @@ -111,7 +111,7 @@ def create_tag_with_hierarchy pacticipant_name, pacticipant_version, tag_name def create_pacticipant pacticipant_name, params = {} params.delete(:comment) - @pacticipant = PactBroker::Domain::Pacticipant.create({ :name => pacticipant_name }.merge(params)) + @pacticipant = PactBroker::Domain::Pacticipant.create({ :name => pacticipant_name, repository_url: "https://github.com/example-organization/#{pacticipant_name}" }.merge(params)) self end diff --git a/lib/pact_broker/ui/controllers/groups.rb b/lib/pact_broker/ui/controllers/groups.rb index 7733526e2..5795156d8 100644 --- a/lib/pact_broker/ui/controllers/groups.rb +++ b/lib/pact_broker/ui/controllers/groups.rb @@ -10,10 +10,13 @@ class Groups < Base include PactBroker::Services get ":name" do + pacticipant = pacticipant_service.find_pacticipant_by_name(params[:name]) erb :'groups/show.html', { - locals: { - csv_path: "/groups/#{params[:name]}.csv", - pacticipant_name: params[:name]} + locals: { + csv_path: "/groups/#{params[:name]}.csv", + pacticipant_name: params[:name], + repository_url: pacticipant&.repository_url + } }, { layout: 'layouts/main' } diff --git a/lib/pact_broker/ui/views/groups/show.html.erb b/lib/pact_broker/ui/views/groups/show.html.erb index 495a09c0e..87daedf6b 100644 --- a/lib/pact_broker/ui/views/groups/show.html.erb +++ b/lib/pact_broker/ui/views/groups/show.html.erb @@ -1,3 +1,5 @@ +<% require 'sanitize' %> + @@ -30,6 +32,19 @@ body{

Network graph of <%= pacticipant_name %> relationships

+ +<% if repository_url %> +

Repository URL: + +<% +repository_link = "#{escape_html(repository_url)}" +%> + +<%= Sanitize.fragment(repository_link, Sanitize::Config::BASIC) %> + +<% end %> + +