Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions projects/observability/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ export * from './shared/components/timeline-card-list/timeline-card-list.compone
export * from './shared/components/timeline-card-list/container/timeline-card-container.component';
export * from './shared/components/timeline-card-list/timeline-card-list.module';

// Explore Filter link
export * from './shared/components/explore-filter-link/explore-filter-link.component';
export * from './shared/components/explore-filter-link/explore-filter-link.module';

// Interval Select
export * from './shared/components/interval-select/interval-select.component';
export * from './shared/components/interval-select/interval-select.module';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@import 'font';
@import 'color-palette';

.explore-filter {
display: flex;
flex-direction: row;
align-items: center;

.filter-icon {
transition: all 0.2s ease-in-out;
}

&:hover {
.filter-icon {
transform: scale(1.2);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { LinkComponent, IconComponent, IconSize } from '@hypertrace/components';
import { createHostFactory, SpectatorHost } from '@ngneat/spectator/jest';
import { MockComponent } from 'ng-mocks';
import { ExploreFilterLinkComponent } from './explore-filter-link.component';
import { IconType } from '@hypertrace/assets-library';

describe('Explore Filter Link component', () => {
let spectator: SpectatorHost<ExploreFilterLinkComponent>;

const createHost = createHostFactory({
component: ExploreFilterLinkComponent,
declarations: [MockComponent(LinkComponent), MockComponent(IconComponent)]
});

test('should display all elements', () => {
spectator = createHost(`<ht-link [paramsOrUrl]="paramsOrUrl"></ht-link>`, {
props: {
paramsOrUrl: undefined
}
});

expect(spectator.query('.ht-link')).not.toExist();
});

test('Link should navigate correctly to external URLs', () => {
spectator = createHost(`<ht-explore-filter-link [paramsOrUrl]="paramsOrUrl"></ht-explore-filter-link>`, {
hostProps: {
paramsOrUrl: 'http://test.hypertrace.ai'
}
});

const linkComponent = spectator.query(LinkComponent);
expect(linkComponent).toExist();
expect(linkComponent?.paramsOrUrl).toEqual('http://test.hypertrace.ai');

const iconComponent = spectator.query(IconComponent);
expect(iconComponent).toExist();
expect(iconComponent?.icon).toEqual(IconType.Filter);
expect(iconComponent?.size).toEqual(IconSize.Small);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { IconType } from '@hypertrace/assets-library';
import { NavigationParams } from '@hypertrace/common';
import { IconSize } from '@hypertrace/components';

@Component({
selector: 'ht-explore-filter-link',
styleUrls: ['./explore-filter-link.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ht-link class="explore-filter" [paramsOrUrl]="this.paramsOrUrl">
<ng-content></ng-content>
<ht-icon class="filter-icon" size="${IconSize.ExtraSmall}" icon="${IconType.Filter}"></ht-icon>
</ht-link>
`
})
export class ExploreFilterLinkComponent {
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels a bit weird to call this explore filter link when it doesn't reference explorer, it just adds a filter icon around a provided link + content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The icon type should be more specific to explorer.

@Input()
public paramsOrUrl?: NavigationParams | string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { LinkModule, IconModule } from '@hypertrace/components';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ExploreFilterLinkComponent } from './explore-filter-link.component';

@NgModule({
declarations: [ExploreFilterLinkComponent],
exports: [ExploreFilterLinkComponent],
imports: [CommonModule, LinkModule, IconModule]
})
export class ExploreFilterLinkModule {}