pact_broker 2.90.0 → 2.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a41b90582f2bdd3705172c79b28f01ca1bf9db3c2a32aa221baf164315017d74
4
- data.tar.gz: 3e3c6263edf2440b0fd1003f4a4bc03a4b81df3f85953a56e2dae23bd2b95fa2
3
+ metadata.gz: c1634d0a3519aae8c805e0c8f13e2e132e86b623c92e019d37285b98ecd7574d
4
+ data.tar.gz: 2652bd80a29b04e222bad6ffb0513c95618f16185feb98cffc9c7bd283858b79
5
5
  SHA512:
6
- metadata.gz: 0fdf1ae5f33491587a8a26f730976089a91a763376974f4703df46317b64e9814d2d4c56319c5417ebcad4485b79b9ec3d152175b4470d8021b7e27f9ce6ef6d
7
- data.tar.gz: 7a02341d2cd0f63a7168b2d437f4b10346d82243dc0b624af686d74de645c4f611deb756ecd9076eb226666af38600bd6448c8abcb58633f4db10c8a5d5ed468
6
+ metadata.gz: 8e3bc701ea3fe67d6ffe24330faf61b5def23d7293e2c59bfa1d4c5b8874dd3ef8b622f8adbef202bdfd784804f67a5c9efd39c79c1bba54bb52a8fe2abc7661
7
+ data.tar.gz: ab7a4c68f71251bbf36e3f58bb18267b28cc1bd72df5f3959caedd8fe1b776439b6ba25fd972f2a819ba5f0872d9861d22284da501a5d921f255aea368bedfab
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ <a name="v2.91.0"></a>
2
+ ### v2.91.0 (2021-11-15)
3
+
4
+ #### Features
5
+
6
+ * add environments to matrix response ([fd50f22c](/../../commit/fd50f22c))
7
+ * remove feature toggle around change to return the pact for the latest tagged version, rather than the latest pact that has a version with the tag ([fac3fc8a](/../../commit/fac3fc8a))
8
+
9
+ #### Bug Fixes
10
+
11
+ * load images from the correct path when the Pact Broker application is run from a non root context ([a268ef25](/../../commit/a268ef25))
12
+
1
13
  <a name="v2.90.0"></a>
2
14
  ### v2.90.0 (2021-11-12)
3
15
 
@@ -0,0 +1,25 @@
1
+ require_relative "base_decorator"
2
+ require_relative "timestamps"
3
+
4
+ module PactBroker
5
+ module Api
6
+ module Decorators
7
+ class EmbeddedEnvironmentDecorator < BaseDecorator
8
+ property :uuid, writeable: false
9
+ property :name
10
+ property :display_name, camelize: true
11
+ property :production
12
+
13
+ include Timestamps
14
+
15
+ link :self do | user_options |
16
+ {
17
+ title: "Environment",
18
+ name: represented.name,
19
+ href: environment_url(represented, user_options.fetch(:base_url))
20
+ }
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,6 +3,7 @@ require "pact_broker/api/pact_broker_urls"
3
3
  require "pact_broker/api/decorators/reason_decorator"
4
4
  require "pact_broker/api/decorators/format_date_time"
5
5
  require "pact_broker/api/decorators/embedded_branch_version_decorator"
6
+ require "pact_broker/api/decorators/embedded_environment_decorator"
6
7
 
7
8
  module PactBroker
8
9
  module Api
