pact_broker 2.84.0 → 2.87.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/trigger_pact_docs_update.yml +22 -0
  3. data/CHANGELOG.md +63 -0
  4. data/DEVELOPER_DOCUMENTATION.md +0 -2
  5. data/db/migrations/20210913_add_pending_to_verifications.rb +7 -0
  6. data/db/migrations/20210914_add_labels_to_webhooks.rb +14 -0
  7. data/db/migrations/20210915_add_verified_by_to_verification.rb +6 -0
  8. data/db/migrations/20210929_increase_event_context_column_size.rb +14 -0
  9. data/docker-compose-ci-mysql.yml +1 -0
  10. data/docker-compose-test.yml +2 -0
  11. data/docs/CONFIGURATION.md +255 -66
  12. data/docs/configuration.yml +166 -101
  13. data/lib/db.rb +0 -1
  14. data/lib/pact/doc/interaction_view_model.rb +2 -2
  15. data/lib/pact/doc/markdown/consumer_contract_renderer.rb +4 -4
  16. data/lib/pact_broker/api/contracts/configuration.rb +33 -0
  17. data/lib/pact_broker/api/contracts/publish_contracts_schema.rb +35 -16
  18. data/lib/pact_broker/api/contracts/webhook_contract.rb +24 -2
  19. data/lib/pact_broker/api/decorators/matrix_decorator.rb +3 -1
  20. data/lib/pact_broker/api/decorators/reason_decorator.rb +2 -2
  21. data/lib/pact_broker/api/decorators/verification_decorator.rb +9 -3
  22. data/lib/pact_broker/api/decorators/verification_summary_decorator.rb +1 -2
  23. data/lib/pact_broker/api/decorators/webhook_decorator.rb +27 -4
  24. data/lib/pact_broker/api/middleware/configuration.rb +33 -0
  25. data/lib/pact_broker/api/pact_broker_urls.rb +35 -7
  26. data/lib/pact_broker/api/renderers/html_pact_renderer.rb +15 -11
  27. data/lib/pact_broker/api/resources/all_webhooks.rb +2 -2
  28. data/lib/pact_broker/api/resources/default_base_resource.rb +4 -0
  29. data/lib/pact_broker/api/resources/environment.rb +1 -1
  30. data/lib/pact_broker/api/resources/environments.rb +1 -1
  31. data/lib/pact_broker/api/resources/index.rb +7 -1
  32. data/lib/pact_broker/api/resources/pact_versions_for_branch.rb +40 -0
  33. data/lib/pact_broker/api/resources/publish_contracts.rb +1 -1
  34. data/lib/pact_broker/api/resources/verification.rb +5 -2
  35. data/lib/pact_broker/api/resources/verifications.rb +5 -1
  36. data/lib/pact_broker/api/resources/webhook_execution_methods.rb +23 -17
  37. data/lib/pact_broker/api.rb +2 -0
  38. data/lib/pact_broker/app.rb +2 -0
  39. data/lib/pact_broker/application_context.rb +5 -0
  40. data/lib/pact_broker/badges/service.rb +3 -1
  41. data/lib/pact_broker/config/runtime_configuration.rb +4 -0
  42. data/lib/pact_broker/config/runtime_configuration_database_methods.rb +1 -1
  43. data/lib/pact_broker/configuration.rb +33 -29
  44. data/lib/pact_broker/db/clean.rb +1 -2
  45. data/lib/pact_broker/db/delete_overwritten_data.rb +41 -23
  46. data/lib/pact_broker/deployments/deployed_version.rb +1 -0
  47. data/lib/pact_broker/deployments/deployed_version_service.rb +1 -0
  48. data/lib/pact_broker/deployments/environment_service.rb +4 -1
  49. data/lib/pact_broker/deployments/released_version_service.rb +1 -0
  50. data/lib/pact_broker/doc/controllers/app.rb +1 -0
  51. data/lib/pact_broker/doc/views/can-i-deploy.markdown +2 -1
  52. data/lib/pact_broker/doc/views/index/publish-contracts.markdown +38 -9
  53. data/lib/pact_broker/doc/views/pacticipant/label.markdown +12 -0
  54. data/lib/pact_broker/doc/views/webhooks.markdown +17 -0
  55. data/lib/pact_broker/domain/index_item.rb +9 -0
  56. data/lib/pact_broker/domain/pacticipant.rb +4 -0
  57. data/lib/pact_broker/domain/verification.rb +28 -4
  58. data/lib/pact_broker/domain/webhook.rb +27 -15
  59. data/lib/pact_broker/domain/webhook_pacticipant.rb +6 -0
  60. data/lib/pact_broker/domain/webhook_request.rb +2 -2
  61. data/lib/pact_broker/index/service.rb +77 -26
  62. data/lib/pact_broker/locale/en.yml +6 -1
  63. data/lib/pact_broker/matrix/head_row.rb +1 -1
  64. data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +5 -3
  65. data/lib/pact_broker/matrix/quick_row.rb +0 -1
  66. data/lib/pact_broker/matrix/repository.rb +0 -1
  67. data/lib/pact_broker/matrix/row.rb +2 -2
  68. data/lib/pact_broker/pacticipants/repository.rb +1 -1
  69. data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +0 -1
  70. data/lib/pact_broker/pacts/metadata.rb +11 -3
  71. data/lib/pact_broker/pacts/pact_publication.rb +44 -0
  72. data/lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module.rb +19 -0
  73. data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +68 -1
  74. data/lib/pact_broker/pacts/pact_version.rb +24 -1
  75. data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +5 -4
  76. data/lib/pact_broker/pacts/repository.rb +52 -48
  77. data/lib/pact_broker/pacts/service.rb +5 -5
  78. data/lib/pact_broker/string_refinements.rb +1 -1
  79. data/lib/pact_broker/test/http_test_data_builder.rb +40 -11
  80. data/lib/pact_broker/test/test_data_builder.rb +27 -6
  81. data/lib/pact_broker/ui/app.rb +7 -1
  82. data/lib/pact_broker/ui/controllers/dashboard.rb +80 -0
  83. data/lib/pact_broker/ui/controllers/groups.rb +23 -8
  84. data/lib/pact_broker/ui/helpers/url_helper.rb +17 -1
  85. data/lib/pact_broker/ui/view_models/index_item.rb +64 -8
  86. data/lib/pact_broker/ui/view_models/index_item_branch_head.rb +39 -0
  87. data/lib/pact_broker/ui/view_models/index_item_provider_branch_head.rb +39 -0
  88. data/lib/pact_broker/ui/view_models/matrix_branch.rb +1 -1
  89. data/lib/pact_broker/ui/view_models/matrix_tag.rb +0 -1
  90. data/lib/pact_broker/ui/views/dashboard/show.haml +202 -0
  91. data/lib/pact_broker/ui/views/groups/show.html.erb +60 -14
  92. data/lib/pact_broker/ui/views/index/_dashboard_navbar.haml +7 -0
  93. data/lib/pact_broker/ui/views/index/_navbar.haml +0 -7
  94. data/lib/pact_broker/ui/views/index/show-with-tags.haml +3 -1
  95. data/lib/pact_broker/ui/views/index/show.haml +35 -13
  96. data/lib/pact_broker/ui/views/matrix/show.haml +7 -3
  97. data/lib/pact_broker/verifications/pseudo_branch_status.rb +2 -0
  98. data/lib/pact_broker/verifications/repository.rb +5 -2
  99. data/lib/pact_broker/verifications/service.rb +8 -4
  100. data/lib/pact_broker/version.rb +1 -1
  101. data/lib/pact_broker/versions/branch_head.rb +0 -2
  102. data/lib/pact_broker/versions/branch_version.rb +1 -0
  103. data/lib/pact_broker/versions/repository.rb +0 -1
  104. data/lib/pact_broker/webhooks/event_listener.rb +7 -5
  105. data/lib/pact_broker/webhooks/execution_configuration.rb +16 -0
  106. data/lib/pact_broker/webhooks/execution_configuration_creator.rb +3 -0
  107. data/lib/pact_broker/webhooks/job.rb +1 -1
  108. data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +18 -3
  109. data/lib/pact_broker/webhooks/repository.rb +10 -4
  110. data/lib/pact_broker/webhooks/trigger_service.rb +3 -3
  111. data/lib/pact_broker/webhooks/webhook.rb +71 -8
  112. data/lib/pact_broker/webhooks/webhook_execution_result.rb +3 -7
  113. data/lib/pact_broker/webhooks/webhook_request_logger.rb +4 -12
  114. data/lib/pact_broker/webhooks/webhook_request_template.rb +6 -8
  115. data/pact_broker.gemspec +4 -0
  116. data/public/javascripts/index.js +75 -68
  117. data/public/javascripts/pact.js +14 -14
  118. data/public/stylesheets/index.css +6 -2
  119. data/public/stylesheets/pact.css +11 -0
  120. data/script/data/auto-create-things-for-tags.rb +3 -0
  121. data/script/data/branches.rb +2 -2
  122. data/script/data/contract-published-requiring-verification.rb +0 -1
  123. data/script/data/environments.rb +0 -0
  124. data/script/data/pending.rb +26 -0
  125. data/script/data/tags.rb +35 -0
  126. data/script/data/verify-pact-for-multiple-selectors.rb +30 -0
  127. data/script/data/webhook.rb +22 -0
  128. data/script/docs/generate-configuration-docs.rb +24 -3
  129. data/script/generate-erd +55 -0
  130. data/script/seed.rb +50 -89
  131. data/spec/features/create_webhook_spec.rb +55 -10
  132. data/spec/features/delete_pact_versions_for_branch_spec.rb +34 -0
  133. data/spec/features/get_pact_spec.rb +2 -3
  134. data/spec/fixtures/approvals/modifiable_resources.approved.json +4 -0
  135. data/spec/fixtures/invalid-publish-contract-body.json +38 -0
  136. data/spec/fixtures/verification.json +4 -0
  137. data/spec/integration/app_spec.rb +6 -6
  138. data/spec/integration/webhooks/contract_publication_spec.rb +68 -0
  139. data/spec/integration/webhooks/contract_requiring_verification_published_spec.rb +67 -0
  140. data/spec/integration/webhooks/pact_publication_spec.rb +51 -0
  141. data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +2 -2
  142. data/spec/lib/pact_broker/api/contracts/publish_contracts_schema_spec.rb +13 -0
  143. data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +50 -0
  144. data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +1 -1
  145. data/spec/lib/pact_broker/api/decorators/reason_decorator_spec.rb +2 -2
  146. data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +15 -7
  147. data/spec/lib/pact_broker/api/decorators/verification_summary_decorator_spec.rb +6 -2
  148. data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +4 -4
  149. data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +1 -1
  150. data/spec/lib/pact_broker/api/middleware/configuration_spec.rb +43 -0
  151. data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +18 -0
  152. data/spec/lib/pact_broker/api/resources/triggered_webhook_logs_spec.rb +6 -5
  153. data/spec/lib/pact_broker/api/resources/verifications_spec.rb +2 -3
  154. data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +1 -1
  155. data/spec/lib/pact_broker/badges/service_spec.rb +22 -0
  156. data/spec/lib/pact_broker/config/runtime_configuration_documentation_spec.rb +30 -0
  157. data/spec/lib/pact_broker/deployments/environment_service_spec.rb +1 -1
  158. data/spec/lib/pact_broker/domain/webhook_request_spec.rb +2 -1
  159. data/spec/lib/pact_broker/domain/webhook_spec.rb +15 -5
  160. data/spec/lib/pact_broker/index/service_spec.rb +1 -5
  161. data/spec/lib/pact_broker/index/service_view_spec.rb +144 -0
  162. data/spec/lib/pact_broker/matrix/head_row_spec.rb +9 -5
  163. data/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb +13 -0
  164. data/spec/lib/pact_broker/pacts/metadata_spec.rb +11 -2
  165. data/spec/lib/pact_broker/pacts/{latest_tagged_pact_publications_spec.rb → pact_publication_clean_selector_dataset_module_spec.rb} +7 -9
  166. data/spec/lib/pact_broker/pacts/pact_publication_latest_verification_spec.rb +29 -0
  167. data/spec/lib/pact_broker/pacts/pact_version_spec.rb +32 -0
  168. data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +4 -5
  169. data/spec/lib/pact_broker/pacts/repository_spec.rb +48 -2
  170. data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +12 -9
  171. data/spec/lib/pact_broker/verifications/pseudo_branch_status_spec.rb +9 -1
  172. data/spec/lib/pact_broker/verifications/service_spec.rb +24 -8
  173. data/spec/lib/pact_broker/webhooks/job_spec.rb +4 -4
  174. data/spec/lib/pact_broker/webhooks/render_spec.rb +3 -2
  175. data/spec/lib/pact_broker/webhooks/repository_spec.rb +158 -15
  176. data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +9 -5
  177. data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +6 -12
  178. data/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb +3 -2
  179. data/spec/lib/pact_broker/webhooks/webhook_spec.rb +8 -5
  180. data/spec/support/generated_markdown.md +3 -3
  181. data/tasks/db.rake +4 -1
  182. metadata +72 -14
  183. data/lib/pact_broker/pacts/all_pact_publications.rb +0 -158
  184. data/lib/pact_broker/pacts/latest_pact_publications.rb +0 -48
  185. data/lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb +0 -26
  186. data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +0 -45
  187. data/lib/pact_broker/verifications/latest_verification_for_pact_version.rb +0 -39
  188. data/spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb +0 -56
  189. data/spec/lib/pact_broker/verifications/latest_verification_for_pact_version_spec.rb +0 -18
