[PM-6426] Merging main into branch and fixing merge conflicts
This commit is contained in:
commit
1bd44d11c3
|
@ -160,9 +160,9 @@ jobs:
|
|||
run: npm run dist
|
||||
working-directory: browser-source/apps/browser
|
||||
|
||||
# - name: Build Manifest v3
|
||||
# run: npm run dist:mv3
|
||||
# working-directory: browser-source/apps/browser
|
||||
- name: Build Manifest v3
|
||||
run: npm run dist:mv3
|
||||
working-directory: browser-source/apps/browser
|
||||
|
||||
- name: Gulp
|
||||
run: gulp ci
|
||||
|
|
|
@ -3011,5 +3011,11 @@
|
|||
},
|
||||
"unassignedItemsBannerSelfHost": {
|
||||
"message": "Notice: On May 2, 2024, unassigned organization items will no longer be visible in the All Vaults view and will only be accessible via the Admin Console. Assign these items to a collection from the Admin Console to make them visible."
|
||||
},
|
||||
"errorAssigningTargetCollection": {
|
||||
"message": "Error assigning target collection."
|
||||
},
|
||||
"errorAssigningTargetFolder": {
|
||||
"message": "Error assigning target folder."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -345,11 +345,11 @@ export default class MainBackground {
|
|||
private syncTimeout: any;
|
||||
private isSafari: boolean;
|
||||
private nativeMessagingBackground: NativeMessagingBackground;
|
||||
popupOnlyContext: boolean;
|
||||
|
||||
constructor(public isPrivateMode: boolean = false) {
|
||||
this.popupOnlyContext = isPrivateMode || BrowserApi.isManifestVersion(3);
|
||||
|
||||
constructor(
|
||||
public isPrivateMode: boolean = false,
|
||||
public popupOnlyContext: boolean = false,
|
||||
) {
|
||||
// Services
|
||||
const lockedCallback = async (userId?: string) => {
|
||||
if (this.notificationsService != null) {
|
||||
|
@ -901,82 +901,83 @@ export default class MainBackground {
|
|||
this.isSafari = this.platformUtilsService.isSafari();
|
||||
|
||||
// Background
|
||||
this.runtimeBackground = new RuntimeBackground(
|
||||
this,
|
||||
this.autofillService,
|
||||
this.platformUtilsService as BrowserPlatformUtilsService,
|
||||
this.i18nService,
|
||||
this.notificationsService,
|
||||
this.stateService,
|
||||
this.autofillSettingsService,
|
||||
this.systemService,
|
||||
this.environmentService,
|
||||
this.messagingService,
|
||||
this.logService,
|
||||
this.configService,
|
||||
this.fido2Service,
|
||||
);
|
||||
this.nativeMessagingBackground = new NativeMessagingBackground(
|
||||
this.accountService,
|
||||
this.masterPasswordService,
|
||||
this.cryptoService,
|
||||
this.cryptoFunctionService,
|
||||
this.runtimeBackground,
|
||||
this.messagingService,
|
||||
this.appIdService,
|
||||
this.platformUtilsService,
|
||||
this.stateService,
|
||||
this.logService,
|
||||
this.authService,
|
||||
this.biometricStateService,
|
||||
);
|
||||
this.commandsBackground = new CommandsBackground(
|
||||
this,
|
||||
this.passwordGenerationService,
|
||||
this.platformUtilsService,
|
||||
this.vaultTimeoutService,
|
||||
this.authService,
|
||||
);
|
||||
this.notificationBackground = new NotificationBackground(
|
||||
this.autofillService,
|
||||
this.cipherService,
|
||||
this.authService,
|
||||
this.policyService,
|
||||
this.folderService,
|
||||
this.stateService,
|
||||
this.userNotificationSettingsService,
|
||||
this.domainSettingsService,
|
||||
this.environmentService,
|
||||
this.logService,
|
||||
themeStateService,
|
||||
this.configService,
|
||||
);
|
||||
this.overlayBackground = new OverlayBackground(
|
||||
this.cipherService,
|
||||
this.autofillService,
|
||||
this.authService,
|
||||
this.environmentService,
|
||||
this.domainSettingsService,
|
||||
this.stateService,
|
||||
this.autofillSettingsService,
|
||||
this.i18nService,
|
||||
this.platformUtilsService,
|
||||
themeStateService,
|
||||
);
|
||||
this.filelessImporterBackground = new FilelessImporterBackground(
|
||||
this.configService,
|
||||
this.authService,
|
||||
this.policyService,
|
||||
this.notificationBackground,
|
||||
this.importService,
|
||||
this.syncService,
|
||||
);
|
||||
this.tabsBackground = new TabsBackground(
|
||||
this,
|
||||
this.notificationBackground,
|
||||
this.overlayBackground,
|
||||
);
|
||||
if (!this.popupOnlyContext) {
|
||||
this.runtimeBackground = new RuntimeBackground(
|
||||
this,
|
||||
this.autofillService,
|
||||
this.platformUtilsService as BrowserPlatformUtilsService,
|
||||
this.i18nService,
|
||||
this.notificationsService,
|
||||
this.stateService,
|
||||
this.autofillSettingsService,
|
||||
this.systemService,
|
||||
this.environmentService,
|
||||
this.messagingService,
|
||||
this.logService,
|
||||
this.configService,
|
||||
this.fido2Service,
|
||||
);
|
||||
this.nativeMessagingBackground = new NativeMessagingBackground(
|
||||
this.accountService,
|
||||
this.masterPasswordService,
|
||||
this.cryptoService,
|
||||
this.cryptoFunctionService,
|
||||
this.runtimeBackground,
|
||||
this.messagingService,
|
||||
this.appIdService,
|
||||
this.platformUtilsService,
|
||||
this.stateService,
|
||||
this.logService,
|
||||
this.authService,
|
||||
this.biometricStateService,
|
||||
);
|
||||
this.commandsBackground = new CommandsBackground(
|
||||
this,
|
||||
this.passwordGenerationService,
|
||||
this.platformUtilsService,
|
||||
this.vaultTimeoutService,
|
||||
this.authService,
|
||||
);
|
||||
this.notificationBackground = new NotificationBackground(
|
||||
this.autofillService,
|
||||
this.cipherService,
|
||||
this.authService,
|
||||
this.policyService,
|
||||
this.folderService,
|
||||
this.stateService,
|
||||
this.userNotificationSettingsService,
|
||||
this.domainSettingsService,
|
||||
this.environmentService,
|
||||
this.logService,
|
||||
themeStateService,
|
||||
this.configService,
|
||||
);
|
||||
this.overlayBackground = new OverlayBackground(
|
||||
this.cipherService,
|
||||
this.autofillService,
|
||||
this.authService,
|
||||
this.environmentService,
|
||||
this.domainSettingsService,
|
||||
this.stateService,
|
||||
this.autofillSettingsService,
|
||||
this.i18nService,
|
||||
this.platformUtilsService,
|
||||
themeStateService,
|
||||
);
|
||||
this.filelessImporterBackground = new FilelessImporterBackground(
|
||||
this.configService,
|
||||
this.authService,
|
||||
this.policyService,
|
||||
this.notificationBackground,
|
||||
this.importService,
|
||||
this.syncService,
|
||||
);
|
||||
this.tabsBackground = new TabsBackground(
|
||||
this,
|
||||
this.notificationBackground,
|
||||
this.overlayBackground,
|
||||
);
|
||||
|
||||
const contextMenuClickedHandler = new ContextMenuClickedHandler(
|
||||
(options) => this.platformUtilsService.copyToClipboard(options.text),
|
||||
async (_tab) => {
|
||||
|
@ -1018,11 +1019,6 @@ export default class MainBackground {
|
|||
this.notificationsService,
|
||||
this.accountService,
|
||||
);
|
||||
this.webRequestBackground = new WebRequestBackground(
|
||||
this.platformUtilsService,
|
||||
this.cipherService,
|
||||
this.authService,
|
||||
);
|
||||
|
||||
this.usernameGenerationService = new UsernameGenerationService(
|
||||
this.cryptoService,
|
||||
|
@ -1044,34 +1040,40 @@ export default class MainBackground {
|
|||
this.authService,
|
||||
this.cipherService,
|
||||
);
|
||||
|
||||
if (BrowserApi.isManifestVersion(2)) {
|
||||
this.webRequestBackground = new WebRequestBackground(
|
||||
this.platformUtilsService,
|
||||
this.cipherService,
|
||||
this.authService,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async bootstrap() {
|
||||
this.containerService.attachToGlobal(self);
|
||||
|
||||
await this.stateService.init();
|
||||
await this.stateService.init({ runMigrations: !this.isPrivateMode });
|
||||
|
||||
await this.vaultTimeoutService.init(true);
|
||||
await (this.i18nService as I18nService).init();
|
||||
await (this.eventUploadService as EventUploadService).init(true);
|
||||
await this.runtimeBackground.init();
|
||||
await this.notificationBackground.init();
|
||||
this.filelessImporterBackground.init();
|
||||
await this.commandsBackground.init();
|
||||
|
||||
(this.eventUploadService as EventUploadService).init(true);
|
||||
this.twoFactorService.init();
|
||||
|
||||
await this.overlayBackground.init();
|
||||
|
||||
await this.tabsBackground.init();
|
||||
if (!this.popupOnlyContext) {
|
||||
await this.vaultTimeoutService.init(true);
|
||||
await this.runtimeBackground.init();
|
||||
await this.notificationBackground.init();
|
||||
this.filelessImporterBackground.init();
|
||||
await this.commandsBackground.init();
|
||||
await this.overlayBackground.init();
|
||||
await this.tabsBackground.init();
|
||||
this.contextMenusBackground?.init();
|
||||
await this.idleBackground.init();
|
||||
if (BrowserApi.isManifestVersion(2)) {
|
||||
await this.webRequestBackground.init();
|
||||
}
|
||||
}
|
||||
await this.idleBackground.init();
|
||||
await this.webRequestBackground.init();
|
||||
|
||||
await this.fido2Service.init();
|
||||
|
||||
if (this.platformUtilsService.isFirefox() && !this.isPrivateMode) {
|
||||
// Set Private Mode windows to the default icon - they do not share state with the background page
|
||||
|
@ -1222,7 +1224,7 @@ export default class MainBackground {
|
|||
BrowserApi.sendMessage("updateBadge");
|
||||
}
|
||||
await this.refreshBadge();
|
||||
await this.mainContextMenuHandler.noAccess();
|
||||
await this.mainContextMenuHandler?.noAccess();
|
||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.notificationsService.updateConnection(false);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
|
||||
import { DeepJsonify } from "@bitwarden/common/types/deep-jsonify";
|
||||
|
||||
|
@ -7,13 +5,6 @@ import { BrowserComponentState } from "./browserComponentState";
|
|||
|
||||
export class BrowserSendComponentState extends BrowserComponentState {
|
||||
sends: SendView[];
|
||||
typeCounts: Map<SendType, number>;
|
||||
|
||||
toJSON() {
|
||||
return Utils.merge(this, {
|
||||
typeCounts: Utils.mapToRecord(this.typeCounts),
|
||||
});
|
||||
}
|
||||
|
||||
static fromJSON(json: DeepJsonify<BrowserSendComponentState>) {
|
||||
if (json == null) {
|
||||
|
@ -22,7 +13,6 @@ export class BrowserSendComponentState extends BrowserComponentState {
|
|||
|
||||
return Object.assign(new BrowserSendComponentState(), json, {
|
||||
sends: json.sends?.map((s) => SendView.fromJSON(s)),
|
||||
typeCounts: Utils.recordToMap(json.typeCounts),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ const mainBackground: MainBackground = needsBackgroundInit
|
|||
: BrowserApi.getBackgroundPage().bitwardenMain;
|
||||
|
||||
function createLocalBgService() {
|
||||
const localBgService = new MainBackground(isPrivateMode);
|
||||
const localBgService = new MainBackground(isPrivateMode, true);
|
||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
localBgService.bootstrap();
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<div class="icon"><i class="bwi bwi-fw bwi-lg bwi-file-text"></i></div>
|
||||
<span class="text">{{ "sendTypeText" | i18n }}</span>
|
||||
</div>
|
||||
<span class="row-sub-label">{{ typeCounts.get(sendType.Text) || 0 }}</span>
|
||||
<span class="row-sub-label">{{ getSendCount(sends, sendType.Text) }}</span>
|
||||
<span><i class="bwi bwi-angle-right bwi-lg row-sub-icon"></i></span>
|
||||
</button>
|
||||
<button
|
||||
|
@ -74,7 +74,7 @@
|
|||
<div class="icon"><i class="bwi bwi-fw bwi-lg bwi-file"></i></div>
|
||||
<span class="text">{{ "sendTypeFile" | i18n }}</span>
|
||||
</div>
|
||||
<span class="row-sub-label">{{ typeCounts.get(sendType.File) || 0 }}</span>
|
||||
<span class="row-sub-label">{{ getSendCount(sends, sendType.File) }}</span>
|
||||
<span><i class="bwi bwi-angle-right bwi-lg row-sub-icon"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -29,8 +29,6 @@ const ComponentId = "SendComponent";
|
|||
export class SendGroupingsComponent extends BaseSendComponent {
|
||||
// Header
|
||||
showLeftHeader = true;
|
||||
// Send Type Calculations
|
||||
typeCounts = new Map<SendType, number>();
|
||||
// State Handling
|
||||
state: BrowserSendComponentState;
|
||||
private loadedTimeout: number;
|
||||
|
@ -65,7 +63,6 @@ export class SendGroupingsComponent extends BaseSendComponent {
|
|||
dialogService,
|
||||
);
|
||||
super.onSuccessfulLoad = async () => {
|
||||
this.calculateTypeCounts();
|
||||
this.selectAll();
|
||||
};
|
||||
}
|
||||
|
@ -174,17 +171,8 @@ export class SendGroupingsComponent extends BaseSendComponent {
|
|||
return this.hasSearched || (!this.searchPending && this.isSearchable);
|
||||
}
|
||||
|
||||
private calculateTypeCounts() {
|
||||
// Create type counts
|
||||
const typeCounts = new Map<SendType, number>();
|
||||
this.sends.forEach((s) => {
|
||||
if (typeCounts.has(s.type)) {
|
||||
typeCounts.set(s.type, typeCounts.get(s.type) + 1);
|
||||
} else {
|
||||
typeCounts.set(s.type, 1);
|
||||
}
|
||||
});
|
||||
this.typeCounts = typeCounts;
|
||||
getSendCount(sends: SendView[], type: SendType): number {
|
||||
return sends.filter((s) => s.type === type).length;
|
||||
}
|
||||
|
||||
private async saveState() {
|
||||
|
@ -192,7 +180,6 @@ export class SendGroupingsComponent extends BaseSendComponent {
|
|||
scrollY: BrowserPopupUtils.getContentScrollY(window),
|
||||
searchText: this.searchText,
|
||||
sends: this.sends,
|
||||
typeCounts: this.typeCounts,
|
||||
});
|
||||
await this.stateService.setBrowserSendComponentState(this.state);
|
||||
}
|
||||
|
@ -206,9 +193,6 @@ export class SendGroupingsComponent extends BaseSendComponent {
|
|||
if (this.state.sends != null) {
|
||||
this.sends = this.state.sends;
|
||||
}
|
||||
if (this.state.typeCounts != null) {
|
||||
this.typeCounts = this.state.typeCounts;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import { FakeStateProvider } from "@bitwarden/common/../spec/fake-state-provider
|
|||
import { awaitAsync } from "@bitwarden/common/../spec/utils";
|
||||
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
|
||||
import { BrowserComponentState } from "../../../models/browserComponentState";
|
||||
|
@ -33,7 +32,6 @@ describe("Browser Send State Service", () => {
|
|||
const state = new BrowserSendComponentState();
|
||||
state.scrollY = 0;
|
||||
state.searchText = "test";
|
||||
state.typeCounts = new Map<SendType, number>().set(SendType.File, 1);
|
||||
|
||||
await stateService.setBrowserSendComponentState(state);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ export class BrowserSendStateService {
|
|||
}
|
||||
|
||||
/** Set the active user's browser send component state
|
||||
* @param { BrowserSendComponentState } value sets the sends and type counts along with the scroll position and search text for
|
||||
* @param { BrowserSendComponentState } value sets the sends along with the scroll position and search text for
|
||||
* the send component on the browser
|
||||
*/
|
||||
async setBrowserSendComponentState(value: BrowserSendComponentState): Promise<void> {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Jsonify } from "type-fest";
|
||||
|
||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||
|
||||
import { BrowserSendComponentState } from "../../../models/browserSendComponentState";
|
||||
|
||||
import { BROWSER_SEND_COMPONENT, BROWSER_SEND_TYPE_COMPONENT } from "./key-definitions";
|
||||
|
@ -12,7 +10,8 @@ describe("Key definitions", () => {
|
|||
const keyDef = BROWSER_SEND_COMPONENT;
|
||||
|
||||
const expectedState = {
|
||||
typeCounts: new Map<SendType, number>(),
|
||||
scrollY: 0,
|
||||
searchText: "test",
|
||||
};
|
||||
|
||||
const result = keyDef.deserializer(
|
||||
|
|
|
@ -49,5 +49,14 @@
|
|||
},
|
||||
"unsupportedEncryptedImport": {
|
||||
"message": "Importing encrypted files is currently not supported."
|
||||
},
|
||||
"importUnassignedItemsError": {
|
||||
"message": "File contains unassigned items."
|
||||
},
|
||||
"errorAssigningTargetCollection": {
|
||||
"message": "Error assigning target collection."
|
||||
},
|
||||
"errorAssigningTargetFolder": {
|
||||
"message": "Error assigning target folder."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2705,5 +2705,11 @@
|
|||
},
|
||||
"passkeyRemoved": {
|
||||
"message": "Passkey removed"
|
||||
},
|
||||
"errorAssigningTargetCollection": {
|
||||
"message": "Error assigning target collection."
|
||||
},
|
||||
"errorAssigningTargetFolder": {
|
||||
"message": "Error assigning target folder."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ export class SendComponent extends BaseSendComponent {
|
|||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.dialogService.closeAll();
|
||||
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
||||
}
|
||||
|
||||
|
|
|
@ -7944,5 +7944,11 @@
|
|||
},
|
||||
"deleteProviderWarning": {
|
||||
"message": "Deleting your provider is permanent. It cannot be undone."
|
||||
},
|
||||
"errorAssigningTargetCollection": {
|
||||
"message": "Error assigning target collection."
|
||||
},
|
||||
"errorAssigningTargetFolder": {
|
||||
"message": "Error assigning target folder."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Observable, firstValueFrom } from "rxjs";
|
||||
import { Observable, firstValueFrom, map } from "rxjs";
|
||||
import { SemVer } from "semver";
|
||||
|
||||
import { ApiService } from "../../abstractions/api.service";
|
||||
|
@ -100,9 +100,9 @@ export class CipherService implements CipherServiceAbstraction {
|
|||
this.decryptedCiphersState = this.stateProvider.getActive(DECRYPTED_CIPHERS);
|
||||
this.addEditCipherInfoState = this.stateProvider.getActive(ADD_EDIT_CIPHER_INFO_KEY);
|
||||
|
||||
this.localData$ = this.localDataState.state$;
|
||||
this.ciphers$ = this.encryptedCiphersState.state$;
|
||||
this.cipherViews$ = this.decryptedCiphersState.state$;
|
||||
this.localData$ = this.localDataState.state$.pipe(map((data) => data ?? {}));
|
||||
this.ciphers$ = this.encryptedCiphersState.state$.pipe(map((ciphers) => ciphers ?? {}));
|
||||
this.cipherViews$ = this.decryptedCiphersState.state$.pipe(map((views) => views ?? {}));
|
||||
this.addEditCipherInfo$ = this.addEditCipherInfoState.state$;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ describe("ImportService", () => {
|
|||
new Object() as FolderView,
|
||||
);
|
||||
|
||||
await expect(setImportTargetMethod).rejects.toThrow("Error assigning target collection");
|
||||
await expect(setImportTargetMethod).rejects.toThrow();
|
||||
});
|
||||
|
||||
it("passing importTarget as null on setImportTarget throws error", async () => {
|
||||
|
@ -206,7 +206,7 @@ describe("ImportService", () => {
|
|||
new Object() as CollectionView,
|
||||
);
|
||||
|
||||
await expect(setImportTargetMethod).rejects.toThrow("Error assigning target folder");
|
||||
await expect(setImportTargetMethod).rejects.toThrow();
|
||||
});
|
||||
|
||||
it("passing importTarget, collectionRelationship has the expected values", async () => {
|
||||
|
|
|
@ -432,7 +432,7 @@ export class ImportService implements ImportServiceAbstraction {
|
|||
|
||||
if (organizationId) {
|
||||
if (!(importTarget instanceof CollectionView)) {
|
||||
throw new Error("Error assigning target collection");
|
||||
throw new Error(this.i18nService.t("errorAssigningTargetCollection"));
|
||||
}
|
||||
|
||||
const noCollectionRelationShips: [number, number][] = [];
|
||||
|
@ -463,7 +463,7 @@ export class ImportService implements ImportServiceAbstraction {
|
|||
}
|
||||
|
||||
if (!(importTarget instanceof FolderView)) {
|
||||
throw new Error("Error assigning target folder");
|
||||
throw new Error(this.i18nService.t("errorAssigningTargetFolder"));
|
||||
}
|
||||
|
||||
const noFolderRelationShips: [number, number][] = [];
|
||||
|
|
Loading…
Reference in New Issue