summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-09 12:09:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-09 12:09:24 +0000
commita9ced7da447785c57477b3d8dbccc73a78cface1 (patch)
tree5179d27ab9d801748ee4ed1c64c985974e799812 /app/controllers
parentad0265eead72a624ce7a020847db4f0f0c877e57 (diff)
downloadgitlab-ce-a9ced7da447785c57477b3d8dbccc73a78cface1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/groups_controller.rb40
-rw-r--r--app/controllers/projects/import/jira_controller.rb4
2 files changed, 41 insertions, 3 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 7175eefcde7..44120fda17c 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -6,18 +6,20 @@ class GroupsController < Groups::ApplicationController
include ParamsBackwardCompatibility
include PreviewMarkdown
include RecordUserLastActivity
+ include SendFileUpload
extend ::Gitlab::Utils::Override
respond_to :html
prepend_before_action(only: [:show, :issues]) { authenticate_sessionless_user!(:rss) }
prepend_before_action(only: [:issues_calendar]) { authenticate_sessionless_user!(:ics) }
+ prepend_before_action :ensure_export_enabled, only: [:export, :download_export]
before_action :authenticate_user!, only: [:new, :create]
before_action :group, except: [:index, :new, :create]
# Authorize
- before_action :authorize_admin_group!, only: [:edit, :update, :destroy, :projects, :transfer]
+ before_action :authorize_admin_group!, only: [:edit, :update, :destroy, :projects, :transfer, :export, :download_export]
before_action :authorize_create_group!, only: [:new]
before_action :group_projects, only: [:projects, :activity, :issues, :merge_requests]
@@ -29,6 +31,8 @@ class GroupsController < Groups::ApplicationController
push_frontend_feature_flag(:vue_issuables_list, @group)
end
+ before_action :export_rate_limit, only: [:export, :download_export]
+
skip_cross_project_access_check :index, :new, :create, :edit, :update,
:destroy, :projects
# When loading show as an atom feed, we render events that could leak cross
@@ -134,6 +138,25 @@ class GroupsController < Groups::ApplicationController
end
# rubocop: enable CodeReuse/ActiveRecord
+ def export
+ export_service = Groups::ImportExport::ExportService.new(group: @group, user: current_user)
+
+ if export_service.async_execute
+ redirect_to edit_group_path(@group), notice: _('Group export started.')
+ else
+ redirect_to edit_group_path(@group), alert: _('Group export could not be started.')
+ end
+ end
+
+ def download_export
+ if @group.export_file_exists?
+ send_upload(@group.export_file, attachment: @group.export_file.filename)
+ else
+ redirect_to edit_group_path(@group),
+ alert: _('Group export link has expired. Please generate a new export from your group settings.')
+ end
+ end
+
protected
def render_show_html
@@ -234,6 +257,21 @@ class GroupsController < Groups::ApplicationController
url_for(safe_params)
end
+ def export_rate_limit
+ prefixed_action = "group_#{params[:action]}".to_sym
+
+ if Gitlab::ApplicationRateLimiter.throttled?(prefixed_action, scope: [current_user, prefixed_action, @group])
+ Gitlab::ApplicationRateLimiter.log_request(request, "#{prefixed_action}_request_limit".to_sym, current_user)
+
+ flash[:alert] = _('This endpoint has been requested too many times. Try again later.')
+ redirect_to edit_group_path(@group)
+ end
+ end
+
+ def ensure_export_enabled
+ render_404 unless Feature.enabled?(:group_import_export, @group, default_enabled: true)
+ end
+
private
def groups
diff --git a/app/controllers/projects/import/jira_controller.rb b/app/controllers/projects/import/jira_controller.rb
index c8f53cef5b2..b5adef399c7 100644
--- a/app/controllers/projects/import/jira_controller.rb
+++ b/app/controllers/projects/import/jira_controller.rb
@@ -9,7 +9,7 @@ module Projects
def show
return if Feature.enabled?(:jira_issue_import_vue, @project)
- unless @project.import_state&.in_progress?
+ unless @project.latest_jira_import&.in_progress?
jira_client = @project.jira_service.client
jira_projects = jira_client.Project.all
@@ -20,7 +20,7 @@ module Projects
end
end
- flash[:notice] = _("Import %{status}") % { status: @project.import_state.status } if @project.import_state.present? && !@project.import_state.none?
+ flash[:notice] = _("Import %{status}") % { status: @project.jira_import_status } unless @project.latest_jira_import&.initial?
end
def import