Skip to content

Commit

Permalink
Merge pull request zendesk#2020 from zendesk/grosser/refs
Browse files Browse the repository at this point in the history
make current deploy labels clickable
  • Loading branch information
grosser authored Jun 6, 2017
2 parents 8e4d026 + 1b4280f commit f192696
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
8 changes: 3 additions & 5 deletions app/assets/javascripts/deploys.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ $(function () {
}
}

// When user clicks a release label, fill the deploy reference field with that version
// When user clicks a release or deploy label, fill the deploy reference field with that version
// also trigger version check ... see ref_status_typeahead.js
$(".clickable-releases .label").on('click', function(event){
$(".clickable-releases [data-ref]").on('click', function(event){
event.preventDefault();
// Get version number from link href
var version = event.target.href.substring(event.target.href.lastIndexOf('/') + 1);
$("#deploy_reference").val(version).trigger('input');
$("#deploy_reference").val(event.target.dataset.ref).trigger('input');
});

$form.submit(function(event) {
Expand Down
6 changes: 5 additions & 1 deletion app/helpers/releases_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# frozen_string_literal: true
module ReleasesHelper
def release_label(project, release)
link_to(release.version, [project, release], class: "release-label label label-success")
link_to(
release.version,
[project, release],
class: "release-label label label-success", data: {ref: release.version}
)
end

def link_to_deploy_stage(stage, release)
Expand Down
2 changes: 1 addition & 1 deletion app/views/deploys/_currently_deployed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<td>
<%= link_to deploy.stage.name, [@project, deploy.stage] %>
</td>
<td><%= link_to deploy.short_reference, [@project, deploy], class: "status label #{status_label(deploy.status)}" %></td>
<td><%= link_to deploy.short_reference, "#", class: "status label #{status_label(deploy.status)}", data: {ref: deploy.short_reference} %></td>
</tr>
<% end %>
</table>
Expand Down
4 changes: 3 additions & 1 deletion test/helpers/releases_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
let(:result) { release_label(projects(:test), release) }

it "produces a label" do
result.must_equal "<a class=\"release-label label label-success\" href=\"/projects/foo/releases/v123\">v123</a>"
result.must_equal(
"<a class=\"release-label label label-success\" data-ref=\"v123\" href=\"/projects/foo/releases/v123\">v123</a>"
)
end
end

Expand Down

0 comments on commit f192696

Please sign in to comment.