From 832d7fa3ce3e97113dd783600de57b8d2276d8a1 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 13 Apr 2016 13:11:44 +0100 Subject: Issuable filtering improvements This improves the filtering of issues and merge requests by creating a single file that encapsulates all the filtering. Previously this was done with a file for issues and a file for merge requests. Created the ability for the text search to be done alongside other filterables. Previously because this was outside the filterable form, this wasn't possible and would instead do either filter dropdown or text filter - not both. --- app/helpers/application_helper.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3e0074da394..da4dee443a0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -263,6 +263,7 @@ module ApplicationHelper assignee_id: params[:assignee_id], author_id: params[:author_id], sort: params[:sort], + issue_search: params[:issue_search] } options = exist_opts.merge(options) @@ -273,15 +274,21 @@ module ApplicationHelper end end + params = options.compact.to_param + path = request.path - path << "?#{options.to_param}" - if add_label - if params[:label_name].present? and params[:label_name].respond_to?('any?') - params[:label_name].each do |label| - path << "&label_name[]=#{label}" + + if params != nil + path << "?#{options.to_param}" + if add_label + if params[:label_name].present? and params[:label_name].respond_to?('any?') + params[:label_name].each do |label| + path << "&label_name[]=#{label}" + end end end end + path end -- cgit v1.2.1 From 3a76cc5c411433d39b8ac5e9af037a839767152c Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 13 Apr 2016 16:41:52 +0100 Subject: Fixed Ruby issues --- app/helpers/application_helper.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index da4dee443a0..e6f11f95ec8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -279,7 +279,7 @@ module ApplicationHelper path = request.path if params != nil - path << "?#{options.to_param}" + path << "?#{params}" if add_label if params[:label_name].present? and params[:label_name].respond_to?('any?') params[:label_name].each do |label| @@ -288,7 +288,6 @@ module ApplicationHelper end end end - path end -- cgit v1.2.1 From 1a086745fc9a3e1ad74a7156f7f8bbf826a46b83 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 15 Apr 2016 15:18:55 +0100 Subject: Fixed tests --- app/helpers/application_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6f11f95ec8..27fae716216 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -274,12 +274,12 @@ module ApplicationHelper end end - params = options.compact.to_param + params = options.compact path = request.path if params != nil - path << "?#{params}" + path << "?#{params.to_param}" if add_label if params[:label_name].present? and params[:label_name].respond_to?('any?') params[:label_name].each do |label| -- cgit v1.2.1 From 31b1dc3c31a4da59acd2deff2ded0d6d2aed8557 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 26 Apr 2016 11:10:39 +0100 Subject: Fixed failing rubocop tests Fixed issue with issuable checkboxs not being init'd --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 27fae716216..59a04578c58 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -278,7 +278,7 @@ module ApplicationHelper path = request.path - if params != nil + if !params.nil? path << "?#{params.to_param}" if add_label if params[:label_name].present? and params[:label_name].respond_to?('any?') -- cgit v1.2.1 From 66cebb6f61193a5fb4199b85580a312ed6d94b42 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 21 May 2016 18:02:49 -0500 Subject: Remove `event_to_atom` helper --- app/helpers/events_helper.rb | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index e1489381706..bfedcb1c42b 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -159,28 +159,6 @@ module EventsHelper "--broken encoding" end - def event_to_atom(xml, event) - if event.visible_to_user?(current_user) - xml.entry do - event_link = event_feed_url(event) - event_title = event_feed_title(event) - event_summary = event_feed_summary(event) - - xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}" - xml.link href: event_link - xml.title truncate(event_title, length: 80) - xml.updated event.created_at.xmlschema - xml.media :thumbnail, width: "40", height: "40", url: image_url(avatar_icon(event.author_email)) - xml.author do |author| - xml.name event.author_name - xml.email event.author_email - end - - xml.summary(type: "xhtml") { |x| x << event_summary unless event_summary.nil? } - end - end - end - def event_row_class(event) if event.body? "event-block" -- cgit v1.2.1 From 7001842dc463f1ba9ac4f1479c7310c75707c35b Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 23 May 2016 17:06:26 -0400 Subject: Remove `issue_to_atom` helper --- app/helpers/issues_helper.rb | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 198d39455d7..551409e8855 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -105,23 +105,6 @@ module IssuesHelper return 'hidden' if issue.closed? == closed end - def issue_to_atom(xml, issue) - xml.entry do - xml.id namespace_project_issue_url(issue.project.namespace, - issue.project, issue) - xml.link href: namespace_project_issue_url(issue.project.namespace, - issue.project, issue) - xml.title truncate(issue.title, length: 80) - xml.updated issue.created_at.xmlschema - xml.media :thumbnail, width: "40", height: "40", url: image_url(avatar_icon(issue.author_email)) - xml.author do |author| - xml.name issue.author_name - xml.email issue.author_email - end - xml.summary issue.title - end - end - def merge_requests_sentence(merge_requests) # Sorting based on the `!123` or `group/project!123` reference will sort # local merge requests first. -- cgit v1.2.1 From 5cca2d3bb171c260ad4b07f2a69962d3856c4d99 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 23 May 2016 09:49:13 +0100 Subject: Updated Ruby based on feedback --- app/helpers/application_helper.rb | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 59a04578c58..a3fe1d01292 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -263,7 +263,8 @@ module ApplicationHelper assignee_id: params[:assignee_id], author_id: params[:author_id], sort: params[:sort], - issue_search: params[:issue_search] + issue_search: params[:issue_search], + label_name: params[:label_name] } options = exist_opts.merge(options) @@ -276,19 +277,9 @@ module ApplicationHelper params = options.compact - path = request.path + params.delete(:label_name) unless add_label - if !params.nil? - path << "?#{params.to_param}" - if add_label - if params[:label_name].present? and params[:label_name].respond_to?('any?') - params[:label_name].each do |label| - path << "&label_name[]=#{label}" - end - end - end - end - path + "#{request.path}?#{params.to_param}" end def outdated_browser? -- cgit v1.2.1 From 33be8181ac7a7885ccf5ea4850a87908d974ac28 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 28 Apr 2016 13:54:13 -0500 Subject: Add target status --- app/helpers/todos_helper.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 81b9b5d7052..5d020e7f241 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -37,6 +37,15 @@ module TodosHelper end end + def todo_target_state_pill(todo) + klass = 'status-box ' + klass << "status-box-#{todo.target.state.dasherize}" + + content_tag(:span, nil, class: klass) { + todo.target.state.capitalize + } + end + def todos_filter_params { state: params[:state], -- cgit v1.2.1 From 7586807fc3e01d641dfb1211e7c0a6a92e5e68c0 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 28 Apr 2016 16:37:00 -0500 Subject: Fix syntax --- app/helpers/todos_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 5d020e7f241..e01ff8407c3 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -41,9 +41,9 @@ module TodosHelper klass = 'status-box ' klass << "status-box-#{todo.target.state.dasherize}" - content_tag(:span, nil, class: klass) { + content_tag(:span, nil, class: klass) do todo.target.state.capitalize - } + end end def todos_filter_params -- cgit v1.2.1 From 2c8000e302c7c5382caaa235ece133ade687c7ac Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Tue, 3 May 2016 10:30:33 -0500 Subject: Move conditional to a method --- app/helpers/todos_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index e01ff8407c3..150d826ac44 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -46,6 +46,10 @@ module TodosHelper end end + def show_todo_state?(todo) + (todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && ['closed', 'merged'].include?(todo.target.state) + end + def todos_filter_params { state: params[:state], -- cgit v1.2.1 From fd0c40fc801b766622654485717532f821efb795 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Mon, 9 May 2016 17:19:26 -0500 Subject: Address feedback Signed-off-by: Alfredo Sumaran --- app/helpers/todos_helper.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 150d826ac44..27f33b3eded 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -38,18 +38,15 @@ module TodosHelper end def todo_target_state_pill(todo) - klass = 'status-box ' - klass << "status-box-#{todo.target.state.dasherize}" - - content_tag(:span, nil, class: klass) do - todo.target.state.capitalize + if show_todo_state?(todo) + content_tag(:span, nil, class: 'target-status') do + content_tag(:span, nil, class: "status-box status-box-#{todo.target.state.dasherize}") do + todo.target.state.capitalize + end + end end end - def show_todo_state?(todo) - (todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && ['closed', 'merged'].include?(todo.target.state) - end - def todos_filter_params { state: params[:state], @@ -108,4 +105,10 @@ module TodosHelper options_from_collection_for_select(types, 'name', 'title', params[:type]) end + + private + + def show_todo_state?(todo) + (todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && ['closed', 'merged'].include?(todo.target.state) + end end -- cgit v1.2.1 From 77ca4a675ac7f8684f0b7c10592140365fc13a2d Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Wed, 18 May 2016 20:23:00 -0500 Subject: Make conditional a guard clause --- app/helpers/todos_helper.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 27f33b3eded..b9d7edb4185 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -38,11 +38,11 @@ module TodosHelper end def todo_target_state_pill(todo) - if show_todo_state?(todo) - content_tag(:span, nil, class: 'target-status') do - content_tag(:span, nil, class: "status-box status-box-#{todo.target.state.dasherize}") do - todo.target.state.capitalize - end + return unless show_todo_state?(todo) + + content_tag(:span, nil, class: 'target-status') do + content_tag(:span, nil, class: "status-box status-box-#{todo.target.state.dasherize}") do + todo.target.state.capitalize end end end -- cgit v1.2.1 From 65a175bbd9d5e5a8f6937bcbee9505c67f168b38 Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Date: Mon, 16 May 2016 14:58:15 -0500 Subject: Remove arrows from mobile scroll fade out --- app/helpers/nav_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb index fbb799eecd3..597a12cd53b 100644 --- a/app/helpers/nav_helper.rb +++ b/app/helpers/nav_helper.rb @@ -51,4 +51,8 @@ module NavHelper def layout_dropdown_class "controls-dropdown-visible" if current_user end + + def nav_control_class + "nav-control" if current_user + end end -- cgit v1.2.1 From 3c3402b0ae4c2f70cc421d97ad9605a9abeb9398 Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Date: Tue, 24 May 2016 11:30:53 -0500 Subject: Add fade out to left side of layout nav; remove dropdown nav helper; remove controls button from mobile --- app/helpers/nav_helper.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb index 597a12cd53b..f685e547537 100644 --- a/app/helpers/nav_helper.rb +++ b/app/helpers/nav_helper.rb @@ -48,10 +48,6 @@ module NavHelper "page-with-layout-nav" if defined?(nav) && nav end - def layout_dropdown_class - "controls-dropdown-visible" if current_user - end - def nav_control_class "nav-control" if current_user end -- cgit v1.2.1 From bc0666b3c906c990c1a10efc4b0acc73281ea533 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 19 Apr 2016 15:58:20 +0100 Subject: Filter issuables by any user Closes #2836 --- app/helpers/issuables_helper.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 39474217286..a7a6657b948 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -50,14 +50,10 @@ module IssuablesHelper end def user_dropdown_label(user_id, default_label) + return default_label if user_id.nil? return "Unassigned" if user_id == "0" - if @project - member = @project.team.find_member(user_id) - user = member.user if member - else - user = User.find_by(id: user_id) - end + user = User.find_by(id: user_id) if user user.name -- cgit v1.2.1 From 2830b46cbcbf754b81da6771471a95a8bf65f915 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 26 May 2016 11:19:11 +0100 Subject: Reduced number of buttons in commit header Closes #17576 --- app/helpers/commits_helper.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index b59c3982edd..d328f56c80c 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -123,13 +123,14 @@ module CommitsHelper ) end - def revert_commit_link(commit, continue_to_path, btn_class: nil) + def revert_commit_link(commit, continue_to_path, btn_class: nil, has_tooltip: true) return unless current_user - tooltip = "Revert this #{commit.change_type_title} in a new merge request" + tooltip = "Revert this #{commit.change_type_title} in a new merge request" if has_tooltip if can_collaborate_with_project? - link_to 'Revert', '#modal-revert-commit', 'data-toggle' => 'modal', 'data-container' => 'body', title: tooltip, class: "btn btn-default btn-grouped btn-#{btn_class} has-tooltip" + btn_class = "btn btn-grouped btn-close btn-#{btn_class}" unless btn_class.nil? + link_to 'Revert', '#modal-revert-commit', 'data-toggle' => 'modal', 'data-container' => 'body', title: (tooltip if has_tooltip), class: "#{btn_class} #{'has-tooltip' if has_tooltip}" elsif can?(current_user, :fork_project, @project) continue_params = { to: continue_to_path, @@ -140,17 +141,20 @@ module CommitsHelper namespace_key: current_user.namespace.id, continue: continue_params) - link_to 'Revert', fork_path, class: 'btn btn-grouped btn-close', method: :post, 'data-toggle' => 'tooltip', 'data-container' => 'body', title: tooltip + btn_class = "btn btn-grouped btn-close" unless btn_class.nil? + + link_to 'Revert', fork_path, class: btn_class, method: :post, 'data-toggle' => 'tooltip', 'data-container' => 'body', title: (tooltip if has_tooltip) end end - def cherry_pick_commit_link(commit, continue_to_path, btn_class: nil) + def cherry_pick_commit_link(commit, continue_to_path, btn_class: nil, has_tooltip: true) return unless current_user tooltip = "Cherry-pick this #{commit.change_type_title} in a new merge request" if can_collaborate_with_project? - link_to 'Cherry-pick', '#modal-cherry-pick-commit', 'data-toggle' => 'modal', 'data-container' => 'body', title: tooltip, class: "btn btn-default btn-grouped btn-#{btn_class} has-tooltip" + btn_class = "btn btn-default btn-grouped btn-#{btn_class}" unless btn_class.nil? + link_to 'Cherry-pick', '#modal-cherry-pick-commit', 'data-toggle' => 'modal', 'data-container' => 'body', title: (tooltip if has_tooltip), class: "#{btn_class} #{'has-tooltip' if has_tooltip}" elsif can?(current_user, :fork_project, @project) continue_params = { to: continue_to_path, @@ -161,7 +165,8 @@ module CommitsHelper namespace_key: current_user.namespace.id, continue: continue_params) - link_to 'Cherry-pick', fork_path, class: 'btn btn-grouped btn-close', method: :post, 'data-toggle' => 'tooltip', 'data-container' => 'body', title: tooltip + btn_class = "btn btn-grouped btn-close" unless btn_class.nil? + link_to 'Cherry-pick', fork_path, class: "#{btn_class}", method: :post, 'data-toggle' => 'tooltip', 'data-container' => 'body', title: (tooltip if has_tooltip) end end -- cgit v1.2.1 From d84992375c1b30c647212633874b1abff9d32e95 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 27 May 2016 11:44:28 +0100 Subject: Fixed issue with spacing in issuable header The Ruby was returning the HTML without a spacing next to the word 'by' Closes #17864 --- app/helpers/issuables_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index a7a6657b948..fe84ee3de44 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -72,7 +72,7 @@ module IssuablesHelper def issuable_meta(issuable, project, text) output = content_tag :strong, "#{text} #{issuable.to_reference}", class: "identifier" - output << " opened #{time_ago_with_tooltip(issuable.created_at)} by".html_safe + output << " opened #{time_ago_with_tooltip(issuable.created_at)} by ".html_safe output << content_tag(:strong) do author_output = link_to_member(project, issuable.author, size: 24, mobile_classes: "hidden-xs") author_output << link_to_member(project, issuable.author, size: 24, by_username: true, avatar: false, mobile_classes: "hidden-sm hidden-md hidden-lg") -- cgit v1.2.1