mirror of
https://github.com/bitwarden/web
synced 2025-12-19 17:53:22 +00:00
Apply Prettier (#1347)
This commit is contained in:
@@ -1,100 +1,107 @@
|
||||
import {
|
||||
Directive,
|
||||
ViewChild,
|
||||
ViewContainerRef,
|
||||
} from '@angular/core';
|
||||
import { Directive, ViewChild, ViewContainerRef } from "@angular/core";
|
||||
|
||||
import { CipherView } from 'jslib-common/models/view/cipherView';
|
||||
import { CipherView } from "jslib-common/models/view/cipherView";
|
||||
|
||||
import { Organization } from 'jslib-common/models/domain/organization';
|
||||
import { Organization } from "jslib-common/models/domain/organization";
|
||||
|
||||
import { AddEditComponent as OrgAddEditComponent } from '../organizations/vault/add-edit.component';
|
||||
import { AddEditComponent } from '../vault/add-edit.component';
|
||||
import { AddEditComponent as OrgAddEditComponent } from "../organizations/vault/add-edit.component";
|
||||
import { AddEditComponent } from "../vault/add-edit.component";
|
||||
|
||||
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
|
||||
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
|
||||
import { StateService } from 'jslib-common/abstractions/state.service';
|
||||
import { MessagingService } from "jslib-common/abstractions/messaging.service";
|
||||
import { PasswordRepromptService } from "jslib-common/abstractions/passwordReprompt.service";
|
||||
import { StateService } from "jslib-common/abstractions/state.service";
|
||||
|
||||
import { CipherRepromptType } from 'jslib-common/enums/cipherRepromptType';
|
||||
import { CipherRepromptType } from "jslib-common/enums/cipherRepromptType";
|
||||
|
||||
import { ModalService } from 'jslib-angular/services/modal.service';
|
||||
import { ModalService } from "jslib-angular/services/modal.service";
|
||||
|
||||
@Directive()
|
||||
export class CipherReportComponent {
|
||||
@ViewChild('cipherAddEdit', { read: ViewContainerRef, static: true }) cipherAddEditModalRef: ViewContainerRef;
|
||||
@ViewChild("cipherAddEdit", { read: ViewContainerRef, static: true })
|
||||
cipherAddEditModalRef: ViewContainerRef;
|
||||
|
||||
loading = false;
|
||||
hasLoaded = false;
|
||||
ciphers: CipherView[] = [];
|
||||
organization: Organization;
|
||||
loading = false;
|
||||
hasLoaded = false;
|
||||
ciphers: CipherView[] = [];
|
||||
organization: Organization;
|
||||
|
||||
constructor(private modalService: ModalService, protected messagingService: MessagingService,
|
||||
public requiresPaid: boolean, private stateService: StateService,
|
||||
protected passwordRepromptService: PasswordRepromptService) { }
|
||||
constructor(
|
||||
private modalService: ModalService,
|
||||
protected messagingService: MessagingService,
|
||||
public requiresPaid: boolean,
|
||||
private stateService: StateService,
|
||||
protected passwordRepromptService: PasswordRepromptService
|
||||
) {}
|
||||
|
||||
async load() {
|
||||
this.loading = true;
|
||||
await this.setCiphers();
|
||||
this.loading = false;
|
||||
this.hasLoaded = true;
|
||||
async load() {
|
||||
this.loading = true;
|
||||
await this.setCiphers();
|
||||
this.loading = false;
|
||||
this.hasLoaded = true;
|
||||
}
|
||||
|
||||
async selectCipher(cipher: CipherView) {
|
||||
if (!(await this.repromptCipher(cipher))) {
|
||||
return;
|
||||
}
|
||||
|
||||
async selectCipher(cipher: CipherView) {
|
||||
if (!await this.repromptCipher(cipher)) {
|
||||
return;
|
||||
}
|
||||
const type = this.organization != null ? OrgAddEditComponent : AddEditComponent;
|
||||
|
||||
const type = this.organization != null ? OrgAddEditComponent : AddEditComponent;
|
||||
|
||||
const [modal, childComponent] = await this.modalService.openViewRef(type, this.cipherAddEditModalRef, (comp: OrgAddEditComponent | AddEditComponent) => {
|
||||
if (this.organization != null) {
|
||||
(comp as OrgAddEditComponent).organization = this.organization;
|
||||
comp.organizationId = this.organization.id;
|
||||
}
|
||||
|
||||
comp.cipherId = cipher == null ? null : cipher.id;
|
||||
comp.onSavedCipher.subscribe(async (c: CipherView) => {
|
||||
modal.close();
|
||||
await this.load();
|
||||
});
|
||||
comp.onDeletedCipher.subscribe(async (c: CipherView) => {
|
||||
modal.close();
|
||||
await this.load();
|
||||
});
|
||||
comp.onRestoredCipher.subscribe(async (c: CipherView) => {
|
||||
modal.close();
|
||||
await this.load();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return childComponent;
|
||||
}
|
||||
|
||||
protected async checkAccess(): Promise<boolean> {
|
||||
const [modal, childComponent] = await this.modalService.openViewRef(
|
||||
type,
|
||||
this.cipherAddEditModalRef,
|
||||
(comp: OrgAddEditComponent | AddEditComponent) => {
|
||||
if (this.organization != null) {
|
||||
// TODO: Maybe we want to just make sure they are not on a free plan? Just compare useTotp for now
|
||||
// since all paid plans include useTotp
|
||||
if (this.requiresPaid && !this.organization.useTotp) {
|
||||
this.messagingService.send('upgradeOrganization', { organizationId: this.organization.id });
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
const accessPremium = await this.stateService.getCanAccessPremium();
|
||||
if (this.requiresPaid && !accessPremium) {
|
||||
this.messagingService.send('premiumRequired');
|
||||
this.loading = false;
|
||||
return false;
|
||||
}
|
||||
(comp as OrgAddEditComponent).organization = this.organization;
|
||||
comp.organizationId = this.organization.id;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected async setCiphers() {
|
||||
this.ciphers = [];
|
||||
}
|
||||
comp.cipherId = cipher == null ? null : cipher.id;
|
||||
comp.onSavedCipher.subscribe(async (c: CipherView) => {
|
||||
modal.close();
|
||||
await this.load();
|
||||
});
|
||||
comp.onDeletedCipher.subscribe(async (c: CipherView) => {
|
||||
modal.close();
|
||||
await this.load();
|
||||
});
|
||||
comp.onRestoredCipher.subscribe(async (c: CipherView) => {
|
||||
modal.close();
|
||||
await this.load();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
protected async repromptCipher(c: CipherView) {
|
||||
return c.reprompt === CipherRepromptType.None || await this.passwordRepromptService.showPasswordPrompt();
|
||||
return childComponent;
|
||||
}
|
||||
|
||||
protected async checkAccess(): Promise<boolean> {
|
||||
if (this.organization != null) {
|
||||
// TODO: Maybe we want to just make sure they are not on a free plan? Just compare useTotp for now
|
||||
// since all paid plans include useTotp
|
||||
if (this.requiresPaid && !this.organization.useTotp) {
|
||||
this.messagingService.send("upgradeOrganization", { organizationId: this.organization.id });
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
const accessPremium = await this.stateService.getCanAccessPremium();
|
||||
if (this.requiresPaid && !accessPremium) {
|
||||
this.messagingService.send("premiumRequired");
|
||||
this.loading = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected async setCiphers() {
|
||||
this.ciphers = [];
|
||||
}
|
||||
|
||||
protected async repromptCipher(c: CipherView) {
|
||||
return (
|
||||
c.reprompt === CipherRepromptType.None ||
|
||||
(await this.passwordRepromptService.showPasswordPrompt())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user