debian-mirror-gitlab/app/helpers/gitlab_routing_helper.rb

197 lines
5.5 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
# Shorter routing method for some project items
2015-04-26 12:48:37 +05:30
module GitlabRoutingHelper
2017-09-10 17:25:29 +05:30
extend ActiveSupport::Concern
2017-09-10 17:25:29 +05:30
included do
Gitlab::Routing.includes_helpers(self)
2015-09-25 12:07:36 +05:30
end
2017-09-10 17:25:29 +05:30
# Project
def project_tree_path(project, ref = nil, *args)
namespace_project_tree_path(project.namespace, project, ref || @ref || project.repository.root_ref, *args) # rubocop:disable Cop/ProjectPathHelper
2015-10-24 18:46:33 +05:30
end
2017-09-10 17:25:29 +05:30
def project_commits_path(project, ref = nil, *args)
namespace_project_commits_path(project.namespace, project, ref || @ref || project.repository.root_ref, *args) # rubocop:disable Cop/ProjectPathHelper
2016-06-02 11:05:42 +05:30
end
2017-09-10 17:25:29 +05:30
def project_ref_path(project, ref_name, *args)
project_commits_path(project, ref_name, *args)
2015-09-11 14:41:01 +05:30
end
2016-09-29 09:46:39 +05:30
def environment_path(environment, *args)
2017-09-10 17:25:29 +05:30
project_environment_path(environment.project, environment, *args)
2016-09-29 09:46:39 +05:30
end
2017-08-17 22:00:37 +05:30
def environment_metrics_path(environment, *args)
2017-09-10 17:25:29 +05:30
metrics_project_environment_path(environment.project, environment, *args)
2017-08-17 22:00:37 +05:30
end
2015-04-26 12:48:37 +05:30
def issue_path(entity, *args)
2017-09-10 17:25:29 +05:30
project_issue_path(entity.project, entity, *args)
2015-04-26 12:48:37 +05:30
end
def merge_request_path(entity, *args)
2017-09-10 17:25:29 +05:30
project_merge_request_path(entity.project, entity, *args)
2015-04-26 12:48:37 +05:30
end
2017-08-17 22:00:37 +05:30
def pipeline_path(pipeline, *args)
2017-09-10 17:25:29 +05:30
project_pipeline_path(pipeline.project, pipeline.id, *args)
2015-04-26 12:48:37 +05:30
end
def issue_url(entity, *args)
2017-09-10 17:25:29 +05:30
project_issue_url(entity.project, entity, *args)
2015-04-26 12:48:37 +05:30
end
def merge_request_url(entity, *args)
2017-09-10 17:25:29 +05:30
project_merge_request_url(entity.project, entity, *args)
2015-04-26 12:48:37 +05:30
end
2016-11-03 12:29:30 +05:30
def pipeline_url(pipeline, *args)
2017-09-10 17:25:29 +05:30
project_pipeline_url(pipeline.project, pipeline.id, *args)
2016-11-03 12:29:30 +05:30
end
2017-09-10 17:25:29 +05:30
def pipeline_job_url(pipeline, build, *args)
project_job_url(pipeline.project, build.id, *args)
2016-11-03 12:29:30 +05:30
end
def commits_url(entity, *args)
2017-09-10 17:25:29 +05:30
project_commits_url(entity.project, entity.ref, *args)
2016-11-03 12:29:30 +05:30
end
def commit_url(entity, *args)
2017-09-10 17:25:29 +05:30
project_commit_url(entity.project, entity.sha, *args)
2015-04-26 12:48:37 +05:30
end
2015-09-11 14:41:01 +05:30
2018-03-17 18:26:18 +05:30
def preview_markdown_path(parent, *args)
return group_preview_markdown_path(parent) if parent.is_a?(Group)
2017-08-17 22:00:37 +05:30
if @snippet.is_a?(PersonalSnippet)
2017-09-10 17:25:29 +05:30
preview_markdown_snippets_path
2017-08-17 22:00:37 +05:30
else
2018-03-17 18:26:18 +05:30
preview_markdown_project_path(parent, *args)
2017-08-17 22:00:37 +05:30
end
end
2018-10-15 14:42:47 +05:30
def edit_milestone_path(entity, *args)
if entity.parent.is_a?(Group)
edit_group_milestone_path(entity.parent, entity, *args)
else
edit_project_milestone_path(entity.parent, entity, *args)
end
end
2015-09-11 14:41:01 +05:30
def toggle_subscription_path(entity, *args)
if entity.is_a?(Issue)
2017-09-10 17:25:29 +05:30
toggle_subscription_project_issue_path(entity.project, entity)
2015-09-11 14:41:01 +05:30
else
2017-09-10 17:25:29 +05:30
toggle_subscription_project_merge_request_path(entity.project, entity)
2015-09-11 14:41:01 +05:30
end
end
2016-09-29 09:46:39 +05:30
def toggle_award_emoji_personal_snippet_path(*args)
toggle_award_emoji_snippet_path(*args)
end
def toggle_award_emoji_namespace_project_project_snippet_path(*args)
toggle_award_emoji_namespace_project_snippet_path(*args)
end
## Members
def project_members_url(project, *args)
2017-09-10 17:25:29 +05:30
project_project_members_url(project, *args)
end
def project_member_path(project_member, *args)
2017-09-10 17:25:29 +05:30
project_project_member_path(project_member.source, project_member)
end
def request_access_project_members_path(project, *args)
2017-09-10 17:25:29 +05:30
request_access_project_project_members_path(project)
end
def leave_project_members_path(project, *args)
2017-09-10 17:25:29 +05:30
leave_project_project_members_path(project)
end
def approve_access_request_project_member_path(project_member, *args)
2017-09-10 17:25:29 +05:30
approve_access_request_project_project_member_path(project_member.source, project_member)
end
def resend_invite_project_member_path(project_member, *args)
2017-09-10 17:25:29 +05:30
resend_invite_project_project_member_path(project_member.source, project_member)
2017-08-17 22:00:37 +05:30
end
# Groups
## Members
def group_members_url(group, *args)
group_group_members_url(group, *args)
end
def group_member_path(group_member, *args)
group_group_member_path(group_member.source, group_member)
end
def request_access_group_members_path(group, *args)
request_access_group_group_members_path(group)
end
def leave_group_members_path(group, *args)
leave_group_group_members_path(group)
end
def approve_access_request_group_member_path(group_member, *args)
approve_access_request_group_group_member_path(group_member.source, group_member)
end
def resend_invite_group_member_path(group_member, *args)
resend_invite_group_group_member_path(group_member.source, group_member)
end
2016-09-29 09:46:39 +05:30
# Artifacts
def artifacts_action_path(path, project, build)
action, path_params = path.split('/', 2)
2017-09-10 17:25:29 +05:30
args = [project, build, path_params]
2016-09-29 09:46:39 +05:30
case action
when 'download'
2017-09-10 17:25:29 +05:30
download_project_job_artifacts_path(*args)
2016-09-29 09:46:39 +05:30
when 'browse'
2017-09-10 17:25:29 +05:30
browse_project_job_artifacts_path(*args)
2016-09-29 09:46:39 +05:30
when 'file'
2017-09-10 17:25:29 +05:30
file_project_job_artifacts_path(*args)
2017-08-17 22:00:37 +05:30
when 'raw'
2017-09-10 17:25:29 +05:30
raw_project_job_artifacts_path(*args)
2016-09-29 09:46:39 +05:30
end
end
2017-08-17 22:00:37 +05:30
# Pipeline Schedules
def pipeline_schedules_path(project, *args)
2017-09-10 17:25:29 +05:30
project_pipeline_schedules_path(project, *args)
2017-08-17 22:00:37 +05:30
end
def pipeline_schedule_path(schedule, *args)
project = schedule.project
2017-09-10 17:25:29 +05:30
project_pipeline_schedule_path(project, schedule, *args)
2017-08-17 22:00:37 +05:30
end
def edit_pipeline_schedule_path(schedule)
project = schedule.project
2017-09-10 17:25:29 +05:30
edit_project_pipeline_schedule_path(project, schedule)
2017-08-17 22:00:37 +05:30
end
2018-03-17 18:26:18 +05:30
def play_pipeline_schedule_path(schedule, *args)
project = schedule.project
play_project_pipeline_schedule_path(project, schedule, *args)
end
2017-08-17 22:00:37 +05:30
def take_ownership_pipeline_schedule_path(schedule, *args)
project = schedule.project
2017-09-10 17:25:29 +05:30
take_ownership_project_pipeline_schedule_path(project, schedule, *args)
2017-08-17 22:00:37 +05:30
end
2015-04-26 12:48:37 +05:30
end