Module: GitlabRoutingHelper

Overview

Shorter routing method for some project items

Instance Method Summary collapse

Methods included from API::Helpers::RelatedResourcesHelpers

#expose_path, #expose_url, #issues_available?, #mrs_available?

Instance Method Details

#approve_access_request_group_member_path(group_member, *args) ⇒ Object


159
160
161
# File 'app/helpers/gitlab_routing_helper.rb', line 159

def approve_access_request_group_member_path(group_member, *args)
  approve_access_request_group_group_member_path(group_member.source, group_member)
end

#approve_access_request_project_member_path(project_member, *args) ⇒ Object


132
133
134
# File 'app/helpers/gitlab_routing_helper.rb', line 132

def approve_access_request_project_member_path(project_member, *args)
  approve_access_request_project_project_member_path(project_member.source, project_member)
end

#artifacts_action_path(path, project, build) ⇒ Object


197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'app/helpers/gitlab_routing_helper.rb', line 197

def artifacts_action_path(path, project, build)
  action, path_params = path.split('/', 2)
  args = [project, build, path_params]

  case action
  when 'download'
    download_project_job_artifacts_path(*args)
  when 'browse'
    browse_project_job_artifacts_path(*args)
  when 'file'
    file_project_job_artifacts_path(*args)
  when 'raw'
    raw_project_job_artifacts_path(*args)
  end
end

#commit_url(entity, *args) ⇒ Object


69
70
71
# File 'app/helpers/gitlab_routing_helper.rb', line 69

def commit_url(entity, *args)
  project_commit_url(entity.project, entity.sha, *args)
end

#commits_url(entity, *args) ⇒ Object


65
66
67
# File 'app/helpers/gitlab_routing_helper.rb', line 65

def commits_url(entity, *args)
  project_commits_url(entity.project, entity.source_ref, *args)
end

#edit_milestone_path(entity, *args) ⇒ Object


87
88
89
90
91
92
93
# File 'app/helpers/gitlab_routing_helper.rb', line 87

def edit_milestone_path(entity, *args)
  if entity.resource_parent.is_a?(Group)
    edit_group_milestone_path(entity.resource_parent, entity, *args)
  else
    edit_project_milestone_path(entity.resource_parent, entity, *args)
  end
end

#edit_pipeline_schedule_path(schedule) ⇒ Object


223
224
225
226
# File 'app/helpers/gitlab_routing_helper.rb', line 223

def edit_pipeline_schedule_path(schedule)
  project = schedule.project
  edit_project_pipeline_schedule_path(project, schedule)
end

#environment_delete_path(environment, *args) ⇒ Object


33
34
35
# File 'app/helpers/gitlab_routing_helper.rb', line 33

def environment_delete_path(environment, *args)
  expose_path(api_v4_projects_environments_path(id: environment.project.id, environment_id: environment.id))
end

#environment_metrics_path(environment, *args) ⇒ Object


29
30
31
# File 'app/helpers/gitlab_routing_helper.rb', line 29

def environment_metrics_path(environment, *args)
  metrics_project_environment_path(environment.project, environment, *args)
end

#environment_path(environment, *args) ⇒ Object


25
26
27
# File 'app/helpers/gitlab_routing_helper.rb', line 25

def environment_path(environment, *args)
  project_environment_path(environment.project, environment, *args)
end

#expose_fast_artifacts_path(project, job, action, params = {}) ⇒ Object


187
188
189
190
191
192
193
194
195
# File 'app/helpers/gitlab_routing_helper.rb', line 187

def expose_fast_artifacts_path(project, job, action, params = {})
  path = "#{project.full_path}/-/jobs/#{job.id}/artifacts/#{action}"

  unless params.empty?
    path += "?#{params.to_query}"
  end

  Gitlab::Utils.append_path(Gitlab.config.gitlab.relative_url_root, path)
end

#fast_browse_project_job_artifacts_path(project, job) ⇒ Object

