1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

Select folder at save bar (#1409)

* Markup changes

* Render in notification bar folders list that is provided form TS code

* Implemented getting of folders list

* Refactor addPlatformEventListener and added default selection of "No Folder"

* Pass folder id info to saveAddLogin

* Modify saveAddLogin to use folder id

* Try to fix default folder selection

* Fix styling issues found during review

* Fix review issues found by kspearrin

* Fix default selection and null handling

* Fix import order

* Applied review suggestions

* Implement checking if folderExist during saving

* Fix compile issues

* Added select folder... option

* Add internalization for select folder message

* Hide select folder element on narrow screens

* Fix lint issues

* Review fixes in notification bar

* Adjust semi-responsive layout for folder selector

* Revert style change

Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
This commit is contained in:
Dmitry Chepurovskiy
2021-09-03 04:54:52 +03:00
committed by GitHub
parent 61f551087f
commit cd2f174923
6 changed files with 48 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ import { LoginView } from 'jslib-common/models/view/loginView';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { FolderService } from 'jslib-common/abstractions/folder.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { NotificationsService } from 'jslib-common/abstractions/notifications.service';
@@ -39,7 +40,8 @@ export default class RuntimeBackground {
private notificationsService: NotificationsService,
private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService,
private environmentService: EnvironmentService, private policyService: PolicyService,
private userService: UserService, private messagingService: MessagingService) {
private userService: UserService, private messagingService: MessagingService,
private folderService: FolderService) {
// onInstalled listener must be wired up before anything else, so we do it in the ctor
chrome.runtime.onInstalled.addListener((details: any) => {
@@ -107,7 +109,7 @@ export default class RuntimeBackground {
this.removeTabFromNotificationQueue(sender.tab);
break;
case 'bgAddSave':
await this.saveAddLogin(sender.tab);
await this.saveAddLogin(sender.tab, msg.folder);
break;
case 'bgChangeSave':
await this.saveChangePassword(sender.tab);
@@ -218,7 +220,7 @@ export default class RuntimeBackground {
this.pageDetailsToAutoFill = [];
}
private async saveAddLogin(tab: any) {
private async saveAddLogin(tab: any, folderId: string) {
if (await this.vaultTimeoutService.isLocked()) {
return;
}
@@ -249,6 +251,13 @@ export default class RuntimeBackground {
model.type = CipherType.Login;
model.login = loginModel;
if (!Utils.isNullOrWhitespace(folderId)) {
const folders = await this.folderService.getAllDecrypted();
if (folders.some(x => x.id === folderId)) {
model.folderId = folderId;
}
}
const cipher = await this.cipherService.encrypt(model);
await this.cipherService.saveWithServer(cipher);
}
@@ -452,6 +461,8 @@ export default class RuntimeBackground {
notificationChangeSave: this.i18nService.t('notificationChangeSave'),
notificationChangeDesc: this.i18nService.t('notificationChangeDesc'),
};
} else if (responseCommand === 'notificationBarGetFoldersList') {
responseData.folders = await this.folderService.getAllDecrypted();
}
await BrowserApi.tabSendMessageData(tab, responseCommand, responseData);