summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb16
-rw-r--r--app/helpers/builds_helper.rb12
-rw-r--r--app/helpers/form_helper.rb32
-rw-r--r--app/helpers/gitlab_routing_helper.rb6
-rw-r--r--app/helpers/issuables_helper.rb10
-rw-r--r--app/helpers/notes_helper.rb43
-rw-r--r--app/helpers/system_note_helper.rb1
7 files changed, 111 insertions, 9 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index fff57472a4f..6d6bcbaf88a 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -180,16 +180,16 @@ module ApplicationHelper
element
end
- def edited_time_ago_with_tooltip(object, placement: 'top', html_class: 'time_ago', include_author: false)
- return if object.updated_at == object.created_at
+ def edited_time_ago_with_tooltip(object, placement: 'top', html_class: 'time_ago', exclude_author: false)
+ return if object.last_edited_at == object.created_at || object.last_edited_at.blank?
- content_tag :small, class: "edited-text" do
- output = content_tag(:span, "Edited ")
- output << time_ago_with_tooltip(object.updated_at, placement: placement, html_class: html_class)
+ content_tag :small, class: 'edited-text' do
+ output = content_tag(:span, 'Edited ')
+ output << time_ago_with_tooltip(object.last_edited_at, placement: placement, html_class: html_class)
- if include_author && object.updated_by && object.updated_by != object.author
- output << content_tag(:span, " by ")
- output << link_to_member(object.project, object.updated_by, avatar: false, author_class: nil)
+ if !exclude_author && object.last_edited_by
+ output << content_tag(:span, ' by ')
+ output << link_to_member(object.project, object.last_edited_by, avatar: false, author_class: nil)
end
output
diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb
index 2fcb7a59fc3..2eb2c6c7389 100644
--- a/app/helpers/builds_helper.rb
+++ b/app/helpers/builds_helper.rb
@@ -1,4 +1,16 @@
module BuildsHelper
+ def build_summary(build, skip: false)
+ if build.has_trace?
+ if skip
+ link_to "View job trace", pipeline_build_url(build.pipeline, build)
+ else
+ build.trace.html(last_lines: 10).html_safe
+ end
+ else
+ "No job trace"
+ end
+ end
+
def sidebar_build_class(build, current_build)
build_class = ''
build_class += ' active' if build.id === current_build.id
diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb
index 1182939f656..53962b84618 100644
--- a/app/helpers/form_helper.rb
+++ b/app/helpers/form_helper.rb
@@ -15,4 +15,36 @@ module FormHelper
end
end
end
+
+ def issue_dropdown_options(issuable, has_multiple_assignees = true)
+ options = {
+ toggle_class: 'js-user-search js-assignee-search js-multiselect js-save-user-data',
+ title: 'Select assignee',
+ filter: true,
+ dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee',
+ placeholder: 'Search users',
+ data: {
+ first_user: current_user&.username,
+ null_user: true,
+ current_user: true,
+ project_id: issuable.project.try(:id),
+ field_name: "#{issuable.class.model_name.param_key}[assignee_ids][]",
+ default_label: 'Assignee',
+ 'max-select': 1,
+ 'dropdown-header': 'Assignee',
+ multi_select: true,
+ 'input-meta': 'name',
+ 'always-show-selectbox': true,
+ current_user_info: current_user.to_json(only: [:id, :name])
+ }
+ }
+
+ if has_multiple_assignees
+ options[:title] = 'Select assignee(s)'
+ options[:data][:'dropdown-header'] = 'Assignee(s)'
+ options[:data].delete(:'max-select')
+ end
+
+ options
+ end
end
diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb
index 88f9a691a17..3769830de2a 100644
--- a/app/helpers/gitlab_routing_helper.rb
+++ b/app/helpers/gitlab_routing_helper.rb
@@ -123,7 +123,11 @@ module GitlabRoutingHelper
end
def preview_markdown_path(project, *args)
- preview_markdown_namespace_project_path(project.namespace, project, *args)
+ if @snippet.is_a?(PersonalSnippet)
+ preview_markdown_snippet_path(@snippet)
+ else
+ preview_markdown_namespace_project_path(project.namespace, project, *args)
+ end
end
def toggle_subscription_path(entity, *args)
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index 0b13dbf5f8d..7656929efe7 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -63,6 +63,16 @@ module IssuablesHelper
end
end
+ def users_dropdown_label(selected_users)
+ if selected_users.length == 0
+ "Unassigned"
+ elsif selected_users.length == 1
+ selected_users[0].name
+ else
+ "#{selected_users[0].name} + #{selected_users.length - 1} more"
+ end
+ end
+
def user_dropdown_label(user_id, default_label)
return default_label if user_id.nil?
return "Unassigned" if user_id == "0"
diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb
index 08180883eb9..52403640c05 100644
--- a/app/helpers/notes_helper.rb
+++ b/app/helpers/notes_helper.rb
@@ -76,4 +76,47 @@ module NotesHelper
namespace_project_commit_path(discussion.project.namespace, discussion.project, discussion.noteable, anchor: anchor)
end
end
+
+ def notes_url
+ if @snippet.is_a?(PersonalSnippet)
+ snippet_notes_path(@snippet)
+ else
+ namespace_project_noteable_notes_path(
+ namespace_id: @project.namespace,
+ project_id: @project,
+ target_id: @noteable.id,
+ target_type: @noteable.class.name.underscore
+ )
+ end
+ end
+
+ def note_url(note)
+ if note.noteable.is_a?(PersonalSnippet)
+ snippet_note_path(note.noteable, note)
+ else
+ namespace_project_note_path(@project.namespace, @project, note)
+ end
+ end
+
+ def form_resources
+ if @snippet.is_a?(PersonalSnippet)
+ [@note]
+ else
+ [@project.namespace.becomes(Namespace), @project, @note]
+ end
+ end
+
+ def new_form_url
+ return nil unless @snippet.is_a?(PersonalSnippet)
+
+ snippet_notes_path(@snippet)
+ end
+
+ def can_create_note?
+ if @snippet.is_a?(PersonalSnippet)
+ can?(current_user, :comment_personal_snippet, @snippet)
+ else
+ can?(current_user, :create_note, @project)
+ end
+ end
end
diff --git a/app/helpers/system_note_helper.rb b/app/helpers/system_note_helper.rb
index 1ea60e39386..d889d141101 100644
--- a/app/helpers/system_note_helper.rb
+++ b/app/helpers/system_note_helper.rb
@@ -1,6 +1,7 @@
module SystemNoteHelper
ICON_NAMES_BY_ACTION = {
'commit' => 'icon_commit',
+ 'description' => 'icon_edit',
'merge' => 'icon_merge',
'merged' => 'icon_merged',
'opened' => 'icon_status_open',