2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-03-10 18:59:14 -04:00
|
|
|
module ExploreHelper
|
2016-08-05 22:03:01 -04:00
|
|
|
def filter_projects_path(options = {})
|
2015-03-10 18:59:14 -04:00
|
|
|
exist_opts = {
|
2017-03-03 05:13:03 -05:00
|
|
|
sort: params[:sort] || @sort,
|
2015-03-10 18:59:14 -04:00
|
|
|
scope: params[:scope],
|
|
|
|
group: params[:group],
|
|
|
|
tag: params[:tag],
|
|
|
|
visibility_level: params[:visibility_level],
|
2017-03-03 05:13:03 -05:00
|
|
|
name: params[:name],
|
|
|
|
personal: params[:personal],
|
|
|
|
archived: params[:archived],
|
|
|
|
shared: params[:shared],
|
2017-05-03 07:22:03 -04:00
|
|
|
namespace_id: params[:namespace_id]
|
2015-03-10 18:59:14 -04:00
|
|
|
}
|
|
|
|
|
2017-03-03 13:03:58 -05:00
|
|
|
options = exist_opts.merge(options).delete_if { |key, value| value.blank? }
|
2017-03-01 08:31:56 -05:00
|
|
|
request_path_with_options(options)
|
|
|
|
end
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
def filter_audit_path(options = {})
|
|
|
|
exist_opts = {
|
|
|
|
entity_type: params[:entity_type],
|
|
|
|
entity_id: params[:entity_id],
|
|
|
|
created_before: params[:created_before],
|
|
|
|
created_after: params[:created_after],
|
|
|
|
sort: params[:sort]
|
|
|
|
}
|
|
|
|
options = exist_opts.merge(options).delete_if { |key, value| value.blank? }
|
|
|
|
request_path_with_options(options)
|
|
|
|
end
|
|
|
|
|
2017-03-01 08:31:56 -05:00
|
|
|
def filter_groups_path(options = {})
|
|
|
|
request_path_with_options(options)
|
2015-03-10 18:59:14 -04:00
|
|
|
end
|
2016-02-03 14:13:26 -05:00
|
|
|
|
|
|
|
def explore_controller?
|
|
|
|
controller.class.name.split("::").first == "Explore"
|
|
|
|
end
|
2017-03-01 08:31:56 -05:00
|
|
|
|
2017-12-11 09:21:06 -05:00
|
|
|
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
|
|
|
|
|
2020-04-15 11:09:17 -04:00
|
|
|
def public_visibility_restricted?
|
2020-04-27 14:09:41 -04:00
|
|
|
Gitlab::VisibilityLevel.public_visibility_restricted?
|
2020-04-15 11:09:17 -04:00
|
|
|
end
|
|
|
|
|
2017-03-01 08:31:56 -05:00
|
|
|
private
|
|
|
|
|
2017-12-11 09:21:06 -05:00
|
|
|
def get_explore_nav_links
|
|
|
|
[:projects, :groups, :snippets]
|
|
|
|
end
|
|
|
|
|
2017-03-01 08:31:56 -05:00
|
|
|
def request_path_with_options(options = {})
|
|
|
|
request.path + "?#{options.to_param}"
|
|
|
|
end
|
2015-03-10 18:59:14 -04:00
|
|
|
end
|