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
|
2016-06-02 12:05:06 -04:00
|
|
|
# Project
|
2015-02-25 22:34:16 -05:00
|
|
|
def project_path(project, *args)
|
|
|
|
namespace_project_path(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
def project_url(project, *args)
|
|
|
|
namespace_project_url(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_project_path(project, *args)
|
|
|
|
edit_namespace_project_path(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_project_url(project, *args)
|
|
|
|
edit_namespace_project_url(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
|
|
|
|
|
2016-04-29 09:14:38 -04:00
|
|
|
def project_environments_path(project, *args)
|
|
|
|
namespace_project_environments_path(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
2016-09-14 17:03:42 -04:00
|
|
|
def project_cycle_analytics_path(project, *args)
|
|
|
|
namespace_project_cycle_analytics_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
|
|
|
|
|
2017-05-11 11:47:44 -04:00
|
|
|
def project_ref_path(project, ref_name, *args)
|
|
|
|
namespace_project_commits_path(project.namespace, project, ref_name, *args)
|
|
|
|
end
|
|
|
|
|
2016-05-08 16:50:30 -04:00
|
|
|
def project_container_registry_path(project, *args)
|
2016-05-12 14:03:04 -04:00
|
|
|
namespace_project_container_registry_index_path(project.namespace, project, *args)
|
2016-04-18 08:14:40 -04:00
|
|
|
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-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
|
|
|
|
|
2016-09-21 07:13:50 -04:00
|
|
|
def environment_path(environment, *args)
|
|
|
|
namespace_project_environment_path(environment.project.namespace, environment.project, environment, *args)
|
|
|
|
end
|
|
|
|
|
2017-03-07 11:57:42 -05:00
|
|
|
def environment_metrics_path(environment, *args)
|
|
|
|
metrics_namespace_project_environment_path(environment.project.namespace, environment.project, environment, *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
|
|
|
|
2016-10-24 16:20:27 -04:00
|
|
|
def pipeline_path(pipeline, *args)
|
|
|
|
namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id, *args)
|
|
|
|
end
|
|
|
|
|
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 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
|
|
|
|
2016-10-13 15:33:49 -04:00
|
|
|
def pipeline_url(pipeline, *args)
|
2016-10-14 05:41:56 -04:00
|
|
|
namespace_project_pipeline_url(pipeline.project.namespace, pipeline.project, pipeline.id, *args)
|
2016-10-13 15:33:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def pipeline_build_url(pipeline, build, *args)
|
2016-10-14 08:11:56 -04:00
|
|
|
namespace_project_build_url(pipeline.project.namespace, pipeline.project, build.id, *args)
|
2016-10-13 15:33:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def commits_url(entity, *args)
|
2016-10-14 05:41:56 -04:00
|
|
|
namespace_project_commits_url(entity.project.namespace, entity.project, entity.ref, *args)
|
2016-10-13 15:33:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def commit_url(entity, *args)
|
2016-10-14 05:41:56 -04:00
|
|
|
namespace_project_commit_url(entity.project.namespace, entity.project, entity.sha, *args)
|
2016-10-13 15:33:49 -04:00
|
|
|
end
|
|
|
|
|
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
|
|
|
|
2016-11-16 06:09:09 -05:00
|
|
|
def preview_markdown_path(project, *args)
|
2017-05-03 04:48:01 -04:00
|
|
|
if @snippet.is_a?(PersonalSnippet)
|
|
|
|
preview_markdown_snippet_path(@snippet)
|
|
|
|
else
|
|
|
|
preview_markdown_namespace_project_path(project.namespace, project, *args)
|
|
|
|
end
|
2016-11-16 06:09:09 -05:00
|
|
|
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
|
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)
|
|
|
|
namespace_project_project_members_url(project.namespace, project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def project_member_path(project_member, *args)
|
|
|
|
namespace_project_project_member_path(project_member.source.namespace, project_member.source, project_member)
|
|
|
|
end
|
|
|
|
|
|
|
|
def request_access_project_members_path(project, *args)
|
|
|
|
request_access_namespace_project_project_members_path(project.namespace, project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def leave_project_members_path(project, *args)
|
|
|
|
leave_namespace_project_project_members_path(project.namespace, project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def approve_access_request_project_member_path(project_member, *args)
|
|
|
|
approve_access_request_namespace_project_project_member_path(project_member.source.namespace, project_member.source, project_member)
|
|
|
|
end
|
|
|
|
|
|
|
|
def resend_invite_project_member_path(project_member, *args)
|
|
|
|
resend_invite_namespace_project_project_member_path(project_member.source.namespace, project_member.source, project_member)
|
|
|
|
end
|
|
|
|
|
2016-11-26 10:37:26 -05:00
|
|
|
# Snippets
|
|
|
|
def personal_snippet_url(snippet, *args)
|
|
|
|
snippet_url(snippet)
|
|
|
|
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)
|
|
|
|
args = [project.namespace, 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'
|
2016-08-18 03:31:20 -04:00
|
|
|
download_namespace_project_build_artifacts_path(*args)
|
2016-08-17 05:38:38 -04:00
|
|
|
when 'browse'
|
2016-08-18 03:31:20 -04:00
|
|
|
browse_namespace_project_build_artifacts_path(*args)
|
2016-08-17 05:38:38 -04:00
|
|
|
when 'file'
|
2016-08-18 03:31:20 -04:00
|
|
|
file_namespace_project_build_artifacts_path(*args)
|
2017-05-02 18:42:37 -04:00
|
|
|
when 'raw'
|
|
|
|
raw_namespace_project_build_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)
|
|
|
|
namespace_project_pipeline_schedules_path(project.namespace, project, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def pipeline_schedule_path(schedule, *args)
|
|
|
|
project = schedule.project
|
|
|
|
namespace_project_pipeline_schedule_path(project.namespace, project, schedule, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_pipeline_schedule_path(schedule)
|
|
|
|
project = schedule.project
|
|
|
|
edit_namespace_project_pipeline_schedule_path(project.namespace, project, schedule)
|
|
|
|
end
|
|
|
|
|
|
|
|
def take_ownership_pipeline_schedule_path(schedule, *args)
|
|
|
|
project = schedule.project
|
|
|
|
take_ownership_namespace_project_pipeline_schedule_path(project.namespace, project, schedule, *args)
|
|
|
|
end
|
|
|
|
|
2016-12-22 17:38:27 -05:00
|
|
|
# Settings
|
2016-12-30 12:30:25 -05:00
|
|
|
def project_settings_integrations_path(project, *args)
|
|
|
|
namespace_project_settings_integrations_path(project.namespace, project, *args)
|
|
|
|
end
|
2017-01-23 17:19:39 -05:00
|
|
|
|
2016-12-22 17:38:27 -05:00
|
|
|
def project_settings_members_path(project, *args)
|
|
|
|
namespace_project_settings_members_path(project.namespace, project, *args)
|
|
|
|
end
|
2017-01-23 19:51:16 -05:00
|
|
|
|
|
|
|
def project_settings_ci_cd_path(project, *args)
|
|
|
|
namespace_project_settings_ci_cd_path(project.namespace, project, *args)
|
|
|
|
end
|
2015-02-25 22:34:16 -05:00
|
|
|
end
|