Merge remote-tracking branch 'origin/release/11.4' into dev

pull/9704/head
ulferts 3 years ago
parent 2aad439d01
commit 2d6eec0874
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 6
      app/models/enterprise_token.rb
  2. 7
      app/views/enterprises/_current.html.erb
  3. 2
      config/locales/js-en.yml
  4. 17
      frontend/src/app/features/enterprise/enterprise-active-trial/ee-active-saved-trial.component.ts
  5. 2
      frontend/src/app/features/enterprise/enterprise-active-trial/ee-active-trial.base.ts
  6. 1
      frontend/src/app/features/enterprise/enterprise-active-trial/ee-active-trial.component.html
  7. 42
      spec/fixtures/ee_tokens/v1_expired_with_7_days_reprieve_at_2021_09_01.token
  8. 42
      spec/fixtures/ee_tokens/v1_expired_without_reprieve_at_2021_09_01.token
  9. 86
      spec/views/admin/enterprises/_current.html.erb_spec.rb
  10. 2
      spec/workers/extract_fulltext_job_spec.rb

@ -69,6 +69,8 @@ class EnterpriseToken < ApplicationRecord
:issued_at,
:starts_at,
:expires_at,
:reprieve_days,
:reprieve_days_left,
:restrictions,
to: :token_object
@ -86,8 +88,8 @@ class EnterpriseToken < ApplicationRecord
RequestStore.delete :current_ee_token
end
def expired?
token_object.expired? || invalid_domain?
def expired?(reprieve: true)
token_object.expired?(reprieve: reprieve) || invalid_domain?
end
##

@ -5,10 +5,13 @@
data-domain="<%= @current_token.try(:domain) %>"
data-user-count="<%= @current_token.restrictions.nil? ? t('js.admin.enterprise.upsale.unlimited') : @current_token.restrictions[:active_user_count] %>"
data-starts-at="<%= format_date @current_token.starts_at %>"
data-expires-at="<%= (!@current_token.will_expire?) ? t('js.admin.enterprise.upsale.unlimited') : (format_date @current_token.expires_at) %>">
data-expires-at="<%= (!@current_token.will_expire?) ? t('js.admin.enterprise.upsale.unlimited') : (format_date @current_token.expires_at) %>"
data-is-expired="<%= @current_token.expired?(reprieve: false) %>"
data-reprieve-days-left="<%= @current_token.reprieve_days_left %>"
>
</enterprise-active-saved-trial>
<%= form_tag({}, method: :delete) do %>
<%= form_tag(enterprise_path, method: :delete) do %>
<confirm-form-submit></confirm-form-submit>
<%= styled_button_tag t(:button_delete),
method: :delete,

@ -210,6 +210,8 @@ en:
new_group: 'New group'
reset_to_defaults: 'Reset to defaults'
enterprise:
text_reprieve_days_left: "%{days} days until end of grace period"
text_expired: "expired"
trial:
confirmation: "Confirmation of email address"
confirmation_info: >