@@ -3,6 +3,8 @@ require "pact_broker/ui/helpers/url_helper"
3
3
  require "pact_broker/date_helper"
4
4
  require "pact_broker/versions/abbreviate_number"
5
5
  require "pact_broker/configuration"
6
+ require "pact_broker/ui/view_models/index_item_branch_head"
7
+ require "pact_broker/ui/view_models/index_item_provider_branch_head"
6
8
  require "forwardable"
7
9
 
8
10
  module PactBroker
@@ -18,7 +20,8 @@ module PactBroker
18
20
  :provider_version_branches,
19
21
  :latest_for_branch?,
20
22
  :consumer_version_environment_names,
21
- :provider_version_environment_names
23
+ :provider_version_environment_names,
24
+ :latest_verification
22
25
  ] => :relationship
23
26
 
24
27
 
@@ -57,10 +60,20 @@ module PactBroker
57
60
  PactBroker::Versions::AbbreviateNumber.call(provider_version_number)
58
61
  end
59
62
 
63
+ def display_latest_label?
64
+ consumer_version_latest_tag_names.empty? && @relationship.tag_names.empty?
65
+ end
66
+
60
67
  def latest?
61
68
  @relationship.latest?
62
69
  end
63
70
 
71
+ def consumer_version_branch_heads
72
+ @relationship.consumer_version_branch_heads.collect do | branch_head |
73
+ IndexItemBranchHead.new(branch_head, consumer_name)
74
+ end
75
+ end
76
+
64
77
  def consumer_version_latest_tag_names
