Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ task coreDev {
dependsOn 'javadoc'
dependsOn 'checkDependenciesDotGradle'
dependsOn 'checkLicense'
dependsOn ':console-webapp:runConsoleWebappUnitTests'
dependsOn ':core:check'
dependsOn 'assemble'

Expand Down
9 changes: 5 additions & 4 deletions config/presubmits.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@

# We should never analyze any generated files
UNIVERSALLY_SKIPPED_PATTERNS = {"/build/", "cloudbuild-caches", "/out/", ".git/",
".gradle/", "/dist/", "/console-alpha/", "/console-crash/", "/console-qa",
"/console-sandbox", "/console-production", "karma.conf.js", "polyfills.ts",
"test.ts", "/docs/console-endpoints/", "/bin/generated-sources/",
"/bin/generated-test-sources/", "src/main/generated", "src/test/generated"}
".gradle/", "/.angular/", "/dist/", "/console-alpha/", "/console-crash/",
"/console-qa", "/console-sandbox", "/console-production", "karma.conf.js",
"polyfills.ts", "test.ts", "/docs/console-endpoints/",
"/bin/generated-sources/", "/bin/generated-test-sources/",
"src/main/generated", "src/test/generated"}
# We can't rely on CI to have the Enum package installed so we do this instead.
FORBIDDEN = 1
REQUIRED = 2
Expand Down
2 changes: 1 addition & 1 deletion console-webapp/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
},
"cli": {
"cache": {
"enabled": false
"enabled": true
},
"analytics": false,
"schematicCollections": ["@angular-eslint/schematics"]
Expand Down
57 changes: 48 additions & 9 deletions console-webapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,23 @@ def consoleDir = "${rootDir}/console-webapp"
def projectParam = "--project=${rootProject.gcpProject}"

clean {
delete "${consoleDir}/.angular"
delete "${consoleDir}/node_modules"
delete "${consoleDir}/staged/dist"
}

def consoleSourceInputs = [
"${consoleDir}/package.json",
"${consoleDir}/package-lock.json",
"${consoleDir}/angular.json",
"${consoleDir}/tsconfig.json",
"${consoleDir}/tsconfig.app.json",
]

task npmInstallDeps(type: Exec) {
workingDir "${consoleDir}/"
inputs.files("${consoleDir}/package.json", "${consoleDir}/package-lock.json")
outputs.dir("${consoleDir}/node_modules")
commandLine 'sh', '-c', 'npm i --no-audit --no-fund --loglevel=error'
}

Expand All @@ -31,12 +42,20 @@ task runConsoleWebappLocally(type: Exec) {

task runConsoleWebappUnitTests(type: Exec) {
workingDir "${consoleDir}/"
inputs.dir("${consoleDir}/src")
inputs.files(consoleSourceInputs)
inputs.file("${consoleDir}/tsconfig.spec.json")
outputs.upToDateWhen { true }
commandLine 'sh', '-c', 'npm run test'
}

task buildConsoleWebapp(type: Exec) {
workingDir "${consoleDir}/"
def configuration = project.getProperty('configuration')
inputs.property('configuration', configuration)
inputs.dir("${consoleDir}/src")
inputs.files(consoleSourceInputs)
outputs.dir("${consoleDir}/staged/dist")
commandLine 'sh', '-c', "npx ng build --base-href=/console/ --configuration=${configuration} --output-path=staged/dist"
doFirst {
println "Building console for environment: ${configuration}"
Expand All @@ -45,9 +64,12 @@ task buildConsoleWebapp(type: Exec) {

task buildConsoleForAll() {}

def createConsoleTask = { env ->
def createConsoleBuildTask = { env ->
project.tasks.register("buildConsoleFor${env.capitalize()}", Exec) {
workingDir "${consoleDir}/"
inputs.dir("${consoleDir}/src")
inputs.files(consoleSourceInputs)
outputs.dir("${consoleDir}/staged/console-${env}")
commandLine 'sh', '-c', "npx ng build --base-href=/console/ --configuration=${env}"
doFirst {
println "Building console for environment: ${env}"
Expand All @@ -61,6 +83,26 @@ def createConsoleTask = { env ->
}
dependsOn(tasks.npmInstallDeps)
}
}

def createConsoleCopyTask = { env, sourceEnv ->
project.tasks.register("buildConsoleFor${env.capitalize()}", Copy) {
from "${consoleDir}/staged/console-${sourceEnv}"
into "${consoleDir}/staged/console-${env}"
dependsOn(tasks.named("buildConsoleFor${sourceEnv.capitalize()}"))
}
}

['alpha', 'sandbox', 'production'].forEach { env ->
createConsoleBuildTask(env)
}

// 'crash' and 'qa' share the exact same unoptimized build configuration as 'alpha'
['crash', 'qa'].forEach { env ->
createConsoleCopyTask(env, 'alpha')
}

['alpha', 'crash', 'qa', 'sandbox', 'production'].forEach { env ->
project.tasks.register("deleteConsoleFor${env.capitalize()}", Delete) {
delete "${consoleDir}/staged/console-${env}"
}
Expand All @@ -72,14 +114,8 @@ def createConsoleTask = { env ->
}
}

['alpha', 'crash', 'qa', 'sandbox', 'production'].forEach {env ->
createConsoleTask(env)
}

// Force an order so we don't run these tasks in parallel.
tasks.buildConsoleForCrash.mustRunAfter(tasks.buildConsoleForAlpha)
tasks.buildConsoleForQa.mustRunAfter(tasks.buildConsoleForCrash)
tasks.buildConsoleForSandbox.mustRunAfter(tasks.buildConsoleForQa)
// Force an order so the Exec tasks that stage through staged/dist don't run in parallel.
tasks.buildConsoleForSandbox.mustRunAfter(tasks.buildConsoleForAlpha)
tasks.buildConsoleForProduction.mustRunAfter(tasks.buildConsoleForSandbox)
// This task must run last, otherwise the previous tasks will have deleted the "dist" folder.
tasks.buildConsoleWebapp.mustRunAfter(tasks.buildConsoleForProduction)
Expand All @@ -91,13 +127,16 @@ task applyFormatting(type: Exec) {

task checkFormatting(type: Exec) {
workingDir "${consoleDir}/"
inputs.dir("${consoleDir}/src")
outputs.upToDateWhen { true }
commandLine 'sh', '-c', 'npm run prettify:check'
}

tasks.buildConsoleWebapp.dependsOn(tasks.npmInstallDeps)
tasks.runConsoleWebappUnitTests.dependsOn(tasks.npmInstallDeps)
tasks.applyFormatting.dependsOn(tasks.npmInstallDeps)
tasks.checkFormatting.dependsOn(tasks.npmInstallDeps)
tasks.test.dependsOn(tasks.runConsoleWebappUnitTests)
tasks.build.dependsOn(tasks.checkFormatting)
tasks.build.dependsOn(tasks.runConsoleWebappUnitTests)
tasks.build.dependsOn(tasks.buildConsoleForAll)
17 changes: 0 additions & 17 deletions console-webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion console-webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^22.0.6",
"@angular/cdk": "^22.0.4",
"@angular/common": "^22.0.6",
"@angular/compiler": "^22.0.6",
Expand Down
14 changes: 6 additions & 8 deletions console-webapp/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import { provideHttpClient } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { routes } from './app.routes';
import { PocReminderComponent } from './shared/components/pocReminder/pocReminder.component';
Expand Down Expand Up @@ -66,7 +65,6 @@ describe('AppComponent', () => {
await TestBed.configureTestingModule({
imports: [
MatSidenavModule,
NoopAnimationsModule,
MatSnackBarModule,
AppComponent,
RouterModule.forRoot(routes),
Expand Down Expand Up @@ -166,17 +164,17 @@ describe('AppComponent', () => {
describe('Sidenav behavior', () => {
it('should toggle sidenav open and closed', () => {
fixture.detectChanges();
const closeSpy = vi.spyOn(component.sidenav, 'close');
const openSpy = vi.spyOn(component.sidenav, 'open');
const closeSpy = vi.spyOn(component.sidenav(), 'close');
const openSpy = vi.spyOn(component.sidenav(), 'open');

Object.defineProperty(component.sidenav, 'opened', {
Object.defineProperty(component.sidenav(), 'opened', {
value: true,
configurable: true,
});
component.toggleSidenav();
expect(closeSpy).toHaveBeenCalled();

Object.defineProperty(component.sidenav, 'opened', {
Object.defineProperty(component.sidenav(), 'opened', {
value: false,
configurable: true,
});
Expand All @@ -189,7 +187,7 @@ describe('AppComponent', () => {
const eventsSubject = router.events as unknown as Subject<any>;
fixture.detectChanges();

const closeSpy = vi.spyOn(component.sidenav, 'close');
const closeSpy = vi.spyOn(component.sidenav(), 'close');
mockBreakPointService.isMobileView.set(true);
eventsSubject.next(new NavigationEnd(1, '/home', '/home'));

Expand All @@ -201,7 +199,7 @@ describe('AppComponent', () => {
const eventsSubject = router.events as unknown as Subject<any>;
fixture.detectChanges();

const closeSpy = vi.spyOn(component.sidenav, 'close');
const closeSpy = vi.spyOn(component.sidenav(), 'close');
mockBreakPointService.isMobileView.set(false);
eventsSubject.next(new NavigationEnd(1, '/home', '/home'));

Expand Down
13 changes: 6 additions & 7 deletions console-webapp/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
AfterViewInit,
Component,
effect,
ViewChild,
viewChild,
ChangeDetectionStrategy,
} from '@angular/core';
import { MatSidenav } from '@angular/material/sidenav';
Expand All @@ -39,8 +39,7 @@ import { PocReminderComponent } from './shared/components/pocReminder/pocReminde
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent implements AfterViewInit {
@ViewChild(MatSidenav)
sidenav!: MatSidenav;
sidenav = viewChild.required(MatSidenav);

constructor(
protected registrarService: RegistrarService,
Expand Down Expand Up @@ -74,17 +73,17 @@ export class AppComponent implements AfterViewInit {
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
if (this.breakpointObserver.isMobileView()) {
this.sidenav.close();
this.sidenav().close();
}
}
});
}

toggleSidenav() {
if (this.sidenav.opened) {
this.sidenav.close();
if (this.sidenav().opened) {
this.sidenav().close();
} else {
this.sidenav.open();
this.sidenav().open();
}
}
}
5 changes: 0 additions & 5 deletions console-webapp/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ import {
} from '@angular/common/http';
import {
ApplicationConfig,
importProvidersFrom,
provideZonelessChangeDetection,
} from '@angular/core';
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideRouter, withHashLocation } from '@angular/router';
import { routes } from './app.routes';
import { MaterialModule } from './material.module';
import { BackendService } from './shared/services/backend.service';
import { BreakPointObserverService } from './shared/services/breakPoint.service';
import { GlobalLoaderService } from './shared/services/globalLoader.service';
Expand All @@ -37,8 +34,6 @@ export const appConfig: ApplicationConfig = {
providers: [
provideZonelessChangeDetection(),
provideRouter(routes, withHashLocation()),
provideAnimations(),
importProvidersFrom(MaterialModule),
provideHttpClient(
withInterceptorsFromDi(),
withXsrfConfiguration({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ <h1 class="console-app__title" forceFocus>Billing Info</h1>
>
</div>
<div>
<img src="./assets/billing.png" alt="Generic billing image" />
<img
src="./assets/billing.png"
alt="Generic billing image"
loading="lazy"
/>
</div>
</div>
</app-selected-registrar-wrapper>
Loading
Loading