summaryrefslogtreecommitdiff
path: root/app/helpers/gitlab_routing_helper.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-28 15:06:57 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-28 15:06:57 +0000
commit7cdd70dcec27402e89e65451b4b1feb75b5eb267 (patch)
tree1691c8e1afd469fa426ecf5bc127de8df16d4855 /app/helpers/gitlab_routing_helper.rb
parent79348faced5e7e62103ad27f6a6594dfdca463e2 (diff)
downloadgitlab-ce-7cdd70dcec27402e89e65451b4b1feb75b5eb267.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers/gitlab_routing_helper.rb')
-rw-r--r--app/helpers/gitlab_routing_helper.rb95
1 files changed, 95 insertions, 0 deletions
diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb
index 404ea7b00d4..38ca12e6f90 100644
--- a/app/helpers/gitlab_routing_helper.rb
+++ b/app/helpers/gitlab_routing_helper.rb
@@ -193,6 +193,101 @@ module GitlabRoutingHelper
project = schedule.project
take_ownership_project_pipeline_schedule_path(project, schedule, *args)
end
+
+ def snippet_path(snippet, *args)
+ if snippet.is_a?(ProjectSnippet)
+ application_url_helpers.project_snippet_path(snippet.project, snippet, *args)
+ else
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.snippet_path(snippet, *new_args)
+ end
+ end
+
+ def snippet_url(snippet, *args)
+ if snippet.is_a?(ProjectSnippet)
+ application_url_helpers.project_snippet_url(snippet.project, snippet, *args)
+ else
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.snippet_url(snippet, *new_args)
+ end
+ end
+
+ def raw_snippet_path(snippet, *args)
+ if snippet.is_a?(ProjectSnippet)
+ application_url_helpers.raw_project_snippet_path(snippet.project, snippet, *args)
+ else
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.raw_snippet_path(snippet, *new_args)
+ end
+ end
+
+ def raw_snippet_url(snippet, *args)
+ if snippet.is_a?(ProjectSnippet)
+ application_url_helpers.raw_project_snippet_url(snippet.project, snippet, *args)
+ else
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.raw_snippet_url(snippet, *new_args)
+ end
+ end
+
+ def snippet_notes_path(snippet, *args)
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.snippet_notes_path(snippet, *new_args)
+ end
+
+ def snippet_notes_url(snippet, *args)
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.snippet_notes_url(snippet, *new_args)
+ end
+
+ def snippet_note_path(snippet, note, *args)
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.snippet_note_path(snippet, note, *new_args)
+ end
+
+ def snippet_note_url(snippet, note, *args)
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.snippet_note_url(snippet, note, *new_args)
+ end
+
+ def toggle_award_emoji_snippet_note_path(snippet, note, *args)
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.toggle_award_emoji_snippet_note_path(snippet, note, *new_args)
+ end
+
+ def toggle_award_emoji_snippet_note_url(snippet, note, *args)
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.toggle_award_emoji_snippet_note_url(snippet, note, *new_args)
+ end
+
+ def toggle_award_emoji_snippet_path(snippet, *args)
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.toggle_award_emoji_snippet_path(snippet, *new_args)
+ end
+
+ def toggle_award_emoji_snippet_url(snippet, *args)
+ new_args = snippet_query_params(snippet, *args)
+ application_url_helpers.toggle_award_emoji_snippet_url(snippet, *new_args)
+ end
+
+ private
+
+ def application_url_helpers
+ Gitlab::Routing.url_helpers
+ end
+
+ def snippet_query_params(snippet, *args)
+ opts = case args.last
+ when Hash
+ args.pop
+ when ActionController::Parameters
+ args.pop.to_h
+ else
+ {}
+ end
+
+ args << opts
+ end
end
GitlabRoutingHelper.include_if_ee('EE::GitlabRoutingHelper')