65
78
  @relationship.tag_names
66
79
  end
@@ -69,6 +82,12 @@ module PactBroker
69
82
  @relationship.latest_verification_latest_tags.collect(&:name)
70
83
  end
71
84
 
85
+ def provider_version_branch_heads
86
+ @relationship.provider_version_branch_heads.collect do | branch_head |
87
+ IndexItemProviderBranchHead.new(branch_head, provider_name)
88
+ end
89
+ end
90
+
72
91
  def consumer_group_url
73
92
  Helpers::URLHelper.group_url(consumer_name, base_url)
74
93
  end
@@ -81,12 +100,16 @@ module PactBroker
81
100
  "#{pactigration_base_url(base_url, @relationship)}/latest"
82
101
  end
83
102
 
103
+ def dashboard_url
104
+ Helpers::URLHelper.dashboard_url(consumer_name, provider_name, base_url)
105
+ end
106
+
84
107
  def pact_url
85
108
  PactBroker::Api::PactBrokerUrls.pact_url(base_url, @relationship)
86
109
  end
87
110
 
88
111
  def pact_matrix_url
89
- Helpers::URLHelper.matrix_url(consumer_name, provider_name, base_url)
112
+ Helpers::URLHelper.matrix_url_for_consumer_version(consumer_name, consumer_version_number, provider_name, base_url)
90
113
  end
