diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-12-06 20:53:07 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-12-06 20:53:07 +0800 |
commit | d6287ab230d1507893895397e759eaf38377cb18 (patch) | |
tree | 76030a4c6599c04245b1d13ed062dd299a568a01 /app/helpers | |
parent | 28102ec28e1ef3d3203db3d05aa89ab3da234e70 (diff) | |
parent | e27fa5bc14382abb4383ad5df2867f23bf9f1092 (diff) | |
download | gitlab-ce-d6287ab230d1507893895397e759eaf38377cb18.tar.gz |
Merge remote-tracking branch 'upstream/master' into feature/1376-allow-write-access-deploy-keys
* upstream/master: (488 commits)
Merge branch 'issue_25064' into 'security'
It's secret variables, not secure
Fix dead links, add example of debug trace output, simplify titles
Authorize users into imported GitLab project
Document button secondary states. Update icons and color section
Remove unused votes.scss
Remove unused errors css
Fixed MR widget content wrapping for XS viewports
NIGNX -> Nginx
Use pry-byebug instead byebug
Fixed influence from other specs.
Accept `issue new` as command to create an issue
Update paranoia from 2.1.4 to 2.2.0.
Use the pagination helper in the API
Added changelog for #25221
Fixed top margin for Builds page status header information
Satisfied eslint
Fix compatibility with Internet Explorer 11 for merge requests
change the date label to match the date used
fix gfm doc typo about two spaces for next line transfer
...
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_settings_helper.rb | 8 | ||||
-rw-r--r-- | app/helpers/builds_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/ci_status_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/dropdowns_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/gitlab_markdown_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/groups_helper.rb | 6 | ||||
-rw-r--r-- | app/helpers/issuables_helper.rb | 28 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/labels_helper.rb | 9 | ||||
-rw-r--r-- | app/helpers/lfs_helper.rb | 85 | ||||
-rw-r--r-- | app/helpers/milestones_helper.rb | 24 | ||||
-rw-r--r-- | app/helpers/nav_helper.rb | 5 | ||||
-rw-r--r-- | app/helpers/projects_helper.rb | 16 | ||||
-rw-r--r-- | app/helpers/sidekiq_helper.rb | 10 |
14 files changed, 63 insertions, 138 deletions
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 6d10fe3e9d7..60485160495 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -67,14 +67,14 @@ module ApplicationSettingsHelper def import_sources_checkboxes(help_block_id) Gitlab::ImportSources.options.map do |name, source| checked = current_application_settings.import_sources.include?(source) - css_class = 'btn' - css_class += ' active' if checked + css_class = checked ? 'active' : '' checkbox_name = 'application_setting[import_sources][]' - label_tag(checkbox_name, class: css_class) do + label_tag(name, class: css_class) do check_box_tag(checkbox_name, source, checked, autocomplete: 'off', - 'aria-describedby' => help_block_id) + name + 'aria-describedby' => help_block_id, + id: name.tr(' ', '_')) + name end end end diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb index fde297c588e..9fc69e12266 100644 --- a/app/helpers/builds_helper.rb +++ b/app/helpers/builds_helper.rb @@ -12,7 +12,7 @@ module BuildsHelper build_url: namespace_project_build_url(@project.namespace, @project, @build, :json), build_status: @build.status, build_stage: @build.stage, - state1: @build.trace_with_state[:state] + log_state: @build.trace_with_state[:state].to_s } end end diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index 895c3d728ad..abcf84b4d15 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -5,7 +5,7 @@ module CiStatusHelper end def ci_status_with_icon(status, target = nil) - content = ci_icon_for_status(status) + ' '.html_safe + ci_label_for_status(status) + content = ci_icon_for_status(status) + ci_label_for_status(status) klass = "ci-status ci-#{status}" if target link_to content, target, class: klass diff --git a/app/helpers/dropdowns_helper.rb b/app/helpers/dropdowns_helper.rb index cbab1fd5967..81e0b6bb5ae 100644 --- a/app/helpers/dropdowns_helper.rb +++ b/app/helpers/dropdowns_helper.rb @@ -43,7 +43,7 @@ module DropdownsHelper default_label = data_attr[:default_label] content_tag(:button, class: "dropdown-menu-toggle #{options[:toggle_class] if options.has_key?(:toggle_class)}", id: (options[:id] if options.has_key?(:id)), type: "button", data: data_attr) do output = content_tag(:span, toggle_text, class: "dropdown-toggle-text #{'is-default' if toggle_text == default_label}") - output << icon('caret-down') + output << icon('chevron-down') output.html_safe end end diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index 0772d848289..eb435cc1783 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -174,7 +174,7 @@ module GitlabMarkdownHelper # Returns a String def cross_project_reference(project, entity) if entity.respond_to?(:to_reference) - "#{project.to_reference}#{entity.to_reference}" + entity.to_reference(project) else '' end diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 75cd9eece5c..19ab059aea6 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -8,11 +8,7 @@ module GroupsHelper group = Group.find_by(path: group) end - if group && group.avatar.present? - group.avatar.url - else - image_path('no_group_avatar.png') - end + group.try(:avatar_url) || image_path('no_group_avatar.png') end def group_title(group, name = nil, url = nil) diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 8bebda07787..8231f8fa334 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -143,6 +143,20 @@ module IssuablesHelper end end + def issuable_filter_params + [ + :search, + :author_id, + :assignee_id, + :milestone_title, + :label_name + ] + end + + def issuable_filter_present? + issuable_filter_params.any? { |k| params.key?(k) } + end + private def assigned_issuables_count(assignee, issuable_type, state) @@ -165,17 +179,10 @@ module IssuablesHelper end end - def issuable_filters_present - params[:search] || params[:author_id] || params[:assignee_id] || params[:milestone_title] || params[:label_name] - end - def issuables_count_for_state(issuable_type, state) - issuables_finder = public_send("#{issuable_type}_finder") - - params = issuables_finder.params.merge(state: state) - finder = issuables_finder.class.new(issuables_finder.current_user, params) - - finder.execute.page(1).total_count + @counts ||= {} + @counts[issuable_type] ||= public_send("#{issuable_type}_finder").count_by_state + @counts[issuable_type][state] end IRRELEVANT_PARAMS_FOR_CACHE_KEY = %i[utf8 sort page] @@ -185,6 +192,7 @@ module IssuablesHelper opts = params.with_indifferent_access opts[:state] = state opts.except!(*IRRELEVANT_PARAMS_FOR_CACHE_KEY) + opts.delete_if { |_, value| value.blank? } hexdigest(['issuables_count', issuable_type, opts.sort].flatten.join('-')) end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 1644c346dd8..a8a49e43b05 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -64,6 +64,8 @@ module IssuesHelper 'status-box-merged' elsif item.closed? 'status-box-closed' + elsif item.respond_to?(:upcoming?) && item.upcoming? + 'status-box-upcoming' else 'status-box-open' end diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 4f180456b16..e5b1e6e8bc7 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -82,12 +82,6 @@ module LabelsHelper span.html_safe end - def render_colored_cross_project_label(label, source_project = nil, tooltip: true) - label_suffix = source_project ? source_project.name_with_namespace : label.project.name_with_namespace - label_suffix = " <i>in #{escape_once(label_suffix)}</i>" - render_colored_label(label, label_suffix, tooltip: tooltip) - end - def suggested_colors [ '#0033CC', @@ -166,6 +160,5 @@ module LabelsHelper end # Required for Banzai::Filter::LabelReferenceFilter - module_function :render_colored_label, :render_colored_cross_project_label, - :text_color_for_bg, :escape_once + module_function :render_colored_label, :text_color_for_bg, :escape_once end diff --git a/app/helpers/lfs_helper.rb b/app/helpers/lfs_helper.rb deleted file mode 100644 index 2425c3a8bc8..00000000000 --- a/app/helpers/lfs_helper.rb +++ /dev/null @@ -1,85 +0,0 @@ -module LfsHelper - include Gitlab::Routing.url_helpers - - def require_lfs_enabled! - return if Gitlab.config.lfs.enabled - - render( - json: { - message: 'Git LFS is not enabled on this GitLab server, contact your admin.', - documentation_url: help_url, - }, - status: 501 - ) - end - - def lfs_check_access! - return if download_request? && lfs_download_access? - return if upload_request? && lfs_upload_access? - - if project.public? || (user && user.can?(:read_project, project)) - render_lfs_forbidden - else - render_lfs_not_found - end - end - - def lfs_download_access? - return false unless project.lfs_enabled? - - ci? || lfs_deploy_token? || user_can_download_code? || build_can_download_code? - end - - def objects - @objects ||= (params[:objects] || []).to_a - end - - def user_can_download_code? - has_authentication_ability?(:download_code) && can?(user, :download_code, project) - end - - def build_can_download_code? - has_authentication_ability?(:build_download_code) && can?(user, :build_download_code, project) - end - - def lfs_upload_access? - return false unless project.lfs_enabled? - - has_authentication_ability?(:push_code) && can?(user, :push_code, project) - end - - def render_lfs_forbidden - render( - json: { - message: 'Access forbidden. Check your access level.', - documentation_url: help_url, - }, - content_type: "application/vnd.git-lfs+json", - status: 403 - ) - end - - def render_lfs_not_found - render( - json: { - message: 'Not found.', - documentation_url: help_url, - }, - content_type: "application/vnd.git-lfs+json", - status: 404 - ) - end - - def storage_project - @storage_project ||= begin - result = project - - loop do - break unless result.forked? - result = result.forked_from_project - end - - result - end - end -end diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb index 83a2a4ad3ec..729928ce1dd 100644 --- a/app/helpers/milestones_helper.rb +++ b/app/helpers/milestones_helper.rb @@ -86,6 +86,30 @@ module MilestonesHelper days = milestone.remaining_days content = content_tag(:strong, days) content << " #{'day'.pluralize(days)} remaining" + elsif milestone.upcoming? + content_tag(:strong, 'Upcoming') + elsif milestone.start_date && milestone.start_date.past? + days = milestone.elapsed_days + content = content_tag(:strong, days) + content << " #{'day'.pluralize(days)} elapsed" + end + end + + def milestone_date_range(milestone) + if milestone.start_date && milestone.due_date + "#{milestone.start_date.to_s(:medium)} - #{milestone.due_date.to_s(:medium)}" + elsif milestone.due_date + if milestone.due_date.past? + "expired on #{milestone.due_date.to_s(:medium)}" + else + "expires on #{milestone.due_date.to_s(:medium)}" + end + elsif milestone.start_date + if milestone.start_date.past? + "started on #{milestone.start_date.to_s(:medium)}" + else + "starts on #{milestone.start_date.to_s(:medium)}" + end end end end diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb index df87fac132d..a3331dc80cb 100644 --- a/app/helpers/nav_helper.rb +++ b/app/helpers/nav_helper.rb @@ -20,6 +20,11 @@ module NavHelper end elsif current_path?('builds#show') "page-gutter build-sidebar right-sidebar-expanded" + elsif current_path?('wikis#show') || + current_path?('wikis#edit') || + current_path?('wikis#history') || + current_path?('wikis#git_access') + "page-gutter wiki-sidebar right-sidebar-expanded" end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 704a80dd958..3acbc5fea27 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -392,21 +392,7 @@ module ProjectsHelper "success" end end - - def new_readme_path - ref = @repository.root_ref if @repository - ref ||= 'master' - - namespace_project_new_blob_path(@project.namespace, @project, tree_join(ref), file_name: 'README.md') - end - - def new_license_path - ref = @repository.root_ref if @repository - ref ||= 'master' - - namespace_project_new_blob_path(@project.namespace, @project, tree_join(ref), file_name: 'LICENSE') - end - + def readme_cache_key sha = @project.commit.try(:sha) || 'nil' [@project.path_with_namespace, sha, "readme"].join('-') diff --git a/app/helpers/sidekiq_helper.rb b/app/helpers/sidekiq_helper.rb index 56749d80bd3..b5017080cfb 100644 --- a/app/helpers/sidekiq_helper.rb +++ b/app/helpers/sidekiq_helper.rb @@ -5,15 +5,11 @@ module SidekiqHelper (?<mem>[\d\.,]+)\s+ (?<state>[DRSTWXZNLsl\+<]+)\s+ (?<start>.+)\s+ - (?<command>sidekiq.*\])\s* + (?<command>sidekiq.*\]) \z/x def parse_sidekiq_ps(line) - match = line.match(SIDEKIQ_PS_REGEXP) - if match - match[1..6] - else - %w[? ? ? ? ? ?] - end + match = line.strip.match(SIDEKIQ_PS_REGEXP) + match ? match[1..6] : Array.new(6, '?') end end |