change instance variable to local variable in helper

pull/10156/head
bsatarnejad 3 years ago
parent ce555179e7
commit 1be86fa61f
  1. 8
      app/helpers/enterprise_helper.rb
  2. 2
      frontend/src/app/features/enterprise/enterprise-modal/enterprise-trial.modal.ts
  3. 2
      frontend/src/app/features/enterprise/free-trial-button/free-trial-button.component.html
  4. 9
      frontend/src/app/features/enterprise/free-trial-button/free-trial-button.component.ts

@ -5,11 +5,11 @@ module EnterpriseHelper
end
def write_trial_key_to_gon
@trial_key = Token::EnterpriseTrialKey.find_by(user_id: User.system.id)
if @trial_key
trial_key = Token::EnterpriseTrialKey.find_by(user_id: User.system.id)
if trial_key
gon.ee_trial_key = {
value: @trial_key.value,
created: @trial_key.created_at
value: trial_key.value,
created: trial_key.created_at
}
end
end

@ -114,7 +114,7 @@ export class EnterpriseTrialModalComponent extends OpModalComponent implements A
if (this.eeTrialService.trialStarted || this.eeTrialService.confirmed) {
window.location.reload();
}
else if(this.eeTrialService.mailSubmitted) {
else if (this.eeTrialService.mailSubmitted) {
window.location.reload();
return;
}

@ -1,4 +1,4 @@
<div [attr.data-tooltip]="text.confirmation_info(created, email)" [ngClass]="{'tooltip--top': trialRequested}">
<div [attr.data-tooltip]="trialRequested ? text.confirmation_info(created, email) : ''" [ngClass]="{'tooltip--top': trialRequested}">
<button [disabled]="trialRequested" class="button -alt-highlight -round" (click)="openTrialModal()">
{{ text.button_trial }}
</button>

@ -39,7 +39,7 @@ import { OpModalService } from 'core-app/shared/components/modal/modal.service';
import { EnterpriseTrialService } from 'core-app/features/enterprise/enterprise-trial.service';
import { TimezoneService } from 'core-app/core/datetime/timezone.service';
import { distinctUntilChanged } from 'rxjs/operators';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { GonService } from 'core-app/core/gon/gon.service';
export const freeTrialButtonSelector = 'free-trial-button';
@ -56,11 +56,10 @@ export class FreeTrialButtonComponent implements OnInit {
public text = {
button_trial: this.I18n.t('js.admin.enterprise.upsale.button_start_trial'),
confirmation_info: (date:string, email:string) =>
this.trialRequested ? this.I18n.t('js.admin.enterprise.trial.confirmation_info', {
confirmation_info: (date:string, email:string) => this.I18n.t('js.admin.enterprise.trial.confirmation_info', {
date,
email,
}) : '',
}),
};
constructor(protected I18n:I18nService,
@ -122,7 +121,7 @@ export class FreeTrialButtonComponent implements OnInit {
this.opModalService.show(EnterpriseTrialModalComponent, this.injector);
}
public get trialRequested() {
public get trialRequested(): boolean {
const eeTrialKey = this.Gon.get('ee_trial_key') as any;
return (eeTrialKey && eeTrialKey !== undefined);
}

Loading…
Cancel
Save