Skip to content

Commit

Permalink
feat: copy full git sha rather than abbreviated one when clicking the…
Browse files Browse the repository at this point in the history
… copy button next to an application version
  • Loading branch information
bethesque committed Feb 21, 2021
1 parent e92dbc1 commit dae9cae
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
12 changes: 10 additions & 2 deletions lib/pact_broker/ui/view_models/index_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,23 @@ def provider_name
end

def consumer_version_number
PactBroker::Versions::AbbreviateNumber.call(@relationship.consumer_version_number)
@relationship.consumer_version_number
end

def display_consumer_version_number
PactBroker::Versions::AbbreviateNumber.call(consumer_version_number)
end

def consumer_version_order
@relationship.consumer_version_order
end

def provider_version_number
PactBroker::Versions::AbbreviateNumber.call(@relationship.provider_version_number)
@relationship.provider_version_number
end

def display_provider_version_number
PactBroker::Versions::AbbreviateNumber.call(provider_version_number)
end

def latest?
Expand Down
12 changes: 6 additions & 6 deletions lib/pact_broker/ui/views/index/show-with-tags.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
%a{:href => index_item.consumer_group_url }
= index_item.consumer_name
%td.consumer-version-number{"data-text": index_item.consumer_version_order}
%div.clippable
= index_item.consumer_version_number
- if index_item.consumer_version_number
%div.clippable{"data-clippable": index_item.consumer_version_number}
= index_item.display_consumer_version_number
- if index_item.display_consumer_version_number
%button.clippy.invisible{ title: "Copy to clipboard" }
%span.copy-icon
- if index_item.latest?
Expand All @@ -63,9 +63,9 @@
%a{ href: index_item.provider_group_url }
= index_item.provider_name
%td.provider-version-number
%div.clippable
= index_item.provider_version_number
- if index_item.provider_version_number
%div.clippable{"data-clippable": index_item.provider_version_number}
= index_item.display_provider_version_number
- if index_item.display_provider_version_number
%button.clippy.invisible{ title: "Copy to clipboard" }
%span.copy-icon
- if index_item.provider_version_branch
Expand Down
4 changes: 2 additions & 2 deletions lib/pact_broker/ui/views/matrix/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
%a{href: line.consumer_name_url}
= line.consumer_name
%td.consumer-version{'data-sort-value' => line.consumer_version_order, 'data-consumer-version-id' => line.consumer_version_id}
%div.clippable
%div.clippable{'data-clippable': line.consumer_version_number}
%a{href: line.consumer_version_number_url}
= line.display_consumer_version_number
- if line.display_consumer_version_number
Expand Down Expand Up @@ -144,7 +144,7 @@
%a{href: line.provider_name_url}
= line.provider_name
%td.provider-version{'data-sort-value' => line.provider_version_order, 'data-provider-version-id' => line.provider_version_id }
%div.clippable
%div.clippable{'data-clippable': line.provider_version_number}
%a{href: line.provider_version_number_url}
= line.display_provider_version_number
- if line.display_provider_version_number
Expand Down
10 changes: 8 additions & 2 deletions public/javascripts/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ function initializeClipper(selector) {
.children(".clippy")
.click(function() {
const clippyButton = $(this);
const text = $.trim(clippyButton.closest(selector).text());
const clipTarget = clippyButton.closest(selector);
let text = null;
if(clipTarget.data('clippable')) {
text = clipTarget.data('clippable');
} else {
text = clippyButton.closest(selector).text();
}
copyToClipboard($.trim(text));

copyToClipboard(text);
flashClipped(clippyButton);
});
}
Expand Down

0 comments on commit dae9cae

Please sign in to comment.