Skip to content
Merged
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
6 changes: 1 addition & 5 deletions modules/ui/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@
</ng-container>
<app-version
[consentShown]="vm.consentShown"
[hasRiskProfiles]="vm.hasRiskProfiles"
(consentShownEvent)="consentShown()"
(navigateToRiskAssessmentEvent)="
navigateToRiskAssessment()
"></app-version>
(consentShownEvent)="consentShown()"></app-version>
</div>
</mat-drawer>

Expand Down
2 changes: 0 additions & 2 deletions modules/ui/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,5 @@ class FakeShutdownAppComponent {
})
class FakeVersionComponent {
@Input() consentShown!: boolean;
@Input() hasRiskProfiles!: boolean;
@Output() consentShownEvent = new EventEmitter<void>();
@Output() navigateToRiskAssessmentEvent = new EventEmitter<void>();
}
2 changes: 2 additions & 0 deletions modules/ui/src/app/components/callout/callout.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
-->
<div class="callout-container" [ngClass]="type">
<mat-icon
*ngIf="type !== CalloutType.InfoPilot"
class="callout-icon"
fontSet="material-icons-outlined"
color="primary">
{{ type }}
</mat-icon>
<span *ngIf="type === CalloutType.InfoPilot" class="callout-icon">🚀</span>
<p class="callout-context">
<ng-content></ng-content>
</p>
Expand Down
2 changes: 2 additions & 0 deletions modules/ui/src/app/components/callout/callout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatIconModule } from '@angular/material/icon';
import { CalloutType } from '../../model/callout-type';

