mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 13:23:34 +00:00
Restrict angular imports (#5597)
* Refactor restricted imports eslint rule, add angular deps * Move FormValidationErrorsService into libs/angular * Remove angular decorators from configService * Remove angular decorator from anonymousHubService
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
import { AbstractControl } from "@angular/forms";
|
||||
export interface AllValidationErrors {
|
||||
controlName: string;
|
||||
errorName: string;
|
||||
}
|
||||
|
||||
export interface FormGroupControls {
|
||||
[key: string]: AbstractControl;
|
||||
}
|
||||
|
||||
export abstract class FormValidationErrorsService {
|
||||
getFormValidationErrors: (controls: FormGroupControls) => AllValidationErrors[];
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Injectable, OnDestroy } from "@angular/core";
|
||||
import { BehaviorSubject, Subject, concatMap, from, takeUntil, timer } from "rxjs";
|
||||
import { BehaviorSubject, concatMap, from, timer } from "rxjs";
|
||||
|
||||
import { AuthService } from "../../../auth/abstractions/auth.service";
|
||||
import { AuthenticationStatus } from "../../../auth/enums/authentication-status";
|
||||
@@ -11,11 +10,9 @@ import { EnvironmentService } from "../../abstractions/environment.service";
|
||||
import { StateService } from "../../abstractions/state.service";
|
||||
import { ServerConfigData } from "../../models/data/server-config.data";
|
||||
|
||||
@Injectable()
|
||||
export class ConfigService implements ConfigServiceAbstraction, OnDestroy {
|
||||
export class ConfigService implements ConfigServiceAbstraction {
|
||||
protected _serverConfig = new BehaviorSubject<ServerConfig | null>(null);
|
||||
serverConfig$ = this._serverConfig.asObservable();
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
private stateService: StateService,
|
||||
@@ -30,16 +27,11 @@ export class ConfigService implements ConfigServiceAbstraction, OnDestroy {
|
||||
this._serverConfig.next(serverConfig);
|
||||
});
|
||||
|
||||
this.environmentService.urls.pipe(takeUntil(this.destroy$)).subscribe(() => {
|
||||
this.environmentService.urls.subscribe(() => {
|
||||
this.fetchServerConfig();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
async fetchServerConfig(): Promise<ServerConfig> {
|
||||
try {
|
||||
const response = await this.configApiService.get();
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import { UntypedFormGroup, ValidationErrors } from "@angular/forms";
|
||||
|
||||
import {
|
||||
FormGroupControls,
|
||||
FormValidationErrorsService as FormValidationErrorsAbstraction,
|
||||
AllValidationErrors,
|
||||
} from "../abstractions/form-validation-errors.service";
|
||||
|
||||
export class FormValidationErrorsService implements FormValidationErrorsAbstraction {
|
||||
getFormValidationErrors(controls: FormGroupControls): AllValidationErrors[] {
|
||||
let errors: AllValidationErrors[] = [];
|
||||
Object.keys(controls).forEach((key) => {
|
||||
const control = controls[key];
|
||||
if (control instanceof UntypedFormGroup) {
|
||||
errors = errors.concat(this.getFormValidationErrors(control.controls));
|
||||
}
|
||||
|
||||
const controlErrors: ValidationErrors = controls[key].errors;
|
||||
if (controlErrors !== null) {
|
||||
Object.keys(controlErrors).forEach((keyError) => {
|
||||
errors.push({
|
||||
controlName: key,
|
||||
errorName: keyError,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import {
|
||||
HttpTransportType,
|
||||
HubConnection,
|
||||
@@ -17,7 +16,6 @@ import {
|
||||
NotificationResponse,
|
||||
} from "./../models/response/notification.response";
|
||||
|
||||
@Injectable()
|
||||
export class AnonymousHubService implements AnonymousHubServiceAbstraction {
|
||||
private anonHubConnection: HubConnection;
|
||||
private url: string;
|
||||
|
||||
Reference in New Issue
Block a user