91
114
 
92
115
  def any_webhooks?
@@ -145,7 +168,7 @@ module PactBroker
145
168
 
146
169
  def last_verified_date
147
170
  if @relationship.ever_verified?
148
- date = @relationship.latest_verification.execution_date
171
+ date = latest_verification.execution_date
149
172
  PactBroker::DateHelper.distance_of_time_in_words(date, DateTime.now) + " ago"
150
173
  else
151
174
  ""
@@ -166,10 +189,15 @@ module PactBroker
166
189
  when :success then "success"
167
190
  when :stale then "warning"
168
191
  when :failed then "danger"
192
+ when :failed_pending then "danger"
169
193
  else ""
170
194
  end
171
195
  end
172
196
 
197
+ def failed_and_pact_pending?
198
+ latest_verification&.failed_and_pact_pending?
199
+ end
200
+
173
201
  def warning?
174
202
  pseudo_branch_verification_status == "warning"
175
203
  end
@@ -179,7 +207,18 @@ module PactBroker
179
207
  when :success
180
208
  "Successfully verified by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)})"
181
209
  when :stale
182
- "Pact has changed since last successful verification by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)})"
210
+ # TODO when there are multiple tags/branches, the tag/branch shown may not be the relevant one, but
211
+ # it shouldn't happen very often. Can change this to "tag a or b"
212
+ desc = if @relationship.consumer_version_branches.any?
213
+ "from branch #{@relationship.consumer_version_branches.first} "
214
+ elsif @relationship.tag_names.any?
215
+ "with tag #{@relationship.tag_names.first} "
216
+ else
217
+ ""
218
+ end
219
+ "Pact #{desc}has changed since last successful verification by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)})"
220
+ when :failed_pending
221
+ "Verification by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)}) failed, but did not fail the build as the pact content was in pending state for that provider branch"
183
222
  when :failed
184
223
  "Verification by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)}) failed"
185
224
  else
@@ -204,17 +243,34 @@ module PactBroker
204
243
  end
205
244
  end
206
245
 
246
+ def show_menu?
247
+ !view_by_environment? && (@relationship.tag_names.any? || consumer_version_branches.any?)
248
+ end
249
+
207
250
  def base_url
208
251
  @options[:base_url]
209
252
  end
210
253
 
211
- def tagged_pacts
254
+ def pact_tags
212
255
  @relationship.tag_names.map do |tag|
