Skip to content

Commit 6887a19

Browse files
committed
Merge branch 'notification-update' of github.com:hypertrace/hypertrace-ui into notification-update
2 parents f554ee6 + 2f8ea8b commit 6887a19

File tree

15 files changed

+320
-27777
lines changed

15 files changed

+320
-27777
lines changed

package-lock.json

Lines changed: 104 additions & 27767 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
"private": true,
2626
"dependencies": {
2727
"@angular/animations": "^11.0.7",
28-
"@angular/cdk": "^11.0.3",
28+
"@angular/cdk": "^11.0.4",
2929
"@angular/common": "^11.0.7",
3030
"@angular/compiler": "^11.0.7",
3131
"@angular/core": "^11.0.7",
3232
"@angular/flex-layout": "^11.0.0-beta.33",
3333
"@angular/forms": "^11.0.7",
34-
"@angular/material": "^11.0.3",
34+
"@angular/material": "^11.0.4",
3535
"@angular/platform-browser": "^11.0.7",
3636
"@angular/platform-browser-dynamic": "^11.0.7",
3737
"@angular/router": "^11.0.7",
38-
"@apollo/client": "^3.3.6",
38+
"@apollo/client": "^3.3.7",
3939
"@hypertrace/hyperdash": "^1.2.1",
4040
"@hypertrace/hyperdash-angular": "^2.4.0",
4141
"@types/d3-hierarchy": "^2.0.0",
@@ -57,7 +57,7 @@
5757
"d3-shape": "^1.3.5",
5858
"d3-transition": "^1.2.0",
5959
"d3-zoom": "^1.8.3",
60-
"graphql": "^15.4.0",
60+
"graphql": "^15.5.0",
6161
"graphql-tag": "^2.11.0",
6262
"iso8601-duration": "^1.3.0",
6363
"lodash-es": "^4.17.20",
@@ -75,7 +75,7 @@
7575
"@commitlint/cli": "^11.0.0",
7676
"@commitlint/config-conventional": "^11.0.0",
7777
"@compodoc/compodoc": "^1.1.11",
78-
"@ngneat/spectator": "^6.1.3",
78+
"@ngneat/spectator": "^7.0.0",
7979
"@types/d3-array": "^2.9.0",
8080
"@types/d3-axis": "^2.0.0",
8181
"@types/d3-brush": "^2.1.0",
@@ -89,7 +89,7 @@
8989
"@types/d3-zoom": "^1.7.5",
9090
"@types/jest": "^26.0.20",
9191
"@types/lodash-es": "^4.17.4",
92-
"@types/node": "^14.14.14",
92+
"@types/node": "^14.14.25",
9393
"@types/uuid": "^8.3.0",
9494
"@types/webpack-env": "^1.14.0",
9595
"codelyzer": "^6.0.1",
@@ -102,7 +102,7 @@
102102
"jest-junit": "^12.0.0",
103103
"lodash": "^4.17.20",
104104
"ng-mocks": "^11.3.1",
105-
"ng-packagr": "^11.1.2",
105+
"ng-packagr": "^11.1.4",
106106
"prettier": "^2.2.1",
107107
"pretty-quick": "^3.0.0",
108108
"ts-node": "~9.1.1",

projects/common/src/time/time-range.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export class TimeRangeService {
5959
return this.setTimeRange(TimeRangeService.toFixedTimeRange(startTime, endTime));
6060
}
6161

62+
public refresh(): void {
63+
this.setTimeRange(this.getCurrentTimeRange());
64+
}
65+
6266
private initializeTimeRange(): void {
6367
this.navigationService.navigation$
6468
.pipe(
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
:host {
2+
min-width: 0;
3+
}
4+
5+
.description {
6+
display: flex;
7+
}
8+
9+
.description-button {
10+
cursor: pointer;
11+
text-decoration: underline;
12+
white-space: nowrap;
13+
&-more {
14+
margin-left: 5px;
15+
}
16+
}
17+
18+
.truncated-text {
19+
overflow: hidden;
20+
text-overflow: ellipsis;
21+
white-space: nowrap;
22+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { createHostFactory, Spectator } from '@ngneat/spectator/jest';
2+
import { DescriptionComponent } from './description.component';
3+
4+
describe('Description Component', () => {
5+
let spectator: Spectator<DescriptionComponent>;
6+
7+
const createHost = createHostFactory<DescriptionComponent>({
8+
component: DescriptionComponent,
9+
shallow: true
10+
});
11+
12+
test('should render the description', () => {
13+
spectator = createHost('<ht-description [description] = "description"> </ht-description>', {
14+
hostProps: {
15+
description: 'Description text'
16+
}
17+
});
18+
19+
expect(spectator.query('.description')).toExist();
20+
expect(spectator.query('.description-text')).toHaveText('Description text');
21+
});
22+
23+
test('should show full description text if pressed button show more', () => {
24+
spectator = createHost('<ht-description [description] = "description"> </ht-description>', {
25+
hostProps: {
26+
description: 'Description text'
27+
}
28+
});
29+
30+
expect(spectator.component.isDescriptionTextToggled).toBeFalsy();
31+
spectator.component.toggleDescriptionText();
32+
expect(spectator.component.isDescriptionTextToggled).toBeTruthy();
33+
});
34+
});
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import {
2+
AfterViewInit,
3+
ChangeDetectionStrategy,
4+
ChangeDetectorRef,
5+
Component,
6+
ElementRef,
7+
Input,
8+
OnChanges,
9+
ViewChild
10+
} from '@angular/core';
11+
12+
@Component({
13+
selector: 'ht-description',
14+
styleUrls: ['./description.component.scss'],
15+
changeDetection: ChangeDetectionStrategy.OnPush,
16+
template: `
17+
<div class="description" (htLayoutChange)="this.remeasure()" #eventDescriptionContainer>
18+
<div
19+
class="description-text"
20+
[ngClass]="{ 'truncated-text': !isDescriptionTextToggled }"
21+
data-sensitive-pii
22+
#eventDescriptionText
23+
>
24+
{{ description }}
25+
<span
26+
*ngIf="isDescriptionTruncated && isDescriptionTextToggled"
27+
(click)="toggleDescriptionText()"
28+
class="description-button"
29+
>show less</span
30+
>
31+
</div>
32+
<div
33+
class="description-button description-button-more"
34+
*ngIf="isDescriptionTruncated && !isDescriptionTextToggled"
35+
(click)="toggleDescriptionText()"
36+
>
37+
show more
38+
</div>
39+
</div>
40+
`
41+
})
42+
export class DescriptionComponent implements OnChanges, AfterViewInit {
43+
public isInitialized: boolean = false;
44+
public isDescriptionTextToggled: boolean = false;
45+
public isDescriptionTruncated!: boolean;
46+
47+
@ViewChild('eventDescriptionText', { read: ElementRef })
48+
public readonly eventDescriptionText!: ElementRef;
49+
50+
@ViewChild('eventDescriptionContainer', { read: ElementRef })
51+
public readonly eventDescriptionContainer!: ElementRef;
52+
53+
@Input()
54+
public description!: string;
55+
56+
public constructor(private readonly cdRef: ChangeDetectorRef) {}
57+
58+
public ngOnChanges(): void {
59+
if (this.isInitialized) {
60+
this.remeasure();
61+
}
62+
}
63+
64+
public ngAfterViewInit(): void {
65+
this.isInitialized = true;
66+
this.remeasure();
67+
}
68+
69+
public toggleDescriptionText(): void {
70+
this.isDescriptionTextToggled = !this.isDescriptionTextToggled;
71+
}
72+
73+
public remeasure(): void {
74+
this.isDescriptionTextToggled = false;
75+
this.cdRef.detectChanges();
76+
77+
this.isDescriptionTruncated =
78+
this.eventDescriptionContainer.nativeElement.offsetWidth < this.eventDescriptionText.nativeElement.scrollWidth;
79+
this.cdRef.detectChanges();
80+
}
81+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
3+
import { LayoutChangeModule } from '../layout/layout-change.module';
4+
import { DescriptionComponent } from './description.component';
5+
6+
@NgModule({
7+
imports: [CommonModule, LayoutChangeModule],
8+
declarations: [DescriptionComponent],
9+
exports: [DescriptionComponent]
10+
})
11+
export class DescriptionModule {}

projects/components/src/modal/modal-container.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, Component, Inject, Injector, TemplateRef, Type } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, HostListener, Inject, Injector, TemplateRef, Type } from '@angular/core';
22
import { IconType } from '@hypertrace/assets-library';
33
import { LayoutChangeService } from '@hypertrace/common';
44
import { ButtonSize, ButtonStyle } from '../button/button';
@@ -46,6 +46,7 @@ export class ModalContainerComponent {
4646
public readonly renderer: TemplateRef<unknown> | Type<unknown>;
4747
public readonly rendererInjector: Injector;
4848
public readonly rendererContext: unknown;
49+
public readonly closeOnEscape: boolean;
4950

5051
public visible: boolean = true;
5152

@@ -59,6 +60,7 @@ export class ModalContainerComponent {
5960
this.modalTitle = config.title ?? '';
6061
this.size = config.size;
6162
this.isComponentModal = !(config.content instanceof TemplateRef);
63+
this.closeOnEscape = config.closeOnEscapeKey ?? true;
6264
this.renderer = config.content;
6365
this.rendererInjector = Injector.create({
6466
providers: [
@@ -72,6 +74,13 @@ export class ModalContainerComponent {
7274
this.rendererContext = this.rendererInjector.get(MODAL_DATA, {});
7375
}
7476

77+
@HostListener('document:keydown.escape', ['$event'])
78+
public onKeydownHandler(): void {
79+
if (this.closeOnEscape) {
80+
this.close();
81+
}
82+
}
83+
7584
public close(): void {
7685
this.visible = false;
7786
this.popoverRef.close();

projects/components/src/modal/modal.service.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,24 @@ describe('Modal service', () => {
6969

7070
flush(); // CDK timer to remove overlay
7171
}));
72+
73+
test('modal can be closed on press ESC key', fakeAsync(() => {
74+
const spectator = createHost();
75+
const modal: ModalRef<string> = spectator.inject(ModalService).createModal({
76+
content: TestComponent,
77+
size: ModalSize.Small,
78+
data: 'custom input'
79+
});
80+
81+
spectator.tick();
82+
const subscription = modal.closed$.subscribe();
83+
expect(subscription.closed).toBe(false);
84+
85+
spectator.dispatchKeyboardEvent(document, 'keydown', { key: 'Escape', keyCode: 27 });
86+
87+
expect(spectator.query('.test-modal-content', { root: true })).not.toExist();
88+
expect(subscription.closed).toBe(true);
89+
90+
flush();
91+
}));
7292
});

projects/components/src/modal/modal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface ModalConfig<TData = unknown> {
77
showControls?: boolean;
88
title?: string;
99
data?: TData;
10+
closeOnEscapeKey?: boolean;
1011
}
1112

1213
export const enum ModalSize {

0 commit comments

Comments
 (0)