summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-07-05 15:46:39 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-07-11 12:22:57 +0300
commit98d29f6e78526d9bc35233a1049a502294f56384 (patch)
treea2b8074f5b59b24ebc6fb3d59f9cbe3dd6c99e40
parent68f8ae26bf7ae73b70ce31be1fae9fe36cd012f3 (diff)
downloadgitlab-ce-98d29f6e78526d9bc35233a1049a502294f56384.tar.gz
Add ability to disable manifest import
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/controllers/application_controller.rb12
-rw-r--r--app/controllers/import/manifest_controller.rb5
-rw-r--r--app/views/projects/_import_project_pane.html.haml9
3 files changed, 21 insertions, 5 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 21cc6dfdd16..07089ada51d 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -30,7 +30,13 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception, prepend: true
helper_method :can?
- helper_method :import_sources_enabled?, :github_import_enabled?, :gitea_import_enabled?, :github_import_configured?, :gitlab_import_enabled?, :gitlab_import_configured?, :bitbucket_import_enabled?, :bitbucket_import_configured?, :google_code_import_enabled?, :fogbugz_import_enabled?, :git_import_enabled?, :gitlab_project_import_enabled?
+ helper_method :import_sources_enabled?, :github_import_enabled?,
+ :gitea_import_enabled?, :github_import_configured?,
+ :gitlab_import_enabled?, :gitlab_import_configured?,
+ :bitbucket_import_enabled?, :bitbucket_import_configured?,
+ :google_code_import_enabled?, :fogbugz_import_enabled?,
+ :git_import_enabled?, :gitlab_project_import_enabled?,
+ :manifest_import_enabled?
rescue_from Encoding::CompatibilityError do |exception|
log_exception(exception)
@@ -351,6 +357,10 @@ class ApplicationController < ActionController::Base
Gitlab::CurrentSettings.import_sources.include?('gitlab_project')
end
+ def manifest_import_enabled?
+ Gitlab::CurrentSettings.import_sources.include?('manifest')
+ end
+
# U2F (universal 2nd factor) devices need a unique identifier for the application
# to perform authentication.
# https://developers.yubico.com/U2F/App_ID.html
diff --git a/app/controllers/import/manifest_controller.rb b/app/controllers/import/manifest_controller.rb
index c183bbe1ded..1af686bfa83 100644
--- a/app/controllers/import/manifest_controller.rb
+++ b/app/controllers/import/manifest_controller.rb
@@ -1,4 +1,5 @@
class Import::ManifestController < Import::BaseController
+ before_action :verify_import_enabled
before_action :ensure_import_vars, only: [:create, :status]
def new
@@ -80,4 +81,8 @@ class Import::ManifestController < Import::BaseController
.where(creator_id: current_user)
.includes(:import_state)
end
+
+ def verify_import_enabled
+ render_404 unless manifest_import_enabled?
+ end
end
diff --git a/app/views/projects/_import_project_pane.html.haml b/app/views/projects/_import_project_pane.html.haml
index 7cb5d51bec1..8472714b8a5 100644
--- a/app/views/projects/_import_project_pane.html.haml
+++ b/app/views/projects/_import_project_pane.html.haml
@@ -38,13 +38,14 @@
= link_to new_import_gitea_path, class: 'btn import_gitea' do
= custom_icon('go_logo')
Gitea
- - if git_import_enabled?
- %div
+ %div
+ - if git_import_enabled?
%button.btn.js-toggle-button.js-import-git-toggle-button{ type: "button", data: { toggle_open_class: 'active' } }
= icon('git', text: 'Repo by URL')
- %div
+ %div
+ - if manifest_import_enabled?
%button.btn{ type: "button" }
- = icon('git', text: 'Manifest file')
+ = icon('file', text: 'Manifest file')
.js-toggle-content.toggle-import-form{ class: ('hide' if active_tab != 'import') }
= form_for @project, html: { class: 'new_project' } do |f|