diff options
author | Rémy Coutable <remy@rymai.me> | 2017-08-11 17:33:45 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-08-11 17:33:45 +0000 |
commit | 455dc74e65e7461c1a51bf3ea6594fe20b9df90c (patch) | |
tree | 774f83562305748b671f07d94f91c42079a8e066 /app | |
parent | 5ab158f5459dc774f4613cab43de721b6366d833 (diff) | |
parent | 649d042dbc9e2bfda96bb98b0eabd4b00ea2daff (diff) | |
download | gitlab-ce-455dc74e65e7461c1a51bf3ea6594fe20b9df90c.tar.gz |
Merge branch 'disable-project-export' into 'master'
Add option to disable project export on instance
See merge request !13211
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects_controller.rb | 5 | ||||
-rw-r--r-- | app/helpers/application_settings_helper.rb | 1 | ||||
-rw-r--r-- | app/models/application_setting.rb | 1 | ||||
-rw-r--r-- | app/views/admin/application_settings/_form.html.haml | 6 | ||||
-rw-r--r-- | app/views/projects/_export.html.haml | 41 | ||||
-rw-r--r-- | app/views/projects/edit.html.haml | 37 |
6 files changed, 55 insertions, 36 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e93f34498d6..1d24563a6a6 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -7,6 +7,7 @@ class ProjectsController < Projects::ApplicationController before_action :repository, except: [:index, :new, :create] before_action :assign_ref_vars, only: [:show], if: :repo_exists? before_action :tree, only: [:show], if: [:repo_exists?, :project_view_files?] + before_action :project_export_enabled, only: [:export, :download_export, :remove_export, :generate_new_export] # Authorize before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping, :download_export, :export, :remove_export, :generate_new_export] @@ -390,4 +391,8 @@ class ProjectsController < Projects::ApplicationController url_for(params) end + + def project_export_enabled + render_404 unless current_application_settings.project_export_enabled? + end end diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 6825adcb39f..150188f0b65 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -146,6 +146,7 @@ module ApplicationSettingsHelper :plantuml_enabled, :plantuml_url, :polling_interval_multiplier, + :project_export_enabled, :prometheus_metrics_enabled, :recaptcha_enabled, :recaptcha_private_key, diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index bd7c4cd45ea..8e446ff6dd8 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -241,6 +241,7 @@ class ApplicationSetting < ActiveRecord::Base performance_bar_allowed_group_id: nil, plantuml_enabled: false, plantuml_url: nil, + project_export_enabled: true, recaptcha_enabled: false, repository_checks_enabled: true, repository_storages: ['default'], diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index a4f49d3f6d7..8bf6556079b 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -48,6 +48,12 @@ = select(:application_setting, :enabled_git_access_protocol, [['Both SSH and HTTP(S)', nil], ['Only SSH', 'ssh'], ['Only HTTP(S)', 'http']], {}, class: 'form-control') %span.help-block#clone-protocol-help Allow only the selected protocols to be used for Git access. + .form-group + .col-sm-offset-2.col-sm-10 + .checkbox + = f.label :project_export_enabled do + = f.check_box :project_export_enabled + Project export enabled %fieldset %legend Account and Limit Settings diff --git a/app/views/projects/_export.html.haml b/app/views/projects/_export.html.haml new file mode 100644 index 00000000000..623d3bc91c6 --- /dev/null +++ b/app/views/projects/_export.html.haml @@ -0,0 +1,41 @@ +- return unless current_application_settings.project_export_enabled? + +- project = local_assigns.fetch(:project) +- expanded = Rails.env.test? + +%section.settings + .settings-header + %h4 + Export project + %button.btn.js-settings-toggle + = expanded ? 'Collapse' : 'Expand' + %p + Export this project with all its related data in order to move your project to a new GitLab instance. Once the export is finished, you can import the file from the "New Project" page. + .settings-content.no-animate{ class: ('expanded' if expanded) } + .bs-callout.bs-callout-info + %p.append-bottom-0 + %p + The following items will be exported: + %ul + %li Project and wiki repositories + %li Project uploads + %li Project configuration including web hooks and services + %li Issues with comments, merge requests with diffs and comments, labels, milestones, snippets, and other project entities + %p + The following items will NOT be exported: + %ul + %li Job traces and artifacts + %li LFS objects + %li Container registry images + %li CI variables + %li Any encrypted tokens + %p + Once the exported file is ready, you will receive a notification email with a download link. + - if project.export_project_path + = link_to 'Download export', download_export_project_path(project), + rel: 'nofollow', download: '', method: :get, class: "btn btn-default" + = link_to 'Generate new export', generate_new_export_project_path(project), + method: :post, class: "btn btn-default" + - else + = link_to 'Export project', export_project_path(project), + method: :post, class: "btn btn-default" diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index c2794f8aaa8..6178abe9160 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -161,42 +161,7 @@ = render 'merge_request_settings', form: f = f.submit 'Save changes', class: "btn btn-save" - %section.settings - .settings-header - %h4 - Export project - %button.btn.js-settings-toggle - = expanded ? 'Collapse' : 'Expand' - %p - Export this project with all its related data in order to move your project to a new GitLab instance. Once the export is finished, you can import the file from the "New Project" page. - .settings-content.no-animate{ class: ('expanded' if expanded) } - .bs-callout.bs-callout-info - %p.append-bottom-0 - %p - The following items will be exported: - %ul - %li Project and wiki repositories - %li Project uploads - %li Project configuration including web hooks and services - %li Issues with comments, merge requests with diffs and comments, labels, milestones, snippets, and other project entities - %p - The following items will NOT be exported: - %ul - %li Job traces and artifacts - %li LFS objects - %li Container registry images - %li CI variables - %li Any encrypted tokens - %p - Once the exported file is ready, you will receive a notification email with a download link. - - if @project.export_project_path - = link_to 'Download export', download_export_project_path(@project), - rel: 'nofollow', download: '', method: :get, class: "btn btn-default" - = link_to 'Generate new export', generate_new_export_project_path(@project), - method: :post, class: "btn btn-default" - - else - = link_to 'Export project', export_project_path(@project), - method: :post, class: "btn btn-default" + = render 'export', project: @project %section.settings.advanced-settings .settings-header |