@@ -85,7 +86,9 @@ module PactBroker
85
86
  version: {
86
87
  number: line.consumer_version_number,
87
88
  branch: line.consumer_version_branch_versions.last&.branch_name,
88
- branches: branches(line.consumer_version_branch_versions, base_url),
89
+ branches: branches(line.consumer_version_branch_versions, base_url), # TODO delete this
90
+ branchVersions: branches(line.consumer_version_branch_versions, base_url),
91
+ environments: environments(line.consumer_version_deployed_versions, line.consumer_version_released_versions, base_url),
89
92
  _links: {
90
93
  self: {
91
94
  href: version_url(base_url, consumer_version)
@@ -107,6 +110,16 @@ module PactBroker
107
110
  end
108
111
  end
109
112
 
113
+ def environments(deployed_versions, released_versions, base_url)
114
+ (deployed_versions + released_versions).sort_by(&:created_at).collect(&:environment).uniq.collect do | environment |
115
+ environment_decorator_class.new(environment).to_hash(user_options: { base_url: base_url })
116
+ end
117
+ end
118
+
119
+ def environment_decorator_class
120
+ PactBroker::Api::Decorators::EmbeddedEnvironmentDecorator
121
+ end
122
+
110
123
  def tags(tags, base_url)
111
124
  tags.sort_by(&:created_at).collect do | tag |
112
125
  {
@@ -136,7 +149,9 @@ module PactBroker
136
149
  hash[:version] = {
137
150
  number: line.provider_version_number,
138
151
  branch: line.provider_version_branch_versions.last&.branch_name,
139
- branches: branches(line.provider_version_branch_versions, base_url),
152
+ branches: branches(line.provider_version_branch_versions, base_url), # TODO delete this
153
+ branchVersions: branches(line.provider_version_branch_versions, base_url),
154
+ environments: environments(line.provider_version_deployed_versions, line.provider_version_released_versions, base_url),
140
155
  _links: {
141
156
  self: {
142
157
  href: version_url(base_url, provider_version)
@@ -7,7 +7,9 @@ module PactBroker
7
7
  class VersionDecorator < BaseDecorator
8
8
 
9
9
  property :number, writeable: false
10
+ # TODO delete branches in preference for branchVersions
10
11
  collection :branch_versions, as: :branches, embedded: true, writeable: false, extend: PactBroker::Api::Decorators::EmbeddedBranchVersionDecorator
12
+ collection :branch_versions, as: :branchVersions, embedded: true, writeable: false, extend: PactBroker::Api::Decorators::EmbeddedBranchVersionDecorator
11
13
  property :build_url, as: :buildUrl
12
14
 
13
15
  collection :tags, embedded: true, :extend => PactBroker::Api::Decorators::EmbeddedTagDecorator, class: OpenStruct
@@ -44,6 +44,10 @@ module PactBroker
44
44
  <link rel='stylesheet' type='text/css' href='#{base_url}/stylesheets/material-menu.css'>
45
45
  <link rel='stylesheet' type='text/css' href='#{base_url}/stylesheets/pact.css'>
46
46
  <link rel='stylesheet' type='text/css' href='#{base_url}/stylesheets/jquery-confirm.min.css'>
47
+ <script type='text/javascript'>
48
+ const BASE_URL = '#{base_url}';
49
+ </script>
50
+ <script src='#{base_url}/javascripts/set-css-asset-base-url.js'></script>
47
51
  <script src='#{base_url}/javascripts/highlight.pack.js'></script>
48
52
  <script src='#{base_url}/javascripts/jquery-3.5.1.min.js'></script>
49
53
  <script src='#{base_url}/js/bootstrap.min.js'></script>
@@ -361,6 +361,14 @@ module PactBroker
361
361
  consumer_version.branch_versions
362
362
  end
363
363
 
364
+ def consumer_version_deployed_versions
365
+ consumer_version.current_deployed_versions
366
+ end
367
+
368
+ def consumer_version_released_versions
369
+ consumer_version.current_supported_released_versions
370
+ end
371
+
364
372
  def consumer_version_order
365
373
  consumer_version.order
366
374
  end
@@ -377,6 +385,14 @@ module PactBroker
377
385
  provider_version&.branch_versions || []
378
386
  end
379
387
 
388
+ def provider_version_deployed_versions
389
+ provider_version&.current_deployed_versions || []
390
+ end
391
+
392
+ def provider_version_released_versions
393
+ provider_version&.current_supported_released_versions || []
394
+ end
395
+
380
396
  def provider_version_order
381
397
  provider_version&.order
382
398
  end
@@ -204,28 +204,24 @@ module PactBroker
204
204
  # The pacts for the latest versions with the specified tag (new logic)
205
205
  # NOT the latest pact that belongs to a version with the specified tag.
206
206
  def for_latest_consumer_versions_with_tag(tag_name)
207
- if PactBroker.feature_enabled?(:fix_issue_494)
208
- head_tags = PactBroker::Domain::Tag
209
- .select_group(:pacticipant_id, :name)
210
- .select_append{ max(version_order).as(:latest_version_order) }
211
- .where(name: tag_name)
212
-
213
- head_tags_join = {
214
- Sequel[:pact_publications][:consumer_id] => Sequel[:head_tags][:pacticipant_id],
215
- Sequel[:pact_publications][:consumer_version_order] => Sequel[:head_tags][:latest_version_order]
216
- }
217
-
218
- base_query = self
219
- if no_columns_selected?
220
- base_query = base_query.select_all_qualified.select_append(Sequel[:head_tags][:name].as(:tag_name))
221
- end
222
-
223
- base_query
224
- .join(head_tags, head_tags_join, { table_alias: :head_tags })
225
- .remove_overridden_revisions_from_complete_query
226
- else
227
- latest_for_consumer_tag(tag_name)
207
+ head_tags = PactBroker::Domain::Tag
208
+ .select_group(:pacticipant_id, :name)
209
+ .select_append{ max(version_order).as(:latest_version_order) }
210
+ .where(name: tag_name)
211
+
212
+ head_tags_join = {
213
+ Sequel[:pact_publications][:consumer_id] => Sequel[:head_tags][:pacticipant_id],
214
+ Sequel[:pact_publications][:consumer_version_order] => Sequel[:head_tags][:latest_version_order]
215
+ }
216
+
217
+ base_query = self
218
+ if no_columns_selected?
219
+ base_query = base_query.select_all_qualified.select_append(Sequel[:head_tags][:name].as(:tag_name))
228
220
  end
221
+
222
+ base_query
223
+ .join(head_tags, head_tags_join, { table_alias: :head_tags })
224
+ .remove_overridden_revisions_from_complete_query
229
225
  end
230
226
 
231
227
  def in_environments
@@ -9,3 +9,4 @@
9
9
  %script{type: 'text/javascript', src:"#{base_url}/javascripts/index.js?v=#{PactBroker::VERSION}"}
10
10
  %script{type: 'text/javascript', src:"#{base_url}/javascripts/clipboard.js?v=#{PactBroker::VERSION}"}
11
11
  %script{type: 'text/javascript', src:"#{base_url}/javascripts/jquery-confirm.min.js?v=#{PactBroker::VERSION}"}
12
+ %script{type: 'text/javascript', src:"#{base_url}/javascripts/set-css-asset-base-url.js?v=#{PactBroker::VERSION}"}
@@ -8,4 +8,8 @@
8
8
  %link{rel: 'stylesheet', href: "#{base_url}/css/bootstrap.min.css?v=#{PactBroker::VERSION}"}
9
9
  %script{type: 'text/javascript', src:"#{base_url}/javascripts/jquery-3.5.1.min.js?v=#{PactBroker::VERSION}"}
10
10
  %script{type: 'text/javascript', src:"#{base_url}/js/bootstrap.bundle.min.js?v=#{PactBroker::VERSION}"}
11
+
12
+ :javascript
13
+ const BASE_URL = '#{base_url}';
14
+
11
15
  != yield
@@ -9,6 +9,7 @@
9
9
  %script{type: 'text/javascript', src: "#{base_url}/javascripts/matrix.js?v=#{PactBroker::VERSION}"}
10
10
  %script{type: 'text/javascript', src: "#{base_url}/javascripts/clipboard.js?v=#{PactBroker::VERSION}"}
11
11
  %script{type: 'text/javascript', src: "#{base_url}/js/bootstrap.bundle.min.js?v=#{PactBroker::VERSION}"}
12
+ %script{type: 'text/javascript', src: "#{base_url}/javascripts/set-css-asset-base-url.js?v=#{PactBroker::VERSION}"}
12
13
 
13
14
  .container
14
15
  %nav{'aria-label': 'breadcrumb'}
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = "2.90.0"
2
+ VERSION = "2.91.0"
3
3
  end
@@ -0,0 +1,23 @@
1
+ /*
2
+ Set the base URL of the background images
3
+ so they load from the right path when the base
4
+ URL of the app is not /
5
+ Must be loaded after the css but before any of the elements have started to render.
6
+ */
7
+
8
+ function setCssAssetBaseUrl(base_url, varName) {
9
+ const urlVar = getComputedStyle(document.documentElement).getPropertyValue(varName)
10
+ if (urlVar) {
11
+ const absoluteUrlVar = urlVar.replace(/\//, (base_url + '/'));
12
+ const root = document.querySelector(':root');
13
+ root.style.setProperty(varName, absoluteUrlVar);
14
+ }
15
+ }
16
+
17
+ setCssAssetBaseUrl(BASE_URL, '--kebab-url');
18
+ setCssAssetBaseUrl(BASE_URL, '--pact-kebab-url');
19
+ setCssAssetBaseUrl(BASE_URL, '--clock-url');
20
+ setCssAssetBaseUrl(BASE_URL, '--arrow-switch-url');
21
+ setCssAssetBaseUrl(BASE_URL, '--alert-url');
22
+ setCssAssetBaseUrl(BASE_URL, '--copy-url');
23
+ setCssAssetBaseUrl(BASE_URL, '--check-url');
@@ -1,3 +1,12 @@
1
+ :root {
2
+ /* See public/javascripts/set-css-asset-base-url.js */
3
+ --kebab-url: url('/images/kebab-horizontal.svg');
4
+ --arrow-switch-url: url('/images/arrow-switch.svg');
5
+ --alert-url: url('/images/alert.svg');
6
+ --copy-url: url('/images/copy.svg');
7
+ --check-url: url('/images/check.svg');
8
+ }
9
+
1
10
  .table-striped>tbody>tr>td.pact, .table-striped>thead>tr>th.pact {
2
11
  border-left: none;
3
12
  border-right: none;
@@ -173,7 +182,7 @@ span.integration-settings {
173
182
  }
174
183
 
175
184
  span.kebab-horizontal {
176
- background-image: url('/images/kebab-horizontal.svg');
185
+ background-image: var(--kebab-url);
177
186
  background-repeat: no-repeat;
178
187
  display:block;
179
188
  position: relative;
@@ -183,7 +192,7 @@ span.kebab-horizontal {
183
192
  }
184
193
 
185
194
  span.sort-icon {
186
- background-image: url('/images/arrow-switch.svg');
195
+ background-image: var(--arrow-switch-url);
187
196
  background-repeat: no-repeat;
188
197
  display:inline-block;
189
198
  position: relative;
@@ -194,7 +203,7 @@ span.sort-icon {
194
203
  }
195
204
 
196
205
  span.warning-icon {
197
- background-image: url('/images/alert.svg');
206
+ background-image: var(--alert-url);
198
207
  background-repeat: no-repeat;
199
208
  display:inline-block;
200
209
  position: relative;
@@ -213,7 +222,7 @@ span.warning-icon {
213
222
  }
214
223
 
215
224
  span.copy-icon {
216
- background-image: url('/images/copy.svg');
225
+ background-image: var(--copy-url);
217
226
  background-size: 16px 16px;
218
227
  background-repeat: no-repeat;
219
228
  display:block;
@@ -224,7 +233,7 @@ span.copy-icon {
224
233
  }
225
234
 
226
235
  span.copy-success-icon {
227
- background-image: url('/images/check.svg');
236
+ background-image: var(--check-url);
228
237
  background-size: 16px 16px;
229
238
  background-repeat: no-repeat;
230
239
  display:block;
@@ -1,3 +1,8 @@
1
+ :root {
2
+ /* See public/javascripts/set-css-asset-base-url.js */
3
+ --clock-url: url('/images/clock.svg');
4
+ }
5
+
1
6
  div {
2
7
  /*border: 1px solid red;*/
3
8
  }
@@ -33,7 +38,7 @@ div.tag, div.version {
33
38
 
34
39
  span.pre-verified-icon {
35
40
  color: #337ab7;
36
- background-image: url('/images/clock.svg');
41
+ background-image: var(--clock-url);
37
42
  background-repeat: no-repeat;
38
43
  display:inline-block;
39
44
  position: relative;
@@ -1,3 +1,8 @@
1
+ :root {
2
+ /* See public/javascripts/set-css-asset-base-url.js */
3
+ --pact-kebab-url: url('/images/kebab-horizontal.svg');
4
+ }
5
+
1
6
  div.pact-metadata {
2
7
  margin-top: 40px;
3
8
  float: right;
@@ -30,7 +35,7 @@ div.pact-badge-markdown {
30
35
  }
31
36
 
32
37
  span.kebab-horizontal {
33
- background-image: url('/images/kebab-horizontal.svg');
38
+ background-image: var(--pact-kebab-url);
34
39
  background-repeat: no-repeat;
35
40
  display:block;
36
41
  position: relative;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.90.0
4
+ version: 2.91.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-11-12 00:00:00.000000000 Z
13
+ date: 2021-11-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -633,6 +633,7 @@ files:
633
633
  - lib/pact_broker/api/decorators/deployed_version_decorator.rb
634
634
  - lib/pact_broker/api/decorators/deployed_versions_decorator.rb
635
635
  - lib/pact_broker/api/decorators/embedded_branch_version_decorator.rb
636
+ - lib/pact_broker/api/decorators/embedded_environment_decorator.rb
636
637
  - lib/pact_broker/api/decorators/embedded_label_decorator.rb
637
638
  - lib/pact_broker/api/decorators/embedded_pacticipant_decorator.rb
638
639
  - lib/pact_broker/api/decorators/embedded_tag_decorator.rb
@@ -1144,6 +1145,7 @@ files:
1144
1145
  - public/javascripts/matrix.js
1145
1146
  - public/javascripts/pact.js
1146
1147
  - public/javascripts/pagination.js
1148
+ - public/javascripts/set-css-asset-base-url.js
1147
1149
  - public/js/bootstrap.bundle.js
1148
1150
  - public/js/bootstrap.bundle.js.map
1149
1151
  - public/js/bootstrap.bundle.min.js