summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-10-07 15:15:35 +0200
committerDouwe Maan <douwe@gitlab.com>2015-10-07 15:15:35 +0200
commit4f629dab2a14c190b641bd709c28ebdad5b7a062 (patch)
tree00035d114b896a38b4a2a6ac835411ba36d3e1e5 /app/helpers
parent48837850838c8acb0c02ae60b29e18d287865878 (diff)
parent0611a18964a998b6edc81ef9b469f9f70430e542 (diff)
downloadgitlab-ce-4f629dab2a14c190b641bd709c28ebdad5b7a062.tar.gz
Merge branch 'master' into rs-redactor-filter
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb14
-rw-r--r--app/helpers/auth_helper.rb8
-rw-r--r--app/helpers/builds_helper.rb13
-rw-r--r--app/helpers/ci/gitlab_helper.rb36
-rw-r--r--app/helpers/ci/projects_helper.rb36
-rw-r--r--app/helpers/ci_status_helper.rb45
-rw-r--r--app/helpers/commits_helper.rb2
-rw-r--r--app/helpers/diff_helper.rb23
-rw-r--r--app/helpers/events_helper.rb22
-rw-r--r--app/helpers/gitlab_markdown_helper.rb4
-rw-r--r--app/helpers/gitlab_routing_helper.rb16
-rw-r--r--app/helpers/graph_helper.rb5
-rw-r--r--app/helpers/groups_helper.rb11
-rw-r--r--app/helpers/merge_requests_helper.rb13
-rw-r--r--app/helpers/notifications_helper.rb45
-rw-r--r--app/helpers/page_layout_helper.rb24
-rw-r--r--app/helpers/preferences_helper.rb11
-rw-r--r--app/helpers/projects_helper.rb42
-rw-r--r--app/helpers/runners_helper.rb20
-rw-r--r--app/helpers/time_helper.rb27
-rw-r--r--app/helpers/triggers_helper.rb5
-rw-r--r--app/helpers/version_check_helper.rb2
-rw-r--r--app/helpers/wiki_helper.rb24
23 files changed, 381 insertions, 67 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a803b66c502..cab2278adb7 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -13,7 +13,9 @@ module ApplicationHelper
# current_controller?(:commits) # => false
# current_controller?(:commits, :tree) # => true
def current_controller?(*args)
- args.any? { |v| v.to_s.downcase == controller.controller_name }
+ args.any? do |v|
+ v.to_s.downcase == controller.controller_name || v.to_s.downcase == controller.controller_path
+ end
end
# Check if a particular action is the current one
@@ -33,7 +35,7 @@ module ApplicationHelper
def project_icon(project_id, options = {})
project =
if project_id.is_a?(Project)
- project = project_id
+ project_id
else
Project.find_with_namespace(project_id)
end
@@ -82,7 +84,7 @@ module ApplicationHelper
end
def default_avatar
- image_path('no_avatar.png')
+ 'no_avatar.png'
end
def last_commit(project)
@@ -201,7 +203,7 @@ module ApplicationHelper
class: "#{html_class} js-timeago",
datetime: time.getutc.iso8601,
title: time.in_time_zone.stamp('Aug 21, 2011 9:23pm'),
- data: { toggle: 'tooltip', placement: placement }
+ data: { toggle: 'tooltip', placement: placement, container: 'body' }
element += javascript_tag "$('.js-timeago').timeago()" unless skip_js
@@ -312,4 +314,8 @@ module ApplicationHelper
html.html_safe
end
+
+ def truncate_first_line(message, length = 50)
+ truncate(message.each_line.first.chomp, length: length) if message
+ end
end
diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb
index 0e7a37b4cc6..cd99a232403 100644
--- a/app/helpers/auth_helper.rb
+++ b/app/helpers/auth_helper.rb
@@ -1,6 +1,6 @@
module AuthHelper
PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2).freeze
- FORM_BASED_PROVIDERS = [/\Aldap/, 'kerberos'].freeze
+ FORM_BASED_PROVIDERS = [/\Aldap/, 'crowd'].freeze
def ldap_enabled?
Gitlab.config.ldap.enabled
@@ -26,6 +26,10 @@ module AuthHelper
auth_providers.select { |provider| form_based_provider?(provider) }
end
+ def crowd_enabled?
+ auth_providers.include? :crowd
+ end
+
def button_based_providers
auth_providers.reject { |provider| form_based_provider?(provider) }
end
@@ -36,7 +40,7 @@ module AuthHelper
if provider_has_icon?(provider)
file_name = "#{provider.to_s.split('_').first}_#{size}.png"
- image_tag(image_path("auth_buttons/#{file_name}"), alt: label, title: "Sign in with #{label}")
+ image_tag("auth_buttons/#{file_name}", alt: label, title: "Sign in with #{label}")
else
label
end
diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb
new file mode 100644
index 00000000000..1b5a2c31d74
--- /dev/null
+++ b/app/helpers/builds_helper.rb
@@ -0,0 +1,13 @@
+module BuildsHelper
+ def build_ref_link build
+ gitlab_ref_link build.project, build.ref
+ end
+
+ def build_commit_link build
+ gitlab_commit_link build.project, build.short_sha
+ end
+
+ def build_url(build)
+ namespace_project_build_path(build.gl_project, build.project, build)
+ end
+end
diff --git a/app/helpers/ci/gitlab_helper.rb b/app/helpers/ci/gitlab_helper.rb
new file mode 100644
index 00000000000..baddbc806f2
--- /dev/null
+++ b/app/helpers/ci/gitlab_helper.rb
@@ -0,0 +1,36 @@
+module Ci
+ module GitlabHelper
+ def no_turbolink
+ { :"data-no-turbolink" => "data-no-turbolink" }
+ end
+
+ def gitlab_ref_link project, ref
+ gitlab_url = project.gitlab_url.dup
+ gitlab_url << "/commits/#{ref}"
+ link_to ref, gitlab_url, no_turbolink
+ end
+
+ def gitlab_compare_link project, before, after
+ gitlab_url = project.gitlab_url.dup
+ gitlab_url << "/compare/#{before}...#{after}"
+
+ link_to "#{before}...#{after}", gitlab_url, no_turbolink
+ end
+
+ def gitlab_commit_link project, sha
+ gitlab_url = project.gitlab_url.dup
+ gitlab_url << "/commit/#{sha}"
+ link_to Ci::Commit.truncate_sha(sha), gitlab_url, no_turbolink
+ end
+
+ def yaml_web_editor_link(project)
+ commits = project.commits
+
+ if commits.any? && commits.last.ci_yaml_file
+ "#{project.gitlab_url}/edit/master/.gitlab-ci.yml"
+ else
+ "#{project.gitlab_url}/new/master"
+ end
+ end
+ end
+end
diff --git a/app/helpers/ci/projects_helper.rb b/app/helpers/ci/projects_helper.rb
new file mode 100644
index 00000000000..fd991a4165a
--- /dev/null
+++ b/app/helpers/ci/projects_helper.rb
@@ -0,0 +1,36 @@
+module Ci
+ module ProjectsHelper
+ def ref_tab_class ref = nil
+ 'active' if ref == @ref
+ end
+
+ def success_ratio(success_builds, failed_builds)
+ failed_builds = failed_builds.count(:all)
+ success_builds = success_builds.count(:all)
+
+ return 100 if failed_builds.zero?
+
+ ratio = (success_builds.to_f / (success_builds + failed_builds)) * 100
+ ratio.to_i
+ end
+
+ def markdown_badge_code(project, ref)
+ url = status_ci_project_url(project, ref: ref, format: 'png')
+ "[![build status](#{url})](#{ci_project_url(project, ref: ref)})"
+ end
+
+ def html_badge_code(project, ref)
+ url = status_ci_project_url(project, ref: ref, format: 'png')
+ "<a href='#{ci_project_url(project, ref: ref)}'><img src='#{url}' /></a>"
+ end
+
+ def project_uses_specific_runner?(project)
+ project.runners.any?
+ end
+
+ def no_runners_for_project?(project)
+ project.runners.blank? &&
+ Ci::Runner.shared.blank?
+ end
+ end
+end
diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb
new file mode 100644
index 00000000000..dbd1e26fa79
--- /dev/null
+++ b/app/helpers/ci_status_helper.rb
@@ -0,0 +1,45 @@
+module CiStatusHelper
+ def ci_status_path(ci_commit)
+ project = ci_commit.gl_project
+ ci_namespace_project_commit_path(project.namespace, project, ci_commit.sha)
+ end
+
+ def ci_status_icon(ci_commit)
+ ci_icon_for_status(ci_commit.status)
+ end
+
+ def ci_status_color(ci_commit)
+ case ci_commit.status
+ when 'success'
+ 'green'
+ when 'failed'
+ 'red'
+ when 'running', 'pending'
+ 'yellow'
+ else
+ 'gray'
+ end
+ end
+
+ def ci_status_with_icon(status)
+ content_tag :span, class: "ci-status ci-#{status}" do
+ ci_icon_for_status(status) + '&nbsp;'.html_safe + status
+ end
+ end
+
+ def ci_icon_for_status(status)
+ icon_name =
+ case status
+ when 'success'
+ 'check'
+ when 'failed'
+ 'close'
+ when 'running', 'pending'
+ 'clock-o'
+ else
+ 'circle'
+ end
+
+ icon(icon_name)
+ end
+end
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index d13d80be293..9df20c9fce5 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -135,7 +135,7 @@ module CommitsHelper
# size: size of the avatar image in px
def commit_person_link(commit, options = {})
user = commit.send(options[:source])
-
+
source_name = clean(commit.send "#{options[:source]}_name".to_sym)
source_email = clean(commit.send "#{options[:source]}_email".to_sym)
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 1bd3ec5e0e0..b896fba3704 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -137,7 +137,7 @@ module DiffHelper
# Always use HTML to handle case where JSON diff rendered this button
params_copy.delete(:format)
- link_to url_for(params_copy), id: "commit-diff-viewtype", class: (params[:view] != 'parallel' ? 'btn btn-sm active' : 'btn btn-sm') do
+ link_to url_for(params_copy), id: "inline-diff-btn", class: (params[:view] != 'parallel' ? 'btn btn-sm active' : 'btn btn-sm') do
'Inline'
end
end
@@ -148,7 +148,7 @@ module DiffHelper
# Always use HTML to handle case where JSON diff rendered this button
params_copy.delete(:format)
- link_to url_for(params_copy), id: "commit-diff-viewtype", class: (params[:view] == 'parallel' ? 'btn active btn-sm' : 'btn btn-sm') do
+ link_to url_for(params_copy), id: "parallel-diff-btn", class: (params[:view] == 'parallel' ? 'btn active btn-sm' : 'btn btn-sm') do
'Side-by-side'
end
end
@@ -167,4 +167,23 @@ module DiffHelper
content_tag(:span, commit_id, class: 'monospace'),
].join(' ').html_safe
end
+
+ def commit_for_diff(diff)
+ if diff.deleted_file
+ @merge_request ? @merge_request.commits.last : @commit.parents.first
+ else
+ @commit
+ end
+ end
+
+ def diff_file_html_data(project, diff_commit, diff_file)
+ {
+ blob_diff_path: namespace_project_blob_diff_path(project.namespace, project,
+ tree_join(diff_commit.id, diff_file.file_path))
+ }
+ end
+
+ def editable_diff?(diff)
+ !diff.deleted_file && @merge_request && @merge_request.source_project
+ end
end
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb
index 8428281f8f6..6f69c2a9f32 100644
--- a/app/helpers/events_helper.rb
+++ b/app/helpers/events_helper.rb
@@ -27,16 +27,13 @@ module EventsHelper
key = key.to_s
active = 'active' if @event_filter.active?(key)
link_opts = {
- class: 'event_filter_link',
+ class: "event-filter-link btn btn-default #{active}",
id: "#{key}_event_filter",
title: "Filter by #{tooltip.downcase}",
- data: { toggle: 'tooltip', placement: 'top' }
}
- content_tag :li, class: "filter_icon #{active}" do
- link_to request.path, link_opts do
- icon(icon_for_event[key]) + content_tag(:span, ' ' + tooltip)
- end
+ link_to request.path, link_opts do
+ content_tag(:span, ' ' + tooltip)
end
end
@@ -49,6 +46,14 @@ module EventsHelper
}
end
+ def event_preposition(event)
+ if event.push? || event.commented? || event.target
+ "at"
+ elsif event.milestone?
+ "in"
+ end
+ end
+
def event_feed_title(event)
words = []
words << event.author_name
@@ -65,8 +70,11 @@ module EventsHelper
words << "##{truncate event.note_target_iid}"
end
words << "at"
+ elsif event.milestone?
+ words << "##{event.target_iid}" if event.target_iid
+ words << "in"
elsif event.target
- words << "##{event.target_iid}:"
+ words << "##{event.target_iid}:"
words << event.target.title if event.target.respond_to?(:title)
words << "at"
end
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb
index 0d175e1ea18..40161c5a641 100644
--- a/app/helpers/gitlab_markdown_helper.rb
+++ b/app/helpers/gitlab_markdown_helper.rb
@@ -21,7 +21,7 @@ module GitlabMarkdownHelper
gfm_body = Gitlab::Markdown.gfm(escaped_body, project: @project, current_user: current_user)
- fragment = Nokogiri::XML::DocumentFragment.parse(gfm_body)
+ fragment = Nokogiri::HTML::DocumentFragment.parse(gfm_body)
if fragment.children.size == 1 && fragment.children[0].name == 'a'
# Fragment has only one node, and it's a link generated by `gfm`.
# Replace it with our requested link.
@@ -171,7 +171,7 @@ module GitlabMarkdownHelper
# and return true. Otherwise return false.
def truncate_if_block(node, truncated)
if node.element? && node.description.block? && !truncated
- node.content = "#{node.content}..." if node.next_sibling
+ node.inner_html = "#{node.inner_html}..." if node.next_sibling
true
else
truncated
diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb
index d0fae255a04..4d9da6ff837 100644
--- a/app/helpers/gitlab_routing_helper.rb
+++ b/app/helpers/gitlab_routing_helper.rb
@@ -17,6 +17,14 @@ module GitlabRoutingHelper
namespace_project_path(project.namespace, project, *args)
end
+ def project_files_path(project, *args)
+ namespace_project_tree_path(project.namespace, project, @ref || project.repository.root_ref)
+ end
+
+ def project_commits_path(project, *args)
+ namespace_project_commits_path(project.namespace, project, @ref || project.repository.root_ref)
+ end
+
def activity_project_path(project, *args)
activity_namespace_project_path(project.namespace, project, *args)
end
@@ -25,6 +33,14 @@ module GitlabRoutingHelper
edit_namespace_project_path(project.namespace, project, *args)
end
+ def runners_path(project, *args)
+ namespace_project_runners_path(project.namespace, project, *args)
+ end
+
+ def runner_path(runner, *args)
+ namespace_project_runner_path(@project.namespace, @project, runner, *args)
+ end
+
def issue_path(entity, *args)
namespace_project_issue_path(entity.project.namespace, entity.project, entity, *args)
end
diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb
index e1dda20de85..1e372d5631d 100644
--- a/app/helpers/graph_helper.rb
+++ b/app/helpers/graph_helper.rb
@@ -1,7 +1,10 @@
module GraphHelper
def get_refs(repo, commit)
refs = ""
- refs << commit.ref_names(repo).join(' ')
+ # Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX)
+ # so anything leftover is internally used by GitLab
+ commit_refs = commit.ref_names(repo).reject{ |name| name.starts_with?('refs/') }
+ refs << commit_refs.join(' ')
# append note count
refs << "[#{@graph.notes[commit.id]}]" if @graph.notes[commit.id] > 0
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
index b067cb54a43..1d36969cd62 100644
--- a/app/helpers/groups_helper.rb
+++ b/app/helpers/groups_helper.rb
@@ -27,7 +27,16 @@ module GroupsHelper
if group && group.avatar.present?
group.avatar.url
else
- image_path('no_group_avatar.png')
+ 'no_group_avatar.png'
+ end
+ end
+
+ def group_title(group, name = nil, url = nil)
+ full_title = link_to(simple_sanitize(group.name), group_path(group))
+ full_title += ' &middot; '.html_safe + link_to(simple_sanitize(name), url) if name
+
+ content_tag :span do
+ full_title
end
end
end
diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb
index f8169b4f288..81773e7afcf 100644
--- a/app/helpers/merge_requests_helper.rb
+++ b/app/helpers/merge_requests_helper.rb
@@ -71,4 +71,17 @@ module MergeRequestsHelper
merge_request.source_branch
end
end
+
+ def format_mr_branch_names(merge_request)
+ source_path = merge_request.source_project_path
+ target_path = merge_request.target_project_path
+ source_branch = merge_request.source_branch
+ target_branch = merge_request.target_branch
+
+ if source_path == target_path
+ [source_branch, target_branch]
+ else
+ ["#{source_path}:#{source_branch}", "#{target_path}:#{target_branch}"]
+ end
+ end
end
diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb
index 2f8e64c375f..cf11f8e5320 100644
--- a/app/helpers/notifications_helper.rb
+++ b/app/helpers/notifications_helper.rb
@@ -12,4 +12,49 @@ module NotificationsHelper
icon('circle-o', class: 'ns-default')
end
end
+
+ def notification_list_item(notification_level, user_membership)
+ case notification_level
+ when Notification::N_DISABLED
+ content_tag(:li, class: active_level_for(user_membership, Notification::N_DISABLED)) do
+ link_to '#', class: 'update-notification', data: { notification_level: Notification::N_DISABLED } do
+ icon('microphone-slash fw', text: 'Disabled')
+ end
+ end
+ when Notification::N_PARTICIPATING
+ content_tag(:li, class: active_level_for(user_membership, Notification::N_PARTICIPATING)) do
+ link_to '#', class: 'update-notification', data: { notification_level: Notification::N_PARTICIPATING } do
+ icon('volume-up fw', text: 'Participate')
+ end
+ end
+ when Notification::N_WATCH
+ content_tag(:li, class: active_level_for(user_membership, Notification::N_WATCH)) do
+ link_to '#', class: 'update-notification', data: { notification_level: Notification::N_WATCH } do
+ icon('eye fw', text: 'Watch')
+ end
+ end
+ when Notification::N_MENTION
+ content_tag(:li, class: active_level_for(user_membership, Notification::N_MENTION)) do
+ link_to '#', class: 'update-notification', data: { notification_level: Notification::N_MENTION } do
+ icon('at fw', text: 'On mention')
+ end
+ end
+ when Notification::N_GLOBAL
+ content_tag(:li, class: active_level_for(user_membership, Notification::N_GLOBAL)) do
+ link_to '#', class: 'update-notification', data: { notification_level: Notification::N_GLOBAL } do
+ icon('globe fw', text: 'Global')
+ end
+ end
+ else
+ # do nothing
+ end
+ end
+
+ def notification_label(user_membership)
+ Notification.new(user_membership).to_s
+ end
+
+ def active_level_for(user_membership, level)
+ 'active' if user_membership.notification_level == level
+ end
end
diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb
index 8473d6d75d0..775cf5a3dd4 100644
--- a/app/helpers/page_layout_helper.rb
+++ b/app/helpers/page_layout_helper.rb
@@ -26,9 +26,31 @@ module PageLayoutHelper
def fluid_layout(enabled = false)
if @fluid_layout.nil?
- @fluid_layout = enabled
+ @fluid_layout = (current_user && current_user.layout == "fluid") || enabled
else
@fluid_layout
end
end
+
+ def blank_container(enabled = false)
+ if @blank_container.nil?
+ @blank_container = enabled
+ else
+ @blank_container
+ end
+ end
+
+ def container_class
+ css_class = "container-fluid"
+
+ unless fluid_layout
+ css_class += " container-limited"
+ end
+
+ if blank_container
+ css_class += " container-blank"
+ end
+
+ css_class
+ end
end
diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb
index 7f1b6a69926..4710171ebaa 100644
--- a/app/helpers/preferences_helper.rb
+++ b/app/helpers/preferences_helper.rb
@@ -1,9 +1,18 @@
# Helper methods for per-User preferences
module PreferencesHelper
+ def layout_choices
+ [
+ ['Fixed', :fixed],
+ ['Fluid', :fluid]
+ ]
+ end
+
# Maps `dashboard` values to more user-friendly option text
DASHBOARD_CHOICES = {
projects: 'Your Projects (default)',
- stars: 'Starred Projects'
+ stars: 'Starred Projects',
+ project_activity: "Your Projects' Activity",
+ starred_project_activity: "Starred Projects' Activity"
}.with_indifferent_access.freeze
# Returns an Array usable by a select field for more user-friendly option text
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index ab9b068de05..a0220af4c30 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -43,24 +43,22 @@ module ProjectsHelper
end
end
- def project_title(project)
- if project.group
- content_tag :span do
- link_to(
- simple_sanitize(project.group.name), group_path(project.group)
- ) + ' / ' +
- link_to(simple_sanitize(project.name),
- project_path(project))
- end
- else
- owner = project.namespace.owner
- content_tag :span do
- link_to(
- simple_sanitize(owner.name), user_path(owner)
- ) + ' / ' +
- link_to(simple_sanitize(project.name),
- project_path(project))
+ def project_title(project, name = nil, url = nil)
+ namespace_link =
+ if project.group
+ link_to(simple_sanitize(project.group.name), group_path(project.group))
+ else
+ owner = project.namespace.owner
+ link_to(simple_sanitize(owner.name), user_path(owner))
end
+
+ project_link = link_to(simple_sanitize(project.name), project_path(project))
+
+ full_title = namespace_link + ' / ' + project_link
+ full_title += ' &middot; '.html_safe + link_to(simple_sanitize(name), url) if name
+
+ content_tag :span do
+ full_title
end
end
@@ -158,8 +156,8 @@ module ProjectsHelper
end
end
- def repository_size(project = nil)
- "#{(project || @project).repository_size} MB"
+ def repository_size(project = @project)
+ "#{project.repository_size} MB"
rescue
# In order to prevent 500 error
# when application cannot allocate memory
@@ -298,7 +296,7 @@ module ProjectsHelper
def readme_cache_key
sha = @project.commit.try(:sha) || 'nil'
- [@project.id, sha, "readme"].join('-')
+ [@project.path_with_namespace, sha, "readme"].join('-')
end
def round_commit_count(project)
@@ -315,6 +313,10 @@ module ProjectsHelper
end
end
+ def current_ref
+ @ref || @repository.try(:root_ref)
+ end
+
private
def filename_path(project, filename)
diff --git a/app/helpers/runners_helper.rb b/app/helpers/runners_helper.rb
new file mode 100644
index 00000000000..5d7d06c8490
--- /dev/null
+++ b/app/helpers/runners_helper.rb
@@ -0,0 +1,20 @@
+module RunnersHelper
+ def runner_status_icon(runner)
+ unless runner.contacted_at
+ return content_tag :i, nil,
+ class: "fa fa-warning-sign",
+ title: "New runner. Has not connected yet"
+ end
+
+ status =
+ if runner.active?
+ runner.contacted_at > 3.hour.ago ? :online : :offline
+ else
+ :paused
+ end
+
+ content_tag :i, nil,
+ class: "fa fa-circle runner-status-#{status}",
+ title: "Runner is #{status}, last contact was #{time_ago_in_words(runner.contacted_at)} ago"
+ end
+end
diff --git a/app/helpers/time_helper.rb b/app/helpers/time_helper.rb
new file mode 100644
index 00000000000..8142f733e76
--- /dev/null
+++ b/app/helpers/time_helper.rb
@@ -0,0 +1,27 @@
+module TimeHelper
+ def duration_in_words(finished_at, started_at)
+ if finished_at && started_at
+ interval_in_seconds = finished_at.to_i - started_at.to_i
+ elsif started_at
+ interval_in_seconds = Time.now.to_i - started_at.to_i
+ end
+
+ time_interval_in_words(interval_in_seconds)
+ end
+
+ def time_interval_in_words(interval_in_seconds)
+ minutes = interval_in_seconds / 60
+ seconds = interval_in_seconds - minutes * 60
+
+ if minutes >= 1
+ "#{pluralize(minutes, "minute")} #{pluralize(seconds, "second")}"
+ else
+ "#{pluralize(seconds, "second")}"
+ end
+ end
+
+
+ def date_from_to(from, to)
+ "#{from.to_s(:short)} - #{to.to_s(:short)}"
+ end
+end
diff --git a/app/helpers/triggers_helper.rb b/app/helpers/triggers_helper.rb
new file mode 100644
index 00000000000..2a3a7e80fca
--- /dev/null
+++ b/app/helpers/triggers_helper.rb
@@ -0,0 +1,5 @@
+module TriggersHelper
+ def ci_build_trigger_url(project_id, ref_name)
+ "#{Settings.gitlab_ci.url}/ci/api/v1/projects/#{project_id}/refs/#{ref_name}/trigger"
+ end
+end
diff --git a/app/helpers/version_check_helper.rb b/app/helpers/version_check_helper.rb
index f64d730b448..a674564c4ec 100644
--- a/app/helpers/version_check_helper.rb
+++ b/app/helpers/version_check_helper.rb
@@ -1,6 +1,6 @@
module VersionCheckHelper
def version_status_badge
- if Rails.env.production?
+ if Rails.env.production? && current_application_settings.version_check_enabled
image_tag VersionCheck.new.url
end
end
diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb
deleted file mode 100644
index f8a96516e61..00000000000
--- a/app/helpers/wiki_helper.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-module WikiHelper
- # Rails v4.1.9+ escapes all model IDs, converting slashes into %2F. The
- # only way around this is to implement our own path generators.
- def namespace_project_wiki_path(namespace, project, wiki_page, *args)
- slug =
- case wiki_page
- when Symbol
- wiki_page
- when String
- wiki_page
- else
- wiki_page.slug
- end
- namespace_project_path(namespace, project) + "/wikis/#{slug}"
- end
-
- def edit_namespace_project_wiki_path(namespace, project, wiki_page, *args)
- namespace_project_wiki_path(namespace, project, wiki_page) + '/edit'
- end
-
- def history_namespace_project_wiki_path(namespace, project, wiki_page, *args)
- namespace_project_wiki_path(namespace, project, wiki_page) + '/history'
- end
-end