Chore: update to Angular v18 (#7106)

This commit is contained in:
shamoon
2024-06-26 20:57:39 -07:00
committed by GitHub
parent 4f1185c65d
commit 3435ffd00c
93 changed files with 3461 additions and 2829 deletions

View File

@@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'
import { NgbAlertModule } from '@ng-bootstrap/ng-bootstrap'
import { PermissionsGuard } from 'src/app/guards/permissions.guard'
import { DashboardComponent } from './dashboard.component'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { provideHttpClientTesting } from '@angular/common/http/testing'
import { SettingsService } from 'src/app/services/settings.service'
import { StatisticsWidgetComponent } from './widgets/statistics-widget/statistics-widget.component'
import { PageHeaderComponent } from '../common/page-header/page-header.component'
@@ -22,6 +22,7 @@ import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { CdkDragDrop, DragDropModule } from '@angular/cdk/drag-drop'
import { SavedView } from 'src/app/data/saved-view'
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
const saved_views = [
{
@@ -81,6 +82,13 @@ describe('DashboardComponent', () => {
SavedViewWidgetComponent,
LogoComponent,
],
imports: [
NgbAlertModule,
RouterTestingModule,
TourNgBootstrapModule,
DragDropModule,
NgxBootstrapIconsModule.pick(allIcons),
],
providers: [
PermissionsGuard,
{
@@ -101,14 +109,8 @@ describe('DashboardComponent', () => {
dashboardViews: saved_views.filter((v) => v.show_on_dashboard),
},
},
],
imports: [
NgbAlertModule,
HttpClientTestingModule,
RouterTestingModule,
TourNgBootstrapModule,
DragDropModule,
NgxBootstrapIconsModule.pick(allIcons),
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
}).compileComponents()

View File

@@ -1,5 +1,5 @@
import { DatePipe } from '@angular/common'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { provideHttpClientTesting } from '@angular/common/http/testing'
import {
ComponentFixture,
TestBed,
@@ -41,6 +41,7 @@ import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service
import { CustomFieldDataType } from 'src/app/data/custom-field'
import { CustomFieldDisplayComponent } from 'src/app/components/common/custom-field-display/custom-field-display.component'
import { DisplayMode, DisplayField } from 'src/app/data/document'
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
const savedView: SavedView = {
id: 1,
@@ -125,6 +126,12 @@ describe('SavedViewWidgetComponent', () => {
PreviewPopupComponent,
CustomFieldDisplayComponent,
],
imports: [
NgbModule,
RouterTestingModule.withRoutes(routes),
DragDropModule,
NgxBootstrapIconsModule.pick(allIcons),
],
providers: [
PermissionsGuard,
DocumentService,
@@ -163,13 +170,8 @@ describe('SavedViewWidgetComponent', () => {
}),
},
},
],
imports: [
HttpClientTestingModule,
NgbModule,
RouterTestingModule.withRoutes(routes),
DragDropModule,
NgxBootstrapIconsModule.pick(allIcons),
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
}).compileComponents()

View File

@@ -2,8 +2,8 @@ import { TestBed } from '@angular/core/testing'
import { StatisticsWidgetComponent } from './statistics-widget.component'
import { ComponentFixture } from '@angular/core/testing'
import {
HttpClientTestingModule,
HttpTestingController,
provideHttpClientTesting,
} from '@angular/common/http/testing'
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { WidgetFrameComponent } from '../widget-frame/widget-frame.component'
@@ -18,6 +18,7 @@ import {
} from 'src/app/services/consumer-status.service'
import { Subject } from 'rxjs'
import { DragDropModule } from '@angular/cdk/drag-drop'
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
describe('StatisticsWidgetComponent', () => {
let component: StatisticsWidgetComponent
@@ -33,13 +34,16 @@ describe('StatisticsWidgetComponent', () => {
WidgetFrameComponent,
IfPermissionsDirective,
],
providers: [PermissionsGuard],
imports: [
HttpClientTestingModule,
NgbModule,
RouterTestingModule.withRoutes(routes),
DragDropModule,
],
providers: [
PermissionsGuard,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
}).compileComponents()
fixture = TestBed.createComponent(StatisticsWidgetComponent)

View File

@@ -39,7 +39,7 @@
<a [routerLink]="[]" (click)="alertsExpanded = !alertsExpanded" aria-controls="hiddenAlerts" [attr.aria-expanded]="alertsExpanded" i18n>Show all</a>
</p>
}
<div #hiddenAlerts="ngbCollapse" [(ngbCollapse)]="!alertsExpanded">
<div #hiddenAlerts="ngbCollapse" [ngbCollapse]="!alertsExpanded" (ngbCollapseChange)="alertsExpanded = $event">
@for (status of getStatusHidden(); track status) {
<div>
<ng-container [ngTemplateOutlet]="consumerAlert" [ngTemplateOutletContext]="{ $implicit: status }"></ng-container>

View File

@@ -1,4 +1,4 @@
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { provideHttpClientTesting } from '@angular/common/http/testing'
import {
ComponentFixture,
TestBed,
@@ -27,6 +27,7 @@ import { WidgetFrameComponent } from '../widget-frame/widget-frame.component'
import { UploadFileWidgetComponent } from './upload-file-widget.component'
import { DragDropModule } from '@angular/cdk/drag-drop'
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
const FAILED_STATUSES = [new FileStatus()]
const WORKING_STATUSES = [new FileStatus(), new FileStatus()]
@@ -59,6 +60,13 @@ describe('UploadFileWidgetComponent', () => {
WidgetFrameComponent,
IfPermissionsDirective,
],
imports: [
NgbModule,
RouterTestingModule.withRoutes(routes),
NgbAlertModule,
DragDropModule,
NgxBootstrapIconsModule.pick(allIcons),
],
providers: [
PermissionsGuard,
{
@@ -67,14 +75,8 @@ describe('UploadFileWidgetComponent', () => {
currentUserCan: () => true,
},
},
],
imports: [
HttpClientTestingModule,
NgbModule,
RouterTestingModule.withRoutes(routes),
NgbAlertModule,
DragDropModule,
NgxBootstrapIconsModule.pick(allIcons),
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
}).compileComponents()