@genesislcap/blank-app-seed 3.20.5 → 3.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/.genx/package.json +1 -1
  2. package/.genx/static.js +8 -0
  3. package/.genx/templates/angular/chart.hbs +21 -9
  4. package/.genx/templates/angular/entityManager.hbs +57 -45
  5. package/.genx/templates/angular/form.hbs +21 -8
  6. package/.genx/templates/angular/grid.hbs +30 -18
  7. package/.genx/templates/angular/route.hbs +8 -5
  8. package/.genx/templates/web-components/component/component.column.defs.hbs +6 -0
  9. package/.genx/templates/web-components/component/component.create.form.hbs +8 -0
  10. package/.genx/templates/web-components/component/component.gridOptions.hbs +6 -0
  11. package/.genx/templates/web-components/component/component.hbs +13 -0
  12. package/.genx/templates/web-components/component/component.index.hbs +1 -0
  13. package/.genx/templates/web-components/component/component.styles.hbs +7 -0
  14. package/.genx/templates/web-components/component/component.template.hbs +23 -0
  15. package/.genx/templates/web-components/component/component.update.form.hbs +5 -0
  16. package/.genx/templates/web-components/entityManager.hbs +5 -11
  17. package/.genx/templates/web-components/form.hbs +1 -3
  18. package/.genx/templates/web-components/grid.hbs +1 -3
  19. package/.genx/templates/web-components/gridLayout.hbs +30 -0
  20. package/.genx/templates/web-components/horizontalLayout.hbs +7 -0
  21. package/.genx/templates/web-components/route.template.hbs +8 -2
  22. package/.genx/templates/web-components/tabsLayout.hbs +7 -0
  23. package/.genx/utils/formatRouteData.js +5 -0
  24. package/.genx/utils/generateRoute.js +8 -0
  25. package/.genx/utils/generateTile.js +137 -0
  26. package/.genx/utils/gridSerializers.js +10 -10
  27. package/.genx/utils/registerPartials.js +4 -3
  28. package/CHANGELOG.md +14 -0
  29. package/client-tmp/angular/angular.json +21 -12
  30. package/client-tmp/angular/package.json +45 -20
  31. package/client-tmp/angular/src/app/app-routing.module.ts +10 -3
  32. package/client-tmp/angular/src/app/app.component.spec.ts +2 -8
  33. package/client-tmp/angular/src/app/app.component.ts +0 -1
  34. package/client-tmp/angular/src/app/app.config.ts +1 -0
  35. package/client-tmp/angular/src/app/components/error-message/error-message.component.html +15 -0
  36. package/client-tmp/angular/src/app/components/error-message/error-message.component.spec.ts +74 -0
  37. package/client-tmp/angular/src/app/components/error-message/error-message.component.ts +15 -0
  38. package/client-tmp/angular/src/app/guards/auth.guard.ts +3 -3
  39. package/client-tmp/angular/src/app/guards/permissions.guard.ts +24 -0
  40. package/client-tmp/angular/src/app/layouts/blank/blank.layout.html +0 -1
  41. package/client-tmp/angular/src/app/layouts/blank/blank.layout.spec.ts +1 -1
  42. package/client-tmp/angular/src/app/layouts/default/default.layout.html +0 -1
  43. package/client-tmp/angular/src/app/layouts/default/default.layout.spec.ts +30 -15
  44. package/client-tmp/angular/src/app/pages/auth-login/auth-login.component.spec.ts +6 -6
  45. package/client-tmp/angular/src/app/pages/not-permitted/not-permitted.component.html +4 -0
  46. package/client-tmp/angular/src/app/pages/not-permitted/not-permitted.component.scss +12 -0
  47. package/client-tmp/angular/src/app/pages/not-permitted/not-permitted.component.spec.ts +32 -0
  48. package/client-tmp/angular/src/app/pages/not-permitted/not-permitted.component.ts +13 -0
  49. package/client-tmp/angular/src/app/services/auth.service.ts +12 -4
  50. package/client-tmp/angular/src/app/share/foundation-login.ts +3 -0
  51. package/client-tmp/angular/src/app/utils/index.ts +1 -0
  52. package/client-tmp/angular/src/app/utils/permissions.ts +7 -0
  53. package/client-tmp/angular/src/styles/_mixins.scss +8 -0
  54. package/package.json +1 -1
  55. /package/.genx/templates/{gridLayout.hbs → angular/gridLayout.hbs} +0 -0
  56. /package/.genx/templates/{horizontalLayout.hbs → angular/horizontalLayout.hbs} +0 -0
  57. /package/.genx/templates/{tabsLayout.hbs → angular/tabsLayout.hbs} +0 -0