/*namespace_id/:project_id/-/jobs/:job_id/artifacts/browse(/*path)


183
184
185
# File 'app/helpers/gitlab_routing_helper.rb', line 183

def fast_browse_project_job_artifacts_path(project, job)
  expose_fast_artifacts_path(project, job, :browse)
end

#fast_download_project_job_artifacts_path(project, job, params = {}) ⇒ Object

/*namespace_id/:project_id/-/jobs/:job_id/artifacts/download(.:format)


173
174
175
# File 'app/helpers/gitlab_routing_helper.rb', line 173

def fast_download_project_job_artifacts_path(project, job, params = {})
  expose_fast_artifacts_path(project, job, :download, params)
end

#fast_keep_project_job_artifacts_path(project, job) ⇒ Object

/*namespace_id/:project_id/-/jobs/:job_id/artifacts/keep(.:format)


178
179
180
# File 'app/helpers/gitlab_routing_helper.rb', line 178

def fast_keep_project_job_artifacts_path(project, job)
  expose_fast_artifacts_path(project, job, :keep)
end

#gitlab_dashboard_snippets_path(snippet, *args) ⇒ Object


256
257
258
259
260
261
262
# File 'app/helpers/gitlab_routing_helper.rb', line 256

def gitlab_dashboard_snippets_path(snippet, *args)
  if snippet.is_a?(ProjectSnippet)
    project_snippets_path(snippet.project, *args)
  else
    dashboard_snippets_path
  end
end

#gitlab_raw_snippet_blob_path(snippet, path, ref = nil, **options) ⇒ Object


296
297
298
# File 'app/helpers/gitlab_routing_helper.rb', line 296

def gitlab_raw_snippet_blob_path(snippet, path, ref = nil, **options)
  gitlab_raw_snippet_blob_url(snippet, path, ref, only_path: true, **options)
end

#gitlab_raw_snippet_blob_url(snippet, path, ref = nil, **options) ⇒ Object


282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'app/helpers/gitlab_routing_helper.rb', line 282

def gitlab_raw_snippet_blob_url(snippet, path, ref = nil, **options)
  params = {
    snippet_id: snippet,
    ref: ref || snippet.repository.root_ref,
    path: path
  }

  if snippet.is_a?(ProjectSnippet)
    project_snippet_blob_raw_url(snippet.project, **params, **options)
  else
    snippet_blob_raw_url(**params, **options)
  end
end

#gitlab_raw_snippet_path(snippet, *args) ⇒ Object


264
265
266
267
268
269
270
271
# File 'app/helpers/gitlab_routing_helper.rb', line 264

def gitlab_raw_snippet_path(snippet, *args)
  if snippet.is_a?(ProjectSnippet)
    raw_project_snippet_path(snippet.project, snippet, *args)
  else
    new_args = snippet_query_params(snippet, *args)
    raw_snippet_path(snippet, *new_args)
  end
end

#gitlab_raw_snippet_url(snippet, *args) ⇒ Object


273
274
275
276
277
278
279
280
# File 'app/helpers/gitlab_routing_helper.rb', line 273

def gitlab_raw_snippet_url(snippet, *args)
  if snippet.is_a?(ProjectSnippet)
    raw_project_snippet_url(snippet.project, snippet, *args)
  else
    new_args = snippet_query_params(snippet, *args)
    raw_snippet_url(snippet, *new_args)
  end
end

#gitlab_snippet_note_path(snippet, note, *args) ⇒ Object


310
311
312
313
# File 'app/helpers/gitlab_routing_helper.rb', line 310

def gitlab_snippet_note_path(snippet, note, *args)
  new_args = snippet_query_params(snippet, *args)
  snippet_note_path(snippet, note, *new_args)
end

#gitlab_snippet_note_url(snippet, note, *args) ⇒ Object


315
316
317
318
# File 'app/helpers/gitlab_routing_helper.rb', line 315

def gitlab_snippet_note_url(snippet, note, *args)
  new_args = snippet_query_params(snippet, *args)
  snippet_note_url(snippet, note, *new_args)
end

#gitlab_snippet_notes_path(snippet, *args) ⇒ Object


300
301
302
303
# File 'app/helpers/gitlab_routing_helper.rb', line 300

def gitlab_snippet_notes_path(snippet, *args)
  new_args = snippet_query_params(snippet, *args)
  snippet_notes_path(snippet, *new_args)
end

#gitlab_snippet_notes_url(snippet, *args) ⇒ Object


305
306
307
308
# File 'app/helpers/gitlab_routing_helper.rb', line 305

def gitlab_snippet_notes_url(snippet, *args)
  new_args = snippet_query_params(snippet, *args)
  snippet_notes_url(snippet, *new_args)
end

#gitlab_snippet_path(snippet, *args) ⇒ Object


238
239
240
241
242
243
244
245
# File 'app/helpers/gitlab_routing_helper.rb', line 238

def gitlab_snippet_path(snippet, *args)
  if snippet.is_a?(ProjectSnippet)
    project_snippet_path(snippet.project, snippet, *args)
  else
    new_args = snippet_query_params(snippet, *args)
    snippet_path(snippet, *new_args)
  end
end

#gitlab_snippet_url(snippet, *args) ⇒ Object


247
248
249
250
251
252
253
254
# File 'app/helpers/gitlab_routing_helper.rb', line 247

def gitlab_snippet_url(snippet, *args)
  if snippet.is_a?(ProjectSnippet)
    project_snippet_url(snippet.project, snippet, *args)
  else
    new_args = snippet_query_params(snippet, *args)
    snippet_url(snippet, *new_args)
  end
end

#gitlab_toggle_award_emoji_snippet_note_path(snippet, note, *args) ⇒ Object


320
321
322
323
# File 'app/helpers/gitlab_routing_helper.rb', line 320

def gitlab_toggle_award_emoji_snippet_note_path(snippet, note, *args)
  new_args = snippet_query_params(snippet, *args)
  toggle_award_emoji_snippet_note_path(snippet, note, *new_args)
end

#gitlab_toggle_award_emoji_snippet_note_url(snippet, note, *args) ⇒ Object


325
326
327
328
# File 'app/helpers/gitlab_routing_helper.rb', line 325

def gitlab_toggle_award_emoji_snippet_note_url(snippet, note, *args)
  new_args = snippet_query_params(snippet, *args)
  toggle_award_emoji_snippet_note_url(snippet, note, *new_args)
end

#gitlab_toggle_award_emoji_snippet_path(snippet, *args) ⇒ Object


330
331
332
333
# File 'app/helpers/gitlab_routing_helper.rb', line 330

def gitlab_toggle_award_emoji_snippet_path(snippet, *args)
  new_args = snippet_query_params(snippet, *args)
  toggle_award_emoji_snippet_path(snippet, *new_args)
end

#gitlab_toggle_award_emoji_snippet_url(snippet, *args) ⇒ Object


335
336
337
338
# File 'app/helpers/gitlab_routing_helper.rb', line 335

def gitlab_toggle_award_emoji_snippet_url(snippet, *args)
  new_args = snippet_query_params(snippet, *args)
  toggle_award_emoji_snippet_url(snippet, *new_args)
end

#group_member_path(group_member, *args) ⇒ Object


147
148
149
# File 'app/helpers/gitlab_routing_helper.rb', line 147

def group_member_path(group_member, *args)
  group_group_member_path(group_member.source, group_member)
end

#group_members_url(group, *args) ⇒ Object

Members


143
144
145
# File 'app/helpers/gitlab_routing_helper.rb', line 143

def group_members_url(group, *args)
  group_group_members_url(group, *args)
end

#issue_path(entity, *args) ⇒ Object


37
38
39
# File 'app/helpers/gitlab_routing_helper.rb', line 37

def issue_path(entity, *args)
  project_issue_path(entity.project, entity, *args)
end

#issue_url(entity, *args) ⇒ Object


49
50
51
# File 'app/helpers/gitlab_routing_helper.rb', line 49

def issue_url(entity, *args)
  project_issue_url(entity.project, entity, *args)
end

#leave_group_members_path(group, *args) ⇒ Object


155
156
157
# File 'app/helpers/gitlab_routing_helper.rb', line 155

def leave_group_members_path(group, *args)
  leave_group_group_members_path(group)
end

#leave_project_members_path(project, *args) ⇒ Object


128
129
130
# File 'app/helpers/gitlab_routing_helper.rb', line 128

def leave_project_members_path(project, *args)
  leave_project_project_members_path(project)
end

#merge_request_path(entity, *args) ⇒ Object


41
42
43
# File 'app/helpers/gitlab_routing_helper.rb', line 41

def merge_request_path(entity, *args)
  project_merge_request_path(entity.project, entity, *args)
end

#merge_request_url(entity, *args) ⇒ Object


53
54
55
# File 'app/helpers/gitlab_routing_helper.rb', line 53

def merge_request_url(entity, *args)
  project_merge_request_url(entity.project, entity, *args)
end

#pipeline_job_url(pipeline, build, *args) ⇒ Object


61
62
63
# File 'app/helpers/gitlab_routing_helper.rb', line 61

def pipeline_job_url(pipeline, build, *args)
  project_job_url(pipeline.project, build.id, *args)
end

#pipeline_path(pipeline, *args) ⇒ Object


45
46
47
# File 'app/helpers/gitlab_routing_helper.rb', line 45

def pipeline_path(pipeline, *args)
  project_pipeline_path(pipeline.project, pipeline.id, *args)
end

#pipeline_schedule_path(schedule, *args) ⇒ Object


218
219
220
221
# File 'app/helpers/gitlab_routing_helper.rb', line 218

def pipeline_schedule_path(schedule, *args)
  project = schedule.project
  project_pipeline_schedule_path(project, schedule, *args)
end

#pipeline_schedules_path(project, *args) ⇒ Object

Pipeline Schedules


214
215
216
# File 'app/helpers/gitlab_routing_helper.rb', line 214

def pipeline_schedules_path(project, *args)
  project_pipeline_schedules_path(project, *args)
end

#pipeline_url(pipeline, *args) ⇒ Object


57
58
59
# File 'app/helpers/gitlab_routing_helper.rb', line 57

def pipeline_url(pipeline, *args)
  project_pipeline_url(pipeline.project, pipeline.id, *args)
end

#play_pipeline_schedule_path(schedule, *args) ⇒ Object


228
229
230
231
# File 'app/helpers/gitlab_routing_helper.rb', line 228

def play_pipeline_schedule_path(schedule, *args)
  project = schedule.project
  play_project_pipeline_schedule_path(project, schedule, *args)
end

#preview_markdown_path(parent, *args) ⇒ Object


77
78
79
80
81
82
83
84
85
# File 'app/helpers/gitlab_routing_helper.rb', line 77

def preview_markdown_path(parent, *args)
  return group_preview_markdown_path(parent, *args) if parent.is_a?(Group)

  if @snippet.is_a?(PersonalSnippet)
    preview_markdown_snippets_path
  else
    preview_markdown_project_path(parent, *args)
  end
end

#project_commits_path(project, ref = nil, *args) ⇒ Object


17
18
19
# File 'app/helpers/gitlab_routing_helper.rb', line 17

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
end

#project_member_path(project_member, *args) ⇒ Object


120
121
122
# File 'app/helpers/gitlab_routing_helper.rb', line 120

def project_member_path(project_member, *args)
  project_project_member_path(project_member.source, project_member)
end

#project_members_url(project, *args) ⇒ Object

Members


116
117
118
# File 'app/helpers/gitlab_routing_helper.rb', line 116

def project_members_url(project, *args)
  project_project_members_url(project, *args)
end

#project_ref_path(project, ref_name, *args) ⇒ Object


21
22
23
# File 'app/helpers/gitlab_routing_helper.rb', line 21

def project_ref_path(project, ref_name, *args)
  project_commits_path(project, ref_name, *args)
end

#project_tree_path(project, ref = nil, *args) ⇒ Object

Project


13
14
15
# File 'app/helpers/gitlab_routing_helper.rb', line 13

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
end

#release_url(entity, *args) ⇒ Object


73
74
75
# File 'app/helpers/gitlab_routing_helper.rb', line 73

def release_url(entity, *args)
  project_release_url(entity.project, entity, *args)
end

#request_access_group_members_path(group, *args) ⇒ Object


151
152
153
# File 'app/helpers/gitlab_routing_helper.rb', line 151

def request_access_group_members_path(group, *args)
  request_access_group_group_members_path(group)
end

#request_access_project_members_path(project, *args) ⇒ Object


124
125
126
# File 'app/helpers/gitlab_routing_helper.rb', line 124

def request_access_project_members_path(project, *args)
  request_access_project_project_members_path(project)
end

#resend_invite_group_member_path(group_member, *args) ⇒ Object


163
164
165
# File 'app/helpers/gitlab_routing_helper.rb', line 163

def resend_invite_group_member_path(group_member, *args)
  resend_invite_group_group_member_path(group_member.source, group_member)
end

#resend_invite_project_member_path(project_member, *args) ⇒ Object


136
137
138
# File 'app/helpers/gitlab_routing_helper.rb', line 136

def resend_invite_project_member_path(project_member, *args)
  resend_invite_project_project_member_path(project_member.source, project_member)
end

#take_ownership_pipeline_schedule_path(schedule, *args) ⇒ Object


233
234
235
236
# File 'app/helpers/gitlab_routing_helper.rb', line 233

def take_ownership_pipeline_schedule_path(schedule, *args)
  project = schedule.project
  take_ownership_project_pipeline_schedule_path(project, schedule, *args)
end

#toggle_award_emoji_personal_snippet_path(*args) ⇒ Object


103
104
105
# File 'app/helpers/gitlab_routing_helper.rb', line 103

def toggle_award_emoji_personal_snippet_path(*args)
  toggle_award_emoji_snippet_path(*args)
end

#toggle_award_emoji_project_project_snippet_path(*args) ⇒ Object


107
108
109
# File 'app/helpers/gitlab_routing_helper.rb', line 107

def toggle_award_emoji_project_project_snippet_path(*args)
  toggle_award_emoji_project_snippet_path(*args)
end

#toggle_award_emoji_project_project_snippet_url(*args) ⇒ Object


111
112
113
# File 'app/helpers/gitlab_routing_helper.rb', line 111

def toggle_award_emoji_project_project_snippet_url(*args)
  toggle_award_emoji_project_snippet_url(*args)
end

#toggle_subscription_path(entity, *args) ⇒ Object


95
96
97
98
99
100
101
# File 'app/helpers/gitlab_routing_helper.rb', line 95

def toggle_subscription_path(entity, *args)
  if entity.is_a?(Issue)
    toggle_subscription_project_issue_path(entity.project, entity)
  else
    toggle_subscription_project_merge_request_path(entity.project, entity)
  end
end

#wiki_page_path(wiki, page, **options) ⇒ Object


346
347
348
# File 'app/helpers/gitlab_routing_helper.rb', line 346

def wiki_page_path(wiki, page, **options)
  Gitlab::UrlBuilder.wiki_page_url(wiki, page, only_path: true, **options)
end

#wiki_path(wiki, **options) ⇒ Object

Wikis


342
343
344
# File 'app/helpers/gitlab_routing_helper.rb', line 342

def wiki_path(wiki, **options)
  Gitlab::UrlBuilder.wiki_url(wiki, only_path: true, **options)
end