summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-04-13 15:47:18 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-04-13 15:47:18 +0200
commit4af0968c43d517a3d702658749b5117ba4b9e11a (patch)
treed62a15cbcae8e1d1af00208c28fd1b09d01140f1 /app/helpers
parent872bbb9fe2a5fbb5195aa448b615191baae960d7 (diff)
parentf026e53c4df5b0b3bb7435c05d3c8662afe45881 (diff)
downloadgitlab-ce-4af0968c43d517a3d702658749b5117ba4b9e11a.tar.gz
Merge remote-tracking branch 'origin/master' into ci-commit-as-pipeline
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/helpers/issues_helper.rb1
-rw-r--r--app/helpers/namespaces_helper.rb12
-rw-r--r--app/helpers/notifications_helper.rb68
-rw-r--r--app/helpers/projects_helper.rb17
-rw-r--r--app/helpers/todos_helper.rb2
6 files changed, 53 insertions, 49 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e6ceb213532..16e5b8ac223 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -184,7 +184,7 @@ module ApplicationHelper
element = content_tag :time, time.to_s,
class: "#{html_class} js-timeago #{"js-timeago-pending" unless skip_js}",
datetime: time.to_time.getutc.iso8601,
- title: time.in_time_zone.to_s(:medium),
+ title: time.to_time.in_time_zone.to_s(:medium),
data: { toggle: 'tooltip', placement: placement, container: 'body' }
unless skip_js
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index bcf8639c829..4cb8adcebad 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -52,6 +52,7 @@ module IssuesHelper
def milestone_options(object)
milestones = object.project.milestones.active.reorder(due_date: :asc, title: :asc).to_a
+ milestones.unshift(object.milestone) if object.milestone.present? && object.milestone.closed?
milestones.unshift(Milestone::None)
options_from_collection_for_select(milestones, 'id', 'title', object.milestone_id)
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb
index faba418c4db..94c6b548ecd 100644
--- a/app/helpers/namespaces_helper.rb
+++ b/app/helpers/namespaces_helper.rb
@@ -3,8 +3,16 @@ module NamespacesHelper
groups = current_user.owned_groups + current_user.masters_groups
users = [current_user.namespace]
- group_opts = ["Groups", groups.sort_by(&:human_name).map {|g| [display_path ? g.path : g.human_name, g.id]} ]
- users_opts = [ "Users", users.sort_by(&:human_name).map {|u| [display_path ? u.path : u.human_name, u.id]} ]
+ data_attr_group = { 'data-options-parent' => 'groups' }
+ data_attr_users = { 'data-options-parent' => 'users' }
+
+ group_opts = [
+ "Groups", groups.sort_by(&:human_name).map { |g| [display_path ? g.path : g.human_name, g.id, data_attr_group] }
+ ]
+
+ users_opts = [
+ "Users", users.sort_by(&:human_name).map { |u| [display_path ? u.path : u.human_name, u.id, data_attr_users] }
+ ]
options = []
options << group_opts
diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb
index 499c655d2bf..54ab9179efc 100644
--- a/app/helpers/notifications_helper.rb
+++ b/app/helpers/notifications_helper.rb
@@ -1,48 +1,48 @@
module NotificationsHelper
include IconsHelper
- def notification_icon(notification)
- if notification.disabled?
- icon('volume-off', class: 'ns-mute')
- elsif notification.participating?
- icon('volume-down', class: 'ns-part')
- elsif notification.watch?
- icon('volume-up', class: 'ns-watch')
- else
- icon('circle-o', class: 'ns-default')
+ def notification_icon_class(level)
+ case level.to_sym
+ when :disabled
+ 'microphone-slash'
+ when :participating
+ 'volume-up'
+ when :watch
+ 'eye'
+ when :mention
+ 'at'
+ when :global
+ 'globe'
end
end
- def notification_list_item(notification_level, user_membership)
- case notification_level
- when Notification::N_DISABLED
- update_notification_link(Notification::N_DISABLED, user_membership, 'Disabled', 'microphone-slash')
- when Notification::N_PARTICIPATING
- update_notification_link(Notification::N_PARTICIPATING, user_membership, 'Participate', 'volume-up')
- when Notification::N_WATCH
- update_notification_link(Notification::N_WATCH, user_membership, 'Watch', 'eye')
- when Notification::N_MENTION
- update_notification_link(Notification::N_MENTION, user_membership, 'On mention', 'at')
- when Notification::N_GLOBAL
- update_notification_link(Notification::N_GLOBAL, user_membership, 'Global', 'globe')
- else
- # do nothing
- end
+ def notification_icon(level, text = nil)
+ icon("#{notification_icon_class(level)} fw", text: text)
end
- def update_notification_link(notification_level, user_membership, title, icon)
- content_tag(:li, class: active_level_for(user_membership, notification_level)) do
- link_to '#', class: 'update-notification', data: { notification_level: notification_level } do
- icon("#{icon} fw", text: title)
- end
+ def notification_title(level)
+ case level.to_sym
+ when :participating
+ 'Participate'
+ when :mention
+ 'On mention'
+ else
+ level.to_s.titlecase
end
end
- def notification_label(user_membership)
- Notification.new(user_membership).to_s
- end
+ def notification_list_item(level, setting)
+ title = notification_title(level)
+
+ data = {
+ notification_level: level,
+ notification_title: title
+ }
- def active_level_for(user_membership, level)
- 'active' if user_membership.notification_level == level
+ content_tag(:li, class: ('active' if setting.level == level)) do
+ link_to '#', class: 'update-notification', data: data do
+ notification_icon(level, title)
+ end
+ end
end
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 4e4c6e301d5..7e00aacceaa 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -65,21 +65,14 @@ module ProjectsHelper
link_to(simple_sanitize(owner.name), user_path(owner))
end
- project_link = link_to project_path(project), { class: "project-item-select-holder" } do
- link_output = simple_sanitize(project.name)
+ project_link = link_to simple_sanitize(project.name), project_path(project), { class: "project-item-select-holder" }
- if current_user
- link_output += project_select_tag :project_path,
- class: "project-item-select js-projects-dropdown",
- data: { include_groups: false, order_by: 'last_activity_at' }
- end
-
- link_output
+ if current_user
+ project_link << icon("chevron-down", class: "dropdown-toggle-caret js-projects-dropdown-toggle", data: { target: ".js-dropdown-menu-projects", toggle: "dropdown" })
end
- project_link += icon "chevron-down", class: "dropdown-toggle-caret js-projects-dropdown-toggle" if current_user
- full_title = namespace_link + ' / ' + project_link
- full_title += ' &middot; '.html_safe + link_to(simple_sanitize(name), url) if name
+ full_title = "#{namespace_link} / #{project_link}".html_safe
+ full_title << ' &middot; '.html_safe << link_to(simple_sanitize(name), url) if name
full_title
end
diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb
index edc5686cf08..2f066682180 100644
--- a/app/helpers/todos_helper.rb
+++ b/app/helpers/todos_helper.rb
@@ -20,6 +20,8 @@ module TodosHelper
end
def todo_target_path(todo)
+ return unless todo.target.present?
+
anchor = dom_id(todo.note) if todo.note.present?
if todo.for_commit?