Sha256: 42e7b143653a08116f282ef7024da0fd89516bd30c3a3c66c2cc0320a0bc3178
Contents?: true
Size: 1.93 KB
Versions: 8
Compression:
Stored size: 1.93 KB
Contents
module StacksHelper COMMIT_TITLE_LENGTH = 79 def deploy_button(commit) url = new_stack_deploy_path(@stack, sha: commit.sha) classes = %W(btn btn--primary deploy-action #{commit.state}) if deploy_button_disabled?(commit) classes.push(params[:force].present? ? 'btn--warning' : 'btn--disabled') end link_to(deploy_button_caption(commit), url, class: classes) end def github_change_url(commit) commit.pull_request_url || github_commit_url(commit) end def render_commit_message(commit) message = commit.pull_request_title || commit.message content_tag(:span, message.truncate(COMMIT_TITLE_LENGTH), class: 'event-message') end def render_commit_message_with_link(commit) link_to(render_commit_message(commit), github_change_url(commit), target: '_blank') end def render_commit_id_link(commit) if commit.pull_request? pull_request_link(commit) + " (#{render_raw_commit_id_link(commit)})".html_safe else render_raw_commit_id_link(commit) end end def pull_request_link(commit) link_to("##{commit.pull_request_id}", commit.pull_request_url, target: '_blank', class: 'number') end def render_raw_commit_id_link(commit) link_to(commit.short_sha, github_commit_url(commit), target: '_blank', class: 'number') end private def deploy_button_disabled?(commit) !commit.deployable? || commit.stack.locked? || commit.stack.deploying? end def deploy_button_caption(commit) case when commit.stack.locked? then 'Locked' when commit.deployable? then commit.stack.deploying? ? 'Deploy in progress...' : 'Deploy' when commit.pending? then 'CI Pending...' when commit.failure? then 'CI Failure' when commit.error? then 'CI Error' else 'Not Run' end end def render_status(commit) statuses = commit.visible_statuses if statuses.size == 1 render statuses.first else render StatusGroup.new(commit) end end end
Version data entries
8 entries across 8 versions & 1 rubygems