Commit e004119e authored by Sean McGivern's avatar Sean McGivern

Merge branch 'future_dated_license_page' into 'master'

Show specific content for future-dated licenses

See merge request gitlab-org/gitlab!31463
parents a11b4dae 8022fef7
...@@ -7,10 +7,10 @@ class Admin::LicensesController < Admin::ApplicationController ...@@ -7,10 +7,10 @@ class Admin::LicensesController < Admin::ApplicationController
respond_to :html respond_to :html
def show def show
if @license.blank? if @license.present? || License.future_dated_only?
render :missing
else
@licenses = License.history @licenses = License.history
else
render :missing
end end
end end
...@@ -65,6 +65,7 @@ class Admin::LicensesController < Admin::ApplicationController ...@@ -65,6 +65,7 @@ class Admin::LicensesController < Admin::ApplicationController
def license def license
@license ||= begin @license ||= begin
License.reset_current License.reset_current
License.reset_future_dated
License.current License.current
end end
end end
......
...@@ -5,86 +5,96 @@ ...@@ -5,86 +5,96 @@
- else - else
%h3.page-title %h3.page-title
Your License Your License
- if @license.trial? - if @license&.trial?
= render "upload_buy_license" = render "upload_buy_license"
- else - else
= link_to 'Upload New License', new_admin_license_path, class: "btn btn-success float-right" = link_to 'Upload New License', new_admin_license_path, class: "btn btn-success float-right"
%hr %hr
.row - if License.future_dated_only?
.col-md-6 .gl-alert.gl-alert-info
.card = sprite_icon('information-o', size: 16, css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title')
.card-header .gl-alert-body
Licensed to %h4.gl-alert-title= s_('You do not have an active license')
%ul.content-list = s_('You have a license(s) that activates at a future date. Please see the License History table below.')
- @license.licensee.each do |label, value|
%li
%span.light #{label}:
%strong= value
.card.js-license-info-panel - if @license.present?
.card-header .row
Details .col-md-6
%ul.content-list .card
%li .card-header
%span.light Plan: Licensed to
%strong= @license.plan.capitalize %ul.content-list
%li - @license.licensee.each do |label, value|
%span.light Uploaded: %li
%strong= time_ago_with_tooltip @license.created_at %span.light #{label}:
%li %strong= value
%span.light Started:
%strong= time_ago_with_tooltip @license.starts_at .card.js-license-info-panel
%li .card-header
%span.light Details
- if @license.expired? %ul.content-list
Expired: %li
- else %span.light Plan:
Expires: %strong= @license.plan.capitalize
- if @license.will_expire? && !@license.expired? %li
- if @license.trial? %span.light Uploaded:
%strong.has-tooltip{ title: @license.expires_at.to_formatted_s(:long), data: { placement: 'top' } } %strong= time_ago_with_tooltip @license.created_at
Free trial will expire in #{pluralize(@license.remaining_days, 'day')} %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 - else
%strong= time_ago_with_tooltip(@license.expires_at) %strong Never
- else
%strong Never
- if @license.expired? - if @license.expired?
%span.badge.badge-danger.float-right %span.badge.badge-danger.float-right
%strong Expired %strong Expired
.col-md-6 .col-md-6
.card.border-info .card.border-info
.card-header.bg-info.text-white .card-header.bg-info.text-white
Download license Download license
.card-body .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 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. %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 %br
= link_to 'Download license', download_admin_license_path, class: "btn btn-info" = 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' = 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.border-danger
.card-header.bg-danger.text-white .card-header.bg-danger.text-white
Remove license Remove license
.card-body .card-body
%p If you remove this license, GitLab will fall back on the previous license, if any. %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. %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 %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" = 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? - if @licenses.any?
- licensee_keys = @licenses.first.licensee.keys
%h4 License History %h4 License History
.card#license_history .card#license_history
%table.table %table.table
%thead.card-header %thead.card-header
%tr %tr
- @license.licensee.keys.each do |label| - licensee_keys.each do |label|
%th= label %th= label
%th Plan %th Plan
%th Uploaded on %th Uploaded on
...@@ -94,7 +104,7 @@ ...@@ -94,7 +104,7 @@
%tbody %tbody
- @licenses.each do |license| - @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) } } %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= license.licensee[label]
%td %td
%span %span
......
---
title: Show specific content for future-dated licenses
merge_request: 31463
author:
type: added
...@@ -36,6 +36,7 @@ describe "Admin uploads license" do ...@@ -36,6 +36,7 @@ describe "Admin uploads license" do
it "installs 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.") 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 end
end end
...@@ -77,11 +78,27 @@ describe "Admin uploads license" do ...@@ -77,11 +78,27 @@ describe "Admin uploads license" do
context "when license starts in the future" do context "when license starts in the future" do
let_it_be(:license) { build(:gitlab_license, starts_at: Date.current + 1.month) } let_it_be(:license) { build(:gitlab_license, starts_at: Date.current + 1.month) }
it "uploads license" do context "when a current license exists" do
attach_and_upload(path) 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.") 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(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 end
end end
......
...@@ -44,12 +44,10 @@ describe "Admin views license" do ...@@ -44,12 +44,10 @@ describe "Admin views license" do
end end
context "when viewing license history", :aggregate_failures do context "when viewing license history", :aggregate_failures do
let_it_be(:license) { create(:license) }
it "shows licensee" do it "shows licensee" do
license_history = page.find("#license_history") 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) expect(license_history).to have_content(license.licensee.each_value.first)
end end
end end
...@@ -83,4 +81,44 @@ describe "Admin views license" do ...@@ -83,4 +81,44 @@ describe "Admin views license" do
end end
end 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 end
...@@ -24612,6 +24612,9 @@ msgstr "" ...@@ -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." msgid "You didn't renew your %{strong}%{plan_name}%{strong_close} subscription so it was downgraded to the GitLab Core Plan."
msgstr "" msgstr ""
msgid "You do not have an active license"
msgstr ""
msgid "You do not have any subscriptions yet" msgid "You do not have any subscriptions yet"
msgstr "" msgstr ""
...@@ -24660,6 +24663,9 @@ msgstr "" ...@@ -24660,6 +24663,9 @@ msgstr ""
msgid "You don’t have access to Value Stream Analytics for this group" msgid "You don’t have access to Value Stream Analytics for this group"
msgstr "" 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}." msgid "You have been granted %{access_level} access to the %{source_link} %{source_type}."
msgstr "" 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