mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-28 07:49:41 +01:00
Update remaining callers in web
This commit is contained in:
parent
10359328f3
commit
8b21ad25aa
@ -3,6 +3,7 @@ import { ChangeDetectorRef, Component, Inject, OnDestroy, OnInit } from "@angula
|
||||
import { AbstractControl, FormBuilder, Validators } from "@angular/forms";
|
||||
import {
|
||||
combineLatest,
|
||||
firstValueFrom,
|
||||
map,
|
||||
Observable,
|
||||
of,
|
||||
@ -24,6 +25,8 @@ import {
|
||||
} from "@bitwarden/admin-console/common";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
@ -96,6 +99,8 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
protected showDeleteButton = false;
|
||||
protected showAddAccessWarning = false;
|
||||
|
||||
private activeUserId$ = this.accountService.activeAccount$.pipe(getUserId);
|
||||
|
||||
constructor(
|
||||
@Inject(DIALOG_DATA) private params: CollectionDialogParams,
|
||||
private formBuilder: FormBuilder,
|
||||
@ -108,6 +113,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
private organizationUserApiService: OrganizationUserApiService,
|
||||
private dialogService: DialogService,
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private accountService: AccountService,
|
||||
) {
|
||||
this.tabIndex = params.initialTab ?? CollectionDialogTabType.Info;
|
||||
}
|
||||
@ -305,7 +311,10 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
collectionView.name = this.formGroup.controls.name.value;
|
||||
}
|
||||
|
||||
const savedCollection = await this.collectionAdminService.save(collectionView);
|
||||
const savedCollection = await this.collectionAdminService.save(
|
||||
collectionView,
|
||||
await firstValueFrom(this.activeUserId$),
|
||||
);
|
||||
|
||||
this.platformUtilsService.showToast(
|
||||
"success",
|
||||
|
@ -1,9 +1,12 @@
|
||||
import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog";
|
||||
import { Component, Inject } from "@angular/core";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { CollectionService, CollectionView } from "@bitwarden/admin-console/common";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
@ -50,6 +53,8 @@ export class BulkDeleteDialogComponent {
|
||||
collections: CollectionView[];
|
||||
unassignedCiphers: string[];
|
||||
|
||||
private activeUserId$ = this.accountService.activeAccount$.pipe(getUserId);
|
||||
|
||||
constructor(
|
||||
@Inject(DIALOG_DATA) params: BulkDeleteDialogParams,
|
||||
private dialogRef: DialogRef<BulkDeleteDialogResult>,
|
||||
@ -58,6 +63,7 @@ export class BulkDeleteDialogComponent {
|
||||
private i18nService: I18nService,
|
||||
private apiService: ApiService,
|
||||
private collectionService: CollectionService,
|
||||
private accountService: AccountService,
|
||||
) {
|
||||
this.cipherIds = params.cipherIds ?? [];
|
||||
this.permanent = params.permanent;
|
||||
@ -100,7 +106,10 @@ export class BulkDeleteDialogComponent {
|
||||
);
|
||||
}
|
||||
if (this.collections.length) {
|
||||
await this.collectionService.delete(this.collections.map((c) => c.id));
|
||||
await this.collectionService.delete(
|
||||
this.collections.map((c) => c.id),
|
||||
await firstValueFrom(this.activeUserId$),
|
||||
);
|
||||
this.platformUtilsService.showToast(
|
||||
"success",
|
||||
null,
|
||||
|
@ -44,6 +44,7 @@ import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
||||
import { EventType } from "@bitwarden/common/enums";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
@ -55,7 +56,7 @@ import { MessagingService } from "@bitwarden/common/platform/abstractions/messag
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { SyncService } from "@bitwarden/common/platform/sync";
|
||||
import { CipherId, CollectionId, OrganizationId, UserId } from "@bitwarden/common/types/guid";
|
||||
import { CipherId, CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||
@ -120,7 +121,6 @@ import { FolderFilter, OrganizationFilter } from "./vault-filter/shared/models/v
|
||||
import { VaultFilterModule } from "./vault-filter/vault-filter.module";
|
||||
import { VaultHeaderComponent } from "./vault-header/vault-header.component";
|
||||
import { VaultOnboardingComponent } from "./vault-onboarding/vault-onboarding.component";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
|
||||
const BroadcasterSubscriptionId = "VaultComponent";
|
||||
const SearchTextDebounceInterval = 200;
|
||||
@ -174,7 +174,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
protected selectedCollection: TreeNode<CollectionView> | undefined;
|
||||
protected canCreateCollections = false;
|
||||
protected currentSearchText$: Observable<string>;
|
||||
private activeUserId: UserId;
|
||||
private searchText$ = new Subject<string>();
|
||||
private refresh$ = new BehaviorSubject<void>(null);
|
||||
private destroy$ = new Subject<void>();
|
||||
@ -222,10 +221,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
: "trashCleanupWarning",
|
||||
);
|
||||
|
||||
this.activeUserId = await firstValueFrom(
|
||||
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
||||
);
|
||||
|
||||
const firstSetup$ = this.route.queryParams.pipe(
|
||||
first(),
|
||||
switchMap(async (params: Params) => {
|
||||
@ -825,7 +820,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
if (result.collection) {
|
||||
// Update CollectionService with the new collection
|
||||
const c = new CollectionData(result.collection as CollectionDetailsResponse);
|
||||
await this.collectionService.upsert(c);
|
||||
await this.collectionService.upsert(c, await firstValueFrom(this.activeUserId$));
|
||||
}
|
||||
this.refresh();
|
||||
}
|
||||
@ -846,11 +841,14 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
if (result.collection) {
|
||||
// Update CollectionService with the new collection
|
||||
const c = new CollectionData(result.collection as CollectionDetailsResponse);
|
||||
await this.collectionService.upsert(c);
|
||||
await this.collectionService.upsert(c, await firstValueFrom(this.activeUserId$));
|
||||
}
|
||||
this.refresh();
|
||||
} else if (result.action === CollectionDialogAction.Deleted) {
|
||||
await this.collectionService.delete(result.collection?.id);
|
||||
await this.collectionService.delete(
|
||||
result.collection?.id,
|
||||
await firstValueFrom(this.activeUserId$),
|
||||
);
|
||||
this.refresh();
|
||||
// Navigate away if we deleted the collection we were viewing
|
||||
if (this.selectedCollection?.node.id === c?.id) {
|
||||
@ -879,7 +877,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
try {
|
||||
await this.apiService.deleteCollection(collection.organizationId, collection.id);
|
||||
await this.collectionService.delete(collection.id);
|
||||
await this.collectionService.delete(collection.id, await firstValueFrom(this.activeUserId$));
|
||||
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { CollectionDetailsResponse } from "@bitwarden/admin-console/common";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
|
||||
import { CollectionAccessSelectionView, CollectionAdminView } from "../models";
|
||||
|
||||
export abstract class CollectionAdminService {
|
||||
getAll: (organizationId: string) => Promise<CollectionAdminView[]>;
|
||||
get: (organizationId: string, collectionId: string) => Promise<CollectionAdminView | undefined>;
|
||||
save: (collection: CollectionAdminView) => Promise<CollectionDetailsResponse>;
|
||||
save: (collection: CollectionAdminView, userId: UserId) => Promise<CollectionDetailsResponse>;
|
||||
delete: (organizationId: string, collectionId: string) => Promise<void>;
|
||||
bulkAssignAccess: (
|
||||
organizationId: string,
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
CollectionAccessSelectionView,
|
||||
CollectionAdminView,
|
||||
} from "../models";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
|
||||
export class DefaultCollectionAdminService implements CollectionAdminService {
|
||||
constructor(
|
||||
@ -53,7 +54,7 @@ export class DefaultCollectionAdminService implements CollectionAdminService {
|
||||
return view;
|
||||
}
|
||||
|
||||
async save(collection: CollectionAdminView): Promise<CollectionDetailsResponse> {
|
||||
async save(collection: CollectionAdminView, userId: UserId): Promise<CollectionDetailsResponse> {
|
||||
const request = await this.encrypt(collection);
|
||||
|
||||
let response: CollectionDetailsResponse;
|
||||
@ -69,9 +70,9 @@ export class DefaultCollectionAdminService implements CollectionAdminService {
|
||||
}
|
||||
|
||||
if (response.assigned) {
|
||||
await this.collectionService.upsert(new CollectionData(response));
|
||||
await this.collectionService.upsert(new CollectionData(response), userId);
|
||||
} else {
|
||||
await this.collectionService.delete(collection.id);
|
||||
await this.collectionService.delete(collection.id, userId);
|
||||
}
|
||||
|
||||
return response;
|
||||
|
@ -1363,7 +1363,7 @@ const safeProviders: SafeProvider[] = [
|
||||
safeProvider({
|
||||
provide: CipherAuthorizationService,
|
||||
useClass: DefaultCipherAuthorizationService,
|
||||
deps: [CollectionService, OrganizationServiceAbstraction],
|
||||
deps: [CollectionService, OrganizationServiceAbstraction, AccountServiceAbstraction],
|
||||
}),
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user