diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index cc1841907..3da673d13 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -12,7 +12,8 @@ const routes: Routes = [ { path: 'phaseBugReporting', loadChildren: () => PhaseBugReportingModule, canLoad: [AuthGuard] }, { path: 'phaseTeamResponse', loadChildren: () => PhaseTeamResponseModule, canLoad: [AuthGuard] }, { path: 'phaseTesterResponse', loadChildren: () => PhaseTesterResponseModule, canLoad: [AuthGuard] }, - { path: 'phaseModeration', loadChildren: () => PhaseModerationModule, canLoad: [AuthGuard] } + { path: 'phaseModeration', loadChildren: () => PhaseModerationModule, canLoad: [AuthGuard] }, + { path: '**', redirectTo: '' } ]; @NgModule({ diff --git a/src/app/core/directives/internal-link-disable.directive.ts b/src/app/core/directives/internal-link-disable.directive.ts new file mode 100644 index 000000000..d15db8d47 --- /dev/null +++ b/src/app/core/directives/internal-link-disable.directive.ts @@ -0,0 +1,32 @@ +import { Directive, HostListener } from '@angular/core'; +import { ErrorHandlingService } from '../services/error-handling.service'; + +class InvalidLinkError extends Error { + constructor() { + super('Invalid link!'); + Object.setPrototypeOf(this, InvalidLinkError.prototype); + } +} + +@Directive({ + selector: '[disableInternalLink]' +}) +export class InternalLinkDisableDirective { + constructor(private errorHandlingService: ErrorHandlingService) {} + + @HostListener('click', ['$event']) + public onClick(e: MouseEvent): void { + const srcElement = e.target; + + if (srcElement instanceof HTMLAnchorElement) { + const baseURI = srcElement.baseURI; + const href = srcElement.href; + + if (href.startsWith(baseURI)) { + this.errorHandlingService.handleError(new InvalidLinkError()); + e.preventDefault(); + e.stopPropagation(); + } + } + } +} diff --git a/src/app/shared/comment-editor/comment-editor.component.html b/src/app/shared/comment-editor/comment-editor.component.html index bac61dda7..67e729946 100644 --- a/src/app/shared/comment-editor/comment-editor.component.html +++ b/src/app/shared/comment-editor/comment-editor.component.html @@ -57,7 +57,7 @@
- +
Nothing to preview.
diff --git a/src/app/shared/issue/description/description.component.html b/src/app/shared/issue/description/description.component.html index 1d7c9bee8..08837c415 100644 --- a/src/app/shared/issue/description/description.component.html +++ b/src/app/shared/issue/description/description.component.html @@ -8,7 +8,7 @@

{{ descriptionTitle }}

- +
Disputes
?
- +

- +
Disputes
- +
Team's Response
- +
{{ 'The content you are editing has chang
?
- +
@@ -25,7 +25,7 @@

{{ 'The content you are editing has chang
- +
Tester's Response

?
- +

- +
Tester's Response

Reason for Disagreement:

- +