Module: Shipit::StacksHelper
- Defined in:
- app/helpers/shipit/stacks_helper.rb
Instance Method Summary collapse
- #bypass_safeties? ⇒ Boolean
- #contributor_class(stacks_contributed_to, stack_id) ⇒ Object
- #deploy_button(commit) ⇒ Object
- #deployment_checks_message(stack) ⇒ Object
- #github_change_url(commit) ⇒ Object
- #positive_negative_class(value) ⇒ Object
- #pull_request_link(pull_request_or_commit) ⇒ Object
- #redeploy_button(deployed_commit) ⇒ Object
- #render_commit_id_link(commit) ⇒ Object
- #render_commit_message(pull_request_or_commit) ⇒ Object
- #render_commit_message_with_link(commit) ⇒ Object
- #render_pull_request_title_with_link(pull_request) ⇒ Object
- #render_raw_commit_id_link(commit) ⇒ Object
- #rollback_button(deploy) ⇒ Object
- #unlock_commit_tooltip(commit) ⇒ Object
Instance Method Details
#bypass_safeties? ⇒ Boolean
17 18 19 |
# File 'app/helpers/shipit/stacks_helper.rb', line 17 def bypass_safeties? params[:force].present? end |
#contributor_class(stacks_contributed_to, stack_id) ⇒ Object
105 106 107 |
# File 'app/helpers/shipit/stacks_helper.rb', line 105 def contributor_class(stacks_contributed_to, stack_id) stacks_contributed_to.include?(stack_id) ? "contributor" : "not-matching" end |
#deploy_button(commit) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/shipit/stacks_helper.rb', line 21 def (commit) url = new_stack_deploy_path(commit.stack, sha: commit.sha) classes = %W[btn btn--primary deploy-action #{commit.state}] deploy_state = commit.deploy_state(bypass_safeties?) data = {} if commit.deploy_disallowed? classes.push(bypass_safeties? ? 'btn--warning' : 'btn--disabled') data[:tooltip] = t('deploy_button.hint.blocked') if deploy_state == 'blocked' elsif commit.deploy_discouraged? classes.push('btn--warning') data[:tooltip] = t('deploy_button.hint.max_commits', maximum: commit.stack.maximum_commits_per_deploy) end link_to(t("deploy_button.caption.#{deploy_state}"), url, class: classes, data:) end |
#deployment_checks_message(stack) ⇒ Object
109 110 111 112 113 114 115 |
# File 'app/helpers/shipit/stacks_helper.rb', line 109 def (stack) if !stack.deployment_checks_passed? && Shipit.deployment_checks.respond_to?(:message) Shipit.deployment_checks.(stack) else "Deploys have been locked by an external system" end end |
#github_change_url(commit) ⇒ Object
49 50 51 52 53 54 55 |
# File 'app/helpers/shipit/stacks_helper.rb', line 49 def github_change_url(commit) if commit.pull_request? github_pull_request_url(commit) else github_commit_url(commit) end end |
#positive_negative_class(value) ⇒ Object
101 102 103 |
# File 'app/helpers/shipit/stacks_helper.rb', line 101 def positive_negative_class(value) value.to_f >= 0 ? 'positive' : 'negative' end |
#pull_request_link(pull_request_or_commit) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'app/helpers/shipit/stacks_helper.rb', line 80 def pull_request_link(pull_request_or_commit) number = if pull_request_or_commit.respond_to?(:pull_request_number) pull_request_or_commit.pull_request_number else pull_request_or_commit.number end link_to("##{number}", github_pull_request_url(pull_request_or_commit), target: '_blank', class: 'number') end |
#redeploy_button(deployed_commit) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/shipit/stacks_helper.rb', line 5 def (deployed_commit) commit = UndeployedCommit.new(deployed_commit, index: 0) url = new_stack_deploy_path(commit.stack, sha: commit.sha) classes = %W[btn btn--primary deploy-action #{commit.state}] unless commit.stack.deployable? classes.push(bypass_safeties? ? 'btn--warning' : 'btn--disabled') end link_to(t("redeploy_button.caption.#{commit.redeploy_state(bypass_safeties?)}"), url, class: classes) end |
#render_commit_id_link(commit) ⇒ Object
72 73 74 75 76 77 78 |
# File 'app/helpers/shipit/stacks_helper.rb', line 72 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 |
#render_commit_message(pull_request_or_commit) ⇒ Object
57 58 59 60 |
# File 'app/helpers/shipit/stacks_helper.rb', line 57 def (pull_request_or_commit) = pull_request_or_commit.title.to_s content_tag(:span, emojify(), class: 'event-message') end |
#render_commit_message_with_link(commit) ⇒ Object
67 68 69 70 |
# File 'app/helpers/shipit/stacks_helper.rb', line 67 def (commit) = (commit) link_to(, github_change_url(commit), target: '_blank') end |
#render_pull_request_title_with_link(pull_request) ⇒ Object
62 63 64 65 |
# File 'app/helpers/shipit/stacks_helper.rb', line 62 def render_pull_request_title_with_link(pull_request) = (pull_request) link_to(, github_pull_request_url(pull_request), target: '_blank') end |
#render_raw_commit_id_link(commit) ⇒ Object
89 90 91 |
# File 'app/helpers/shipit/stacks_helper.rb', line 89 def render_raw_commit_id_link(commit) link_to(commit.short_sha, github_commit_url(commit), target: '_blank', class: 'number') end |
#rollback_button(deploy) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/shipit/stacks_helper.rb', line 38 def (deploy) if deploy.stack.active_task? link_to('Deploy in progress...', '#', class: 'btn disabled deploy-action') else url = rollback_stack_deploy_path(deploy.stack, deploy) classes = %w[btn btn--delete deploy-action rollback-action] link_to('Rollback to this deploy...', url, class: classes) end end |
#unlock_commit_tooltip(commit) ⇒ Object
93 94 95 96 97 98 99 |
# File 'app/helpers/shipit/stacks_helper.rb', line 93 def unlock_commit_tooltip(commit) if commit..present? t('commit.unlock_with_author', author: commit..name) else t('commit.unlock') end end |