open attachments page in new popout window based on browser (#10036)
This commit is contained in:
parent
2d4783932b
commit
99d2ff4bbd
|
@ -15,6 +15,7 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
|
|
||||||
import BrowserPopupUtils from "../../../../../../platform/popup/browser-popup-utils";
|
import BrowserPopupUtils from "../../../../../../platform/popup/browser-popup-utils";
|
||||||
|
import { FilePopoutUtilsService } from "../../../../../../tools/popup/services/file-popout-utils.service";
|
||||||
|
|
||||||
import { OpenAttachmentsComponent } from "./open-attachments.component";
|
import { OpenAttachmentsComponent } from "./open-attachments.component";
|
||||||
|
|
||||||
|
@ -48,12 +49,14 @@ describe("OpenAttachmentsComponent", () => {
|
||||||
|
|
||||||
const getCipher = jest.fn().mockResolvedValue(cipherDomain);
|
const getCipher = jest.fn().mockResolvedValue(cipherDomain);
|
||||||
const getOrganization = jest.fn().mockResolvedValue(org);
|
const getOrganization = jest.fn().mockResolvedValue(org);
|
||||||
|
const showFilePopoutMessage = jest.fn().mockReturnValue(false);
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
openCurrentPagePopout.mockClear();
|
openCurrentPagePopout.mockClear();
|
||||||
getCipher.mockClear();
|
getCipher.mockClear();
|
||||||
showToast.mockClear();
|
showToast.mockClear();
|
||||||
getOrganization.mockClear();
|
getOrganization.mockClear();
|
||||||
|
showFilePopoutMessage.mockClear();
|
||||||
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [OpenAttachmentsComponent, RouterTestingModule],
|
imports: [OpenAttachmentsComponent, RouterTestingModule],
|
||||||
|
@ -75,6 +78,10 @@ describe("OpenAttachmentsComponent", () => {
|
||||||
provide: OrganizationService,
|
provide: OrganizationService,
|
||||||
useValue: { get: getOrganization },
|
useValue: { get: getOrganization },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: FilePopoutUtilsService,
|
||||||
|
useValue: { showFilePopoutMessage },
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
@ -89,7 +96,9 @@ describe("OpenAttachmentsComponent", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("opens attachments in new popout", async () => {
|
it("opens attachments in new popout", async () => {
|
||||||
component.openAttachmentsInPopout = true;
|
showFilePopoutMessage.mockReturnValue(true);
|
||||||
|
|
||||||
|
await component.ngOnInit();
|
||||||
|
|
||||||
await component.openAttachments();
|
await component.openAttachments();
|
||||||
|
|
||||||
|
@ -101,7 +110,9 @@ describe("OpenAttachmentsComponent", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("opens attachments in same window", async () => {
|
it("opens attachments in same window", async () => {
|
||||||
component.openAttachmentsInPopout = false;
|
showFilePopoutMessage.mockReturnValue(false);
|
||||||
|
|
||||||
|
await component.ngOnInit();
|
||||||
|
|
||||||
await component.openAttachments();
|
await component.openAttachments();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
|
|
||||||
import BrowserPopupUtils from "../../../../../../platform/popup/browser-popup-utils";
|
import BrowserPopupUtils from "../../../../../../platform/popup/browser-popup-utils";
|
||||||
|
import { FilePopoutUtilsService } from "../../../../../../tools/popup/services/file-popout-utils.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
|
@ -31,7 +32,7 @@ export class OpenAttachmentsComponent implements OnInit {
|
||||||
@Input({ required: true }) cipherId: CipherId;
|
@Input({ required: true }) cipherId: CipherId;
|
||||||
|
|
||||||
/** True when the attachments window should be opened in a popout */
|
/** True when the attachments window should be opened in a popout */
|
||||||
openAttachmentsInPopout = BrowserPopupUtils.inPopup(window);
|
openAttachmentsInPopout: boolean;
|
||||||
|
|
||||||
/** True when the user has access to premium or h */
|
/** True when the user has access to premium or h */
|
||||||
canAccessAttachments: boolean;
|
canAccessAttachments: boolean;
|
||||||
|
@ -46,6 +47,7 @@ export class OpenAttachmentsComponent implements OnInit {
|
||||||
private organizationService: OrganizationService,
|
private organizationService: OrganizationService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
|
private filePopoutUtilsService: FilePopoutUtilsService,
|
||||||
) {
|
) {
|
||||||
this.billingAccountProfileStateService.hasPremiumFromAnySource$
|
this.billingAccountProfileStateService.hasPremiumFromAnySource$
|
||||||
.pipe(takeUntilDestroyed())
|
.pipe(takeUntilDestroyed())
|
||||||
|
@ -55,9 +57,12 @@ export class OpenAttachmentsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
|
this.openAttachmentsInPopout = this.filePopoutUtilsService.showFilePopoutMessage(window);
|
||||||
|
|
||||||
if (!this.cipherId) {
|
if (!this.cipherId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cipherDomain = await this.cipherService.get(this.cipherId);
|
const cipherDomain = await this.cipherService.get(this.cipherId);
|
||||||
const cipher = await cipherDomain.decrypt(
|
const cipher = await cipherDomain.decrypt(
|
||||||
await this.cipherService.getKeyForCipherKeyDecryption(cipherDomain),
|
await this.cipherService.getKeyForCipherKeyDecryption(cipherDomain),
|
||||||
|
|
Loading…
Reference in New Issue