diff --git a/ee/app/controllers/admin/licenses_controller.rb b/ee/app/controllers/admin/licenses_controller.rb index fa96edd1ace0a8bed693afe7ed5cf8273767484c..5dc33761f361d86d793c6afa34dd963b07e1f7bd 100644 --- a/ee/app/controllers/admin/licenses_controller.rb +++ b/ee/app/controllers/admin/licenses_controller.rb @@ -7,10 +7,10 @@ class Admin::LicensesController < Admin::ApplicationController respond_to :html def show - if @license.blank? - render :missing - else + if @license.present? || License.future_dated_only? @licenses = License.history + else + render :missing end end @@ -65,6 +65,7 @@ def destroy def license @license ||= begin License.reset_current + License.reset_future_dated License.current end end diff --git a/ee/app/views/admin/licenses/show.html.haml b/ee/app/views/admin/licenses/show.html.haml index 254583f9c182234ab8b7c6dde853d01065671f19..6e9e8edaea9f7d40e0bcd424a68a0024f75bdd07 100644 --- a/ee/app/views/admin/licenses/show.html.haml +++ b/ee/app/views/admin/licenses/show.html.haml @@ -5,86 +5,96 @@ - else %h3.page-title Your License - - if @license.trial? + - if @license&.trial? = render "upload_buy_license" - else = link_to 'Upload New License', new_admin_license_path, class: "btn btn-success float-right" %hr - .row - .col-md-6 - .card - .card-header - Licensed to - %ul.content-list - - @license.licensee.each do |label, value| - %li - %span.light #{label}: - %strong= value + - if License.future_dated_only? + .gl-alert.gl-alert-info + = sprite_icon('information-o', size: 16, css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title') + .gl-alert-body + %h4.gl-alert-title= s_('You do not have an active license') + = s_('You have a license(s) that activates at a future date. Please see the License History table below.') - .card.js-license-info-panel - .card-header - Details - %ul.content-list - %li - %span.light Plan: - %strong= @license.plan.capitalize - %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 - - if @license.expired? - Expired: - - else - Expires: - - if @license.will_expire? && !@license.expired? - - if @license.trial? - %strong.has-tooltip{ title: @license.expires_at.to_formatted_s(:long), data: { placement: 'top' } } - Free trial will expire in #{pluralize(@license.remaining_days, 'day')} + - if @license.present? + .row + .col-md-6 + .card + .card-header + Licensed to + %ul.content-list + - @license.licensee.each do |label, value| + %li + %span.light #{label}: + %strong= value + + .card.js-license-info-panel + .card-header + Details + %ul.content-list + %li + %span.light Plan: + %strong= @license.plan.capitalize + %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 + - if @license.expired? + Expired: + - else + Expires: + - if @license.will_expire? && !@license.expired? + - if @license.trial? + %strong.has-tooltip{ title: @license.expires_at.to_formatted_s(:long), data: { placement: 'top' } } + Free trial will expire in #{pluralize(@license.remaining_days, 'day')} + - else + %strong= time_ago_with_tooltip(@license.expires_at) - else - %strong= time_ago_with_tooltip(@license.expires_at) - - else - %strong Never + %strong Never - - if @license.expired? - %span.badge.badge-danger.float-right - %strong Expired + - if @license.expired? + %span.badge.badge-danger.float-right + %strong Expired - .col-md-6 - .card.border-info - .card-header.bg-info.text-white - Download license - .card-body - %p 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>.gitlab-license</code> file. - %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: "btn btn-info" - = link_to 'Customer Portal', 'https://customers.gitlab.com', class: 'btn btn-info btn-inverted', data: { track_event: 'click_text', track_label: 'license_dashboard', track_property: 'customer_portal' }, target: '_blank', rel: 'noopener noreferrer' + .col-md-6 + .card.border-info + .card-header.bg-info.text-white + Download license + .card-body + %p 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>.gitlab-license</code> file. + %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: "btn btn-info" + = link_to 'Customer Portal', 'https://customers.gitlab.com', class: 'btn btn-info btn-inverted', data: { track_event: 'click_text', track_label: 'license_dashboard', track_property: 'customer_portal' }, target: '_blank', rel: 'noopener noreferrer' - .card.border-danger - .card-header.bg-danger.text-white - Remove license - .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: "btn btn-remove qa-remove-license-link" + .card.border-danger + .card-header.bg-danger.text-white + Remove license + .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: "btn btn-remove qa-remove-license-link" - = render "breakdown", license: @license + = render "breakdown", license: @license - if @licenses.any? + - licensee_keys = @licenses.first.licensee.keys + %h4 License History .card#license_history %table.table %thead.card-header %tr - - @license.licensee.keys.each do |label| + - licensee_keys.each do |label| %th= label %th Plan %th Uploaded on @@ -94,7 +104,7 @@ %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) } } - - @license.licensee.keys.each do |label| + - licensee_keys.each do |label| %td= license.licensee[label] %td %span diff --git a/ee/changelogs/unreleased/future_dated_license_page.yml b/ee/changelogs/unreleased/future_dated_license_page.yml new file mode 100644 index 0000000000000000000000000000000000000000..973a14769e96c663d4ec0ff721bbb110322af718 --- /dev/null +++ b/ee/changelogs/unreleased/future_dated_license_page.yml @@ -0,0 +1,5 @@ +--- +title: Show specific content for future-dated licenses +merge_request: 31463 +author: +type: added diff --git a/ee/spec/features/admin/licenses/admin_uploads_license_spec.rb b/ee/spec/features/admin/licenses/admin_uploads_license_spec.rb index a70242fb7c2b7c6749f71b849162fd7389fb9cb1..f8859b2999cfcecbb918c40903cac1ffbb181388 100644 --- a/ee/spec/features/admin/licenses/admin_uploads_license_spec.rb +++ b/ee/spec/features/admin/licenses/admin_uploads_license_spec.rb @@ -36,6 +36,7 @@ it "installs license" do expect(page).to have_content("The license was successfully uploaded and will be active from #{license.starts_at}. You can see the details below.") + .and have_content("You have a license(s) that activates at a future date. Please see the License History table below.") end end end @@ -77,11 +78,27 @@ context "when license starts in the future" do let_it_be(:license) { build(:gitlab_license, starts_at: Date.current + 1.month) } - it "uploads license" do - attach_and_upload(path) + context "when a current license exists" do + it "uploads license" do + attach_and_upload(path) - expect(page).to have_content("The license was successfully uploaded and will be active from #{license.starts_at}. You can see the details below.") - .and have_content(license.licensee.each_value.first) + expect(page).to have_content("The license was successfully uploaded and will be active from #{license.starts_at}. You can see the details below.") + .and have_content(license.licensee.each_value.first) + end + end + + context "when no current license exists" do + before do + allow(License).to receive(:current).and_return(nil) + end + + it "uploads license" do + attach_and_upload(path) + + expect(page).to have_content("The license was successfully uploaded and will be active from #{license.starts_at}. You can see the details below.") + .and have_content(license.licensee.each_value.first) + .and have_content("You have a license(s) that activates at a future date. Please see the License History table below.") + end end end 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 index f46e4b58f308b5066e7f5050bc20534df3f20bb0..be5ed9cf1d9fc8c05f17bc5fd3c04a36870c480d 100644 --- a/ee/spec/features/admin/licenses/admin_views_license_spec.rb +++ b/ee/spec/features/admin/licenses/admin_views_license_spec.rb @@ -44,12 +44,10 @@ end context "when viewing license history", :aggregate_failures do - let_it_be(:license) { create(:license) } - it "shows licensee" do license_history = page.find("#license_history") - License.all.each do |license| + License.history.each do |license| expect(license_history).to have_content(license.licensee.each_value.first) end end @@ -83,4 +81,44 @@ end end end + + context "when existing licenses only contain a future-dated license" do + let_it_be(:license) { create(:license, data: create(:gitlab_license, starts_at: Date.current + 1.month).export) } + + before do + License.where.not(id: license.id).delete_all + + visit(admin_license_path) + end + + context "when viewing license history" do + it "shows licensee" do + license_history = page.find("#license_history") + + expect(license_history).to have_content(license.licensee.each_value.first) + end + + it "has no highlighted license", :aggregate_failures do + license_history = page.find("#license_history") + + expect(license_history).not_to have_selector("[data-testid='license-current']") + end + + it "shows only the future-dated license", :aggregate_failures do + license_history = page.find("#license_history") + license_history_row = license_history.find('tbody tr', match: :first) + + expect(license_history).to have_css('tbody tr', count: 1) + + expect(license_history_row).to have_content(license.licensee[:name]) + expect(license_history_row).to have_content(license.licensee[:email]) + expect(license_history_row).to have_content(license.licensee[:company]) + expect(license_history_row).to have_content(license.plan.capitalize) + expect(license_history_row).to have_content(license.created_at) + expect(license_history_row).to have_content(license.starts_at) + expect(license_history_row).to have_content(license.expires_at) + expect(license_history_row).to have_content(license.restrictions[:active_user_count]) + end + end + end end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 299fa763cf27d8f6a2e30d9355b28f72491e9954..ae4c454208be146d0894abaac3edd90c578c8979 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -24612,6 +24612,9 @@ msgstr "" msgid "You didn't renew your %{strong}%{plan_name}%{strong_close} subscription so it was downgraded to the GitLab Core Plan." msgstr "" +msgid "You do not have an active license" +msgstr "" + msgid "You do not have any subscriptions yet" msgstr "" @@ -24660,6 +24663,9 @@ msgstr "" msgid "You don’t have access to Value Stream Analytics for this group" msgstr "" +msgid "You have a license(s) 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 ""