diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-01 00:06:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-01 00:06:28 +0300 |
commit | 8f210aebe1d740e8ee194f171f1f33a6e1fba313 (patch) | |
tree | f43c545801bb96fd0737f18493fb30ab92972627 /app/helpers | |
parent | 996f700997805b3590da8d8afdd19d193989078a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_settings_helper.rb | 1 | ||||
-rw-r--r-- | app/helpers/icons_helper.rb | 6 | ||||
-rw-r--r-- | app/helpers/wiki_helper.rb | 107 |
3 files changed, 9 insertions, 105 deletions
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 7b5a1a02b98..f90ad0c300c 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -290,6 +290,7 @@ module ApplicationSettingsHelper :snowplow_cookie_domain, :snowplow_enabled, :snowplow_site_id, + :snowplow_iglu_registry_url, :push_event_hooks_limit, :push_event_activities_limit, :custom_http_clone_url_root, diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 66b88f6b626..4f73270577f 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -41,12 +41,6 @@ module IconsHelper ActionController::Base.helpers.image_path('file_icons.svg', host: sprite_base_url) end - def sprite_icon_with_text(icon_name, content, opts = {}) - wrapper_class = opts.delete(:wrapper_class) - icon = sprite_icon(icon_name, opts) - content_tag(:span, [icon, content].join('').html_safe, class: wrapper_class) - end - def sprite_icon(icon_name, size: nil, css_class: nil) if Gitlab::Sentry.should_raise_for_dev? unless known_sprites.include?(icon_name) diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb index 3cf610cbd38..dd8fde2a697 100644 --- a/app/helpers/wiki_helper.rb +++ b/app/helpers/wiki_helper.rb @@ -48,23 +48,14 @@ module WikiHelper expose_url(api_v4_projects_wikis_attachments_path(id: @project.id)) end - WIKI_SORT_CSS_CLASSES = 'btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort rspec-reverse-sort' - - def wiki_sort_controls(sort_params = {}, &block) - current_sort = sort_params[:sort] || ProjectWiki::TITLE_ORDER - current_direction = (sort_params[:direction] || 'asc').inquiry - - reversed_direction = current_direction.desc? ? 'asc' : 'desc' - icon_class = current_direction.desc? ? 'highest' : 'lowest' - - sorting = sort_params.merge(sort: current_sort, direction: reversed_direction) - opts = { - type: 'button', - class: WIKI_SORT_CSS_CLASSES, - title: _('Sort direction') - } - - link_to(yield(sorting), opts) do + def wiki_sort_controls(project, sort, direction) + sort ||= ProjectWiki::TITLE_ORDER + link_class = 'btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort rspec-reverse-sort' + reversed_direction = direction == 'desc' ? 'asc' : 'desc' + icon_class = direction == 'desc' ? 'highest' : 'lowest' + + link_to(project_wikis_pages_path(project, sort: sort, direction: reversed_direction), + type: 'button', class: link_class, title: _('Sort direction')) do sprite_icon("sort-#{icon_class}", size: 16) end end @@ -76,86 +67,4 @@ module WikiHelper s_("Wiki|Title") end end - - # Render the sprite icon given the current show_children state - def wiki_show_children_icon(nesting) - icon_name, icon_text = - case nesting - when ProjectWiki::NESTING_TREE - ['folder-open', s_("Wiki|Show folder contents")] - when ProjectWiki::NESTING_CLOSED - ['folder-o', s_("Wiki|Hide folder contents")] - else - ['list-bulleted', s_("Wiki|Show files separately")] - end - - sprite_icon_with_text(icon_name, icon_text, size: 16) - end - - def wiki_page_link(wiki_page, nesting, project) - link = link_to(wiki_page.title, - project_wiki_path(project, wiki_page), - class: 'wiki-page-title') - - case nesting - when ProjectWiki::NESTING_FLAT - tags = [] - if wiki_page.directory.present? - wiki_dir = WikiDirectory.new(wiki_page.directory) - tags << link_to(wiki_dir.slug, project_wiki_dir_path(project, wiki_dir), class: 'wiki-page-dir-name') - tags << content_tag(:span, '/', class: 'wiki-page-name-separator') - end - - tags << link - tags.join.html_safe - else - link - end - end - - def sort_params_config - { - keys: [:sort, :direction], - defaults: { - sort: ProjectWiki::TITLE_ORDER, direction: ProjectWiki::DIRECTION_ASC - }, - allowed: { - sort: ProjectWiki::SORT_ORDERS, direction: ProjectWiki::SORT_DIRECTIONS - } - } - end - - def nesting_params_config(sort_key) - default_val = case sort_key - when ProjectWiki::CREATED_AT_ORDER - ProjectWiki::NESTING_FLAT - else - ProjectWiki::NESTING_CLOSED - end - { - keys: [:show_children], - defaults: { show_children: default_val }, - allowed: { show_children: ProjectWiki::NESTINGS } - } - end - - def process_params(config) - unprocessed = params.permit(*config[:keys]) - - processed = unprocessed - .with_defaults(config[:defaults]) - .tap { |h| Gitlab::Utils.allow_hash_values(h, config[:allowed]) } - .to_hash - .transform_keys(&:to_sym) - - if processed.keys == config[:keys] - processed.size == 1 ? processed.values.first : processed - else - raise ActionController::BadRequest, "illegal parameters: #{unprocessed}" - end - end - - def home_page? - params[:id] == 'home' - end end |