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

[EC-475] Auto-save password prompt enhancements (#4808)

* [EC-1062] Convert bar.js to TS and refactor (#4623)

* [EC-476 / EC-478] Add notificationBar edit flow (#4626)

* [EC-477] Enable auto-save for users without individual vault (#4760)

* [EC-1057] Add data loss warning to notificationBar edit flow (#4761)

* [AC-1173] Fix state bugs in auto-save edit flow (#4936)

---------

Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
This commit is contained in:
Thomas Rittson
2023-03-09 08:12:43 +10:00
committed by GitHub
parent cafd2d2561
commit f592963191
22 changed files with 537 additions and 343 deletions

View File

@@ -202,7 +202,7 @@ export class AddEditComponent implements OnInit, OnDestroy {
}
});
if (!this.allowPersonal) {
this.organizationId = this.ownershipOptions[0].value;
this.organizationId = this.defaultOwnerId;
}
}
@@ -220,12 +220,7 @@ export class AddEditComponent implements OnInit, OnDestroy {
this.title = this.i18nService.t("addItem");
}
const addEditCipherInfo: any = await this.stateService.getAddEditCipherInfo();
if (addEditCipherInfo != null) {
this.cipher = addEditCipherInfo.cipher;
this.collectionIds = addEditCipherInfo.collectionIds;
}
await this.stateService.setAddEditCipherInfo(null);
const loadedAddEditCipherInfo = await this.loadAddEditCipherInfo();
if (this.cipher == null) {
if (this.editMode) {
@@ -255,7 +250,7 @@ export class AddEditComponent implements OnInit, OnDestroy {
}
}
if (this.cipher != null && (!this.editMode || addEditCipherInfo != null || this.cloneMode)) {
if (this.cipher != null && (!this.editMode || loadedAddEditCipherInfo || this.cloneMode)) {
await this.organizationChanged();
if (
this.collectionIds != null &&
@@ -618,4 +613,27 @@ export class AddEditComponent implements OnInit, OnDestroy {
protected restoreCipher() {
return this.cipherService.restoreWithServer(this.cipher.id);
}
get defaultOwnerId(): string | null {
return this.ownershipOptions[0].value;
}
async loadAddEditCipherInfo(): Promise<boolean> {
const addEditCipherInfo: any = await this.stateService.getAddEditCipherInfo();
const loadedSavedInfo = addEditCipherInfo != null;
if (loadedSavedInfo) {
this.cipher = addEditCipherInfo.cipher;
this.collectionIds = addEditCipherInfo.collectionIds;
if (!this.editMode && !this.allowPersonal && this.cipher.organizationId == null) {
// This is a new cipher and personal ownership isn't allowed, so we need to set the default owner
this.cipher.organizationId = this.defaultOwnerId;
}
}
await this.stateService.setAddEditCipherInfo(null);
return loadedSavedInfo;
}
}