213
256
  {
214
- tag: tag,
257
+ name: tag,
215
258
  deletionUrl: PactBroker::Api::PactBrokerUrls.tagged_pact_versions_url(consumer_name, provider_name, tag, base_url)
216
- }.to_json
217
- end
259
+ }
260
+ end.to_json
261
+ end
262
+
263
+ def pact_branches
264
+ consumer_version_branches.map do | branch_name |
265
+ {
266
+ name: branch_name,
267
+ deletionUrl: PactBroker::Api::PactBrokerUrls.pact_versions_for_branch_url(consumer_name, provider_name, branch_name, base_url)
268
+ }
269
+ end.to_json
270
+ end
271
+
272
+ def view_by_environment?
273
+ @options[:view] == "environment"
218
274
  end
219
275
 
220
276
  private
@@ -0,0 +1,39 @@
1
+ require "pact_broker/api/pact_broker_urls"
2
+ require "pact_broker/ui/helpers/url_helper"
3
+ require "pact_broker/date_helper"
4
+
5
+ module PactBroker
6
+ module UI
7
+ module ViewDomain
8
+ class IndexItemBranchHead
9
+
10
+ include PactBroker::Api::PactBrokerUrls
11
+
12
+ def initialize branch_head, pacticipant_name
13
+ @branch_head = branch_head
14
+ @pacticipant_name = pacticipant_name
15
+ end
16
+
17
+ def branch_name
18
+ branch_head.branch_name
19
+ end
20
+
21
+ def tooltip
22
+ if branch_head.branch_version.auto_created
23
+ "This is the latest pact from branch \"#{branch_name}\". This branch was automatically inferred from the first tag because the Pact Broker configuration setting `use_first_tag_as_branch` was true."
24
+ else
25
+ "This is the latest pact from branch \"#{branch_name}\"."
26
+ end
27
+ end
28
+
29
+ def latest?
30
+ true
31
+ end
32
+
33
+ private
34
+
35
+ attr_reader :branch_head, :pacticipant_name
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ require "pact_broker/api/pact_broker_urls"
2
+ require "pact_broker/ui/helpers/url_helper"
3
+ require "pact_broker/date_helper"
4
+
5
+ module PactBroker
6
+ module UI
7
+ module ViewDomain
8
+ class IndexItemProviderBranchHead
9
+
10
+ include PactBroker::Api::PactBrokerUrls
11
+
12
+ def initialize branch_head, pacticipant_name
13
+ @branch_head = branch_head
14
+ @pacticipant_name = pacticipant_name
15
+ end
16
+
17
+ def branch_name
18
+ branch_head.branch_name
19
+ end
20
+
21
+ def tooltip
22
+ if branch_head.branch_version.auto_created
23
+ "The latest verification is from branch \"#{branch_name}\". This branch was automatically inferred from the first tag because the Pact Broker configuration setting `use_first_tag_as_branch` was true."
24
+ else
25
+ "The latest verification is from branch \"#{branch_name}\"."
26
+ end
27
+ end
28
+
29
+ def latest?
30
+ true
31
+ end
32
+
33
+ private
34
+
35
+ attr_reader :branch_head, :pacticipant_name
36
+ end
37
+ end
38
+ end
39
+ end
@@ -22,7 +22,7 @@ module PactBroker
22
22
  if branch_version.latest?
23
23
  "This is the latest version of #{pacticipant_name} from branch \"#{branch_version.branch_name}\"."
24
24
  else
25
- "A more recent version of #{pacticipant_name} from branch \"#{branch_version.branch_name}\" exists."
25
+ "This version of #{pacticipant_name} is from branch \"#{branch_version.branch_name}\". A more recent version from this branch exists."
26
26
  end
27
27
  end
28
28
 
@@ -6,7 +6,6 @@ module PactBroker
6
6
  module UI
7
7
  module ViewDomain
8
8
  class MatrixTag
9
-
10
9
  include PactBroker::Api::PactBrokerUrls
11
10
 
12
11
  attr_reader :name, :pacticipant_name, :version_number
