From 3844fdb95980eb2e3b53a2e2fb13287300b254db Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Wed, 13 Jan 2021 18:27:23 +1000 Subject: [PATCH 1/4] Pop out attachments page on Firefox and Safari --- src/popup/services/popup-utils.service.ts | 9 ++++++--- src/popup/vault/add-edit.component.html | 4 +++- src/popup/vault/add-edit.component.ts | 17 +++++++++++++++-- src/popup/vault/attachments.component.ts | 10 +++++++--- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/popup/services/popup-utils.service.ts b/src/popup/services/popup-utils.service.ts index 8f694c87b4..21ce5fd950 100644 --- a/src/popup/services/popup-utils.service.ts +++ b/src/popup/services/popup-utils.service.ts @@ -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) { diff --git a/src/popup/vault/add-edit.component.html b/src/popup/vault/add-edit.component.html index a94e8217da..8ee8bff2fe 100644 --- a/src/popup/vault/add-edit.component.html +++ b/src/popup/vault/add-edit.component.html @@ -274,7 +274,9 @@
{{'attachments' | i18n}}
- + +
diff --git a/src/popup/vault/add-edit.component.ts b/src/popup/vault/add-edit.component.ts index 0a32bdf89a..cfb116c45c 100644 --- a/src/popup/vault/add-edit.component.ts +++ b/src/popup/vault/add-edit.component.ts @@ -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(); + } } diff --git a/src/popup/vault/attachments.component.ts b/src/popup/vault/attachments.component.ts index cee3694975..b2a1afab06 100644 --- a/src/popup/vault/attachments.component.ts +++ b/src/popup/vault/attachments.component.ts @@ -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(); + } } } From bef1008b9dff02ec602d61f844ce6319505d6fd3 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Fri, 15 Jan 2021 15:10:19 +1000 Subject: [PATCH 2/4] Open Attachments in popout on all browsers --- src/popup/vault/add-edit.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/popup/vault/add-edit.component.ts b/src/popup/vault/add-edit.component.ts index cfb116c45c..d5de243200 100644 --- a/src/popup/vault/add-edit.component.ts +++ b/src/popup/vault/add-edit.component.ts @@ -172,6 +172,6 @@ export class AddEditComponent extends BaseAddEditComponent { } openAttachmentsInPopup(): boolean { - return this.popupUtilsService.inPopup(window) && !this.platformUtilsService.isChrome(); + return this.popupUtilsService.inPopup(window); } } From 092110fd5f299ed2b7894ddf5aadc5d9603756e9 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Fri, 15 Jan 2021 15:58:38 +1000 Subject: [PATCH 3/4] Close popout instead of navigating, style fixes --- src/popup/vault/add-edit.component.html | 5 ++--- src/popup/vault/add-edit.component.ts | 13 ++++++------- src/popup/vault/attachments.component.html | 5 ++++- src/popup/vault/attachments.component.ts | 14 +++++++++----- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/popup/vault/add-edit.component.html b/src/popup/vault/add-edit.component.html index 8ee8bff2fe..eba3c193cc 100644 --- a/src/popup/vault/add-edit.component.html +++ b/src/popup/vault/add-edit.component.html @@ -274,9 +274,8 @@
{{'attachments' | i18n}}
- - + +
diff --git a/src/popup/vault/add-edit.component.ts b/src/popup/vault/add-edit.component.ts index d5de243200..655728736e 100644 --- a/src/popup/vault/add-edit.component.ts +++ b/src/popup/vault/add-edit.component.ts @@ -31,6 +31,7 @@ import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/componen export class AddEditComponent extends BaseAddEditComponent { currentUris: string[]; showAttachments = true; + openAttachmentsInPopup: boolean; constructor(cipherService: CipherService, folderService: FolderService, i18nService: I18nService, platformUtilsService: PlatformUtilsService, @@ -83,6 +84,8 @@ export class AddEditComponent extends BaseAddEditComponent { if (queryParamsSub != null) { queryParamsSub.unsubscribe(); } + + this.openAttachmentsInPopup = this.popupUtilsService.inPopup(window); }); if (!this.editMode) { @@ -118,9 +121,9 @@ export class AddEditComponent extends BaseAddEditComponent { attachments() { super.attachments(); - if (this.openAttachmentsInPopup()) { - let destinationUrl = this.router.createUrlTree(['/attachments'], { queryParams: { cipherId: this.cipher.id } }).toString(); - let currentBaseUrl = window.location.href.replace(this.router.url, ''); + if (this.openAttachmentsInPopup) { + const destinationUrl = this.router.createUrlTree(['/attachments'], { queryParams: { cipherId: this.cipher.id } }).toString(); + const currentBaseUrl = window.location.href.replace(this.router.url, ''); this.popupUtilsService.popOut(window, currentBaseUrl + destinationUrl); } else { this.router.navigate(['/attachments'], { queryParams: { cipherId: this.cipher.id } }); @@ -170,8 +173,4 @@ 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); - } } diff --git a/src/popup/vault/attachments.component.html b/src/popup/vault/attachments.component.html index 7c6ec237fe..44c776b9ef 100644 --- a/src/popup/vault/attachments.component.html +++ b/src/popup/vault/attachments.component.html @@ -1,7 +1,10 @@
- + diff --git a/src/popup/vault/attachments.component.ts b/src/popup/vault/attachments.component.ts index b2a1afab06..fe4714132e 100644 --- a/src/popup/vault/attachments.component.ts +++ b/src/popup/vault/attachments.component.ts @@ -15,6 +15,8 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib/angular/ templateUrl: 'attachments.component.html', }) export class AttachmentsComponent extends BaseAttachmentsComponent { + openedAttachmentsInPopup: boolean; + constructor(cipherService: CipherService, i18nService: I18nService, cryptoService: CryptoService, userService: UserService, platformUtilsService: PlatformUtilsService, private location: Location, @@ -30,13 +32,15 @@ export class AttachmentsComponent extends BaseAttachmentsComponent { queryParamsSub.unsubscribe(); } }); + + this.openedAttachmentsInPopup = history.length === 1; } back() { - if (document.referrer === "") { - this.router.navigate(['/edit-cipher'], { queryParams: { cipherId: this.cipher.id } }); - } else { - this.location.back(); - } + this.location.back(); + } + + close() { + window.close(); } } From 9b85b7ba68cba013a862dba11aab5ab1375a89fb Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Fri, 5 Feb 2021 06:23:12 +1000 Subject: [PATCH 4/4] Fix code style --- src/popup/vault/add-edit.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/popup/vault/add-edit.component.ts b/src/popup/vault/add-edit.component.ts index 655728736e..01f159d7a8 100644 --- a/src/popup/vault/add-edit.component.ts +++ b/src/popup/vault/add-edit.component.ts @@ -7,7 +7,6 @@ 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'; @@ -20,6 +19,8 @@ import { PolicyService } from 'jslib/abstractions/policy.service'; import { StateService } from 'jslib/abstractions/state.service'; import { UserService } from 'jslib/abstractions/user.service'; +import { PopupUtilsService } from '../services/popup-utils.service'; + import { LoginUriView } from 'jslib/models/view/loginUriView'; import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/add-edit.component';