Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Import HttpClient module only once (#11370)

Benjamin Bädorf0652db22a6ac
diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts
index 7611f0443bc..c978f2bd0ec 100644
--- a/frontend/src/app/app.module.ts
+++ b/frontend/src/app/app.module.ts
@@ -32,6 +32,10 @@ import {
Injector,
NgModule,
} from '@angular/core';
+import {
+ HTTP_INTERCEPTORS,
+ HttpClientModule,
+} from '@angular/common/http';
import { ReactiveFormsModule } from '@angular/forms';
import { OpContextMenuTrigger } from 'core-app/shared/components/op-context-menu/handlers/op-context-menu-trigger.directive';
import { States } from 'core-app/core/states/states.service';
@@ -88,7 +92,6 @@ import { OpenProjectBackupService } from './core/backup/op-backup.service';
import { OpenProjectDirectFileUploadService } from './core/file-upload/op-direct-file-upload.service';
import { OpenProjectStateModule } from 'core-app/core/state/openproject-state.module';
import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-content-loader/openproject-content-loader.module';
-import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { OpenProjectHeaderInterceptor } from 'core-app/features/hal/http/openproject-header-interceptor';
export function initializeServices(injector:Injector) {
@@ -169,6 +172,9 @@ export function initializeServices(injector:Injector) {
// Angular Forms
ReactiveFormsModule,
+ // Angular Http Client
+ HttpClientModule,
+
// Augmenting Module
OpenprojectAugmentingModule,
diff --git a/frontend/src/app/core/apiv3/endpoints/work_packages/work-package-cache.spec.ts b/frontend/src/app/core/apiv3/endpoints/work_packages/work-package-cache.spec.ts
index 0f7d447c152..a9115646f4b 100644
--- a/frontend/src/app/core/apiv3/endpoints/work_packages/work-package-cache.spec.ts
+++ b/frontend/src/app/core/apiv3/endpoints/work_packages/work-package-cache.spec.ts
@@ -45,6 +45,7 @@ import { OpenProjectDirectFileUploadService } from 'core-app/core/file-upload/op
import { TimezoneService } from 'core-app/core/datetime/timezone.service';
import { HalResourceNotificationService } from 'core-app/features/hal/services/hal-resource-notification.service';
import { OpenprojectHalModule } from 'core-app/features/hal/openproject-hal.module';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('WorkPackageCache', () => {
let injector:Injector;
@@ -57,6 +58,7 @@ describe('WorkPackageCache', () => {
TestBed.configureTestingModule({
imports: [
OpenprojectHalModule,
+ HttpClientTestingModule,
],
providers: [
States,
diff --git a/frontend/src/app/features/hal/openproject-hal.module.ts b/frontend/src/app/features/hal/openproject-hal.module.ts
index ba204f2a56e..aa580f583fb 100644
--- a/frontend/src/app/features/hal/openproject-hal.module.ts
+++ b/frontend/src/app/features/hal/openproject-hal.module.ts
@@ -31,7 +31,6 @@ import {
ErrorHandler,
NgModule,
} from '@angular/core';
-import { HttpClientModule } from '@angular/common/http';
import { CommonModule } from '@angular/common';
import { HalAwareErrorHandler } from 'core-app/features/hal/services/hal-aware-error-handler';
import { initializeHalResourceConfig } from 'core-app/features/hal/services/hal-resource.config';
@@ -41,7 +40,6 @@ import { HalResourceNotificationService } from 'core-app/features/hal/services/h
@NgModule({
imports: [
CommonModule,
- HttpClientModule,
],
providers: [
{ provide: ErrorHandler, useClass: HalAwareErrorHandler },
diff --git a/frontend/src/app/features/hal/resources/hal-resource.spec.ts b/frontend/src/app/features/hal/resources/hal-resource.spec.ts
index e8f192c72a0..78c8d456dc4 100644
--- a/frontend/src/app/features/hal/resources/hal-resource.spec.ts
+++ b/frontend/src/app/features/hal/resources/hal-resource.spec.ts
@@ -35,6 +35,7 @@ import { of } from 'rxjs';
import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';
import { OpenprojectHalModule } from 'core-app/features/hal/openproject-hal.module';
import { HalLink, HalLinkInterface } from 'core-app/features/hal/hal-link/hal-link';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
import Spy = jasmine.Spy;
describe('HalResource', () => {
@@ -52,6 +53,7 @@ describe('HalResource', () => {
TestBed.configureTestingModule({
imports: [
OpenprojectHalModule,
+ HttpClientTestingModule,
],
providers: [
HalResourceService,
diff --git a/frontend/src/app/features/hal/resources/work-package-resource.spec.ts b/frontend/src/app/features/hal/resources/work-package-resource.spec.ts
index 902659f8507..01ce3a97adf 100644
--- a/frontend/src/app/features/hal/resources/work-package-resource.spec.ts
+++ b/frontend/src/app/features/hal/resources/work-package-resource.spec.ts
@@ -50,6 +50,7 @@ import { WorkPackageResource } from 'core-app/features/hal/resources/work-packag
import isNewResource from 'core-app/features/hal/helpers/is-new-resource';
import { WeekdayService } from 'core-app/core/days/weekday.service';
import { of } from 'rxjs';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('WorkPackage', () => {
let halResourceService:HalResourceService;
@@ -73,6 +74,7 @@ describe('WorkPackage', () => {
TestBed.configureTestingModule({
imports: [
OpenprojectHalModule,
+ HttpClientTestingModule,
],
providers: [
HalResourceService,
diff --git a/frontend/src/app/shared/components/dynamic-forms/dynamic-forms.module.ts b/frontend/src/app/shared/components/dynamic-forms/dynamic-forms.module.ts
index a2a424226d5..14cce745546 100644
--- a/frontend/src/app/shared/components/dynamic-forms/dynamic-forms.module.ts
+++ b/frontend/src/app/shared/components/dynamic-forms/dynamic-forms.module.ts
@@ -3,7 +3,6 @@ import { CommonModule } from '@angular/common';
import { FormlyModule } from '@ngx-formly/core';
import { NgOptionHighlightModule } from '@ng-select/ng-option-highlight';
import { NgSelectModule } from '@ng-select/ng-select';
-import { HttpClientModule } from '@angular/common/http';
import { ReactiveFormsModule } from '@angular/forms';
import { TextInputComponent } from 'core-app/shared/components/dynamic-forms/components/dynamic-inputs/text-input/text-input.component';
import { IntegerInputComponent } from 'core-app/shared/components/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component';
@@ -49,7 +48,6 @@ import { UserInputComponent } from 'core-app/shared/components/dynamic-forms/com
},
],
}),
- HttpClientModule,
OPSharedModule,
// Input dependencies
diff --git a/frontend/src/app/shared/components/toaster/toast.service.spec.ts b/frontend/src/app/shared/components/toaster/toast.service.spec.ts
index 26e7693fe86..b783ba8eb9e 100644
--- a/frontend/src/app/shared/components/toaster/toast.service.spec.ts
+++ b/frontend/src/app/shared/components/toaster/toast.service.spec.ts
@@ -28,6 +28,7 @@
import { TestBed, waitForAsync } from '@angular/core/testing';
import { ToastService } from 'core-app/shared/components/toaster/toast.service';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ConfigurationService } from 'core-app/core/config/configuration.service';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { OpenprojectHalModule } from 'core-app/features/hal/openproject-hal.module';
@@ -40,6 +41,7 @@ describe('ToastService', () => {
TestBed.configureTestingModule({
imports: [
OpenprojectHalModule,
+ HttpClientTestingModule,
],
providers: [
{ provide: ConfigurationService, useValue: { autoHidePopups: () => true } },