gitlab-org--gitlab-foss/app/helpers/dashboard_helper.rb

37 lines
1.2 KiB
Ruby
Raw Normal View History

2011-10-08 17:36:38 -04:00
module DashboardHelper
2011-11-02 16:14:03 -04:00
def dashboard_feed_path(project, object)
2011-10-31 16:57:16 -04:00
case object.class.name.to_s
when "Issue" then project_issue_path(project, project.issues.find(object.id))
2011-11-27 10:35:49 -05:00
when "Commit" then project_commit_path(project, project.repo.commits(object.id).first)
2012-01-28 09:47:55 -05:00
when "MergeRequest" then project_merge_request_path(project, object.id)
2011-11-02 16:14:03 -04:00
when "Note"
2011-11-15 03:34:30 -05:00
then
2011-11-02 16:14:03 -04:00
note = object
case note.noteable_type
when "Issue" then project_issue_path(project, note.noteable_id)
when "Snippet" then project_snippet_path(project, note.noteable_id)
when "Commit" then project_commit_path(project, :id => note.noteable_id)
2011-12-11 17:18:51 -05:00
when "MergeRequest" then project_merge_request_path(project, note.noteable_id)
2011-11-02 16:14:03 -04:00
else wall_project_path(project)
end
2011-11-15 03:34:30 -05:00
else wall_project_path(project)
2011-10-31 16:57:16 -04:00
end
2011-11-15 03:34:30 -05:00
rescue
2011-11-02 16:14:03 -04:00
"#"
end
def dashboard_feed_title(object)
klass = object.class.to_s.split("::").last
title = case klass
2011-11-02 16:14:03 -04:00
when "Note" then markdown(object.note)
when "Issue" then object.title
when "Commit" then object.safe_message
2012-01-28 09:47:55 -05:00
when "MergeRequest" then object.title
2011-11-08 18:56:10 -05:00
else return "Project Wall"
2011-11-02 16:14:03 -04:00
end
2011-11-22 08:33:42 -05:00
truncate(sanitize(title, :tags => []), :length => 60)
2011-10-31 16:57:16 -04:00
end
2011-10-08 17:36:38 -04:00
end