mirror of
https://github.com/bitwarden/web
synced 2025-12-15 15:53:18 +00:00
ui updates for send add/edit component (#768)
* ui updates for send add/edit component * move messaging.service import
This commit is contained in:
@@ -10,11 +10,12 @@ import { Component } from '@angular/core';
|
||||
|
||||
import { SendType } from 'jslib/enums/sendType';
|
||||
|
||||
import { ApiService } from 'jslib/abstractions/api.service';
|
||||
import { EnvironmentService } from 'jslib/abstractions/environment.service';
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||
import { SendService } from 'jslib/abstractions/send.service';
|
||||
import { UserService } from 'jslib/abstractions/user.service';
|
||||
|
||||
import { SendView } from 'jslib/models/view/sendView';
|
||||
import { SendFileView } from 'jslib/models/view/sendFileView';
|
||||
@@ -22,8 +23,6 @@ import { SendTextView } from 'jslib/models/view/sendTextView';
|
||||
|
||||
import { Send } from 'jslib/models/domain/send';
|
||||
|
||||
import { SendData } from 'jslib/models/data/sendData';
|
||||
|
||||
@Component({
|
||||
selector: 'app-send-add-edit',
|
||||
templateUrl: 'add-edit.component.html',
|
||||
@@ -52,10 +51,13 @@ export class AddEditComponent {
|
||||
expirationDateOptions: any[];
|
||||
deletionDateSelect = 168;
|
||||
expirationDateSelect: number = null;
|
||||
canAccessPremium = true;
|
||||
premiumRequiredAlertShown = false;
|
||||
|
||||
constructor(private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
|
||||
private environmentService: EnvironmentService, private datePipe: DatePipe,
|
||||
private sendService: SendService) {
|
||||
private sendService: SendService, private userService: UserService,
|
||||
private messagingService: MessagingService) {
|
||||
this.typeOptions = [
|
||||
{ name: i18nService.t('sendTypeFile'), value: SendType.File },
|
||||
{ name: i18nService.t('sendTypeText'), value: SendType.Text },
|
||||
@@ -87,6 +89,11 @@ export class AddEditComponent {
|
||||
this.title = this.i18nService.t('createSend');
|
||||
}
|
||||
|
||||
this.canAccessPremium = await this.userService.canAccessPremium();
|
||||
if (!this.canAccessPremium) {
|
||||
this.type = SendType.Text;
|
||||
}
|
||||
|
||||
if (this.send == null) {
|
||||
if (this.editMode) {
|
||||
const send = await this.loadSend();
|
||||
@@ -194,6 +201,13 @@ export class AddEditComponent {
|
||||
} catch { }
|
||||
}
|
||||
|
||||
typeChanged() {
|
||||
if (!this.canAccessPremium && this.send.type == SendType.File && !this.premiumRequiredAlertShown) {
|
||||
this.premiumRequiredAlertShown = true;
|
||||
this.messagingService.send('premiumRequired');
|
||||
}
|
||||
}
|
||||
|
||||
protected async loadSend(): Promise<Send> {
|
||||
return this.sendService.get(this.sendId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user