private _initBreadcrumbs()

in src/app/frontend/common/components/breadcrumbs/component.ts [54:113]


  private _initBreadcrumbs(): void {
    const currentRoute = this._getCurrentRoute();
    const url = this._router.url.includes('?') ? this._router.url.split('?')[0] : '';
    let urlArray = url.split('/');
    let routeParamsCount =
      currentRoute.routeConfig.data && currentRoute.routeConfig.data.routeParamsCount
        ? +currentRoute.routeConfig.data.routeParamsCount
        : currentRoute.routeConfig.path.split('/').length;

    this.breadcrumbs = [
      {
        label: this._getBreadcrumbLabel(currentRoute.routeConfig, currentRoute.snapshot.params),
        stateLink:
          currentRoute.routeConfig.data && currentRoute.routeConfig.data.link
            ? currentRoute.routeConfig.data.link
            : urlArray,
      },
    ];

    let route: Route;
    if (
      currentRoute &&
      currentRoute.routeConfig &&
      currentRoute.routeConfig.data &&
      currentRoute.routeConfig.data.parent
    ) {
      if (currentRoute.routeConfig.data.parent === LOGS_PARENT_PLACEHOLDER) {
        route = this._getLogsParent(currentRoute.snapshot.params);
        urlArray = ['', urlArray[urlArray.length - 1], urlArray[urlArray.length - 3], urlArray[urlArray.length - 2]];
        routeParamsCount = 0;
      } else if (currentRoute.routeConfig.data.parent === EXEC_PARENT_PLACEHOLDER) {
        route = POD_DETAIL_ROUTE;
        urlArray = ['', 'pod', urlArray[urlArray.length - 3], urlArray[urlArray.length - 2]];
        routeParamsCount = 0;
      } else {
        route = currentRoute.routeConfig.data.parent;
      }

      while (route) {
        // Trim URL by number of path parameters defined on previous route.
        urlArray = urlArray.slice(0, urlArray.length - routeParamsCount);
        routeParamsCount = route.path.split('/').length;

        this.breadcrumbs.push({
          label: this._getBreadcrumbLabel(route, currentRoute.snapshot.params),
          stateLink: route.data.link ? route.data.link : urlArray,
        });

        // Explore the route tree to the root route (parent references have to be defined by us on
        // each route).
        if (route && route.data && route.data.parent) {
          route = route.data.parent;
        } else {
          break;
        }
      }
    }

    this.breadcrumbs.reverse();
  }