@Component({
selector: 'app-callout',
Expand All @@ -26,5 +27,6 @@ import { MatIconModule } from '@angular/material/icon';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CalloutComponent {
public readonly CalloutType = CalloutType;
@Input() type = '';
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,12 @@ <h2>Welcome to Testrun!</h2>
</p>
</app-callout>
</section>
<section class="section-container" *ngIf="data.hasRiskProfiles === false">
<app-callout [type]="CalloutType.Check">
<span class="section-title">Risk Assessment feature added!</span>
<p class="section-content risk-assessment">
Now you can answer a short questionnaire, create a security profile and
attach it to the Testrun result to complete a device verification. Also,
it will speed up the process a lot!
</p>
<p class="section-action-container">
<button
(click)="confirm(optOut, true)"
class="risk-assessment-button"
color="primary"
mat-button
aria-label="Go to Risk Assessment page"
type="button">
Go to Risk Assessment
</button>
<section class="section-container-pilot">
<app-callout [type]="CalloutType.InfoPilot">
<span class="section-title">Pilot Assessment</span>
<p class="section-content">
Pilot project support is now offered through Testrun. Follow the
instructions set out to get your pilot recommendation.
</p>
</app-callout>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@
}
}

.section-container-pilot {
.section-title {
font-weight: 500;
letter-spacing: 0.25px;
}
.section-content {
margin: 0;
padding-top: 9px;
}
}

.consent-actions {
border-top: 1px solid $lighter-grey;
margin: 0 -16px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('ConsentDialogComponent', () => {
});
fixture = TestBed.createComponent(ConsentDialogComponent);
component = fixture.componentInstance;
component.data = { version: NEW_VERSION, hasRiskProfiles: false };
component.data = { version: NEW_VERSION };
component.optOut = false;
fixture.detectChanges();
compiled = fixture.nativeElement as HTMLElement;
Expand All @@ -61,7 +61,7 @@ describe('ConsentDialogComponent', () => {
const confirmButton = compiled.querySelector(
'.confirm-button'
) as HTMLButtonElement;
const dialogRes = { grant: true, isNavigateToRiskAssessment: undefined };
const dialogRes = { grant: true };

confirmButton?.click();

Expand All @@ -77,7 +77,7 @@ describe('ConsentDialogComponent', () => {
const confirmButton = compiled.querySelector(
'.confirm-button'
) as HTMLButtonElement;
const dialogRes = { grant: false, isNavigateToRiskAssessment: undefined };
const dialogRes = { grant: false };

confirmButton?.click();

Expand All @@ -99,7 +99,7 @@ describe('ConsentDialogComponent', () => {

describe('with new version available', () => {
beforeEach(() => {
component.data = { version: NEW_VERSION, hasRiskProfiles: false };
component.data = { version: NEW_VERSION };
fixture.detectChanges();
});

Expand All @@ -122,7 +122,7 @@ describe('ConsentDialogComponent', () => {

describe('with no new version available', () => {
beforeEach(() => {
component.data = { version: VERSION, hasRiskProfiles: false };
component.data = { version: VERSION };
fixture.detectChanges();
});

Expand All @@ -134,51 +134,4 @@ describe('ConsentDialogComponent', () => {
expect(content).toBeNull();
});
});

describe('with no risk assessment profiles', () => {
beforeEach(() => {
component.data = { version: VERSION, hasRiskProfiles: false };
fixture.detectChanges();
});

it('should has risk-assessment content', () => {
const content = compiled.querySelector(
'.section-content.risk-assessment'
) as HTMLElement;

const innerContent = content.innerHTML.trim();
expect(innerContent).toContain(
'Now you can answer a short questionnaire'
);
});

it('should close dialog with isNavigateToRiskAssessment as true when click "confirm"', () => {
const closeSpy = spyOn(component.dialogRef, 'close');
const riskAssessmentBtn = compiled.querySelector(
'.risk-assessment-button'
) as HTMLButtonElement;
const dialogRes = { grant: true, isNavigateToRiskAssessment: true };

riskAssessmentBtn?.click();

expect(closeSpy).toHaveBeenCalledWith(dialogRes);

closeSpy.calls.reset();
});
});

describe('with risk assessment profiles', () => {
beforeEach(() => {
component.data = { version: VERSION, hasRiskProfiles: true };
fixture.detectChanges();
});

it('should not has risk-assessment content', () => {
const content = compiled.querySelector(
'.section-content.risk-assessment'
) as HTMLElement;

expect(content).toBeNull();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { FormsModule } from '@angular/forms';

type DialogData = {
version: Version;
hasRiskProfiles: boolean;
};

@Component({
Expand All @@ -54,11 +53,10 @@ export class ConsentDialogComponent {
@Inject(MAT_DIALOG_DATA) public data: DialogData
) {}

confirm(optOut: boolean, isNavigateToRiskAssessment?: boolean) {
confirm(optOut: boolean) {
// dialog should be closed with opposite value to grant or deny access to GA
const dialogResult: ConsentDialogResult = {
grant: !optOut,
isNavigateToRiskAssessment,
};
this.dialogRef.close(dialogResult);
}
Expand Down
8 changes: 1 addition & 7 deletions modules/ui/src/app/components/version/version.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ declare const gtag: Function;
})
export class VersionComponent implements OnInit, OnDestroy {
@Input() consentShown!: boolean;
@Input() hasRiskProfiles!: boolean;
@Output() consentShownEvent = new EventEmitter<void>();
@Output() navigateToRiskAssessmentEvent = new EventEmitter<void>();
version$!: Observable<Version | null>;
private destroy$: Subject<boolean> = new Subject<boolean>();

Expand Down Expand Up @@ -86,7 +84,7 @@ export class VersionComponent implements OnInit, OnDestroy {
}

openConsentDialog(version: Version) {
const dialogData = { version, hasRiskProfiles: this.hasRiskProfiles };
const dialogData = { version };
const dialogRef = this.dialog.open(ConsentDialogComponent, {
ariaLabel: 'Welcome to Testrun modal window',
data: dialogData,
Expand All @@ -106,10 +104,6 @@ export class VersionComponent implements OnInit, OnDestroy {
gtag('consent', 'update', {
analytics_storage: dialogResult.grant ? 'granted' : 'denied',
});

if (dialogResult.isNavigateToRiskAssessment) {
this.navigateToRiskAssessmentEvent.emit();
}
});
}

Expand Down
1 change: 1 addition & 0 deletions modules/ui/src/app/model/callout-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
export enum CalloutType {
Info = 'info',
InfoPilot = 'info pilot',
Check = 'check_circle',
Warning = 'warning_amber',
Error = 'error',
Expand Down
1 change: 0 additions & 1 deletion modules/ui/src/app/model/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ export interface Version {

export interface ConsentDialogResult {
grant: boolean;
isNavigateToRiskAssessment?: boolean;
}