mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
Address review feedback on UnassignedBannerService (#8680)
* Introduce `UnassignedItemsBannerApiService` * Delete `WebUnassignedItemsBannerService`
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
|
||||
@Injectable({ providedIn: "root" })
|
||||
export class UnassignedItemsBannerApiService {
|
||||
constructor(private apiService: ApiService) {}
|
||||
|
||||
async getShowUnassignedCiphersBanner(): Promise<boolean> {
|
||||
const r = await this.apiService.send(
|
||||
"GET",
|
||||
"/ciphers/has-unassigned-ciphers",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
import { MockProxy, mock } from "jest-mock-extended";
|
||||
import { firstValueFrom, skip } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { FakeStateProvider, mockAccountServiceWith } from "@bitwarden/common/spec";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
|
||||
import { UnassignedItemsBannerApiService } from "./unassigned-items-banner.api.service";
|
||||
import { SHOW_BANNER_KEY, UnassignedItemsBannerService } from "./unassigned-items-banner.service";
|
||||
|
||||
describe("UnassignedItemsBanner", () => {
|
||||
let stateProvider: FakeStateProvider;
|
||||
let apiService: MockProxy<ApiService>;
|
||||
let apiService: MockProxy<UnassignedItemsBannerApiService>;
|
||||
|
||||
const sutFactory = () => new UnassignedItemsBannerService(stateProvider, apiService);
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { EMPTY, concatMap } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import {
|
||||
StateProvider,
|
||||
UNASSIGNED_ITEMS_BANNER_DISK,
|
||||
UserKeyDefinition,
|
||||
} from "@bitwarden/common/platform/state";
|
||||
|
||||
import { UnassignedItemsBannerApiService } from "./unassigned-items-banner.api.service";
|
||||
|
||||
export const SHOW_BANNER_KEY = new UserKeyDefinition<boolean>(
|
||||
UNASSIGNED_ITEMS_BANNER_DISK,
|
||||
"showBanner",
|
||||
@@ -37,7 +38,7 @@ export class UnassignedItemsBannerService {
|
||||
|
||||
constructor(
|
||||
private stateProvider: StateProvider,
|
||||
private apiService: ApiService,
|
||||
private apiService: UnassignedItemsBannerApiService,
|
||||
) {}
|
||||
|
||||
async hideBanner() {
|
||||
|
||||
@@ -207,7 +207,6 @@ export abstract class ApiService {
|
||||
emergencyAccessId?: string,
|
||||
) => Promise<AttachmentResponse>;
|
||||
getCiphersOrganization: (organizationId: string) => Promise<ListResponse<CipherResponse>>;
|
||||
getShowUnassignedCiphersBanner: () => Promise<boolean>;
|
||||
postCipher: (request: CipherRequest) => Promise<CipherResponse>;
|
||||
postCipherCreate: (request: CipherCreateRequest) => Promise<CipherResponse>;
|
||||
postCipherAdmin: (request: CipherCreateRequest) => Promise<CipherResponse>;
|
||||
|
||||
@@ -506,11 +506,6 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
return new ListResponse(r, CipherResponse);
|
||||
}
|
||||
|
||||
async getShowUnassignedCiphersBanner(): Promise<boolean> {
|
||||
const r = await this.send("GET", "/ciphers/has-unassigned-ciphers", null, true, true);
|
||||
return r;
|
||||
}
|
||||
|
||||
async postCipher(request: CipherRequest): Promise<CipherResponse> {
|
||||
const r = await this.send("POST", "/ciphers", request, true, true);
|
||||
return new CipherResponse(r);
|
||||
|
||||
Reference in New Issue
Block a user