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', () => {
const $licenseFile = $('.license-file');
const $licenseKey = $('.license-key');
const licenseFile = document.querySelector('.license-file');
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 $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);
$licenseKey.toggle(!$checkedFile);
const toggleUploadLicenseButton = () => {
uploadLicenseBtn.toggleAttribute('disabled', !acceptEULACheckBox.checked);
};
$('input[name="license_type"]').on('change', showLicenseType);
licenseType.forEach(el => el.addEventListener('change', showLicenseType));
acceptEULACheckBox.addEventListener('change', toggleUploadLicenseButton);
showLicenseType();
});
- 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
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 @@
.col-sm-10
= 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
= f.label :data, "License key"
.col-sm-10
= 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
= 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 @@
require "spec_helper"
RSpec.describe "Admin uploads license" do
RSpec.describe "Admin uploads license", :js do
let_it_be(:admin) { create(:admin) }
before do
......@@ -10,6 +10,32 @@ RSpec.describe "Admin uploads license" do
sign_in(admin)
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
before do
License.destroy_all # rubocop: disable Cop/DestroyAll
......@@ -119,6 +145,7 @@ RSpec.describe "Admin uploads license" do
def attach_and_upload(path)
attach_file("license_data_file", path)
click_button("Upload license")
check("accept_eula")
click_button("Upload License")
end
end
......@@ -26663,6 +26663,9 @@ msgstr ""
msgid "Unknown response text"
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"
msgstr ""
......
......@@ -22,7 +22,7 @@ module QA
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_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
def license?
......@@ -35,7 +35,8 @@ module QA
click_link 'Upload New License'
choose 'Enter license key'
fill_in 'License key', with: key
click_button 'Upload license'
check 'accept_eula'
click_button 'Upload License'
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