Commit 8022fef7 authored by Corinna Wiesner's avatar Corinna Wiesner

Show specific content for future-dated licenses

When a current license already exists and a future-dated license is
uploaded the current license's information and breakdown as well as a
license history is displayed. But when no current license exists and a
future-dated license is uploaded then an information message and the
license history is displayed.
parent dc2fbc70
......@@ -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 @@ class Admin::LicensesController < Admin::ApplicationController
def license
@license ||= begin
License.reset_current
License.reset_future_dated
License.current
end
end
......
......@@ -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
......
---
title: Show specific content for future-dated licenses
merge_request: 31463
author:
type: added
......@@ -36,6 +36,7 @@ describe "Admin uploads license" do
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 @@ describe "Admin uploads license" do
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
......
......@@ -44,12 +44,10 @@ describe "Admin views license" do
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 @@ describe "Admin views license" do
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
......@@ -24606,6 +24606,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 ""
......@@ -24654,6 +24657,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 ""
......
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