Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Color, FeatureState } from '@hypertrace/common';
import { Observable } from 'rxjs';
import { IconSize } from '../icon/icon-size';
import { Color } from '../color/color';
import { FeatureState} from '../feature/state/feature.state';

export type NavItemConfig = NavItemLinkConfig | NavItemHeaderConfig | NavItemDividerConfig;

export interface NavItemLinkConfig {
type: NavItemType.Link;
icon: string;
iconSize?: IconSize;
iconSize?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should remove this type safety. We only support few size options. Moving the method to a new service would solve this.

label: string;
matchPaths: string[]; // For now, default path is index 0
features?: string[];
Expand Down
3 changes: 1 addition & 2 deletions projects/common/src/navigation/navigation.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Title } from '@angular/platform-browser';
import { Router, UrlSegment } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { IconType } from '@hypertrace/assets-library';
import { APP_TITLE } from '@hypertrace/common';
import { NavItemType } from '@hypertrace/components';
import { APP_TITLE, NavItemType } from '@hypertrace/common';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

circular ref, we're in the common project here

import { patchRouterNavigateForTest } from '@hypertrace/test-utils';
import { createServiceFactory, mockProvider, SpectatorService } from '@ngneat/spectator/jest';
import {
Expand Down
2 changes: 1 addition & 1 deletion projects/common/src/navigation/navigation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import {
UrlSegment,
UrlTree
} from '@angular/router';
import { NavItemConfig, NavItemType } from '@hypertrace/components';
import { uniq } from 'lodash-es';
import { from, Observable, of } from 'rxjs';
import { distinctUntilChanged, filter, map, share, skip, startWith, switchMap, take, tap } from 'rxjs/operators';
import { isEqualIgnoreFunctions, throwIfNil } from '../utilities/lang/lang-utils';
import { Dictionary } from '../utilities/types/types';
import { APP_TITLE, HtRoute } from './ht-route';
import { NavItemConfig, NavItemType } from './navigation.config';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the better solution would be to move the method out of nav service into the nav component - that's the only caller and would allow leaving icon size on the config as is, too - but up to you.

Copy link
Contributor

@anandtiwary anandtiwary Nov 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually trying to fix this too as part of nx poc work. I think we should remove the decorateNavItem method from here and move it to a new service -> navigation-list.service.ts. This method is only used when we are using the navigation-list.component.

We can move it to the component too like Aaron is suggesting but that may require some additional work.


@Injectable({ providedIn: 'root' })
export class NavigationService {
Expand Down
1 change: 1 addition & 0 deletions projects/common/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export * from './navigation/breadcrumb';
export * from './navigation/navigation.service';
export * from './navigation/ht-route-data';
export * from './navigation/ht-route';
export * from './navigation/navigation.config';

// Operations
export * from './utilities/operations/operation-utilities';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import {
FeatureStateResolver,
MemoizeModule,
NavigationParamsType,
NavigationService
NavigationService, NavItemConfig, NavItemType
} from '@hypertrace/common';
import { BetaTagComponent, IconComponent, LinkComponent } from '@hypertrace/components';
import { createHostFactory, mockProvider, SpectatorHost } from '@ngneat/spectator/jest';
import { MockComponent } from 'ng-mocks';
import { EMPTY, of } from 'rxjs';
import { NavItemConfig, NavItemType } from '../navigation.config';
import { FeatureConfigCheckModule } from './../../feature-check/feature-config-check.module';
import { NavItemComponent } from './nav-item.component';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { FeatureState, NavigationParams, NavigationParamsType } from '@hypertrace/common';
import { FeatureState, NavigationParams, NavigationParamsType, NavItemLinkConfig } from '@hypertrace/common';
import { IconSize } from '../../icon/icon-size';
import { NavItemLinkConfig } from '../navigation.config';

@Component({
selector: 'ht-nav-item',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { FeatureState, FeatureStateResolver } from '@hypertrace/common';
import { NavItemConfig, NavItemType } from '@hypertrace/components';
import { FeatureState, FeatureStateResolver , NavItemConfig, NavItemHeaderConfig, NavItemType } from '@hypertrace/common';
import { runFakeRxjs } from '@hypertrace/test-utils';
import { createServiceFactory, mockProvider } from '@ngneat/spectator/jest';
import { of } from 'rxjs';
import { NavigationListComponentService } from './navigation-list-component.service';
import { NavItemHeaderConfig } from './navigation.config';

describe('Navigation List Component Service', () => {
const navItems: NavItemConfig[] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Injectable } from '@angular/core';
import { FeatureState, FeatureStateResolver } from '@hypertrace/common';
import { FeatureState, FeatureStateResolver, NavItemConfig, NavItemHeaderConfig, NavItemLinkConfig, NavItemType } from '@hypertrace/common';
import { isEmpty } from 'lodash-es';
import { combineLatest, Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { NavItemConfig, NavItemHeaderConfig, NavItemLinkConfig, NavItemType } from './navigation.config';

@Injectable({ providedIn: 'root' })
export class NavigationListComponentService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ActivatedRoute } from '@angular/router';
import { IconType } from '@hypertrace/assets-library';
import { MemoizeModule, NavigationService } from '@hypertrace/common';
import { FooterItemConfig, MemoizeModule, NavigationService, NavItemConfig, NavItemType } from '@hypertrace/common';
import { createHostFactory, mockProvider, SpectatorHost } from '@ngneat/spectator/jest';
import { MockComponent } from 'ng-mocks';
import { EMPTY, of } from 'rxjs';
Expand All @@ -10,7 +10,6 @@ import { LinkComponent } from './../link/link.component';
import { NavItemComponent } from './nav-item/nav-item.component';
import { NavigationListComponentService } from './navigation-list-component.service';
import { NavigationListComponent } from './navigation-list.component';
import { FooterItemConfig, NavItemConfig, NavItemType } from './navigation.config';
describe('Navigation List Component', () => {
let spectator: SpectatorHost<NavigationListComponent>;
const activatedRoute = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { IconType } from '@hypertrace/assets-library';
import { NavigationService } from '@hypertrace/common';
import { FooterItemConfig, NavigationService, NavItemConfig, NavItemLinkConfig, NavItemType } from '@hypertrace/common';
import { Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { IconSize } from '../icon/icon-size';
import { NavigationListComponentService } from './navigation-list-component.service';
import { FooterItemConfig, NavItemConfig, NavItemLinkConfig, NavItemType } from './navigation.config';

@Component({
selector: 'ht-navigation-list',
Expand Down
1 change: 0 additions & 1 deletion projects/components/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export { LayoutChangeModule } from './layout/layout-change.module';
export * from './navigation/navigation-list.component';
export * from './navigation/navigation-list.module';
export * from './navigation/nav-item/nav-item.component';
export * from './navigation/navigation.config';
export * from './navigation/navigation-list-component.service';

// Let async
Expand Down
3 changes: 1 addition & 2 deletions src/app/shared/navigation/navigation.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { IconType } from '@hypertrace/assets-library';
import { NavigationService, PreferenceService } from '@hypertrace/common';
import { NavItemConfig, NavItemType } from '@hypertrace/components';
import { NavigationService, NavItemConfig, NavItemType, PreferenceService } from '@hypertrace/common';
import { ObservabilityIconType } from '@hypertrace/observability';
import { Observable } from 'rxjs';

Expand Down