From 47634e392fab457dd0634225961944804bc04efe Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 23 Dec 2014 18:49:39 +0200 Subject: Refactor issues and merge requests lists Signed-off-by: Dmitriy Zaporozhets --- app/controllers/application_controller.rb | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f1e1bebe5ce..0ddd743f053 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -239,4 +239,46 @@ class ApplicationController < ActionController::Base redirect_to profile_path, notice: 'Please complete your profile with email address' and return end end + + def set_filters_defaults + params[:sort] ||= 'newest' + params[:scope] = 'all' if params[:scope].blank? + params[:state] = 'opened' if params[:state].blank? + + @sort = params[:sort].humanize + + if @project + params[:project_id] = @project.id + elsif @group + params[:group_id] = @group.id + else + params[:authorized_only] = true + + unless params[:assignee_id].present? + params[:assignee_id] = current_user.id + end + end + end + + def set_filter_values(collection) + assignee_id = params[:assignee_id] + author_id = params[:author_id] + milestone_id = params[:milestone_id] + + @assignees = User.where(id: collection.pluck(:assignee_id)) + @authors = User.where(id: collection.pluck(:author_id)) + @milestones = Milestone.where(id: collection.pluck(:milestone_id)) + + if assignee_id.present? && !assignee_id.to_i.zero? + @assignee = @assignees.find(assignee_id) + end + + if author_id.present? && !author_id.to_i.zero? + @author = @authors.find(author_id) + end + + if milestone_id.present? && !milestone_id.to_i.zero? + @milestone = @milestones.find(milestone_id) + end + end end -- cgit v1.2.1 From 016981c009a2a8c6066085300a838d9c9d6bfd5d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 24 Dec 2014 11:04:33 +0200 Subject: Refactor issuable list pages Signed-off-by: Dmitriy Zaporozhets --- app/controllers/application_controller.rb | 37 ++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0ddd743f053..79824116b41 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -240,24 +240,26 @@ class ApplicationController < ActionController::Base end end - def set_filters_defaults + def set_filters_params params[:sort] ||= 'newest' params[:scope] = 'all' if params[:scope].blank? params[:state] = 'opened' if params[:state].blank? - @sort = params[:sort].humanize + @filter_params = params.dup if @project - params[:project_id] = @project.id + @filter_params[:project_id] = @project.id elsif @group - params[:group_id] = @group.id + @filter_params[:group_id] = @group.id else - params[:authorized_only] = true + @filter_params[:authorized_only] = true - unless params[:assignee_id].present? - params[:assignee_id] = current_user.id + unless @filter_params[:assignee_id] + @filter_params[:assignee_id] = current_user.id end end + + @filter_params end def set_filter_values(collection) @@ -265,20 +267,35 @@ class ApplicationController < ActionController::Base author_id = params[:author_id] milestone_id = params[:milestone_id] + @sort = params[:sort].try(:humanize) @assignees = User.where(id: collection.pluck(:assignee_id)) @authors = User.where(id: collection.pluck(:author_id)) @milestones = Milestone.where(id: collection.pluck(:milestone_id)) if assignee_id.present? && !assignee_id.to_i.zero? - @assignee = @assignees.find(assignee_id) + @assignee = @assignees.find_by(id: assignee_id) end if author_id.present? && !author_id.to_i.zero? - @author = @authors.find(author_id) + @author = @authors.find_by(id: author_id) end if milestone_id.present? && !milestone_id.to_i.zero? - @milestone = @milestones.find(milestone_id) + @milestone = @milestones.find_by(id: milestone_id) end end + + def get_issues_collection + set_filters_params + issues = IssuesFinder.new.execute(current_user, @filter_params) + set_filter_values(issues) + issues + end + + def get_merge_requests_collection + set_filters_params + merge_requests = MergeRequestsFinder.new.execute(current_user, @filter_params) + set_filter_values(merge_requests) + merge_requests + end end -- cgit v1.2.1 From 7b792af872699cd9439c750b780b0b906342cff0 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 24 Dec 2014 11:39:03 +0200 Subject: Improvements to issues/mr filters: * use filter_params variable when set filter values * fix project issues spinach tests Signed-off-by: Dmitriy Zaporozhets --- app/controllers/application_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 79824116b41..1b48572f2b8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -263,11 +263,11 @@ class ApplicationController < ActionController::Base end def set_filter_values(collection) - assignee_id = params[:assignee_id] - author_id = params[:author_id] - milestone_id = params[:milestone_id] + assignee_id = @filter_params[:assignee_id] + author_id = @filter_params[:author_id] + milestone_id = @filter_params[:milestone_id] - @sort = params[:sort].try(:humanize) + @sort = @filter_params[:sort].try(:humanize) @assignees = User.where(id: collection.pluck(:assignee_id)) @authors = User.where(id: collection.pluck(:author_id)) @milestones = Milestone.where(id: collection.pluck(:milestone_id)) -- cgit v1.2.1 From 97d7c06f781f17a21689cf35410009f1247427e9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 24 Dec 2014 12:56:03 +0200 Subject: Fix scroll problems and disable authorized_only filter Signed-off-by: Dmitriy Zaporozhets --- app/controllers/application_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1b48572f2b8..41ad5f98ace 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -252,7 +252,11 @@ class ApplicationController < ActionController::Base elsif @group @filter_params[:group_id] = @group.id else - @filter_params[:authorized_only] = true + # TODO: this filter ignore issues/mr created in public or + # internal repos where you are not a member. Enable this filter + # or improve current implementation to filter only issues you + # created or assigned or mentioned + #@filter_params[:authorized_only] = true unless @filter_params[:assignee_id] @filter_params[:assignee_id] = current_user.id -- cgit v1.2.1 From 465f186954d00fa47c8b05cc91f33e7943aa209a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 26 Dec 2014 18:33:53 +0200 Subject: Show assigned issues/mr be default on dashboard This was default before but now it fixed with providing assignee_id parameter making url shareble and dont reset when other filters users. Also this commit removes old methods that are not used any more. Signed-off-by: Dmitriy Zaporozhets --- app/controllers/application_controller.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 41ad5f98ace..4b8cae469e3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -257,10 +257,6 @@ class ApplicationController < ActionController::Base # or improve current implementation to filter only issues you # created or assigned or mentioned #@filter_params[:authorized_only] = true - - unless @filter_params[:assignee_id] - @filter_params[:assignee_id] = current_user.id - end end @filter_params -- cgit v1.2.1 From 57a65ede77b7bbae6e3b2a7aa52135de7b0c2f8e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Jan 2015 09:53:35 -0800 Subject: Improve application settings and write tests --- app/controllers/application_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4b8cae469e3..b83de68c5d2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,8 @@ require 'gon' class ApplicationController < ActionController::Base + include Gitlab::CurrentSettings + before_filter :authenticate_user_from_token! before_filter :authenticate_user! before_filter :reject_blocked! @@ -13,7 +15,7 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception - helper_method :abilities, :can? + helper_method :abilities, :can?, :current_application_settings rescue_from Encoding::CompatibilityError do |exception| log_exception(exception) -- cgit v1.2.1 From 41d7be3ce1ae9a4bff93b62322f35989b6ad4cf6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 16 Jan 2015 16:01:15 -0800 Subject: Allow to specify home page for non logged-in users --- app/controllers/application_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b83de68c5d2..4780a7a2a9a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -48,6 +48,17 @@ class ApplicationController < ActionController::Base end end + def authenticate_user! + # If user is not signe-in and tries to access root_path - redirect him to landing page + if current_application_settings.home_page_url.present? + if current_user.nil? && controller_name == 'dashboard' && action_name == 'show' + redirect_to current_application_settings.home_page_url and return + end + end + + super + end + def log_exception(exception) application_trace = ActionDispatch::ExceptionWrapper.new(env, exception).application_trace application_trace.map!{ |t| " #{t}\n" } -- cgit v1.2.1 From f2eb234c068ccb57f100080a499d307b9b2f5502 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 16 Jan 2015 18:12:15 -0800 Subject: Fix passign args to original authenticate_user! --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4780a7a2a9a..6da4f91c3f4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -48,7 +48,7 @@ class ApplicationController < ActionController::Base end end - def authenticate_user! + def authenticate_user!(*args) # If user is not signe-in and tries to access root_path - redirect him to landing page if current_application_settings.home_page_url.present? if current_user.nil? && controller_name == 'dashboard' && action_name == 'show' @@ -56,7 +56,7 @@ class ApplicationController < ActionController::Base end end - super + super(*args) end def log_exception(exception) -- cgit v1.2.1 From 5c801602189bdf179432e9ef5885f6c6fef438f2 Mon Sep 17 00:00:00 2001 From: Steven Burgart Date: Sun, 18 Jan 2015 10:29:37 -0500 Subject: Fix various typos signe-in -> signed-in go_to_gihub_for_permissions -> go_to_github_for_permissions descendand -> descendant behavour -> behaviour recepient_email -> recipient_email generate_fingerpint -> generate_fingerprint dependes -> depends Cant't -> Can't wisit -> visit notifcation -> notification sufficent_scope -> sufficient_scope? levet -> level --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6da4f91c3f4..ad13a0ac3e4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -49,7 +49,7 @@ class ApplicationController < ActionController::Base end def authenticate_user!(*args) - # If user is not signe-in and tries to access root_path - redirect him to landing page + # If user is not signed-in and tries to access root_path - redirect him to landing page if current_application_settings.home_page_url.present? if current_user.nil? && controller_name == 'dashboard' && action_name == 'show' redirect_to current_application_settings.home_page_url and return -- cgit v1.2.1 From 537cd66d7e4237f0df6db88b3225327c8e4140c5 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 28 Jan 2015 09:28:17 -0800 Subject: Add gitlab internal issue tracker service. --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ad13a0ac3e4..36e13706768 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -181,7 +181,7 @@ class ApplicationController < ActionController::Base end def add_gon_variables - gon.default_issues_tracker = Project.issues_tracker.default_value + gon.default_issues_tracker = Project.new.default_issue_tracker.to_param gon.api_version = API::API.version gon.relative_url_root = Gitlab.config.gitlab.relative_url_root gon.default_avatar_url = URI::join(Gitlab.config.gitlab.url, ActionController::Base.helpers.image_path('no_avatar.png')).to_s -- cgit v1.2.1 From bbca6a0abd9f5559fe4abbf2cb2100a0e4717ac8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 5 Feb 2015 19:15:05 -0800 Subject: Refactor sorting in project --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 36e13706768..6553027b430 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -254,7 +254,7 @@ class ApplicationController < ActionController::Base end def set_filters_params - params[:sort] ||= 'newest' + params[:sort] ||= 'created_desc' params[:scope] = 'all' if params[:scope].blank? params[:state] = 'opened' if params[:state].blank? @@ -280,7 +280,7 @@ class ApplicationController < ActionController::Base author_id = @filter_params[:author_id] milestone_id = @filter_params[:milestone_id] - @sort = @filter_params[:sort].try(:humanize) + @sort = @filter_params[:sort] @assignees = User.where(id: collection.pluck(:assignee_id)) @authors = User.where(id: collection.pluck(:author_id)) @milestones = Milestone.where(id: collection.pluck(:milestone_id)) -- cgit v1.2.1 From 76aad9b76ed756ca9ba2cbcdb399c815e542b3ae Mon Sep 17 00:00:00 2001 From: Vinnie Okada Date: Sat, 24 Jan 2015 11:02:58 -0700 Subject: Upgrade to Rails 4.1.9 Make the following changes to deal with new behavior in Rails 4.1.2: * Use nested resources to avoid slashes in arguments to path helpers. --- app/controllers/application_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6553027b430..eb3be08df56 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -93,6 +93,7 @@ class ApplicationController < ActionController::Base def project unless @project + namespace = params[:namespace_id] id = params[:project_id] || params[:id] # Redirect from @@ -104,7 +105,7 @@ class ApplicationController < ActionController::Base redirect_to request.original_url.gsub(/\.git\Z/, '') and return end - @project = Project.find_with_namespace(id) + @project = Project.find_with_namespace("#{namespace}/#{id}") if @project and can?(current_user, :read_project, @project) @project @@ -121,7 +122,8 @@ class ApplicationController < ActionController::Base def repository @repository ||= project.repository - rescue Grit::NoSuchPathError + rescue Grit::NoSuchPathError(e) + log_exception(e) nil end -- cgit v1.2.1 From 448817c4de965bf7286f33a3447937987a8864a1 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 17 Feb 2015 22:52:32 +0100 Subject: Load public key in initializer. --- app/controllers/application_controller.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index eb3be08df56..7940b5cb3f4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception helper_method :abilities, :can?, :current_application_settings + helper_method :github_import_enabled?, :gitlab_import_enabled?, :bitbucket_import_enabled? rescue_from Encoding::CompatibilityError do |exception| log_exception(exception) @@ -313,4 +314,16 @@ class ApplicationController < ActionController::Base set_filter_values(merge_requests) merge_requests end + + def github_import_enabled? + OauthHelper.enabled_oauth_providers.include?(:github) + end + + def gitlab_import_enabled? + OauthHelper.enabled_oauth_providers.include?(:gitlab) + end + + def bitbucket_import_enabled? + OauthHelper.enabled_oauth_providers.include?(:bitbucket) && Gitlab::BitbucketImport.public_key.present? + end end -- cgit v1.2.1 From 6de4e4a622a98d86a44e9adf2fca15ff30c478c7 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 26 Feb 2015 09:34:20 -0800 Subject: Include route helper shortcut in controller --- app/controllers/application_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7940b5cb3f4..df1a588313e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,6 +2,7 @@ require 'gon' class ApplicationController < ActionController::Base include Gitlab::CurrentSettings + include GitlabRoutingHelper before_filter :authenticate_user_from_token! before_filter :authenticate_user! -- cgit v1.2.1