Commit ac19798a authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch 'vs-add-eula-checkbox-to-ee' into 'master'

Add 'Accept EULA' checkbox to EE

Closes #224712

See merge request gitlab-org/gitlab!40352
parents c2215a75 0f1ded3c
import $ from 'jquery';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const $licenseFile = $('.license-file'); const licenseFile = document.querySelector('.license-file');
const $licenseKey = $('.license-key'); const licenseKey = document.querySelector('.license-key');
const acceptEULACheckBox = document.querySelector('#accept_eula');
const uploadLicenseBtn = document.querySelector('#js-upload-license');
const licenseType = document.querySelectorAll('input[name="license_type"]');
const showLicenseType = () => { const showLicenseType = () => {
const $checkedFile = $('input[name="license_type"]:checked').val() === 'file'; const checkedFile =
document.querySelector('input[name="license_type"]:checked').value === 'file';
licenseFile.classList.toggle('hidden', !checkedFile);
licenseKey.classList.toggle('hidden', checkedFile);
};
$licenseFile.toggle($checkedFile); const toggleUploadLicenseButton = () => {
$licenseKey.toggle(!$checkedFile); uploadLicenseBtn.toggleAttribute('disabled', !acceptEULACheckBox.checked);
}; };
$('input[name="license_type"]').on('change', showLicenseType); licenseType.forEach(el => el.addEventListener('change', showLicenseType));
acceptEULACheckBox.addEventListener('change', toggleUploadLicenseButton);
showLicenseType(); showLicenseType();
}); });
- page_title _("Upload License") - page_title _("Upload License")
%h3.page-title Upload License - eula_url = 'https://about.gitlab.com/terms/#subscription'
- eula_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: eula_url }
%h3.page-title= _('Upload License')
%p.light %p.light
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. 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.
...@@ -32,11 +34,18 @@ ...@@ -32,11 +34,18 @@
.col-sm-10 .col-sm-10
= f.file_field :data_file, accept: ".gitlab-license,.gitlab_license,.txt", class: "form-control" = f.file_field :data_file, accept: ".gitlab-license,.gitlab_license,.txt", class: "form-control"
.form-group.row.license-key .form-group.row.license-key.hidden
.col-sm-2.col-form-label .col-sm-2.col-form-label
= f.label :data, "License key" = f.label :data, "License key"
.col-sm-10 .col-sm-10
= f.text_area :data, class: "form-control license-key-field", rows: 20 = f.text_area :data, class: "form-control license-key-field", rows: 20
.form-group.row
.col-sm-2
.col-sm-10
= label_tag :accept_eula, nil, class: 'form-check-label' do
= check_box_tag :accept_eula, data: { qa_selector: 'accept_eula' }
= _('Unless otherwise agreed to in writing with GitLab, by clicking "Upload License" you agree that your use of GitLab Software is subject to the %{eula_link_start}Terms of Service%{eula_link_end}.').html_safe % { eula_link_start: eula_link_start, eula_url: eula_url, eula_link_end: '</a>'.html_safe }
.form-actions .form-actions
= f.submit 'Upload license', class: 'btn btn-primary' = f.submit 'Upload License', class: 'btn btn-primary', disabled: true, id: 'js-upload-license'
---
title: Add EULA checkbox on license page
merge_request: 40352
author:
type: added
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require "spec_helper" require "spec_helper"
RSpec.describe "Admin uploads license" do RSpec.describe "Admin uploads license", :js do
let_it_be(:admin) { create(:admin) } let_it_be(:admin) { create(:admin) }
before do before do
...@@ -10,6 +10,32 @@ RSpec.describe "Admin uploads license" do ...@@ -10,6 +10,32 @@ RSpec.describe "Admin uploads license" do
sign_in(admin) sign_in(admin)
end end
context 'default state' do
before do
visit(new_admin_license_path)
end
it 'has unselected EULA checkbox by default' do
expect(page).to have_unchecked_field('accept_eula')
end
it 'has disabled button "Upload license" by default' do
expect(page).to have_button('Upload License', disabled: true)
end
it 'redirects to current Subscription terms' do
expect(page).to have_link('Terms of Service', href: 'https://about.gitlab.com/terms/#subscription')
end
it 'enables button "Upload license" when EULA checkbox is selected' do
expect(page).to have_button('Upload License', disabled: true)
check('accept_eula')
expect(page).to have_button('Upload License', disabled: false)
end
end
context "when license key is provided in the query string" do context "when license key is provided in the query string" do
before do before do
License.destroy_all # rubocop: disable Cop/DestroyAll License.destroy_all # rubocop: disable Cop/DestroyAll
...@@ -119,6 +145,7 @@ RSpec.describe "Admin uploads license" do ...@@ -119,6 +145,7 @@ RSpec.describe "Admin uploads license" do
def attach_and_upload(path) def attach_and_upload(path)
attach_file("license_data_file", path) attach_file("license_data_file", path)
click_button("Upload license") check("accept_eula")
click_button("Upload License")
end end
end end
...@@ -26663,6 +26663,9 @@ msgstr "" ...@@ -26663,6 +26663,9 @@ msgstr ""
msgid "Unknown response text" msgid "Unknown response text"
msgstr "" msgstr ""
msgid "Unless otherwise agreed to in writing with GitLab, by clicking \"Upload License\" you agree that your use of GitLab Software is subject to the %{eula_link_start}Terms of Service%{eula_link_end}."
msgstr ""
msgid "Unlimited" msgid "Unlimited"
msgstr "" msgstr ""
......
...@@ -22,7 +22,7 @@ module QA ...@@ -22,7 +22,7 @@ module QA
element :license_type_placeholder, 'Enter license key' # rubocop:disable QA/ElementWithPattern element :license_type_placeholder, 'Enter license key' # rubocop:disable QA/ElementWithPattern
element :license_key_field, 'text_area :data' # rubocop:disable QA/ElementWithPattern element :license_key_field, 'text_area :data' # rubocop:disable QA/ElementWithPattern
element :license_key_placeholder, 'label :data, "License key"' # rubocop:disable QA/ElementWithPattern element :license_key_placeholder, 'label :data, "License key"' # rubocop:disable QA/ElementWithPattern
element :license_upload_buttonm, "submit 'Upload license'" # rubocop:disable QA/ElementWithPattern element :license_upload_button, "submit 'Upload License'" # rubocop:disable QA/ElementWithPattern
end end
def license? def license?
...@@ -35,7 +35,8 @@ module QA ...@@ -35,7 +35,8 @@ module QA
click_link 'Upload New License' click_link 'Upload New License'
choose 'Enter license key' choose 'Enter license key'
fill_in 'License key', with: key fill_in 'License key', with: key
click_button 'Upload license' check 'accept_eula'
click_button 'Upload License'
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment