From 66ee2c13bb41d7e3fa48c04e6e37100feedafd49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernardo=20Jord=C3=A3o?= <56507118+itsbekas@users.noreply.github.com> Date: Sat, 23 Aug 2025 13:42:11 +0100 Subject: [PATCH] Feature/migrate register page component to standalone (#5393) * Migrate register page component to standalone * Update changelog --- CHANGELOG.md | 1 + apps/client/src/app/app-routing.module.ts | 4 +-- .../register/register-page-routing.module.ts | 22 ------------- .../pages/register/register-page.component.ts | 31 ++++++++++++++----- .../pages/register/register-page.module.ts | 26 ---------------- .../pages/register/register-page.routes.ts | 15 +++++++++ 6 files changed, 40 insertions(+), 59 deletions(-) delete mode 100644 apps/client/src/app/pages/register/register-page-routing.module.ts delete mode 100644 apps/client/src/app/pages/register/register-page.module.ts create mode 100644 apps/client/src/app/pages/register/register-page.routes.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 717cf2813..c1d8adeec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Refactored the register page to standalone - Migrated the login with access token dialog from `ngModel` to form control ## 2.193.0 - 2025-08-22 diff --git a/apps/client/src/app/app-routing.module.ts b/apps/client/src/app/app-routing.module.ts index 70d4f8b30..549a671f7 100644 --- a/apps/client/src/app/app-routing.module.ts +++ b/apps/client/src/app/app-routing.module.ts @@ -120,9 +120,7 @@ const routes: Routes = [ { path: publicRoutes.register.path, loadChildren: () => - import('./pages/register/register-page.module').then( - (m) => m.RegisterPageModule - ) + import('./pages/register/register-page.routes').then((m) => m.routes) }, { path: publicRoutes.resources.path, diff --git a/apps/client/src/app/pages/register/register-page-routing.module.ts b/apps/client/src/app/pages/register/register-page-routing.module.ts deleted file mode 100644 index 157302999..000000000 --- a/apps/client/src/app/pages/register/register-page-routing.module.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { AuthGuard } from '@ghostfolio/client/core/auth.guard'; -import { publicRoutes } from '@ghostfolio/common/routes/routes'; - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { RegisterPageComponent } from './register-page.component'; - -const routes: Routes = [ - { - canActivate: [AuthGuard], - component: RegisterPageComponent, - path: '', - title: publicRoutes.register.title - } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class RegisterPageRoutingModule {} diff --git a/apps/client/src/app/pages/register/register-page.component.ts b/apps/client/src/app/pages/register/register-page.component.ts index 11b81c32a..35b9d5cd2 100644 --- a/apps/client/src/app/pages/register/register-page.component.ts +++ b/apps/client/src/app/pages/register/register-page.component.ts @@ -3,26 +3,39 @@ import { InternetIdentityService } from '@ghostfolio/client/services/internet-id import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service'; import { InfoItem, LineChartItem } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; +import { GfLogoComponent } from '@ghostfolio/ui/logo'; -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { + Component, + CUSTOM_ELEMENTS_SCHEMA, + OnDestroy, + OnInit +} from '@angular/core'; +import { MatButtonModule } from '@angular/material/button'; import { MatDialog } from '@angular/material/dialog'; -import { Router } from '@angular/router'; +import { Router, RouterModule } from '@angular/router'; import { DeviceDetectorService } from 'ngx-device-detector'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { ShowAccessTokenDialogParams } from './show-access-token-dialog/interfaces/interfaces'; import { ShowAccessTokenDialog } from './show-access-token-dialog/show-access-token-dialog.component'; +import { ShowAccessTokenDialogModule } from './show-access-token-dialog/show-access-token-dialog.module'; @Component({ host: { class: 'page' }, + imports: [ + GfLogoComponent, + MatButtonModule, + RouterModule, + ShowAccessTokenDialogModule + ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], selector: 'gf-register-page', styleUrls: ['./register-page.scss'], - templateUrl: './register-page.html', - standalone: false + templateUrl: './register-page.html' }) -export class RegisterPageComponent implements OnDestroy, OnInit { - public demoAuthToken: string; +export class GfRegisterPageComponent implements OnDestroy, OnInit { public deviceType: string; public hasPermissionForSocialLogin: boolean; public hasPermissionForSubscription: boolean; @@ -46,18 +59,20 @@ export class RegisterPageComponent implements OnDestroy, OnInit { } public ngOnInit() { - const { demoAuthToken, globalPermissions } = this.dataService.fetchInfo(); + const { globalPermissions } = this.dataService.fetchInfo(); - this.demoAuthToken = demoAuthToken; this.deviceType = this.deviceService.getDeviceInfo().deviceType; + this.hasPermissionForSocialLogin = hasPermission( globalPermissions, permissions.enableSocialLogin ); + this.hasPermissionForSubscription = hasPermission( globalPermissions, permissions.enableSubscription ); + this.hasPermissionToCreateUser = hasPermission( globalPermissions, permissions.createUserAccount diff --git a/apps/client/src/app/pages/register/register-page.module.ts b/apps/client/src/app/pages/register/register-page.module.ts deleted file mode 100644 index 5ce8e3ed9..000000000 --- a/apps/client/src/app/pages/register/register-page.module.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { GfLogoComponent } from '@ghostfolio/ui/logo'; - -import { CommonModule } from '@angular/common'; -import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; -import { MatButtonModule } from '@angular/material/button'; -import { RouterModule } from '@angular/router'; -import { IonIcon } from '@ionic/angular/standalone'; - -import { RegisterPageRoutingModule } from './register-page-routing.module'; -import { RegisterPageComponent } from './register-page.component'; -import { ShowAccessTokenDialogModule } from './show-access-token-dialog/show-access-token-dialog.module'; - -@NgModule({ - declarations: [RegisterPageComponent], - imports: [ - CommonModule, - GfLogoComponent, - IonIcon, - MatButtonModule, - RegisterPageRoutingModule, - RouterModule, - ShowAccessTokenDialogModule - ], - schemas: [CUSTOM_ELEMENTS_SCHEMA] -}) -export class RegisterPageModule {} diff --git a/apps/client/src/app/pages/register/register-page.routes.ts b/apps/client/src/app/pages/register/register-page.routes.ts new file mode 100644 index 000000000..ca5b00376 --- /dev/null +++ b/apps/client/src/app/pages/register/register-page.routes.ts @@ -0,0 +1,15 @@ +import { AuthGuard } from '@ghostfolio/client/core/auth.guard'; +import { publicRoutes } from '@ghostfolio/common/routes/routes'; + +import { Routes } from '@angular/router'; + +import { GfRegisterPageComponent } from './register-page.component'; + +export const routes: Routes = [ + { + canActivate: [AuthGuard], + component: GfRegisterPageComponent, + path: '', + title: publicRoutes.register.title + } +];