diff --git a/apps/red-ui/src/app/app-routing.module.ts b/apps/red-ui/src/app/app-routing.module.ts index 5eb70338e..16f944ec6 100644 --- a/apps/red-ui/src/app/app-routing.module.ts +++ b/apps/red-ui/src/app/app-routing.module.ts @@ -1,11 +1,8 @@ import { AuthErrorComponent } from '@components/auth-error/auth-error.component'; import { CompositeRouteGuard, - CustomRouteReuseStrategy, DEFAULT_REDIRECT_KEY, - ifLoggedIn, ifNotLoggedIn, - IqserAuthGuard, IqserPermissionsGuard, IqserRoutes, TenantSelectComponent, @@ -27,6 +24,9 @@ import { DossierFilesGuard } from '@guards/dossier-files-guard'; import { WebViewerLoadedGuard } from './modules/pdf-viewer/services/webviewer-loaded.guard'; import { Roles } from '@users/roles'; import { mainResolver } from '@utils/main.resolver'; +import { hasAnyRoleGuard, IqserAuthGuard } from '@iqser/common-ui/lib/users'; +import { CustomRouteReuseStrategy } from '@iqser/common-ui/lib/utils'; +import { ifLoggedIn } from '@guards/if-logged-in.guard'; const dossierTemplateIdRoutes: IqserRoutes = [ { @@ -182,7 +182,7 @@ const mainRoutes: IqserRoutes = [ children: dossierTemplateIdRoutes, canActivate: [CompositeRouteGuard, IqserPermissionsGuard, templateExistsWhenEnteringDossierList()], data: { - routeGuards: [IqserAuthGuard, RedRoleGuard, DossierTemplatesGuard, DashboardGuard], + routeGuards: [IqserAuthGuard, RedRoleGuard], permissions: { allow: [ Roles.any, @@ -220,7 +220,7 @@ const routes: IqserRoutes = [ }, { path: ':tenant/main', - canActivate: [ifLoggedIn], + canActivate: [ifLoggedIn()], component: BaseScreenComponent, resolve: { whateverThisMainRouteNeeds: mainResolver, @@ -230,7 +230,7 @@ const routes: IqserRoutes = [ { path: ':tenant/auth-error', component: AuthErrorComponent, - canActivate: [IqserAuthGuard], + canActivate: [hasAnyRoleGuard()], }, { path: '**', diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index e4d0d0f72..0feb32e33 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -21,7 +21,6 @@ import { IqserListingModule, IqserLoadingModule, IqserTranslateModule, - IqserUsersModule, LanguageService, LogoComponent, MAX_RETRIES_ON_SERVER_ERROR, @@ -71,6 +70,7 @@ import { SkeletonStatsComponent } from '@components/skeleton/skeleton-stats/skel import { UserMenuComponent } from '@components/user-menu/user-menu.component'; import { TenantsMenuComponent } from '@components/tenants-menu/tenants-menu.component'; import { MatDividerModule } from '@angular/material/divider'; +import { IqserUsersModule } from '@iqser/common-ui/lib/users'; export const appModuleFactory = (config: AppConfig) => { @NgModule({ diff --git a/apps/red-ui/src/app/components/base-screen/base-screen.component.ts b/apps/red-ui/src/app/components/base-screen/base-screen.component.ts index 3961f1bb6..086985221 100644 --- a/apps/red-ui/src/app/components/base-screen/base-screen.component.ts +++ b/apps/red-ui/src/app/components/base-screen/base-screen.component.ts @@ -6,13 +6,14 @@ import { Title } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; import { SpotlightSearchAction } from '@components/spotlight-search/spotlight-search-action'; import { filter, map, startWith } from 'rxjs/operators'; -import { IqserPermissionsService, List, shareDistinctLast, TenantsService } from '@iqser/common-ui'; +import { IqserPermissionsService, TenantsService } from '@iqser/common-ui'; import { BreadcrumbsService } from '@services/breadcrumbs.service'; import { FeaturesService } from '@services/features.service'; import { ARCHIVE_ROUTE, DOSSIERS_ARCHIVE, DOSSIERS_ROUTE } from '@red/domain'; import { Roles } from '@users/roles'; import { REDDocumentViewer } from '../../modules/pdf-viewer/services/document-viewer.service'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { List, shareDistinctLast } from '@iqser/common-ui/lib/utils'; const isNavigationStart = event => event instanceof NavigationStart; const isSearchScreen: (url: string) => boolean = url => url.includes('/search'); @@ -22,6 +23,12 @@ const isSearchScreen: (url: string) => boolean = url => url.includes('/search'); styleUrls: ['./base-screen.component.scss'], }) export class BaseScreenComponent { + readonly #navigationStart$ = this._router.events.pipe( + filter(isNavigationStart), + map((event: NavigationStart) => event.url), + startWith(this._router.url), + shareDistinctLast(), + ); readonly roles = Roles; readonly documentViewer = inject(REDDocumentViewer); readonly currentUser = this.userService.currentUser; @@ -44,12 +51,6 @@ export class BaseScreenComponent { action: (query): void => this.#search(query, []), }, ]; - readonly #navigationStart$ = this._router.events.pipe( - filter(isNavigationStart), - map((event: NavigationStart) => event.url), - startWith(this._router.url), - shareDistinctLast(), - ); readonly isSearchScreen$ = this.#navigationStart$.pipe(map(isSearchScreen)); constructor( diff --git a/apps/red-ui/src/app/components/notifications/notifications.component.ts b/apps/red-ui/src/app/components/notifications/notifications.component.ts index 5d9a56c96..743dcda00 100644 --- a/apps/red-ui/src/app/components/notifications/notifications.component.ts +++ b/apps/red-ui/src/app/components/notifications/notifications.component.ts @@ -4,7 +4,7 @@ import { NotificationsService } from '@services/notifications.service'; import { Notification } from '@red/domain'; import { distinctUntilChanged, map } from 'rxjs/operators'; import { Observable } from 'rxjs'; -import { isToday, shareLast, trackByFactory } from '@iqser/common-ui'; +import { isToday, shareLast, trackByFactory } from '@iqser/common-ui/lib/utils'; import dayjs, { Dayjs } from 'dayjs'; import { TranslateService } from '@ngx-translate/core'; diff --git a/apps/red-ui/src/app/components/tenants-menu/tenants-menu.component.html b/apps/red-ui/src/app/components/tenants-menu/tenants-menu.component.html index 66bf2b5f3..96ee8315f 100644 --- a/apps/red-ui/src/app/components/tenants-menu/tenants-menu.component.html +++ b/apps/red-ui/src/app/components/tenants-menu/tenants-menu.component.html @@ -1,11 +1,11 @@