@@ -0,0 +1,202 @@
1
+ %body
2
+ != render :haml, :'index/_css_and_js', :layout => false
3
+ .container
4
+ != render :haml, :'index/_dashboard_navbar', :layout => false, locals: {tag_toggle: nil, base_url: base_url}
5
+
6
+ %div.mt-4
7
+ .row
8
+ .col
9
+ .row.my-0
10
+ .col.my-0{ style: "text-transform: uppercase; font-size: 70%"}
11
+ Consumer
12
+ .row.my-0
13
+ .col.my-0
14
+ %h2.page-header{ style: "margin-top: 0" }
15
+ = consumer_name
16
+ .col
17
+ .row
18
+ .col.my-0{ style: "text-transform: uppercase; font-size: 70%"}
19
+ Provider
20
+ .row.my-0
21
+ .col.my-0
22
+ %h2.page-header{ style: "margin-top: 0" }
23
+ = provider_name
24
+
25
+
26
+ - unless errors.blank?
27
+ - errors.each do | error |
28
+ %div.alert.alert-danger
29
+ = error
30
+
31
+ - if consumer && provider
32
+ %form
33
+ %div.mt-4.mb-2
34
+ %label.mr-2
35
+ View pacts by:
36
+ %div.form-check.form-check-inline
37
+ %input.form-check-input{ type: "radio", name: "view", id: "by_branch", value: "branch", checked: view == "branch" }
38
+ %label.form-check-label{ for:"by_branch"} branches
39
+ %div.form-check.form-check-inline
40
+ %input.form-check-input{ type: "radio", name: "view", id: "by_tag", value: "tag", checked: view == "tag"}
41
+ %label.form-check-label{ for:"by_tag"} tags
42
+ %div.form-check.form-check-inline
43
+ %input.form-check-input{ type: "radio", name: "view", id: "by_environment", value: "environment", checked: view == "environment"}
44
+ %label.form-check-label{ for:"by_environment"} environments
45
+ %div.form-check.form-check-inline
46
+ %input.form-check-input{ type: "radio", name: "view", id: "by_all", value: "all", checked: view == "all"}
47
+ %label.form-check-label{ for:"by_all"} no filter
48
+ %input{ type: "hidden", name: "page", value: page_number }
49
+ %input{ type: "hidden", name: "pageSize", value: page_size }
50
+
51
+ %table.table.table-bordered.table-striped{ id: 'relationships' }
52
+ %thead
53
+ %tr
54
+ %th.consumer-version-number
55
+ Consumer<br>Version
56
+ %span.sort-icon.relationships-sort
57
+ %th.provider-version-number
58
+ Provider<br>Version
59
+ %span.sort-icon.relationships-sort
60
+ %th.pact{ style: 'width: 40px' }
61
+ %th
62
+ Published
63
+ %span.sort-icon.relationships-sort
64
+ %th
65
+ Webhook<br>status
66
+ %th
67
+ Last<br>verified
68
+ %span.sort-icon.relationships-sort
69
+ %th
70
+ %tbody
71
+
72
+ - index_items.each do | index_item |
73
+ %tr{'data-pact-versions-url': index_item.pact_versions_url,
74
+ 'data-consumer-name': index_item.consumer_name,
75
+ 'data-provider-name': index_item.provider_name,
76
+ 'data-integration-url': index_item.integration_url,
77
+ 'data-pact-tags': index_item.pact_tags,
78
+ 'data-pact-branches': index_item.pact_branches,
79
+ 'data-view': view
80
+ }
81
+ %td.consumer-version-number{"data-text": index_item.consumer_version_order}
82
+ %div.clippable{"data-clippable": index_item.consumer_version_number}
83
+ = index_item.display_consumer_version_number
84
+ - if index_item.display_consumer_version_number
85
+ %button.clippy.invisible{ title: "Copy to clipboard" }
86
+ %span.copy-icon
87
+ - if view == "branch" || view == "all"
88
+ - index_item.consumer_version_branch_heads.each do | branch_head |
89
+ %div{"class": "tag badge badge-dark", "title": branch_head.tooltip, "data-toggle": "tooltip", "data-placement": "right"}
90
+ = "branch: " + branch_head.branch_name
91
+ - if view == "tag" || view == "all"
92
+ - index_item.consumer_version_latest_tag_names.each do | tag_name |
93
+ .tag.badge.badge-primary
94
+ = "tag: " + tag_name
95
+ - if view == "environment" || view == "all"
96
+ - index_item.consumer_version_environment_names.each do | environment_name |
97
+ .tag.badge.badge-success
98
+ = "env: " + environment_name
99
+ - if view == "all" && index_item.display_latest_label? && index_item.latest?
100
+ .tag.badge.bg-light
101
+ latest
102
+ %td.provider-version-number
103
+ %div.clippable{"data-clippable": index_item.provider_version_number}
104
+ = index_item.display_provider_version_number
105
+ - if index_item.display_provider_version_number
106
+ %button.clippy.invisible{ title: "Copy to clipboard" }
107
+ %span.copy-icon
108
+ - if view == "branch" || view == "all"
109
+ - index_item.provider_version_branch_heads.each do | branch_head |
110
+ %div{"class": "tag badge badge-dark", "title": branch_head.tooltip, "data-toggle": "tooltip", "data-placement": "right"}
111
+ = "branch: " + branch_head.branch_name
112
+ - if view == "tag" || view == "all"
113
+ - index_item.provider_version_latest_tag_names.each do | tag_name |
114
+ .tag.badge.badge-primary
115
+ = "tag: " + tag_name
116
+ - if view == "environment" || view == "all"
117
+ - index_item.provider_version_environment_names.each do | environment_name |
118
+ .tag.badge.badge-success
119
+ = "env: " + environment_name
120
+ %td.pact
121
+ %span.pact
122
+ %a{ href: index_item.pact_url, title: "View pact" }
123
+ %span.pact-matrix
124
+ %a{ href: index_item.pact_matrix_url, title: "View pact matrix" }
125
+ %td{"data-text": index_item.publication_date_of_latest_pact_order}
126
+ = index_item.publication_date_of_latest_pact.gsub("about ", "")
127
+ %td{ class: "table-#{index_item.webhook_status}" }
128
+ - if index_item.show_webhook_status?
129
+ %a{ href: index_item.webhook_url }
130
+ = index_item.webhook_label
131
+
132
+ %td{ class: "table-#{index_item.pseudo_branch_verification_status}", title: index_item.verification_tooltip, "data-toggle": "tooltip", "data-placement": "left" }
133
+ %div
134
+ = index_item.last_verified_date.gsub("about ", "")
135
+ - if index_item.warning?
136
+ %span.warning-icon{ 'aria-hidden': true }
137
+ - if index_item.failed_and_pact_pending?
138
+ %div
139
+ (pact pending)
140
+ %td
141
+ - if index_item.show_menu?
142
+ %span.integration-settings.kebab-horizontal{ 'aria-hidden': true }
143
+
144
+ %div.pagination.text-center
145
+
146
+ - pagination_locals = { page_number: page_number, page_size: page_size, pagination_record_count: pagination_record_count, current_page_size: current_page_size }
147
+ != render :haml, :'index/_pagination', :layout => false, locals: pagination_locals
148
+
149
+ :javascript
150
+ $(function(){
151
+ $("#relationships").tablesorter();
152
+ });
153
+
154
+ $(document).ready(function(){
155
+ initializeClipper(".clippable");
156
+
157
+ $("span.pact a").load("#{base_url}/images/doc-text.svg");
158
+ $("span.pact-matrix a").load("#{base_url}/images/doc-matrix.svg");
159
+ $('td[data-toggle="tooltip"]').each(function(index, td){
160
+ //appended tooltip div screws up table if it's appended after a
161
+ //td, so need to append it to a div
162
+ $(td).tooltip({ container: $(td).first() });
163
+ });
164
+
165
+ // https://www.w3schools.com/bootstrap/bootstrap_ref_js_tooltip.asp
166
+
167
+ $('div[data-toggle="tooltip"]').each(function(index, div){
168
+ $(div).tooltip()
169
+ });
170
+
171
+ });
172
+
173
+ $(".reset-search").on("click", function() {
174
+ const url = new URL(window.location)
175
+ url.searchParams.delete('search')
176
+ window.location = url.toString();
177
+ })
178
+
179
+ $(".submit-search").on("click", function() {
180
+ search = $("#search").val();
181
+ const url = new URL(window.location)
182
+ url.searchParams.set('search', search)
183
+ window.location = url.toString();
184
+ })
185
+
186
+ $(".search").keypress(function(event) {
187
+ const enterKeyCode = 13;
188
+
189
+ const key = event.which;
190
+ if (key === enterKeyCode) {
191
+ event.preventDefault();
192
+ search = $("#search").val();
193
+ const url = new URL(window.location)
194
+ url.searchParams.set('search', search)
195
+ window.location = url.toString();
196
+ }
197
+ })
198
+
199
+ $("[name*='view']").change(function(event){
200
+ $("[name='page']").attr('disabled','disabled');
201
+ $(this.form).submit()
202
+ })
@@ -1,17 +1,25 @@
1
1
  <% require 'sanitize' %>
