Skip to content

Commit

Permalink
PR review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hudson-newey committed Oct 19, 2023
1 parent 205b05a commit 5ece98b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/app/app.menus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { IconProp } from "@fortawesome/fontawesome-svg-core";
import { Inject } from "@angular/core";
import { ConfigService } from "@services/config/config.service";
import { IPageInfo } from "@helpers/page/pageInfo";
import { Project } from "./models/Project";
import { User } from "./models/User";
Expand Down Expand Up @@ -49,9 +51,15 @@ export const isAdminPredicate = (user: User): boolean =>
isLoggedInPredicate(user) && user.isAdmin;

/**
* Returns true only if the user is an admin and can see work in progress items
* This predicate differs from the `isAdminPredicate` for semantic reasons
*
* Returns true only if the user is an admin and is not in a production environment
* This predicate exists so that we can implement work in progress menu items
*
* @param user User session data. This will be used to check if the user is an admin
*/
export const isWorkInProgressPredicate = isAdminPredicate;
export const isWorkInProgressPredicate = (user: User): boolean => {
const config = Inject(ConfigService);

const isProduction: boolean = config.environment.production;

return isProduction && isAdminPredicate(user);
};
4 changes: 2 additions & 2 deletions src/app/directives/url/url-active.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export class UrlActiveDirective extends RouterLinkActive {
_element: ElementRef,
_renderer: Renderer2,
_cdr: ChangeDetectorRef,
@Optional() _linkWithHref?: UrlDirective
@Optional() _link?: UrlDirective
) {
super(_router, _element, _renderer, _cdr, _linkWithHref);
super(_router, _element, _renderer, _cdr, _link);
}
}
16 changes: 16 additions & 0 deletions src/app/guards/input/input.guard.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

describe("UnsavedInputGuard", () => {
function setup(): void {
}

beforeEach(() => setup());

it("should create", () => {
});

it("should show a confirmation if the user tries to navigate away from the page with unsaved changes", () => {
});

it("should not show a confirmation if the user tries to navigate away from the page witout unsaved changes", () => {
});
});
4 changes: 2 additions & 2 deletions src/app/guards/input/input.guard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from "@angular/core";

import { CanDeactivate } from "@angular/router";

export interface UnsavedInputCheckingComponent {
hasUnsavedChanges: boolean;
Expand All @@ -12,7 +12,7 @@ export interface UnsavedInputCheckingComponent {
*/
@Injectable()
export class UnsavedInputGuard

implements CanDeactivate<UnsavedInputCheckingComponent>
{
public canDeactivate(component: UnsavedInputCheckingComponent): boolean {
// canDeactivate guards can be called with null components: https://github.com/angular/angular/issues/40545
Expand Down

0 comments on commit 5ece98b

Please sign in to comment.