@open-rlb/ng-app 3.0.22 → 3.0.24

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.
@@ -516,7 +516,7 @@ class AppsService {
516
516
  // Return config in there are matched apps, or it's root route case
517
517
  map(apps => {
518
518
  if (appRoutesMatched.length > 0 || fullPath === '') {
519
- return { route, appsConfig: appRoutesMatched, apps };
519
+ return { route, appsConfig: appRoutesMatched, apps, fullPath };
520
520
  }
521
521
  return null;
522
522
  }));
@@ -524,27 +524,28 @@ class AppsService {
524
524
  handleResolvedApps(data) {
525
525
  const route = this.findDeepestChild(this.activatedRoute);
526
526
  const storedId = this.getStoredAppId();
527
- // Check if it is a root route
528
- const currentPath = route.snapshot.url.map(s => s.path).join('/');
527
+ // Check if route is root
528
+ const currentPath = data ? data.fullPath : this.getFullPath(route);
529
529
  const isRoot = currentPath === '';
530
+ // Basic check
530
531
  if (data?.apps?.some(app => !app.id)) {
531
532
  this.logger.error('Some apps are not finalized...');
532
533
  return;
533
534
  }
534
535
  if (!data || !data.apps || data.apps.length === 0) {
535
- this.logger.warn(`No apps found (or data is null). Path: '${currentPath}'`);
536
+ this.logger.warn(`No apps found. Path: '${currentPath}'`);
536
537
  this.selectApp(undefined);
537
538
  return;
538
539
  }
539
- // domain filter
540
+ // Filter by domain
540
541
  const domainApps = data.apps.filter(app => !app.domains || app.domains?.some((domain) => domain.includes(this.currentDomain)));
541
542
  if (domainApps.length === 0) {
542
543
  this.logger.warn(`No apps allowed for domain: ${this.currentDomain}`);
543
544
  this.selectApp(undefined);
544
545
  return;
545
546
  }
546
- // Auto-redirect logic
547
- // if there is a root route and only 1 app matched -> auto redirect on app home page
547
+ // CASE 1: SINGLE APP REDIRECT (Partners)
548
+ // We are in root route and there is only one app available
548
549
  if (isRoot && domainApps.length === 1) {
549
550
  const singleApp = domainApps[0];
550
551
  const targetUrl = singleApp.core?.url;
@@ -554,26 +555,35 @@ class AppsService {
554
555
  queryParams: route.snapshot.queryParams,
555
556
  replaceUrl: true
556
557
  });
557
- // break flow, to prevent selectApp
558
558
  return;
559
559
  }
560
560
  }
561
- const matchedApps = domainApps
562
- .filter(app => app.routes?.some(r => r.includes(route.routeConfig?.path)) ||
563
- app.core?.url === '/' + route.routeConfig?.path ||
564
- (isRoot && app.core?.url));
561
+ // CASE 2: MULTI APP HUB / CORE HOME PAGE
562
+ // We are in root route, and there are more than one app available
563
+ // ====================================================================
564
+ if (isRoot && domainApps.length > 1) {
565
+ this.logger.info(`Root detected with multiple apps (${domainApps.length}). Showing App Hub / Core home page.`);
566
+ this.selectApp(undefined); // Explicit reset chosen app
567
+ return;
568
+ }
569
+ // CASE 3: Standard logic to get app (Deep linking) ---
570
+ // Here we go only if route not empty !="" and not root !="/"
571
+ const matchedApps = domainApps.filter(app => app.routes?.some(r => r.includes(route.routeConfig?.path)) ||
572
+ app.core?.url === '/' + route.routeConfig?.path);
565
573
  let appToSelect;
566
574
  if (matchedApps.length === 1) {
567
575
  appToSelect = matchedApps[0];
568
576
  this.logger.info('Single app matched route:', appToSelect);
569
577
  }
570
578
  else if (matchedApps.length > 1) {
579
+ // Fallback in case of conflict routes
571
580
  appToSelect = matchedApps.find(a => a.id === storedId) || matchedApps[0];
572
581
  this.logger.info('Multiple apps matched route, selected:', appToSelect);
573
582
  }
574
583
  else {
575
- appToSelect = domainApps[0];
576
- this.logger.info('No specific route match. Falling back to domain default:', appToSelect);
584
+ // Fallback: Route path doesn't exist
585
+ appToSelect = undefined;
586
+ this.logger.warn('No app matched this specific route:', currentPath);
577
587
  }
578
588
  const qp = new URLSearchParams(route.snapshot.queryParams).toString();
579
589
  const url = currentPath + (qp ? `?${qp}` : '');