diff --git a/Gemfile b/Gemfile index c1cf8dffacebd3c98960ea70ce6cad105bb874a6..806e25c97a7ef6db730d8b85a6a74e473e2c38ed 100644 --- a/Gemfile +++ b/Gemfile @@ -206,7 +206,7 @@ gem 'request_store', '~> 1.2.0' gem 'select2-rails', '~> 3.5.9' gem 'virtus', '~> 1.0.1' -gem "gitlab-license", "~> 0.0.2" +gem "gitlab-license", "~> 0.0.4" group :development do gem "foreman" diff --git a/Gemfile.lock b/Gemfile.lock index 0040ebe0c4cad4701bcb97e6909e0fc3cdc8e967..12da3342ccb49126ea5713592f51cba5c2931994 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -287,7 +287,7 @@ GEM diff-lcs (~> 1.1) mime-types (~> 1.15) posix-spawn (~> 0.3) - gitlab-license (0.0.3) + gitlab-license (0.0.4) gitlab_emoji (0.1.1) gemojione (~> 2.0) gitlab_git (7.2.20) @@ -840,7 +840,7 @@ DEPENDENCIES github-linguist (~> 4.7.0) github-markup (~> 1.3.1) gitlab-flowdock-git-hook (~> 1.0.1) - gitlab-license (~> 0.0.2) + gitlab-license (~> 0.0.4) gitlab_emoji (~> 0.1) gitlab_git (~> 7.2.20) gitlab_meta (= 7.0) diff --git a/app/assets/stylesheets/pages/admin.scss b/app/assets/stylesheets/pages/admin.scss index 144852e787496222c9286ffae5cbab5650967aea..eb1886d994c5d9ad7a7ae66b265fd0aa6f9c4125 100644 --- a/app/assets/stylesheets/pages/admin.scss +++ b/app/assets/stylesheets/pages/admin.scss @@ -61,3 +61,7 @@ @extend .broadcast-message; margin-bottom: 20px; } + +.license-key-field { + font-family: monospace; +} diff --git a/app/controllers/admin/licenses_controller.rb b/app/controllers/admin/licenses_controller.rb index 513599f94ed2fe6b3d3ab5086ebb9a08aeed36eb..efd358000cd567429cf3ece16a0aafb3b1e7f6a7 100644 --- a/app/controllers/admin/licenses_controller.rb +++ b/app/controllers/admin/licenses_controller.rb @@ -63,6 +63,8 @@ def require_license end def license_params - params.require(:license).permit(:data_file) + license_params = params.require(:license).permit(:data_file, :data) + license_params.delete(:data) if license_params[:data_file] + license_params end end diff --git a/app/models/license.rb b/app/models/license.rb index 81b02593d9cd095ca6182ae3e995209d687dffd4..ce863605a9cbc103b33b2c547f4f8c0261c97e72 100644 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -44,7 +44,7 @@ def data_file=(file) def license return nil unless self.data - @license ||= + @license ||= begin Gitlab::License.import(self.data) rescue Gitlab::License::ImportError @@ -89,7 +89,7 @@ def reset_license def valid_license return if license? - self.errors.add(:base, "The license file is invalid. Make sure it is exactly as you received it from GitLab B.V..") + self.errors.add(:base, "The license key is invalid. Make sure it is exactly as you received it from GitLab Inc.") end def active_user_count @@ -99,7 +99,7 @@ def active_user_count date_range = (self.starts_at - 1.year)..self.starts_at active_user_count = HistoricalData.during(date_range).maximum(:active_user_count) || 0 - + return unless active_user_count return if active_user_count < restricted_user_count diff --git a/app/views/admin/licenses/new.html.haml b/app/views/admin/licenses/new.html.haml index da5c6a7cc4077271ef88877f2f70c762ce534191..a38fbc785b67e1455124c7c7730b5868f96c8264 100644 --- a/app/views/admin/licenses/new.html.haml +++ b/app/views/admin/licenses/new.html.haml @@ -2,7 +2,7 @@ %h3.page-title Upload License %p.light - To #{License.current ? "continue" : "start"} using GitLab Enterprise Edition, upload the <code>.gitlab-license</code> file you have received from GitLab B.V.. + To #{License.current ? "continue" : "start"} using GitLab Enterprise Edition, upload the <code>.gitlab-license</code> file or enter the license key you have received from GitLab Inc. %hr = form_for @license, url: admin_license_path, html: { multipart: true, class: 'form-horizontal fieldset-form' } do |f| @@ -13,9 +13,46 @@ %p= msg .form-group - = f.label :data_file, "License", class: 'control-label col-sm-2' + .col-sm-2 .col-sm-10 - = f.file_field :data_file, accept: ".gitlab-license,.gitlab_license,.txt" + .radio + = label_tag :license_type_file do + = radio_button_tag :license_type, :file, @license.data.blank? + .option-title + Upload <code>.gitlab-license</code> file + .radio + = label_tag :license_type_key do + = radio_button_tag :license_type, :key, @license.data.present? + .option-title + Enter license key + + .form-group.license-file + = f.label :data_file, "License file", class: 'control-label col-sm-2' + .col-sm-10 + = f.file_field :data_file, accept: ".gitlab-license,.gitlab_license,.txt", class: "form-control" + + .form-group.license-key + = f.label :data, "License key", class: 'control-label col-sm-2' + .col-sm-10 + = f.text_area :data, class: "form-control license-key-field", rows: 20 .form-actions = f.submit 'Upload license', class: 'btn btn-primary' + +:javascript + function showLicenseType() { + if ($("input[name='license_type']:checked").val() == "file") + { + $(".license-file").show(); + $(".license-key").hide(); + } + else + { + $(".license-file").hide(); + $(".license-key").show(); + } + } + + $("input[name='license_type']").click(showLicenseType); + + showLicenseType(); diff --git a/app/views/import/google_code/new.html.haml b/app/views/import/google_code/new.html.haml index 9c64e0a009fb73931f3845306911929d33b5ef6e..058f3ff574b60f0570e72fff4ac3349e58a6df0a 100644 --- a/app/views/import/google_code/new.html.haml +++ b/app/views/import/google_code/new.html.haml @@ -6,7 +6,7 @@ = form_tag callback_import_google_code_path, class: 'form-horizontal', multipart: true do %p - Follow the steps below to export your Google Code project data. + Follow the steps below to export your Google Code project data. In the next step, you'll be able to select the projects you want to import. %ol %li