2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
# Shorter routing method for some project items
|
2015-02-25 22:34:16 -05:00
|
|
|
module GitlabRoutingHelper
|
2017-06-29 13:06:35 -04:00
|
|
|
extend ActiveSupport::Concern
|
2016-04-29 09:14:38 -04:00
|
|
|
|
2017-07-08 17:24:18 -04:00
|
|
|
included do
|
|
|
|
Gitlab::Routing.includes_helpers(self)
|
|
|
|
end
|
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
# 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
|
2016-09-14 17:03:42 -04:00
|
|
|
end
|
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
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
|
2015-10-14 06:15:03 -04:00
|
|
|
end
|
|
|
|
|
2017-05-11 11:47:44 -04:00
|
|
|
def project_ref_path(project, ref_name, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_commits_path(project, ref_name, *args)
|
2015-07-07 10:01:12 -04:00
|
|
|
end
|
|
|
|
|
2016-09-21 07:13:50 -04:00
|
|
|
def environment_path(environment, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_environment_path(environment.project, environment, *args)
|
2016-09-21 07:13:50 -04:00
|
|
|
end
|
|
|
|
|
2017-03-07 11:57:42 -05:00
|
|
|
def environment_metrics_path(environment, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
metrics_project_environment_path(environment.project, environment, *args)
|
2017-03-07 11:57:42 -05:00
|
|
|
end
|
|
|
|
|
2015-02-25 22:34:16 -05:00
|
|
|
def issue_path(entity, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_issue_path(entity.project, entity, *args)
|
2015-02-25 22:34:16 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def merge_request_path(entity, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_merge_request_path(entity.project, entity, *args)
|
2015-02-25 22:34:16 -05:00
|
|
|
end
|
2015-03-01 23:15:59 -05:00
|
|
|
|
2016-10-24 16:20:27 -04:00
|
|
|
def pipeline_path(pipeline, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_pipeline_path(pipeline.project, pipeline.id, *args)
|
2016-10-24 16:20:27 -04:00
|
|
|
end
|
|
|
|
|
2015-03-01 23:15:59 -05:00
|
|
|
def issue_url(entity, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_issue_url(entity.project, entity, *args)
|
2015-03-01 23:15:59 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def merge_request_url(entity, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_merge_request_url(entity.project, entity, *args)
|
2015-03-01 23:15:59 -05:00
|
|
|
end
|
2015-03-05 13:38:23 -05:00
|
|
|
|
2016-10-13 15:33:49 -04:00
|
|
|
def pipeline_url(pipeline, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_pipeline_url(pipeline.project, pipeline.id, *args)
|
2016-10-13 15:33:49 -04:00
|
|
|
end
|
|
|
|
|
2017-05-16 07:41:15 -04:00
|
|
|
def pipeline_job_url(pipeline, build, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_job_url(pipeline.project, build.id, *args)
|
2016-10-13 15:33:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def commits_url(entity, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_commits_url(entity.project, entity.ref, *args)
|
2016-10-13 15:33:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def commit_url(entity, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_commit_url(entity.project, entity.sha, *args)
|
2015-03-05 13:38:23 -05:00
|
|
|
end
|
2015-06-25 10:04:50 -04:00
|
|
|
|
2017-11-01 13:35:14 -04:00
|
|
|
def preview_markdown_path(parent, *args)
|
|
|
|
return group_preview_markdown_path(parent) if parent.is_a?(Group)
|
|
|
|
|
2017-05-03 04:48:01 -04:00
|
|
|
if @snippet.is_a?(PersonalSnippet)
|
2017-05-03 11:26:49 -04:00
|
|
|
preview_markdown_snippets_path
|
2017-05-03 04:48:01 -04:00
|
|
|
else
|
2017-11-01 13:35:14 -04:00
|
|
|
preview_markdown_project_path(parent, *args)
|
2017-05-03 04:48:01 -04:00
|
|
|
end
|
2016-11-16 06:09:09 -05:00
|
|
|
end
|
|
|
|
|
2018-04-20 12:03:47 -04:00
|
|
|
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-06-25 10:04:50 -04:00
|
|
|
def toggle_subscription_path(entity, *args)
|
|
|
|
if entity.is_a?(Issue)
|
2017-06-29 13:06:35 -04:00
|
|
|
toggle_subscription_project_issue_path(entity.project, entity)
|
2015-06-25 10:04:50 -04:00
|
|
|
else
|
2017-06-29 13:06:35 -04:00
|
|
|
toggle_subscription_project_merge_request_path(entity.project, entity)
|
2015-06-25 10:04:50 -04:00
|
|
|
end
|
|
|
|
end
|
2016-06-02 12:05:06 -04:00
|
|
|
|
2016-09-07 08:48:43 -04:00
|
|
|
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
|
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
## Members
|
|
|
|
def project_members_url(project, *args)
|
2017-07-07 10:40:41 -04:00
|
|
|
project_project_members_url(project, *args)
|
2016-06-02 12:05:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def project_member_path(project_member, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_project_member_path(project_member.source, project_member)
|
2016-06-02 12:05:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def request_access_project_members_path(project, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
request_access_project_project_members_path(project)
|
2016-06-02 12:05:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def leave_project_members_path(project, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
leave_project_project_members_path(project)
|
2016-06-02 12:05:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def approve_access_request_project_member_path(project_member, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
approve_access_request_project_project_member_path(project_member.source, project_member)
|
2016-06-02 12:05:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def resend_invite_project_member_path(project_member, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
resend_invite_project_project_member_path(project_member.source, project_member)
|
2016-11-26 10:37:26 -05:00
|
|
|
end
|
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
# 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-08-17 05:38:38 -04:00
|
|
|
|
|
|
|
# Artifacts
|
|
|
|
|
2016-08-18 03:31:20 -04:00
|
|
|
def artifacts_action_path(path, project, build)
|
2016-08-24 04:02:56 -04:00
|
|
|
action, path_params = path.split('/', 2)
|
2017-06-29 13:06:35 -04:00
|
|
|
args = [project, build, path_params]
|
2016-08-17 05:38:38 -04:00
|
|
|
|
2016-08-24 04:02:56 -04:00
|
|
|
case action
|
2016-08-17 05:38:38 -04:00
|
|
|
when 'download'
|
2017-06-29 13:06:35 -04:00
|
|
|
download_project_job_artifacts_path(*args)
|
2016-08-17 05:38:38 -04:00
|
|
|
when 'browse'
|
2017-06-29 13:06:35 -04:00
|
|
|
browse_project_job_artifacts_path(*args)
|
2016-08-17 05:38:38 -04:00
|
|
|
when 'file'
|
2017-06-29 13:06:35 -04:00
|
|
|
file_project_job_artifacts_path(*args)
|
2017-05-02 18:42:37 -04:00
|
|
|
when 'raw'
|
2017-06-29 13:06:35 -04:00
|
|
|
raw_project_job_artifacts_path(*args)
|
2016-08-17 05:38:38 -04:00
|
|
|
end
|
|
|
|
end
|
2016-12-22 17:38:27 -05:00
|
|
|
|
2017-05-07 18:35:56 -04:00
|
|
|
# Pipeline Schedules
|
|
|
|
def pipeline_schedules_path(project, *args)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_pipeline_schedules_path(project, *args)
|
2017-05-07 18:35:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def pipeline_schedule_path(schedule, *args)
|
|
|
|
project = schedule.project
|
2017-06-29 13:06:35 -04:00
|
|
|
project_pipeline_schedule_path(project, schedule, *args)
|
2017-05-07 18:35:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit_pipeline_schedule_path(schedule)
|
|
|
|
project = schedule.project
|
2017-06-29 13:06:35 -04:00
|
|
|
edit_project_pipeline_schedule_path(project, schedule)
|
2017-05-07 18:35:56 -04:00
|
|
|
end
|
|
|
|
|
2017-12-06 01:24:20 -05:00
|
|
|
def play_pipeline_schedule_path(schedule, *args)
|
2017-12-03 01:55:49 -05:00
|
|
|
project = schedule.project
|
2017-12-06 01:24:20 -05:00
|
|
|
play_project_pipeline_schedule_path(project, schedule, *args)
|
2017-12-03 01:55:49 -05:00
|
|
|
end
|
|
|
|
|
2017-05-07 18:35:56 -04:00
|
|
|
def take_ownership_pipeline_schedule_path(schedule, *args)
|
|
|
|
project = schedule.project
|
2017-06-29 13:06:35 -04:00
|
|
|
take_ownership_project_pipeline_schedule_path(project, schedule, *args)
|
2017-01-23 19:51:16 -05:00
|
|
|
end
|
2015-02-25 22:34:16 -05:00
|
|
|
end
|