From 12f92951f3be3f9f321c7a2e401d791f773bd77d Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Tue, 13 Jul 2021 15:33:54 +1000 Subject: [PATCH] feat: support viewing all versions for branch in matrix UI --- lib/pact_broker/db/seed_example_data.rb | 3 +++ lib/pact_broker/matrix/unresolved_selector.rb | 2 +- lib/pact_broker/ui/helpers/matrix_helper.rb | 1 + lib/pact_broker/ui/views/matrix/show.haml | 2 ++ public/javascripts/matrix.js | 3 +++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/pact_broker/db/seed_example_data.rb b/lib/pact_broker/db/seed_example_data.rb index 1888496da..34f3776ea 100644 --- a/lib/pact_broker/db/seed_example_data.rb +++ b/lib/pact_broker/db/seed_example_data.rb @@ -31,6 +31,9 @@ def call(consumer_name: CONSUMER_NAME, provider_name: PROVIDER_NAME) .create_consumer_version("725c6ccb7cf7efc51b4394f9828585eea9c379d9", branch: "feat/new-thing", created_at: days_ago(7)) .create_consumer_version_tag("feat-new-thing", created_at: days_ago(7)) .create_pact(json_content: pact_2, created_at: days_ago(7)) + .create_consumer_version("6c992f831da299364cf31be6008ee4752189f6d4", branch: "feat/new-thing", created_at: days_ago(6)) + .create_consumer_version_tag("feat-new-thing", created_at: days_ago(6)) + .create_pact(json_content: pact_2, created_at: days_ago(7)) .create_consumer_version("7bd4d9173522826dc3e8704fd62dde0424f4c827", branch: "main", created_at: days_ago(1)) .create_consumer_version_tag("main", created_at: days_ago(1)) .create_pact(json_content: pact_3, created_at: days_ago(1)) diff --git a/lib/pact_broker/matrix/unresolved_selector.rb b/lib/pact_broker/matrix/unresolved_selector.rb index 641b7cfc9..e10af3b35 100644 --- a/lib/pact_broker/matrix/unresolved_selector.rb +++ b/lib/pact_broker/matrix/unresolved_selector.rb @@ -78,7 +78,7 @@ def max_age end def all_for_pacticipant? - !!pacticipant_name && !pacticipant_version_number && !tag && !latest && !environment_name && !max_age + !!pacticipant_name && !pacticipant_version_number && !tag && !branch && !latest && !environment_name && !max_age end def latest_for_pacticipant_and_tag? diff --git a/lib/pact_broker/ui/helpers/matrix_helper.rb b/lib/pact_broker/ui/helpers/matrix_helper.rb index a690776c6..98dd5d691 100644 --- a/lib/pact_broker/ui/helpers/matrix_helper.rb +++ b/lib/pact_broker/ui/helpers/matrix_helper.rb @@ -11,6 +11,7 @@ def create_selector_objects(selector_hashes) o = OpenStruct.new(selector_hash) o.specify_latest_tag = (o.tag && o.latest) ? "checked" : nil o.specify_latest_branch = (o.branch && o.latest) ? "checked" : nil + o.specify_all_branch = (o.branch && !o.latest) ? "checked" : nil o.specify_environment = o.environment_name ? "checked" : nil o.specify_all_tagged = (o.tag && !o.latest) ? "checked" : nil o.specify_latest = o.latest ? "checked" : nil diff --git a/lib/pact_broker/ui/views/matrix/show.haml b/lib/pact_broker/ui/views/matrix/show.haml index 0619a7732..229d05874 100644 --- a/lib/pact_broker/ui/views/matrix/show.haml +++ b/lib/pact_broker/ui/views/matrix/show.haml @@ -42,6 +42,8 @@ Version number ... %option{ value: 'specify-latest-branch', selected: selector.specify_latest_branch } Latest version from branch ... + %option{ value: 'specify-all-branch', selected: selector.specify_all_branch } + All versions from branch ... %option{ value: 'specify-environment', selected: selector.specify_environment } Version(s) in environment ... %option{ value: 'specify-latest-tag', selected: selector.specify_latest_tag } diff --git a/public/javascripts/matrix.js b/public/javascripts/matrix.js index 42a40849a..453fa7ad0 100644 --- a/public/javascripts/matrix.js +++ b/public/javascripts/matrix.js @@ -34,6 +34,9 @@ function showApplicableTextBoxes(selectorizor) { else if( selectorizorType === 'specify-latest-branch') { setTextboxVisibility(selectorizor, '.branch', true); } + else if( selectorizorType === 'specify-all-branch') { + setTextboxVisibility(selectorizor, '.branch', true); + } else if ( selectorizorType === 'specify-environment') { setTextboxVisibility(selectorizor, '.environment', true); }