@ -26,7 +26,7 @@
// See COPYRIGHT and LICENSE files for more details.
//++
import { Component, ElementRef } from '@angular/core';
import { ChangeDetectionStrategy, Component, ElementRef } from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { EEActiveTrialBase } from 'core-app/features/enterprise/enterprise-active-trial/ee-active-trial.base';
@ -36,6 +36,7 @@ export const enterpriseActiveSavedTrialSelector = 'enterprise-active-saved-trial
selector: enterpriseActiveSavedTrialSelector,
templateUrl: './ee-active-trial.component.html',
styleUrls: ['./ee-active-trial.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class EEActiveSavedTrialComponent extends EEActiveTrialBase {
public subscriber = this.elementRef.nativeElement.dataset.subscriber;
@ -52,8 +53,22 @@ export class EEActiveSavedTrialComponent extends EEActiveTrialBase {
public expiresAt = this.elementRef.nativeElement.dataset.expiresAt;
public isExpired:boolean = this.elementRef.nativeElement.dataset.isExpired === 'true';
public reprieveDaysLeft = this.elementRef.nativeElement.dataset.reprieveDaysLeft;
constructor(readonly elementRef:ElementRef,
readonly I18n:I18nService) {
super(I18n);
}
public get expiredWarningText():string {
let warning = this.text.text_expired;
if (this.reprieveDaysLeft && this.reprieveDaysLeft > 0) {
warning = `${warning}: ${this.text.text_reprieve_days_left(this.reprieveDaysLeft)}`;
}
return warning;
}
}

@ -38,6 +38,8 @@ export class EEActiveTrialBase extends UntilDestroyedMixin {
label_domain: this.I18n.t('js.admin.enterprise.trial.form.label_domain'),
label_starts_at: this.I18n.t('js.admin.enterprise.trial.form.label_starts_at'),
label_subscriber: this.I18n.t('js.admin.enterprise.trial.form.label_subscriber'),
text_expired: this.I18n.t('js.admin.enterprise.text_expired'),
text_reprieve_days_left: (days:number) => this.I18n.t('js.admin.enterprise.text_reprieve_days_left', { days }),
};
constructor(readonly I18n:I18nService) {

@ -42,6 +42,7 @@
<div *ngIf="expiresAt" class="attributes-key-value--value-container">
<div class="attributes-key-value--value -text">
<span [textContent]="expiresAt"></span>
<span *ngIf="isExpired" [textContent]="expiredWarningText" class="expired-warning"></span>
</div>
</div>
</div>

@ -0,0 +1,42 @@
-----BEGIN OPENPROJECT-EE TOKEN-----
eyJkYXRhIjoiMjhjK0xKa2wzS3NrUkVOdXlIWmZBMEg5bHRnbjRIQmxCV0NI
SFBZeDF5YXhvL01qT25Ud1JxUUo1bzlPXG5FaUN0MlRYTzJGNE1PdXhXdUtD
MHo5ek5xZFVHUTlFM3hrbGJGdHpSWldKbmZCTnd4WGIvSzY3NFhDZTlcbmhY
ZmhCcmJlVnFDOVV2Vm5jSExaelVwWVc2ZHpEbmdpRUorV2JlWFdJOEFwbFZj
VWxYZTRZUlRxREl0S1xuYUc4NHVjMDM0SmVHQjNyMS9hQnhnVVhrcFZoZXEy
aHR2VEJ6NWdNRkRBMExjMVNDL2E0K3Q0TzlMZmh6XG5vODJLdUF3MitGNlR2
bG5nbE1JYzdLTm9OdmZFYWkzT0ZXc2FjVHFTcEk3NjJvVlJGbVU5aS9Ramhn
NXVcblI1bkdkY3ZMdjM0N1VlemY0OWdaXG4iLCJrZXkiOiJlWFhCZll2QjV4
cmVBSEg1Lyt5RVlWaDZCV2lmRU1DdnRlc2xMdWIzQlNQd3BKNkZCc1YzbEhy
bS81WUlcbm9nZUJYSkVwMXY5SnU5K1Nvck43UW9OMWxQS3F3TWRsTGpmSlY0
VHZneUVNWng5Sk1wTVdndXVXTkI1blxuT004RXhBd1dxL3ArUTF2OExYem5t
ZTZDK05CMmh6c0ovVHovL2JSazBGaVNaWnFDcEFXNmtwZDZ2M2tVXG5nODJT
SmdHOWNKd3Z5djE2VHJPc1owM2lzRE0xR3pmWmZIM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# Copyright (C) 2012-2021 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
describe 'admin/enterprises/_current', type: :view do
let(:current_user) { FactoryBot.create :admin }
let(:ee_token) { "v1_expired_with_7_days_reprieve_at_2021_09_01.token" }
let(:current_time) { DateTime.now }
before do
allow(User).to receive(:current).and_return current_user
encoded = File.read Rails.root.join("spec/fixtures/ee_tokens/#{ee_token}")
token = EnterpriseToken.new(encoded_token: encoded)
assign :current_token, token
Timecop.travel(current_date) do
render :partial => "enterprises/current"
end
end
context "with token still valid" do
let(:current_date) { "2021-08-28".to_datetime }
it "renders the token as not expired and with no reprieve days" do
expect(rendered.to_s).to include 'data-is-expired="false"'
expect(rendered.to_s).to include 'data-reprieve-days-left=""'
end
end
context "with token just expired (within grace period)" do
let(:current_date) { "2021-09-02".to_datetime }
it "renders the token as expired and with 6 reprieve days" do
expect(rendered.to_s).to include 'data-is-expired="true"'
expect(rendered.to_s).to include 'data-reprieve-days-left="6"'
end
end
context "with token expired past reprieve" do
let(:current_date) { "2021-09-08".to_datetime }
it "renders the token as expired and with 0 reprieve days" do
expect(rendered.to_s).to include 'data-is-expired="true"'
expect(rendered.to_s).to include 'data-reprieve-days-left="0"'
end
end
context "with token expired and no reprieve" do
let(:ee_token) { "v1_expired_without_reprieve_at_2021_09_01.token" }
let(:current_date) { "2021-09-08".to_datetime }
it "renders the token as expired and with no reprieve days" do
expect(rendered.to_s).to include 'data-is-expired="true"'
expect(rendered.to_s).to include 'data-reprieve-days-left=""'
end
end
end

@ -123,5 +123,7 @@ describe ExtractFulltextJob, type: :job do
extracted_attributes
expect(logger).to have_received(:error).with(/boom-internal-error/)
end
include_examples 'only file name indexed'
end
end

Loading…
Cancel
Save