2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
module ExploreHelper
|
2016-09-13 17:45:13 +05:30
|
|
|
def filter_projects_path(options = {})
|
2015-04-26 12:48:37 +05:30
|
|
|
exist_opts = {
|
2017-08-17 22:00:37 +05:30
|
|
|
sort: params[:sort] || @sort,
|
2015-04-26 12:48:37 +05:30
|
|
|
scope: params[:scope],
|
|
|
|
group: params[:group],
|
|
|
|
tag: params[:tag],
|
|
|
|
visibility_level: params[:visibility_level],
|
2017-08-17 22:00:37 +05:30
|
|
|
name: params[:name],
|
|
|
|
personal: params[:personal],
|
|
|
|
archived: params[:archived],
|
|
|
|
shared: params[:shared],
|
2017-09-10 17:25:29 +05:30
|
|
|
namespace_id: params[:namespace_id]
|
2015-04-26 12:48:37 +05:30
|
|
|
}
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
options = exist_opts.merge(options).delete_if { |key, value| value.blank? }
|
|
|
|
request_path_with_options(options)
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_groups_path(options = {})
|
|
|
|
request_path_with_options(options)
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
2016-04-02 18:10:28 +05:30
|
|
|
|
|
|
|
def explore_controller?
|
|
|
|
controller.class.name.split("::").first == "Explore"
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
def explore_nav_links
|
|
|
|
@explore_nav_links ||= get_explore_nav_links
|
|
|
|
end
|
|
|
|
|
|
|
|
def explore_nav_link?(link)
|
|
|
|
explore_nav_links.include?(link)
|
|
|
|
end
|
|
|
|
|
|
|
|
def any_explore_nav_link?(links)
|
|
|
|
links.any? { |link| explore_nav_link?(link) }
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
private
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
def get_explore_nav_links
|
|
|
|
[:projects, :groups, :snippets]
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def request_path_with_options(options = {})
|
|
|
|
request.path + "?#{options.to_param}"
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|