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
|
|
|
}
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
exist_opts[:language] = params[:language]
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
def public_visibility_restricted?
|
2020-05-05 14:28:15 +05:30
|
|
|
Gitlab::VisibilityLevel.public_visibility_restricted?
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
def projects_filter_items
|
|
|
|
[
|
|
|
|
{ value: _('Any'), text: _('Any'), href: filter_projects_path(visibility_level: nil) },
|
|
|
|
*Gitlab::VisibilityLevel.options.keys.map do |key|
|
|
|
|
{
|
|
|
|
value: key,
|
|
|
|
text: key,
|
|
|
|
href: filter_projects_path(visibility_level: Gitlab::VisibilityLevel.options[key])
|
|
|
|
}
|
|
|
|
end
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def projects_filter_selected(visibility_level)
|
|
|
|
visibility_level.present? ? visibility_level_label(visibility_level.to_i) : _('Any')
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
private
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
def get_explore_nav_links
|
2023-05-27 22:25:52 +05:30
|
|
|
[:projects, :groups, :topics, :snippets]
|
2018-03-27 19:54:05 +05:30
|
|
|
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
|