Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-09-15 23:40:35 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2015-09-15 23:40:35 +0300
commite21deaee8ee0d453bf899c1b3fb46262cc60dab9 (patch)
tree59b04c9cb1c8ce6c510a78ee787fb31817619835 /app/controllers
parent7e2dbcbe0915cfd75e91d78e943c153f284df37d (diff)
parent0ad669bb5ba08d012d3daa50b51a3a6b069e3e83 (diff)
Merge remote-tracking branch 'origin/master' into ci-and-ce-sitting-in-a-tree-k-i-s-s-i-n-g
# Conflicts: # Gemfile.lock
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/dashboard/projects_controller.rb15
-rw-r--r--app/controllers/dashboard/snippets_controller.rb10
-rw-r--r--app/controllers/dashboard_controller.rb19
-rw-r--r--app/controllers/explore/application_controller.rb2
-rw-r--r--app/controllers/explore/groups_controller.rb3
-rw-r--r--app/controllers/explore/projects_controller.rb3
-rw-r--r--app/controllers/explore/snippets_controller.rb6
-rw-r--r--app/controllers/groups_controller.rb6
-rw-r--r--app/controllers/help_controller.rb2
-rw-r--r--app/controllers/import/fogbugz_controller.rb8
-rw-r--r--app/controllers/invites_controller.rb4
-rw-r--r--app/controllers/namespaces_controller.rb2
-rw-r--r--app/controllers/projects/blob_controller.rb28
-rw-r--r--app/controllers/projects/forks_controller.rb12
-rw-r--r--app/controllers/projects/project_members_controller.rb2
-rw-r--r--app/controllers/projects_controller.rb6
-rw-r--r--app/controllers/root_controller.rb7
-rw-r--r--app/controllers/snippets_controller.rb8
18 files changed, 90 insertions, 53 deletions
diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb
index da96171e885..467d0f81aca 100644
--- a/app/controllers/dashboard/projects_controller.rb
+++ b/app/controllers/dashboard/projects_controller.rb
@@ -1,6 +1,21 @@
class Dashboard::ProjectsController < Dashboard::ApplicationController
before_action :event_filter
+ def index
+ @projects = current_user.authorized_projects.sorted_by_activity.non_archived
+ @projects = @projects.includes(:namespace)
+ @last_push = current_user.recent_push
+
+ respond_to do |format|
+ format.html
+ format.atom do
+ event_filter
+ load_events
+ render layout: false
+ end
+ end
+ end
+
def starred
@projects = current_user.starred_projects
@projects = @projects.includes(:namespace, :forked_from_project, :tags)
diff --git a/app/controllers/dashboard/snippets_controller.rb b/app/controllers/dashboard/snippets_controller.rb
new file mode 100644
index 00000000000..f4354c6d8ca
--- /dev/null
+++ b/app/controllers/dashboard/snippets_controller.rb
@@ -0,0 +1,10 @@
+class Dashboard::SnippetsController < Dashboard::ApplicationController
+ def index
+ @snippets = SnippetsFinder.new.execute(current_user,
+ filter: :by_user,
+ user: current_user,
+ scope: params[:scope]
+ )
+ @snippets = @snippets.page(params[:page]).per(PER_PAGE)
+ end
+end
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 2bc2e5e58f5..4ebb3d7276e 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -1,23 +1,8 @@
class DashboardController < Dashboard::ApplicationController
- before_action :load_projects, except: :activity
before_action :event_filter, only: :activity
respond_to :html
- def show
- @projects = @projects.includes(:namespace)
- @last_push = current_user.recent_push
-
- respond_to do |format|
- format.html
- format.atom do
- event_filter
- load_events
- render layout: false
- end
- end
- end
-
def merge_requests
@merge_requests = get_merge_requests_collection
@merge_requests = @merge_requests.page(params[:page]).per(PER_PAGE)
@@ -50,10 +35,6 @@ class DashboardController < Dashboard::ApplicationController
protected
- def load_projects
- @projects = current_user.authorized_projects.sorted_by_activity.non_archived
- end
-
def load_events
project_ids =
if params[:filter] == "starred"
diff --git a/app/controllers/explore/application_controller.rb b/app/controllers/explore/application_controller.rb
index 4b275033d26..461fc059a3c 100644
--- a/app/controllers/explore/application_controller.rb
+++ b/app/controllers/explore/application_controller.rb
@@ -1,3 +1,5 @@
class Explore::ApplicationController < ApplicationController
+ skip_before_action :authenticate_user!, :reject_blocked
+
layout 'explore'
end
diff --git a/app/controllers/explore/groups_controller.rb b/app/controllers/explore/groups_controller.rb
index 55cda0cff17..9575a87ee41 100644
--- a/app/controllers/explore/groups_controller.rb
+++ b/app/controllers/explore/groups_controller.rb
@@ -1,7 +1,4 @@
class Explore::GroupsController < Explore::ApplicationController
- skip_before_action :authenticate_user!,
- :reject_blocked, :set_current_user_for_observers
-
def index
@groups = GroupsFinder.new.execute(current_user)
@groups = @groups.search(params[:search]) if params[:search].present?
diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb
index 6c733c1ae4d..a5aeaed66c5 100644
--- a/app/controllers/explore/projects_controller.rb
+++ b/app/controllers/explore/projects_controller.rb
@@ -1,7 +1,4 @@
class Explore::ProjectsController < Explore::ApplicationController
- skip_before_action :authenticate_user!,
- :reject_blocked
-
def index
@projects = ProjectsFinder.new.execute(current_user)
@tags = @projects.tags_on(:tags)
diff --git a/app/controllers/explore/snippets_controller.rb b/app/controllers/explore/snippets_controller.rb
new file mode 100644
index 00000000000..b70ac51d06e
--- /dev/null
+++ b/app/controllers/explore/snippets_controller.rb
@@ -0,0 +1,6 @@
+class Explore::SnippetsController < Explore::ApplicationController
+ def index
+ @snippets = SnippetsFinder.new.execute(current_user, filter: :all)
+ @snippets = @snippets.page(params[:page]).per(PER_PAGE)
+ end
+end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 279c6ef0f4d..524218290c6 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -4,7 +4,7 @@ class GroupsController < Groups::ApplicationController
before_action :group, except: [:new, :create]
# Authorize
- before_action :authorize_read_group!, except: [:new, :create]
+ before_action :authorize_read_group!, except: [:show, :new, :create]
before_action :authorize_admin_group!, only: [:edit, :update, :destroy, :projects]
before_action :authorize_create_group!, only: [:new, :create]
@@ -14,6 +14,10 @@ class GroupsController < Groups::ApplicationController
layout :determine_layout
+ def index
+ redirect_to(current_user ? dashboard_groups_path : explore_groups_path)
+ end
+
def new
@group = Group.new
end
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb
index 71831c5380d..ad00948da51 100644
--- a/app/controllers/help_controller.rb
+++ b/app/controllers/help_controller.rb
@@ -1,4 +1,6 @@
class HelpController < ApplicationController
+ skip_before_action :authenticate_user!, :reject_blocked
+
layout 'help'
def index
diff --git a/app/controllers/import/fogbugz_controller.rb b/app/controllers/import/fogbugz_controller.rb
index bda534fb4de..849646cd665 100644
--- a/app/controllers/import/fogbugz_controller.rb
+++ b/app/controllers/import/fogbugz_controller.rb
@@ -2,7 +2,6 @@ class Import::FogbugzController < Import::BaseController
before_action :verify_fogbugz_import_enabled
before_action :user_map, only: [:new_user_map, :create_user_map]
- # Doesn't work yet due to bug in ruby-fogbugz, see below
rescue_from Fogbugz::AuthenticationException, with: :fogbugz_unauthorized
def new
@@ -13,8 +12,8 @@ class Import::FogbugzController < Import::BaseController
begin
res = Gitlab::FogbugzImport::Client.new(import_params.symbolize_keys)
rescue
- # Needed until https://github.com/firmafon/ruby-fogbugz/pull/9 is merged
- return redirect_to :back, alert: 'Could not authenticate with FogBugz, check your URL, email, and password'
+ # If the URI is invalid various errors can occur
+ return redirect_to new_import_fogbugz_path, alert: 'Could not connect to FogBugz, check your URL'
end
session[:fogbugz_token] = res.get_token
session[:fogbugz_uri] = params[:uri]
@@ -92,8 +91,7 @@ class Import::FogbugzController < Import::BaseController
end
def fogbugz_unauthorized(exception)
- flash[:alert] = exception.message
- redirect_to new_import_fogbugz_path
+ redirect_to new_import_fogbugz_path, alert: exception.message
end
def import_params
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb
index eb3c8233530..8ef10a17f55 100644
--- a/app/controllers/invites_controller.rb
+++ b/app/controllers/invites_controller.rb
@@ -24,7 +24,7 @@ class InvitesController < ApplicationController
path =
if current_user
- dashboard_path
+ dashboard_projects_path
else
new_user_session_path
end
@@ -73,7 +73,7 @@ class InvitesController < ApplicationController
path = group_path(group)
else
label = "who knows what"
- path = dashboard_path
+ path = dashboard_projects_path
end
[label, path]
diff --git a/app/controllers/namespaces_controller.rb b/app/controllers/namespaces_controller.rb
index 83eec1bf4a2..282012c60a1 100644
--- a/app/controllers/namespaces_controller.rb
+++ b/app/controllers/namespaces_controller.rb
@@ -14,7 +14,7 @@ class NamespacesController < ApplicationController
if user
redirect_to user_path(user)
- elsif group && can?(current_user, :read_group, group)
+ elsif group
redirect_to group_path(group)
elsif current_user.nil?
authenticate_user!
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index 100d3d3b317..8776721d243 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -26,10 +26,16 @@ class Projects::BlobController < Projects::ApplicationController
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
- redirect_to namespace_project_blob_path(@project.namespace, @project, File.join(@target_branch, @file_path))
+ respond_to do |format|
+ format.html { redirect_to namespace_project_blob_path(@project.namespace, @project, File.join(@target_branch, @file_path)) }
+ format.json { render json: { message: "success", filePath: namespace_project_blob_path(@project.namespace, @project, File.join(@target_branch, @file_path)) } }
+ end
else
flash[:alert] = result[:message]
- render :new
+ respond_to do |format|
+ format.html { render :new }
+ format.json { render json: { message: "failed", filePath: namespace_project_new_blob_path(@project.namespace, @project, @id) } }
+ end
end
end
@@ -45,10 +51,16 @@ class Projects::BlobController < Projects::ApplicationController
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
- redirect_to after_edit_path
+ respond_to do |format|
+ format.html { redirect_to after_edit_path }
+ format.json { render json: { message: "success", filePath: after_edit_path } }
+ end
else
flash[:alert] = result[:message]
- render :edit
+ respond_to do |format|
+ format.html { render :edit }
+ format.json { render json: { message: "failed", filePath: namespace_project_new_blob_path(@project.namespace, @project, @id) } }
+ end
end
end
@@ -146,11 +158,19 @@ class Projects::BlobController < Projects::ApplicationController
@file_path =
if action_name.to_s == 'create'
+ if params[:file].present?
+ params[:file_name] = params[:file].original_filename
+ end
File.join(@path, File.basename(params[:file_name]))
else
@path
end
+ if params[:file].present?
+ params[:content] = Base64.encode64(params[:file].read)
+ params[:encoding] = 'base64'
+ end
+
@commit_params = {
file_path: @file_path,
current_branch: @current_branch,
diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb
index 9e72597ea87..8a785076bb7 100644
--- a/app/controllers/projects/forks_controller.rb
+++ b/app/controllers/projects/forks_controller.rb
@@ -13,10 +13,14 @@ class Projects::ForksController < Projects::ApplicationController
@forked_project = ::Projects::ForkService.new(project, current_user, namespace: namespace).execute
if @forked_project.saved? && @forked_project.forked?
- redirect_to(
- namespace_project_path(@forked_project.namespace, @forked_project),
- notice: 'Project was successfully forked.'
- )
+ if @forked_project.import_in_progress?
+ redirect_to namespace_project_import_path(@forked_project.namespace, @forked_project)
+ else
+ redirect_to(
+ namespace_project_path(@forked_project.namespace, @forked_project),
+ notice: 'Project was successfully forked.'
+ )
+ end
else
render :error
end
diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb
index b82b6f45d59..cf73bc01c8f 100644
--- a/app/controllers/projects/project_members_controller.rb
+++ b/app/controllers/projects/project_members_controller.rb
@@ -78,7 +78,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
@project.project_members.find_by(user_id: current_user).destroy
respond_to do |format|
- format.html { redirect_to dashboard_path }
+ format.html { redirect_to dashboard_projects_path }
format.js { render nothing: true }
end
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index dafc11d0707..f4d1a828aab 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -10,6 +10,10 @@ class ProjectsController < ApplicationController
layout :determine_layout
+ def index
+ redirect_to(current_user ? root_path : explore_root_path)
+ end
+
def new
@project = Project.new
end
@@ -105,7 +109,7 @@ class ProjectsController < ApplicationController
if request.referer.include?('/admin')
redirect_to admin_namespaces_projects_path
else
- redirect_to dashboard_path
+ redirect_to dashboard_projects_path
end
rescue Projects::DestroyService::DestroyError => ex
redirect_to edit_project_path(@project), alert: ex.message
diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb
index fdfe00dc135..54171ff67c5 100644
--- a/app/controllers/root_controller.rb
+++ b/app/controllers/root_controller.rb
@@ -6,10 +6,10 @@
#
# For users who haven't customized the setting, we simply delegate to
# `DashboardController#show`, which is the default.
-class RootController < DashboardController
- before_action :redirect_to_custom_dashboard, only: [:show]
+class RootController < Dashboard::ProjectsController
+ before_action :redirect_to_custom_dashboard, only: [:index]
- def show
+ def index
super
end
@@ -20,6 +20,7 @@ class RootController < DashboardController
case current_user.dashboard
when 'stars'
+ flash.keep
redirect_to starred_dashboard_projects_path
else
return
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index 8e7e45c781f..9f9f9a92f11 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -24,13 +24,9 @@ class SnippetsController < ApplicationController
scope: params[:scope] }).
page(params[:page]).per(PER_PAGE)
- if @user == current_user
- render 'current_user_index'
- else
- render 'user_index'
- end
+ render 'index'
else
- @snippets = SnippetsFinder.new.execute(current_user, filter: :all).page(params[:page]).per(PER_PAGE)
+ redirect_to(current_user ? dashboard_snippets_path : explore_snippets_path)
end
end