2015-02-25 22:34:16 -05:00
|
|
|
# Shorter routing method for project and project items
|
2015-02-25 22:41:17 -05:00
|
|
|
# Since update to rails 4.1.9 we are now allowed to use `/` in project routing
|
|
|
|
# so we use nested routing for project resources which include project and
|
|
|
|
# project namespace. To avoid writing long methods every time we define shortcuts for
|
|
|
|
# some of routing.
|
|
|
|
#
|
|
|
|
# For example instead of this:
|
|
|
|
#
|
2015-11-24 22:41:36 -05:00
|
|
|
# namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request)
|
2015-02-25 22:41:17 -05:00
|
|
|
#
|
|
|
|
# We can simply use shortcut:
|
|
|
|
#
|
|
|
|
# merge_request_path(merge_request)
|
|
|
|
#
|
2015-02-25 22:34:16 -05:00
|
|
|
module GitlabRoutingHelper
|
|
|
|
def project_path(project, *args)
|
|
|
|
namespace_project_path(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
2015-09-14 13:46:58 -04:00
|
|
|
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
|
|
|
|
|
2016-03-31 13:51:28 -04:00
|
|
|
def project_pipelines_path(project, *args)
|
|
|
|
namespace_project_pipelines_path(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
2015-10-14 06:15:03 -04:00
|
|
|
def project_builds_path(project, *args)
|
|
|
|
namespace_project_builds_path(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
2015-07-07 10:01:12 -04:00
|
|
|
def activity_project_path(project, *args)
|
|
|
|
activity_namespace_project_path(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
2015-02-25 22:34:16 -05:00
|
|
|
def edit_project_path(project, *args)
|
|
|
|
edit_namespace_project_path(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
2015-09-25 12:03:41 -04:00
|
|
|
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
|
|
|
|
|
2015-02-25 22:34:16 -05:00
|
|
|
def issue_path(entity, *args)
|
|
|
|
namespace_project_issue_path(entity.project.namespace, entity.project, entity, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def merge_request_path(entity, *args)
|
|
|
|
namespace_project_merge_request_path(entity.project.namespace, entity.project, entity, *args)
|
|
|
|
end
|
2015-03-01 23:15:59 -05:00
|
|
|
|
2015-03-31 19:45:47 -04:00
|
|
|
def milestone_path(entity, *args)
|
|
|
|
namespace_project_milestone_path(entity.project.namespace, entity.project, entity, *args)
|
|
|
|
end
|
|
|
|
|
2015-03-01 23:15:59 -05:00
|
|
|
def project_url(project, *args)
|
|
|
|
namespace_project_url(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_project_url(project, *args)
|
|
|
|
edit_namespace_project_url(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def issue_url(entity, *args)
|
|
|
|
namespace_project_issue_url(entity.project.namespace, entity.project, entity, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def merge_request_url(entity, *args)
|
|
|
|
namespace_project_merge_request_url(entity.project.namespace, entity.project, entity, *args)
|
|
|
|
end
|
2015-03-05 13:38:23 -05:00
|
|
|
|
2015-03-07 14:47:06 -05:00
|
|
|
def project_snippet_url(entity, *args)
|
2015-03-05 13:38:23 -05:00
|
|
|
namespace_project_snippet_url(entity.project.namespace, entity.project, entity, *args)
|
|
|
|
end
|
2015-06-25 10:04:50 -04:00
|
|
|
|
|
|
|
def toggle_subscription_path(entity, *args)
|
|
|
|
if entity.is_a?(Issue)
|
|
|
|
toggle_subscription_namespace_project_issue_path(entity.project.namespace, entity.project, entity)
|
|
|
|
else
|
|
|
|
toggle_subscription_namespace_project_merge_request_path(entity.project.namespace, entity.project, entity)
|
|
|
|
end
|
|
|
|
end
|
2015-02-25 22:34:16 -05:00
|
|
|
end
|