mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
Wire up key definitions for OrganizationService (#7781)
* Wire up key definitions for OrganizationService [`AC-2009`: Transition OrganizationService to use StateProvider]( https://bitwarden.atlassian.net/browse/AC-2009) In order to support the new `StateProvider` APIs for managing application state this commit modifies `OrganizationService` in the following ways: 1. Adding a `KeyDefinition` object to `OrganizationService` to store the `organization` record in `StateProvider`. 1. Injecting `StateProvider` and wiring up `OrganizationService` to read from the `organizations` key definition for the active user account. 1. Expanding the capabilities of `OrganizationData` to be able to read itself from a JSON string. Previously this was handled directly by `StateService`. 1. Updating tests to include requirements for testing against `StateProvider`. 1. Marking the existing `StateService`-backed `organizations` `Observable` and `BehaviorSubject` as deprecated. This is largely unimplemented code with no intended visible effects to the system. Implementing getting & updating the `organizations` value from `StateProvider` will the next step in this work. * Rework null check on OrganizationData * Remove deprecation signals for the time being * Move key definition inline with its service * Create date objects when deserialzing json from state
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
CachedServices,
|
||||
factory,
|
||||
} from "../../../platform/background/service-factories/factory-options";
|
||||
import { stateProviderFactory } from "../../../platform/background/service-factories/state-provider.factory";
|
||||
import {
|
||||
stateServiceFactory,
|
||||
StateServiceInitOptions,
|
||||
@@ -24,6 +25,10 @@ export function organizationServiceFactory(
|
||||
cache,
|
||||
"organizationService",
|
||||
opts,
|
||||
async () => new BrowserOrganizationService(await stateServiceFactory(cache, opts)),
|
||||
async () =>
|
||||
new BrowserOrganizationService(
|
||||
await stateServiceFactory(cache, opts),
|
||||
await stateProviderFactory(cache, opts),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -442,7 +442,10 @@ export default class MainBackground {
|
||||
this.stateService,
|
||||
);
|
||||
this.syncNotifierService = new SyncNotifierService();
|
||||
this.organizationService = new BrowserOrganizationService(this.stateService);
|
||||
this.organizationService = new BrowserOrganizationService(
|
||||
this.stateService,
|
||||
this.stateProvider,
|
||||
);
|
||||
this.policyService = new BrowserPolicyService(this.stateService, this.organizationService);
|
||||
this.policyApiService = new PolicyApiService(
|
||||
this.policyService,
|
||||
|
||||
@@ -68,7 +68,7 @@ import { GlobalState } from "@bitwarden/common/platform/models/domain/global-sta
|
||||
import { ConfigService } from "@bitwarden/common/platform/services/config/config.service";
|
||||
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
|
||||
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
|
||||
import { DerivedStateProvider } from "@bitwarden/common/platform/state";
|
||||
import { DerivedStateProvider, StateProvider } from "@bitwarden/common/platform/state";
|
||||
import { SearchService } from "@bitwarden/common/services/search.service";
|
||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
|
||||
import { UsernameGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/username";
|
||||
@@ -415,8 +415,8 @@ function getBgService<T>(service: keyof MainBackground) {
|
||||
},
|
||||
{
|
||||
provide: OrganizationService,
|
||||
useFactory: (stateService: StateServiceAbstraction) => {
|
||||
return new BrowserOrganizationService(stateService);
|
||||
useFactory: (stateService: StateServiceAbstraction, stateProvider: StateProvider) => {
|
||||
return new BrowserOrganizationService(stateService, stateProvider);
|
||||
},
|
||||
deps: [StateServiceAbstraction],
|
||||
},
|
||||
|
||||
@@ -352,7 +352,7 @@ export class Main {
|
||||
|
||||
this.providerService = new ProviderService(this.stateService);
|
||||
|
||||
this.organizationService = new OrganizationService(this.stateService);
|
||||
this.organizationService = new OrganizationService(this.stateService, this.stateProvider);
|
||||
|
||||
this.organizationUserService = new OrganizationUserServiceImplementation(this.apiService);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user