2
+ <% require 'pact_broker/version' %>
3
+ <% version = PactBroker::VERSION %>
2
4
 
3
5
  <!DOCTYPE html>
4
6
  <html lang="en">
5
7
  <head>
6
8
  <meta charset="utf-8">
7
- <title>Network Graph</title>
9
+ <title><%= pacticipant_name %></title>
8
10
  <link rel='shortcut icon' href='<%= base_url %>/favicon.ico' type='image/x-icon'/>
9
11
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
12
  <meta name="description" content="">
11
13
  <meta name="author" content="Duncan Alexander">
12
14
  <script type="text/javascript" src="<%= base_url %>/javascripts/d3.v3.js.pagespeed.ce.dFNRrGTALe.js"></script>
15
+ <link href="<%= base_url %>/css/bootstrap.min.css?v=<%= version %>" rel="stylesheet">
16
+ <script src="<%= base_url %>/javascripts/jquery-3.5.1.min.js?v=<%= version %>" type='text/javascript'></script>
17
+ <script src="<%= base_url %>/js/bootstrap.bundle.min.js?v=<%= version %>" type='text/javascript'></script>
13
18
  <style>
14
- body{
19
+ body {
20
+ padding-top: 10px;
21
+ }
22
+ svg{
15
23
  font-family:"Helvetica Neue",Arial,sans-serif;
16
24
  font-size:.95em;
17
25
  font-weight:bold;
@@ -23,6 +31,11 @@ body{
23
31
  .relationship {
24
32
  cursor: pointer;
25
33
  }
34
+ .page-header {
35
+ padding-bottom: 9px;
36
+ margin: 40px 0 20px;
37
+ border-bottom: 1px solid #eee;
38
+ }
26
39
  </style>
27
40
  <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
28
41
  <!--[if lt IE 9]>
@@ -31,20 +44,52 @@ body{
31
44
  <!-- developed by Duncan Alexander - hypothete.com -->
32
45
  </head>
33
46
  <body>
34
- <h1>Network graph of <%= escape_html(pacticipant_name) %> relationships</h1>
35
-
36
- <% if repository_url %>
37
- <p>Repository URL:
38
-
39
- <%
40
- repository_link = "<a href=\"#{repository_url}\">#{repository_url}</a>"
41
- %>
42
-
43
- <%= Sanitize.fragment(repository_link, Sanitize::Config::BASIC) %>
44
-
47
+ <div class="container">
48
+ <nav aria-label="breadcrumb">
49
+ <ol class="breadcrumb">
50
+ <li class="breadcrumb-item" style="margin:0;"><a href="<%= base_url %>/">Home</a></li>
51
+ <li class="breadcrumb-item active" aria-current="page"><%= escape_html(pacticipant_name) %></li>
52
+ </ol>
53
+ </nav>
54
+ <h1 class="page-header"><%= escape_html(pacticipant_name) %></h1>
55
+
56
+ <ul class="nav nav-tabs">
57
+ <li class="nav-item">
58
+ <a class="nav-link <%= tab == "details" ? "active" : "" %>" href="<%= details_url %>">Details</a>
59
+ </li>
60
+ <li class="nav-item">
61
+ <a class="nav-link <%= tab == "network" ? "active" : "" %>" href="<%= network_url %>">Network Graph</a>
62
+ </li>
63
+ </ul>
64
+
65
+ <% if tab == "details" %>
66
+ <div class="container mt-5">
67
+ <div class="row">
68
+ <div class="col col-md-2">
69
+ Main branch:
70
+ </div>
71
+ <div class="col col-md-6">
72
+ <%= pacticipant.main_branch %>
73
+ </div>
74
+ </div>
75
+ <div class="row">
76
+ <div class="col col-md-2">
77
+ Repository URL:
78
+ </div>
79
+ <div class="col col-md-6">
80
+ <% if repository_url %>
81
+ <%
82
+ repository_link = "<a href=\"#{repository_url}\">#{repository_url}</a>"
83
+ %>
84
+
85
+ <%= Sanitize.fragment(repository_link, Sanitize::Config::BASIC) %>
86
+ <% end %>
87
+ </div>
88
+ </div>
89
+ </div>
45
90
  <% end %>
46
91
 
47
-
92
+ <% if tab == "network" %>
48
93
  <script type="text/javascript">
49
94
  var windowWidth, windowHeight, svg;
50
95
 
@@ -421,5 +466,6 @@ window.onload = function() {
421
466
 
422
467
  });
423
468
  }</script>
469
+ <% end %>
424
470
  </body>
425
471
  </html>
@@ -0,0 +1,7 @@
1
+ %nav{'aria-label': 'breadcrumb'}
2
+ %ol.breadcrumb
3
+ %li.breadcrumb-item
4
+ %a{'href': "#{base_url}/"}
5
+ Home
6
+ %li.breadcrumb-item.active{'aria-current': 'page'}
7
+ Pact publications
@@ -3,12 +3,5 @@
3
3
  .navbar-header
4
4
  %ul.navbar-right#top-left-menu
5
5
  %li
6
- - if tag_toggle
7
- %a{href: "#{base_url}?tags=true"}
8
- Show latest tags
9
- - else
10
- %a{href: "#{base_url}/"}
11
- Hide latest tags
12
-
13
6
  %a{href: "#{base_url}/hal-browser/browser.html"}
14
7
  API Browser
@@ -52,7 +52,9 @@
52
52
  'data-consumer-name': index_item.consumer_name,
53
53
  'data-provider-name': index_item.provider_name,
54
54
  'data-integration-url': index_item.integration_url,
55
- 'data-tagged-pacts': index_item.tagged_pacts}
55
+ 'data-pact-tags': index_item.pact_tags,
56
+ 'data-pact-branches': index_item.pact_branches
57
+ }
56
58
  %td.consumer
57
59
  %a{:href => index_item.consumer_group_url }
58
60
  = index_item.consumer_name