mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-24 12:06:15 +01:00
Pop out attachments page on Firefox and Safari
This commit is contained in:
parent
c4388dad66
commit
3844fdb959
@ -6,7 +6,7 @@ import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||
|
||||
@Injectable()
|
||||
export class PopupUtilsService {
|
||||
constructor(private platformUtilsService: PlatformUtilsService) {}
|
||||
constructor(private platformUtilsService: PlatformUtilsService) { }
|
||||
|
||||
inSidebar(win: Window): boolean {
|
||||
return win.location.search !== '' && win.location.search.indexOf('uilocation=sidebar') > -1;
|
||||
@ -37,8 +37,11 @@ export class PopupUtilsService {
|
||||
}
|
||||
}
|
||||
|
||||
popOut(win: Window): void {
|
||||
let href = win.location.href;
|
||||
popOut(win: Window, href: string = null): void {
|
||||
|
||||
if (href === null) {
|
||||
href = win.location.href;
|
||||
}
|
||||
|
||||
if ((typeof chrome !== 'undefined') && chrome.windows && chrome.windows.create) {
|
||||
if (href.indexOf('?uilocation=') > -1) {
|
||||
|
@ -274,7 +274,9 @@
|
||||
<a class="box-content-row box-content-row-flex text-default" href="#" appStopClick appBlurClick
|
||||
(click)="attachments()" *ngIf="editMode && showAttachments && !cloneMode">
|
||||
<div class="row-main">{{'attachments' | i18n}}</div>
|
||||
<i class="fa fa-chevron-right row-sub-icon" aria-hidden="true"></i>
|
||||
<i class="fa fa-chevron-right row-sub-icon" aria-hidden="true"
|
||||
*ngIf="!openAttachmentsInPopup()"></i>
|
||||
<i class="fa fa-external-link fa-lg fa-fw" aria-hidden="true" *ngIf="openAttachmentsInPopup()"></i>
|
||||
</a>
|
||||
<a class="box-content-row box-content-row-flex text-default" href="#" appStopClick appBlurClick
|
||||
(click)="editCollections()" *ngIf="editMode && cipher.organizationId && !cloneMode">
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
|
||||
import { BrowserApi } from '../../browser/browserApi';
|
||||
|
||||
import { PopupUtilsService } from '../services/popup-utils.service';
|
||||
import { AuditService } from 'jslib/abstractions/audit.service';
|
||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||
import { CollectionService } from 'jslib/abstractions/collection.service';
|
||||
@ -37,7 +38,8 @@ export class AddEditComponent extends BaseAddEditComponent {
|
||||
userService: UserService, collectionService: CollectionService,
|
||||
messagingService: MessagingService, private route: ActivatedRoute,
|
||||
private router: Router, private location: Location,
|
||||
eventService: EventService, policyService: PolicyService) {
|
||||
eventService: EventService, policyService: PolicyService,
|
||||
private popupUtilsService: PopupUtilsService) {
|
||||
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
|
||||
userService, collectionService, messagingService, eventService, policyService);
|
||||
}
|
||||
@ -115,7 +117,14 @@ export class AddEditComponent extends BaseAddEditComponent {
|
||||
|
||||
attachments() {
|
||||
super.attachments();
|
||||
this.router.navigate(['/attachments'], { queryParams: { cipherId: this.cipher.id } });
|
||||
|
||||
if (this.openAttachmentsInPopup()) {
|
||||
let destinationUrl = this.router.createUrlTree(['/attachments'], { queryParams: { cipherId: this.cipher.id } }).toString();
|
||||
let currentBaseUrl = window.location.href.replace(this.router.url, '');
|
||||
this.popupUtilsService.popOut(window, currentBaseUrl + destinationUrl);
|
||||
} else {
|
||||
this.router.navigate(['/attachments'], { queryParams: { cipherId: this.cipher.id } });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -161,4 +170,8 @@ export class AddEditComponent extends BaseAddEditComponent {
|
||||
return (!this.editMode || this.cloneMode) && this.ownershipOptions
|
||||
&& (this.ownershipOptions.length > 1 || !this.allowPersonal);
|
||||
}
|
||||
|
||||
openAttachmentsInPopup(): boolean {
|
||||
return this.popupUtilsService.inPopup(window) && !this.platformUtilsService.isChrome();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Location } from '@angular/common';
|
||||
import { Component } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||
@ -18,7 +18,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
|
||||
constructor(cipherService: CipherService, i18nService: I18nService,
|
||||
cryptoService: CryptoService, userService: UserService,
|
||||
platformUtilsService: PlatformUtilsService, private location: Location,
|
||||
private route: ActivatedRoute) {
|
||||
private route: ActivatedRoute, private router: Router) {
|
||||
super(cipherService, i18nService, cryptoService, userService, platformUtilsService, window);
|
||||
}
|
||||
|
||||
@ -33,6 +33,10 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
|
||||
}
|
||||
|
||||
back() {
|
||||
this.location.back();
|
||||
if (document.referrer === "") {
|
||||
this.router.navigate(['/edit-cipher'], { queryParams: { cipherId: this.cipher.id } });
|
||||
} else {
|
||||
this.location.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user