@@ -1,34 +1,49 @@
1
- import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
2
1
  import { ComponentFixture, TestBed } from '@angular/core/testing';
3
- import { provideMockStore } from '@ngrx/store/testing';
4
- import * as StateChangerSelector from '../../store/state-changer/state-changer.selectors';
5
-
2
+ import { Router } from '@angular/router';
6
3
  import { DefaultLayoutComponent } from './default.layout';
4
+ import { ElementRef, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
5
+
6
+ class MockRouter {
7
+ navigate = jasmine.createSpy('navigate');
8
+ }
9
+
10
+ class MockElementRef implements ElementRef {
11
+ nativeElement = {};
12
+ }
7
13
 
8
14
  describe('DefaultLayoutComponent', () => {
9
15
  let component: DefaultLayoutComponent;
10
16
  let fixture: ComponentFixture<DefaultLayoutComponent>;
17
+ let router: MockRouter;
18
+ let elementRef: MockElementRef;
11
19
 
12
- beforeEach(() => {
13
- TestBed.configureTestingModule({
20
+ beforeEach(async () => {
21
+ await TestBed.configureTestingModule({
14
22
  declarations: [DefaultLayoutComponent],
15
23
  providers: [
16
- provideMockStore({
17
- initialState: {},
18
- selectors: [
19
- { selector: StateChangerSelector.getCriteria, value: 'initial-criteria' },
20
- { selector: StateChangerSelector.getResourceName, value: 'initial-resource-name' },
21
- ],
22
- }),
24
+ { provide: Router, useClass: MockRouter },
25
+ { provide: ElementRef, useClass: MockElementRef }
23
26
  ],
24
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
25
- });
27
+ schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
28
+ }).compileComponents();
29
+ });
30
+
31
+ beforeEach(() => {
26
32
  fixture = TestBed.createComponent(DefaultLayoutComponent);
27
33
  component = fixture.componentInstance;
34
+ router = TestBed.inject(Router) as unknown as MockRouter;
35
+ elementRef = TestBed.inject(ElementRef) as unknown as MockElementRef;
36
+ component.designSystemProviderElement = elementRef;
28
37
  fixture.detectChanges();
29
38
  });
30
39
 
31
40
  it('should create', () => {
32
41
  expect(component).toBeTruthy();
33
42
  });
43
+
44
+ it('should navigate to a path', () => {
45
+ const path = 'some/path';
46
+ component.navigateAngular(path);
47
+ expect(router.navigate).toHaveBeenCalledWith([path]);
48
+ });
34
49
  });
@@ -1,17 +1,17 @@
1
1
  import { ComponentFixture, TestBed } from '@angular/core/testing';
2
2
 
3
- import { AuthMockComponent } from './auth-mock.component';
3
+ import { AuthLoginComponent } from './auth-login.component';
4
4
 
5
- describe('AuthMockComponent', () => {
6
- let component: AuthMockComponent;
7
- let fixture: ComponentFixture<AuthMockComponent>;
5
+ describe('AuthLoginComponent', () => {
6
+ let component: AuthLoginComponent;
7
+ let fixture: ComponentFixture<AuthLoginComponent>;
8
8
 
9
9
  beforeEach(async () => {
10
10
  await TestBed.configureTestingModule({
11
- imports: [AuthMockComponent],
11
+ imports: [AuthLoginComponent],
12
12
  }).compileComponents();
13
13
 
14
- fixture = TestBed.createComponent(AuthMockComponent);
14
+ fixture = TestBed.createComponent(AuthLoginComponent);
15
15
  component = fixture.componentInstance;
16
16
  fixture.detectChanges();
17
17
  });
@@ -0,0 +1,4 @@
1
+ <app-error-message
2
+ elementType="h1"
3
+ message="You do not have permission to access this part of the application, please contact your administrator.">
4
+ </app-error-message>
@@ -0,0 +1,12 @@
1
+ @import '../../../styles/mixins';
2
+
3
+ :host {
4
+ @include screen('flex');
5
+ align-items: center;
6
+ justify-content: center;
7
+ }
8
+
9
+ h1 {
10
+ text-align: center;
11
+ color: var(--neutral-foreground-rest);
12
+ }
@@ -0,0 +1,32 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { NotPermittedComponent } from './not-permitted.component';
3
+
4
+ const MESSAGE_NOT_PERMITTED = 'You do not have permission to access this part of the application, please contact your administrator.';
5
+
6
+ describe('NotPermittedComponent', () => {
7
+ let component: NotPermittedComponent;
8
+ let fixture: ComponentFixture<NotPermittedComponent>;
9
+
10
+ beforeEach(async () => {
11
+ await TestBed.configureTestingModule({
12
+ imports: [ NotPermittedComponent ]
13
+ })
14
+ .compileComponents();
15
+ });
16
+
17
+ beforeEach(() => {
18
+ fixture = TestBed.createComponent(NotPermittedComponent);
19
+ component = fixture.componentInstance;
20
+ fixture.detectChanges();
21
+ });
22
+
23
+ it('should create', () => {
24
+ expect(component).toBeTruthy();
25
+ });
26
+
27
+ it('should display the correct error message', () => {
28
+ const compiled = fixture.nativeElement;
29
+ const errorMessageElement = compiled.querySelector('app-error-message h1');
30
+ expect(errorMessageElement.textContent).toBe(MESSAGE_NOT_PERMITTED);
31
+ });
32
+ });
@@ -0,0 +1,13 @@
1
+ import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
2
+ import { ErrorMessageComponent } from '../../components/error-message/error-message.component';
3
+
4
+ @Component({
5
+ selector: 'app-not-permitted',
6
+ standalone: true,
7
+ imports: [ ErrorMessageComponent ],
8
+ templateUrl: './not-permitted.component.html',
9
+ styleUrls: ['./not-permitted.component.scss'],
10
+ schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
11
+ })
12
+ export class NotPermittedComponent {
13
+ }
@@ -1,14 +1,22 @@
1
1
  import { Injectable } from '@angular/core';
2
2
  import { Auth } from '@genesislcap/foundation-comms';
3
- import {DI} from "@microsoft/fast-foundation";
3
+ import { DI } from "@microsoft/fast-foundation";
4
4
 
5
5
  @Injectable({
6
6
  providedIn: 'root',
7
7
  })
8
8
  export class AuthService {
9
+ auth: Auth;
9
10
 
10
- async isUserAuthenticated(): Promise<boolean> {
11
- const auth: Auth = DI.getOrCreateDOMContainer().get(Auth);
12
- return auth.isLoggedIn
11
+ constructor() {
12
+ this.auth = DI.getOrCreateDOMContainer().get(Auth);
13
+ }
14
+
15
+ isUserAuthenticated(): boolean {
16
+ return this.auth.isLoggedIn;
17
+ }
18
+
19
+ hasUserPermission(permissionCode: string): boolean {
20
+ return this.auth.currentUser.hasPermission(permissionCode);
13
21
  }
14
22
  }
@@ -3,6 +3,9 @@ import type { Router } from '@angular/router';
3
3
  import { AUTH_PATH } from '../app.config';
4
4
  import { DI } from '@microsoft/fast-foundation';
5
5
 
6
+ // eslint-disable-next-line
7
+ declare var GENX_ENABLE_SSO: boolean;
8
+
6
9
  const ssoSettings =
7
10
  typeof GENX_ENABLE_SSO !== 'undefined' && GENX_ENABLE_SSO === true
8
11
  ? {
@@ -1,2 +1,3 @@
1
1
  export * from './formatters';
2
2
  export * from './getLayoutNameByRoute';
3
+ export * from './permissions';
@@ -0,0 +1,7 @@
1
+ import { User } from '@genesislcap/foundation-user';
2
+
3
+ export const getViewUpdateRightComponent = (
4
+ user: User,
5
+ right: string,
6
+ event: string | boolean = true,
7
+ ) => (!right || user.hasPermission(right) ? event : '');
@@ -0,0 +1,8 @@
1
+ @mixin screen($display: 'block') {
2
+ contain: content;
3
+ display: #{$display};
4
+ height: 100%;
5
+ width: 100%;
6
+ overflow-y: auto;
7
+ }
8
+
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/blank-app-seed",
3
3
  "description": "Genesis Blank App Seed",
4
- "version": "3.20.5",
4
+ "version": "3.22.0",
5
5
  "license": "Apache-2.0",
6
6
  "scripts": {
7
7
  "release": "semantic-release"