diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index c417ea92cc03c4d04841303a5fffc8b491d50d64..03966d6f4cbbc56ee08aa5cdba90391d46e73dd5 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -454,7 +454,6 @@ RSpec/AnyInstanceOf: - 'ee/spec/features/admin/admin_audit_logs_spec.rb' - 'ee/spec/features/admin/admin_reset_pipeline_minutes_spec.rb' - 'ee/spec/features/admin/admin_users_spec.rb' - - 'ee/spec/features/admin/licenses/admin_views_license_spec.rb' - 'ee/spec/features/boards/scoped_issue_board_spec.rb' - 'ee/spec/features/ci_shared_runner_warnings_spec.rb' - 'ee/spec/features/groups/group_settings_spec.rb' diff --git a/ee/app/assets/javascripts/admin/licenses/components/upload_trial_license_modal.vue b/ee/app/assets/javascripts/admin/licenses/components/upload_trial_license_modal.vue deleted file mode 100644 index 540cb9c72fec184db79a5b318abe29c37d3898ec..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/admin/licenses/components/upload_trial_license_modal.vue +++ /dev/null @@ -1,108 +0,0 @@ -<script> -import { GlModal, GlLink, GlIcon, GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui'; -import trialLicenseActivatedSvg from 'ee_icons/_ee_trial_license_activated.svg'; -import csrf from '~/lib/utils/csrf'; -import { __ } from '~/locale'; - -export default { - name: 'UploadTrialLicenseModal', - components: { - GlModal, - GlLink, - GlIcon, - }, - directives: { - SafeHtml, - }, - props: { - licenseKey: { - type: String, - required: true, - }, - adminLicensePath: { - type: String, - required: true, - }, - initialShow: { - type: Boolean, - required: false, - default: true, - }, - }, - data() { - return { - visible: this.initialShow, - }; - }, - methods: { - submitForm() { - this.$refs.form.submit(); - }, - }, - csrf, - cancelOptions: { - text: __('Cancel'), - }, - primaryOptions: { - text: __('Install license'), - attributes: [ - { - variant: 'confirm', - category: 'primary', - }, - ], - }, - trialLicenseActivatedSvg, -}; -</script> - -<template> - <gl-modal - ref="modal" - :visible="visible" - modal-id="modal-upload-trial-license" - body-class="modal-upload-trial-license" - :action-primary="$options.primaryOptions" - :action-cancel="$options.cancelOptions" - @primary.prevent="submitForm" - > - <div class="trial-activated-graphic gl-display-flex gl-justify-content-center gl-mt-5"> - <span v-safe-html="$options.trialLicenseActivatedSvg" class="svg-container"></span> - </div> - <h3 class="gl-text-center">{{ __('Your trial license was issued!') }}</h3> - <p class="gl-text-center gl-text-gray-500 mw-70p m-auto gl-font-size-h2 gl-line-height-28"> - {{ - __( - 'Your trial license was issued and activated. Install it to enjoy GitLab Ultimate for 30 days.', - ) - }} - </p> - <form - id="new_license" - ref="form" - :action="adminLicensePath" - enctype="multipart/form-data" - method="post" - > - <div class="gl-mt-5"> - <gl-link - id="hide-license" - href="#hide-license" - class="hide-license gl-text-gray-600 gl-text-center" - >{{ __('Show license key') }}<gl-icon name="chevron-down" - /></gl-link> - <gl-link - id="show-license" - href="#show-license" - class="show-license gl-text-gray-600 gl-text-center" - >{{ __('Hide license key') }}<gl-icon name="chevron-up" - /></gl-link> - <div class="card trial-license-preview gl-overflow-y-auto gl-word-break-all gl-mt-5"> - {{ licenseKey }} - </div> - </div> - <input :value="$options.csrf.token" type="hidden" name="authenticity_token" /> - <input id="license_data" :value="licenseKey" type="hidden" name="license[data]" /> - </form> - </gl-modal> -</template> diff --git a/ee/app/assets/javascripts/admin/licenses/init_trial_license_modal.js b/ee/app/assets/javascripts/admin/licenses/init_trial_license_modal.js deleted file mode 100644 index 572137efb6a5a7067dee5ec961ae954c8c79cdaa..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/admin/licenses/init_trial_license_modal.js +++ /dev/null @@ -1,23 +0,0 @@ -import Vue from 'vue'; -import UploadTrialLicenseModal from './components/upload_trial_license_modal.vue'; - -export default function initUploadTrialLicenseModal() { - const el = document.querySelector('.js-upload-trial-license-modal'); - - if (!el) { - return false; - } - const { licenseKey, adminLicensePath } = el.dataset; - - return new Vue({ - el, - render(h) { - return h(UploadTrialLicenseModal, { - props: { - licenseKey, - adminLicensePath, - }, - }); - }, - }); -} diff --git a/ee/app/assets/javascripts/pages/admin/licenses/show/index.js b/ee/app/assets/javascripts/pages/admin/licenses/show/index.js deleted file mode 100644 index 8faaa7a17a2ae999170d9780cb7db6aa476f6aa4..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/pages/admin/licenses/show/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import initUploadTrialLicenseModal from 'ee/admin/licenses/init_trial_license_modal'; -import { shouldQrtlyReconciliationMount } from 'ee/billings/qrtly_reconciliation'; - -shouldQrtlyReconciliationMount(); -initUploadTrialLicenseModal(); diff --git a/ee/app/controllers/admin/licenses_controller.rb b/ee/app/controllers/admin/licenses_controller.rb index ec596458add03a70b70ddf1340199bc23a74447e..56083842815683aba2d35ba07a6df42522e04812 100644 --- a/ee/app/controllers/admin/licenses_controller.rb +++ b/ee/app/controllers/admin/licenses_controller.rb @@ -3,28 +3,15 @@ class Admin::LicensesController < Admin::ApplicationController include Admin::LicenseRequest - before_action :license, only: [:show, :download, :destroy] + before_action :license, only: [:download, :destroy] before_action :require_license, only: [:download, :destroy] - before_action :check_cloud_license, only: [:show] respond_to :html feature_category :license - def show - if @license.present? || License.future_dated_only? - @licenses = License.history - else - render :missing - end - end - - def download - send_data @license.data, filename: @license.data_filename, disposition: 'attachment' - end - def new - build_license + @license ||= License.new(data: params[:trial_key]) end def create @@ -34,7 +21,7 @@ def create return upload_license_error if @license.cloud_license? - respond_with(@license, location: admin_license_path) do + respond_with(@license, location: admin_subscription_path) do if @license.save notice = if @license.started? _('The license was successfully uploaded and is now active. You can see the details below.') @@ -56,11 +43,11 @@ def destroy flash[:alert] = _('The license was removed. GitLab now no longer has a valid license.') end - redirect_to admin_license_path, status: :found + redirect_to admin_subscription_path, status: :found rescue Licenses::DestroyService::DestroyCloudLicenseError => e flash[:error] = e.message - redirect_to admin_license_path, status: :found + redirect_to admin_subscription_path, status: :found end def sync_seat_link @@ -77,14 +64,6 @@ def sync_seat_link private - def build_license - @license ||= License.new(data: params[:trial_key]) - end - - def check_cloud_license - redirect_to admin_subscription_path - end - def license_params license_params = params.require(:license).permit(:data_file, :data) license_params.delete(:data) if license_params[:data_file] diff --git a/ee/app/controllers/projects/path_locks_controller.rb b/ee/app/controllers/projects/path_locks_controller.rb index 7472a701b48d9f5bda14132fd50a0208a065599c..ad381b635f404dd74f8bf71313d8f650000e4e59 100644 --- a/ee/app/controllers/projects/path_locks_controller.rb +++ b/ee/app/controllers/projects/path_locks_controller.rb @@ -57,7 +57,7 @@ def destroy def check_license unless @project.feature_available?(:file_locks) flash[:alert] = _('You need a different license to enable FileLocks feature') - redirect_to admin_license_path + redirect_to admin_subscription_path end end diff --git a/ee/app/models/license.rb b/ee/app/models/license.rb index 1a237c82c74e5df952bfdb89260a1f31433eb3dd..fb1ba2db92b18aa94ba23a66ef0a3871c417bffc 100644 --- a/ee/app/models/license.rb +++ b/ee/app/models/license.rb @@ -324,12 +324,6 @@ def reset_future_dated Gitlab::SafeRequestStore.delete(:future_dated_license) end - def future_dated_only? - return false if current.present? - - future_dated.present? - end - def previous Gitlab::SafeRequestStore.fetch(:previous_license) { load_previous } end diff --git a/ee/app/views/admin/geo/shared/_license_alert.haml b/ee/app/views/admin/geo/shared/_license_alert.haml index b570ca279310ea9f3b0d9b59a36e27dee0fc84ac..33ccd2341b576790de5ae5d78b71e3d0d0960c16 100644 --- a/ee/app/views/admin/geo/shared/_license_alert.haml +++ b/ee/app/views/admin/geo/shared/_license_alert.haml @@ -1,6 +1,6 @@ - return if Gitlab::Geo.license_allows? .js-vue-alert{ 'v-cloak': true, data: { variant: 'tip', primary_button_text: _('Manage your license'), - primary_button_link: admin_license_path, + primary_button_link: admin_subscription_path, dismissible: 'true' } } = _('This GitLab instance is licensed at the %{insufficient_license} tier. Geo is only available for users who have at least a Premium license.') % { insufficient_license: current_license_title } diff --git a/ee/app/views/admin/licenses/_info.html.haml b/ee/app/views/admin/licenses/_info.html.haml deleted file mode 100644 index b046c687429a50873950304401ebcf5896c50b80..0000000000000000000000000000000000000000 --- a/ee/app/views/admin/licenses/_info.html.haml +++ /dev/null @@ -1,65 +0,0 @@ -.row - .col-md-6 - .gl-card.gl-mb-5 - .gl-card-header - = _('Licensed to') - .gl-card-body - %ul.content-list - - @license.licensee.each do |label, value| - %li - %span.light= succeed(':') { label } - %strong= value - - .gl-card.js-license-info-panel.gl-mb-5 - .gl-card-header - = _('Details') - .gl-card-body - %ul.content-list - %li - %span.light= _('Plan:') - %strong{ data: { "qa-selector": "plan_name" } }= @license.plan.capitalize - - unless @license.ultimate? - = ' - ' - = link_to _('Contact Sales to upgrade'), - 'https://about.gitlab.com/sales/?inapplink=contactsalessm', - class: 'inline-link', - target: :_blank, - rel: :noreferrer - %li - %span.light= _('Uploaded:') - %strong= time_ago_with_tooltip @license.created_at - %li - %span.light= _('Started:') - %strong= time_ago_with_tooltip @license.starts_at - %li - %span.light - = render 'license_status' - - - if @license.expired? - %span.badge.badge-danger.float-right - %strong= _('Expired') - %li - %span.light= _('License ID:') - %strong= @license.license_id - = clipboard_button(text: @license.license_id, title: _("Copy ID"), class: "btn-transparent btn-clipboard") - - - .col-md-6 - .gl-card.border-info.gl-mb-5 - .gl-card-header.bg-info.text-white - = _('Download license') - .gl-card-body - %p= html_escape(_('Your license will be included in your GitLab backup and will survive upgrades, so in normal usage you should never need to re-upload your %{code_open}.gitlab-license%{code_close} file.')) % { code_open: '<code>'.html_safe, code_close: '</code>'.html_safe } - %p= _('Still, we recommend keeping a backup saved somewhere. Otherwise, if you ever need it and have lost it, you will need to request GitLab Inc. to send it to you again.') - %br - = link_to _('Download license'), download_admin_license_path, class: 'gl-button btn btn-info' - = link_to _('Customer Portal'), 'https://customers.gitlab.com', class: 'gl-button btn btn-info btn-inverted', data: { track_event: 'click_text', track_label: 'license_dashboard', track_property: 'customer_portal' }, target: '_blank', rel: 'noopener noreferrer' - - .gl-card.border-danger.gl-mb-5 - .gl-card-header.bg-danger.text-white - = _('Remove license') - .gl-card-body - %p= _('If you remove this license, GitLab will fall back on the previous license, if any.') - %p= _('If there is no previous license or if the previous license has expired, some GitLab functionality will be blocked until a new, valid license is uploaded.') - %br - = link_to _('Remove license'), admin_license_path, data: { confirm: _('Are you sure you want to remove the license?') }, method: :delete, class: 'gl-button btn btn-danger' diff --git a/ee/app/views/admin/licenses/_license_history.html.haml b/ee/app/views/admin/licenses/_license_history.html.haml deleted file mode 100644 index 66753f1e7146ae97fd958d03a024dbb03eefb852..0000000000000000000000000000000000000000 --- a/ee/app/views/admin/licenses/_license_history.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -- licensee_keys = @licenses.first.licensee.keys - -%h4= _('License History') - -%table.gl-table.table#license_history - %thead - %tr - - licensee_keys.each do |label| - %th= label - %th= _('Plan') - %th= _('Uploaded on') - %th= _('Valid from') - %th= _('Expires on') - %th= _('Users in License') - %tbody - - @licenses.each do |license| - %tr{ class: ('gl-bg-blue-50 font-weight-bold gl-text-blue-500' if license == @license), data: { testid: ('license-current' if license == @license) } } - - licensee_keys.each do |label| - %td= license.licensee[label] - %td - %span - = license.plan.capitalize - %td - %span - = l(license.created_at, format: :with_timezone) - %td - %span - = l(license.starts_at) - %td - %span - = license.expires_at.present? ? l(license.expires_at) : _('Never') - %td - %span - - if license.restricted?(:active_user_count) - = license.restrictions[:active_user_count] - - else - = _('Unlimited') diff --git a/ee/app/views/admin/licenses/_repeat_trial_info.html.haml b/ee/app/views/admin/licenses/_repeat_trial_info.html.haml deleted file mode 100644 index 3ac4839a1312d7f7eed28ab68ac7556ab4cb6cae..0000000000000000000000000000000000000000 --- a/ee/app/views/admin/licenses/_repeat_trial_info.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -#repeat-trial-info.bs-callout.bs-callout-info.gl-alert.fade.in.show{ role: "alert" } - %button.js-close.gl-alert-dismiss{ type: 'button', 'aria-label' => _('Dismiss') } - = sprite_icon('close', size: 16, css_class: 'gl-icon') - %h4 - = _('Free Trial') - %p - = _('Thank you for signing up for your free trial! You will get additional instructions in your inbox shortly.') diff --git a/ee/app/views/admin/licenses/_summary.html.haml b/ee/app/views/admin/licenses/_summary.html.haml index 8a4016efdc17c0f9041f6ca888863353ff9df420..a64baf91e981cf6c4d5e0b4dc51458d31f8dd82a 100644 --- a/ee/app/views/admin/licenses/_summary.html.haml +++ b/ee/app/views/admin/licenses/_summary.html.haml @@ -14,4 +14,4 @@ %strong= @license.licensee_name = "(#{@license.licensee_email})" %div - = link_to 'View details', admin_license_path, class: "gl-button btn btn-default" + = link_to 'View details', admin_subscription_path, class: "gl-button btn btn-default" diff --git a/ee/app/views/admin/licenses/_upload_buy_license.html.haml b/ee/app/views/admin/licenses/_upload_buy_license.html.haml deleted file mode 100644 index 858a03c174fcc89ac70717606e1d4de61d701883..0000000000000000000000000000000000000000 --- a/ee/app/views/admin/licenses/_upload_buy_license.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -= link_to _('Buy License'), ::EE::SUBSCRIPTIONS_PLANS_URL, target: '_blank', rel: 'noopener noreferrer nofollow', class: 'gl-button btn btn-confirm-secondary float-right btn-buy-license' -= link_to _('Upload New License'), new_admin_license_path, class: 'gl-button btn btn-default float-right btn-upload-license gl-mr-3', data: { qa_selector: 'license_upload_link' } diff --git a/ee/app/views/admin/licenses/missing.html.haml b/ee/app/views/admin/licenses/missing.html.haml deleted file mode 100644 index bcf17ac88d2f4db6aded55f488fbd02cf6c72046..0000000000000000000000000000000000000000 --- a/ee/app/views/admin/licenses/missing.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -- page_title s_('License|License') - -%h3.page-title - = s_('License|Your License') - = render "upload_buy_license" -- if params[:trial_key].present? - .js-upload-trial-license-modal{ data: { license_key: params[:trial_key], admin_license_path: admin_license_path } } - -%hr - - if params.key?(:trial_key) && params[:trial_key].blank? - = render "repeat_trial_info" - -.container.blank-state-container - .text-center - = custom_icon("missing_license") - %h4{ data: { qa_selector: 'missing_license_content' } } - = s_('License|You do not have a license.') - - if License.eligible_for_trial? - %p.trial-description= s_('License|You can start a free trial of GitLab Ultimate without any obligation or payment details.') - = link_to 'Start free trial', new_trial_url, target: '_blank', class: "gl-button btn btn-confirm btn-start-trial gl-mt-3" - - else - %p.trial-description - = s_('License|Your free trial of GitLab Ultimate expired on %{trial_ends_on}.').html_safe % {trial_ends_on: License.trial_ends_on} - = s_('License|You can restore access to the Gold features at any time by upgrading.') - = link_to s_('License|Buy license'), ::EE::SUBSCRIPTIONS_PLANS_URL, target: '_blank', rel: 'noopener noreferrer nofollow', class: "gl-button btn btn-confirm btn-buy-license" diff --git a/ee/app/views/admin/licenses/show.html.haml b/ee/app/views/admin/licenses/show.html.haml deleted file mode 100644 index 51ed6936c130bb333e77bea3dfa5d20bd871fb01..0000000000000000000000000000000000000000 --- a/ee/app/views/admin/licenses/show.html.haml +++ /dev/null @@ -1,29 +0,0 @@ -- page_title _('License') - -= render_if_exists 'shared/qrtly_reconciliation_alert' - -%h3.page-title - = _('Your License') - - if @license&.trial? - = render 'upload_buy_license' - - else - = link_to _('Upload New License'), new_admin_license_path, class: 'gl-button btn btn-confirm float-right' - -%hr - -- if License.future_dated_only? - = render 'shared/global_alert', - title: _('You do not have an active license'), - variant: :info, - is_contained: true, - dismissible: false do - .gl-alert-body - = _('You have a license that activates at a future date. Please see the License History table below.') - -- if @license.present? - = render 'info' - .license-panel.gl-mt-5 - = render 'breakdown' - -- if @licenses.present? - = render 'license_history' diff --git a/ee/app/views/shared/icons/_ee_trial_license_activated.svg b/ee/app/views/shared/icons/_ee_trial_license_activated.svg deleted file mode 100644 index 3b35156e29a8e7849ed95098ae0536b9dd69f350..0000000000000000000000000000000000000000 --- a/ee/app/views/shared/icons/_ee_trial_license_activated.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="78" height="82" viewBox="0 0 78 82"><g fill="none" fill-rule="evenodd"><path fill="#F9F9F9" d="M2.12 42c-.08.99-.12 1.99-.12 3 0 20.435 16.565 37 37 37s37-16.565 37-37c0-1.01-.04-2.01-.12-3C74.353 61.032 58.425 76 39 76 19.575 76 3.647 61.032 2.12 42z"/><path fill="#EEE" fill-rule="nonzero" d="M39 78C17.46 78 0 60.54 0 39S17.46 0 39 0s39 17.46 39 39-17.46 39-39 39zm0-4c19.33 0 35-15.67 35-35S58.33 4 39 4 4 19.67 4 39s15.67 35 35 35z"/><path fill="#6B4FBB" d="M36.6 44.687l-7.314-6.82a3 3 0 1 0-4.092 4.388l9.508 8.866a2.99 2.99 0 0 0 2.15.804 2.99 2.99 0 0 0 2.09-.952l15.686-16.821a3 3 0 1 0-4.388-4.092L36.6 44.687z"/></g></svg> \ No newline at end of file diff --git a/ee/spec/controllers/admin/licenses_controller_spec.rb b/ee/spec/controllers/admin/licenses_controller_spec.rb index 9afd821f3c533e3bbb5c0399196114900d1935fb..8e79081fe0b468601fe2484dadcfbbecf97fb4ac 100644 --- a/ee/spec/controllers/admin/licenses_controller_spec.rb +++ b/ee/spec/controllers/admin/licenses_controller_spec.rb @@ -43,14 +43,14 @@ expect(response.body).to include('The license key is invalid. Make sure it is exactly as you received it from GitLab Inc.') end - it 'redirects to show when a valid license is entered/uploaded' do + it 'redirects to the subscription page when a valid license is entered/uploaded' do license = build_license expect do post :create, params: { license: { data: license.data } } end.to change(License, :count).by(1) - expect(response).to redirect_to(admin_license_path) + expect(response).to redirect_to(admin_subscription_path) end context 'Trials' do @@ -58,14 +58,14 @@ stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') end - it 'redirects to show when a valid trial license is entered/uploaded' do + it 'redirects to the subscription page when a valid trial license is entered/uploaded' do license = build_license(restrictions: { trial: true }) expect do post :create, params: { license: { data: license.data } } end.to change(License, :count).by(1) - expect(response).to redirect_to(admin_license_path) + expect(response).to redirect_to(admin_subscription_path) end end @@ -87,28 +87,6 @@ def build_license(cloud_licensing_enabled: false, restrictions: {}) end end - describe 'GET show' do - context 'with an existent license' do - it 'redirects to new path when a valid license is entered/uploaded' do - allow(License).to receive(:current).and_return(create(:license)) - - get :show - - expect(response).to redirect_to(admin_subscription_path) - end - end - - context 'without a license' do - it 'renders missing license page' do - allow(License).to receive(:current).and_return(nil) - - get :show - - expect(response).to redirect_to(admin_subscription_path) - end - end - end - describe 'POST sync_seat_link' do let_it_be(:historical_data) { create(:historical_data, recorded_at: Time.current) } @@ -152,7 +130,7 @@ def build_license(cloud_licensing_enabled: false, restrictions: {}) it 'is can not be removed' do delete :destroy - expect(response).to redirect_to(admin_license_path) + expect(response).to redirect_to(admin_subscription_path) expect(flash[:error]).to match('Cloud licenses can not be removed.') expect(cloud_licenses).to be_present end @@ -164,7 +142,7 @@ def build_license(cloud_licensing_enabled: false, restrictions: {}) it 'is can be removed' do delete :destroy - expect(response).to redirect_to(admin_license_path) + expect(response).to redirect_to(admin_subscription_path) expect(flash[:notice]).to match('The license was removed. GitLab has fallen back on the previous license.') expect(cloud_licenses).to be_empty end diff --git a/ee/spec/features/admin/licenses/admin_views_license_spec.rb b/ee/spec/features/admin/licenses/admin_views_license_spec.rb deleted file mode 100644 index c08111770dc529d2f955f7954593c907fdb9de3a..0000000000000000000000000000000000000000 --- a/ee/spec/features/admin/licenses/admin_views_license_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Admin views license' do - before do - admin = create(:admin) - - sign_in(admin) - gitlab_enable_admin_mode_sign_in(admin) - end - - it 'gets redirected to the new subscription page' do - visit(admin_license_path) - - expect(page).to have_current_path(admin_subscription_path) - end -end diff --git a/ee/spec/frontend/admin/licenses/components/upload_trial_license_modal_spec.js b/ee/spec/frontend/admin/licenses/components/upload_trial_license_modal_spec.js deleted file mode 100644 index be44df2e3c22c15739219a7191731566a61d9de7..0000000000000000000000000000000000000000 --- a/ee/spec/frontend/admin/licenses/components/upload_trial_license_modal_spec.js +++ /dev/null @@ -1,63 +0,0 @@ -import { GlModal } from '@gitlab/ui'; -import UploadTrialLicenseModal from 'ee/admin/licenses/components/upload_trial_license_modal.vue'; -import { stubComponent } from 'helpers/stub_component'; -import { mountExtended } from 'helpers/vue_test_utils_helper'; - -jest.mock('~/lib/utils/csrf', () => ({ token: 'mock-csrf-token' })); - -describe('UploadTrialLicenseModal', () => { - let wrapper; - let formSubmitSpy; - - function createComponent(props = {}) { - return mountExtended(UploadTrialLicenseModal, { - propsData: { - initialShow: true, - ...props, - }, - stubs: { - GlModal: stubComponent(GlModal, { - template: '<div><slot></slot><slot name="modal-footer"></slot></div>', - }), - }, - }); - } - - beforeEach(() => { - formSubmitSpy = jest.spyOn(HTMLFormElement.prototype, 'submit').mockImplementation(); - }); - - afterEach(() => { - wrapper.destroy(); - }); - - const findModal = () => wrapper.findComponent(GlModal); - const findForm = () => wrapper.find('form'); - const findAuthenticityToken = () => new FormData(findForm().element).get('authenticity_token'); - const findLicenseData = () => new FormData(findForm().element).get('license[data]'); - - describe('template', () => { - const licenseKey = '12345abcde'; - const adminLicensePath = '/admin/license'; - - describe('form', () => { - beforeEach(() => { - wrapper = createComponent({ licenseKey, adminLicensePath }); - }); - - it('displays the form with the correct action and inputs', () => { - expect(findForm().exists()).toBe(true); - expect(findForm().attributes('action')).toBe(adminLicensePath); - expect(findAuthenticityToken()).toBe('mock-csrf-token'); - expect(findLicenseData()).toBe(licenseKey); - }); - - it('submits the form when the primary action is clicked', () => { - const mockEvent = { preventDefault: jest.fn() }; - findModal().vm.$emit('primary', mockEvent); - - expect(formSubmitSpy).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/ee/spec/models/license_spec.rb b/ee/spec/models/license_spec.rb index 33110c9c24532a3dd46b151d60f5fd3148f60237..7265a90fdecb832e9e0ce162bb819d60ebf73c9e 100644 --- a/ee/spec/models/license_spec.rb +++ b/ee/spec/models/license_spec.rb @@ -601,57 +601,6 @@ def current_license_cached_value end end - describe '.future_dated_only?' do - before do - described_class.reset_future_dated - end - - context 'when licenses table does not exist' do - it 'returns false' do - allow(described_class).to receive(:table_exists?).and_return(false) - - expect(described_class.future_dated_only?).to be_falsey - end - end - - context 'when there is no license' do - it 'returns false' do - allow(described_class).to receive(:last_hundred).and_return([]) - - expect(described_class.future_dated_only?).to be_falsey - end - end - - context 'when the license is invalid' do - it 'returns false' do - license = build(:license, data: build(:gitlab_license, starts_at: Date.current + 1.month).export) - - allow(described_class).to receive(:last_hundred).and_return([license]) - allow(license).to receive(:valid?).and_return(false) - - expect(described_class.future_dated_only?).to be_falsey - end - end - - context 'when the license is valid' do - context 'when there is a current license' do - it 'returns the false' do - expect(described_class.future_dated_only?).to be_falsey - end - end - - context 'when the license is future-dated' do - it 'returns the true' do - create(:license, data: create(:gitlab_license, starts_at: Date.current + 1.month).export) - - allow(described_class).to receive(:current).and_return(nil) - - expect(described_class.future_dated_only?).to be_truthy - end - end - end - end - describe '.future_dated' do before do described_class.reset_future_dated diff --git a/ee/spec/views/admin/dashboard/index.html.haml_spec.rb b/ee/spec/views/admin/dashboard/index.html.haml_spec.rb index 9232a9b77304ac416bd36d36f2f15959579ab7bb..a30dfa6863ae9388e5327e3e43f92d6932a00690 100644 --- a/ee/spec/views/admin/dashboard/index.html.haml_spec.rb +++ b/ee/spec/views/admin/dashboard/index.html.haml_spec.rb @@ -39,7 +39,7 @@ expect(rendered).to have_content "Plan:" expect(rendered).to have_content "Expires:" expect(rendered).to have_content "Licensed to:" - expect(rendered).to have_link 'View details', href: admin_license_path + expect(rendered).to have_link 'View details', href: admin_subscription_path end it 'includes license breakdown' do diff --git a/ee/spec/views/admin/licenses/_info.html.haml_spec.rb b/ee/spec/views/admin/licenses/_info.html.haml_spec.rb deleted file mode 100644 index aaaee3914eee1e280efe00edb661d649f24d0654..0000000000000000000000000000000000000000 --- a/ee/spec/views/admin/licenses/_info.html.haml_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'admin/licenses/_info' do - context 'when observing the license' do - before do - assign(:license, license) - end - - context 'when plan can be upgraded' do - let(:license) { create(:license, plan: License::STARTER_PLAN) } - - it 'shows "Contact Sales to upgrade" link' do - render - - expect(rendered).to have_content('Plan: Starter - Contact Sales to upgrade') - expect(rendered).to have_link('Contact Sales to upgrade') - end - end - - context 'when plan can not be upgraded' do - let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } - - it 'does not show "Contact Sales to upgrade" link' do - render - - expect(rendered).to have_content('Plan: Ultimate') - expect(rendered).not_to have_link('Contact Sales to upgrade') - end - end - end -end diff --git a/ee/spec/views/admin/licenses/show.html.haml_spec.rb b/ee/spec/views/admin/licenses/show.html.haml_spec.rb deleted file mode 100644 index 2571cb16a738b04fc53cc1c8de7766f9f7df7e02..0000000000000000000000000000000000000000 --- a/ee/spec/views/admin/licenses/show.html.haml_spec.rb +++ /dev/null @@ -1,78 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'admin/licenses/show.html.haml' do - let_it_be(:license) { create(:license) } - - context 'when trial license is present' do - before do - trial_license = create(:license, trial: true) - assign(:license, trial_license) - end - - it 'shows content as expected' do - render - - expect(rendered).to have_content('Buy License') - expect(rendered).not_to have_content('License overview') - end - end - - context 'when non trial license is present' do - before do - assign(:license, license) - end - - it 'shows content as expected' do - render - - expect(rendered).not_to have_content('Buy License') - expect(rendered).to have_content('Licensed to') - expect(rendered).to have_content('Users in License') - expect(rendered).to have_content('Upload New License') - end - end - - context 'when license is not present' do - it 'does not show content' do - render - - expect(rendered).not_to have_content('Licensed to') - expect(rendered).not_to have_content('Users in License') - expect(rendered).to have_content('Upload New License') - end - end - - context 'when licenses are present' do - before do - assign(:licenses, [license]) - end - - it 'shows content as expected' do - render - - expect(rendered).to have_content('License History') - end - end - - context 'when licenses are empty' do - before do - assign(:licenses, []) - end - - it 'does not show content' do - render - - expect(rendered).not_to have_content('License History') - end - end - - context 'when licenses are not defined' do - it 'does not show content' do - render - - expect(rendered).not_to have_content('License History') - end - end -end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 4e9483ae746b9aba0daf4c982cf815a9f8f806ab..d68712d597523f3515c54b50862c74b3a5e33582 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -5759,9 +5759,6 @@ msgstr "" msgid "Buy CI Minutes" msgstr "" -msgid "Buy License" -msgstr "" - msgid "Buy more Pipeline minutes" msgstr "" @@ -8454,9 +8451,6 @@ msgstr "" msgid "Consistency guarantee method" msgstr "" -msgid "Contact Sales to upgrade" -msgstr "" - msgid "Contact support" msgstr "" @@ -9702,9 +9696,6 @@ msgstr "" msgid "Custom range (UTC)" msgstr "" -msgid "Customer Portal" -msgstr "" - msgid "Customizable by an administrator." msgstr "" @@ -11701,9 +11692,6 @@ msgstr "" msgid "Download image" msgstr "" -msgid "Download license" -msgstr "" - msgid "Download raw data (.csv)" msgstr "" @@ -13323,9 +13311,6 @@ msgstr "" msgid "Expires in %{expires_at}" msgstr "" -msgid "Expires on" -msgstr "" - msgid "Expires:" msgstr "" @@ -14347,9 +14332,6 @@ msgstr "" msgid "Framework successfully deleted" msgstr "" -msgid "Free Trial" -msgstr "" - msgid "Free Trial of GitLab.com Ultimate" msgstr "" @@ -16242,9 +16224,6 @@ msgstr "" msgid "Hide host keys manual input" msgstr "" -msgid "Hide license key" -msgstr "" - msgid "Hide list" msgstr "" @@ -16499,9 +16478,6 @@ msgstr "" msgid "If the number of active users exceeds the user limit, you will be charged for the number of %{users_over_license_link} at your next license reconciliation." msgstr "" -msgid "If there is no previous license or if the previous license has expired, some GitLab functionality will be blocked until a new, valid license is uploaded." -msgstr "" - msgid "If this email was added in error, you can remove it here:" msgstr "" @@ -16541,9 +16517,6 @@ msgstr "" msgid "If you recently signed in and recognize the IP address, you may disregard this email." msgstr "" -msgid "If you remove this license, GitLab will fall back on the previous license, if any." -msgstr "" - msgid "If you want to re-enable two-factor authentication, visit %{two_factor_link}" msgstr "" @@ -17546,9 +17519,6 @@ msgstr "" msgid "Install GitLab Runner on Kubernetes" msgstr "" -msgid "Install license" -msgstr "" - msgid "Install on clusters" msgstr "" @@ -19479,18 +19449,9 @@ msgstr "" msgid "Let's talk!" msgstr "" -msgid "License" -msgstr "" - msgid "License Compliance" msgstr "" -msgid "License History" -msgstr "" - -msgid "License ID:" -msgstr "" - msgid "License file" msgstr "" @@ -19602,9 +19563,6 @@ msgstr "" msgid "Licensed Features" msgstr "" -msgid "Licensed to" -msgstr "" - msgid "Licensed to:" msgstr "" @@ -19662,27 +19620,6 @@ msgstr "" msgid "Licenses|View license details for your project" msgstr "" -msgid "License|Buy license" -msgstr "" - -msgid "License|License" -msgstr "" - -msgid "License|You can restore access to the Gold features at any time by upgrading." -msgstr "" - -msgid "License|You can start a free trial of GitLab Ultimate without any obligation or payment details." -msgstr "" - -msgid "License|You do not have a license." -msgstr "" - -msgid "License|Your License" -msgstr "" - -msgid "License|Your free trial of GitLab Ultimate expired on %{trial_ends_on}." -msgstr "" - msgid "Limit display of time tracking units to hours." msgstr "" @@ -24500,9 +24437,6 @@ msgstr "" msgid "Plain diff" msgstr "" -msgid "Plan" -msgstr "" - msgid "Plan:" msgstr "" @@ -30176,9 +30110,6 @@ msgstr "" msgid "Show latest version" msgstr "" -msgid "Show license key" -msgstr "" - msgid "Show links anyways" msgstr "" @@ -31128,9 +31059,6 @@ msgstr "" msgid "Started asynchronous removal of all repository check states." msgstr "" -msgid "Started:" -msgstr "" - msgid "Starting..." msgstr "" @@ -31353,9 +31281,6 @@ msgstr "" msgid "Step 4." msgstr "" -msgid "Still, we recommend keeping a backup saved somewhere. Otherwise, if you ever need it and have lost it, you will need to request GitLab Inc. to send it to you again." -msgstr "" - msgid "Stop Terminal" msgstr "" @@ -32444,9 +32369,6 @@ msgstr "" msgid "Text style" msgstr "" -msgid "Thank you for signing up for your free trial! You will get additional instructions in your inbox shortly." -msgstr "" - msgid "Thank you for your business." msgstr "" @@ -35331,9 +35253,6 @@ msgstr "" msgid "Upload New File" msgstr "" -msgid "Upload New License" -msgstr "" - msgid "Upload a certificate for your domain with all intermediates" msgstr "" @@ -35358,12 +35277,6 @@ msgstr "" msgid "UploadLink|click to upload" msgstr "" -msgid "Uploaded on" -msgstr "" - -msgid "Uploaded:" -msgstr "" - msgid "Uploading changes to terminal" msgstr "" @@ -36051,9 +35964,6 @@ msgstr "" msgid "Using the %{codeStart}needs%{codeEnd} keyword makes jobs run before their stage is reached. Jobs run as soon as their %{codeStart}needs%{codeEnd} relationships are met, which speeds up your pipelines." msgstr "" -msgid "Valid from" -msgstr "" - msgid "Validate" msgstr "" @@ -37629,9 +37539,6 @@ msgstr "" msgid "You didn't renew your subscription for %{strong}%{namespace_name}%{strong_close} so it was downgraded to the free plan." msgstr "" -msgid "You do not have an active license" -msgstr "" - msgid "You do not have any subscriptions yet" msgstr "" @@ -37695,9 +37602,6 @@ msgstr "" msgid "You don’t have access to Value Stream Analytics for this group" msgstr "" -msgid "You have a license that activates at a future date. Please see the License History table below." -msgstr "" - msgid "You have been granted %{access_level} access to the %{source_link} %{source_type}." msgstr "" @@ -37980,9 +37884,6 @@ msgstr "" msgid "Your Groups" msgstr "" -msgid "Your License" -msgstr "" - msgid "Your Personal Access Token was revoked" msgstr "" @@ -38136,9 +38037,6 @@ msgstr "" msgid "Your license is valid from" msgstr "" -msgid "Your license will be included in your GitLab backup and will survive upgrades, so in normal usage you should never need to re-upload your %{code_open}.gitlab-license%{code_close} file." -msgstr "" - msgid "Your membership in %{group} no longer expires." msgstr "" @@ -38229,12 +38127,6 @@ msgstr "" msgid "Your subscription will expire in %{remaining_days}." msgstr "" -msgid "Your trial license was issued and activated. Install it to enjoy GitLab Ultimate for 30 days." -msgstr "" - -msgid "Your trial license was issued!" -msgstr "" - msgid "Your username is %{username}." msgstr "" diff --git a/qa/qa/ee/page/admin/license.rb b/qa/qa/ee/page/admin/license.rb index af4680f67e21902e0c50aa919f8f539fc9bd2709..757b17c558bf5139e2b582ea79d6bd7193196839 100644 --- a/qa/qa/ee/page/admin/license.rb +++ b/qa/qa/ee/page/admin/license.rb @@ -5,10 +5,6 @@ module EE module Page module Admin class License < QA::Page::Base - view 'ee/app/views/admin/licenses/missing.html.haml' do - element :missing_license_content - end - view 'ee/app/assets/javascripts/admin/subscriptions/show/components/subscription_activation_card.vue' do element :license_upload_link end diff --git a/scripts/verify-tff-mapping b/scripts/verify-tff-mapping index 4555a9854ddae40cbaff7d2e1e651dd0bb7381b9..ca73d4f5f7abf77c3a407f19de5d26eb7f1c598a 100755 --- a/scripts/verify-tff-mapping +++ b/scripts/verify-tff-mapping @@ -90,8 +90,8 @@ tests = [ { explanation: 'EE views should map to respective spec', - source: 'ee/app/views/admin/licenses/show.html.haml', - expected: ['ee/spec/views/admin/licenses/show.html.haml_spec.rb'] + source: 'ee/app/views/subscriptions/new.html.haml', + expected: ['ee/spec/views/subscriptions/new.html.haml_spec.rb'] }, {