Skip to content

Commit bce6f3d

Browse files
authored
Merge branch 'main' into open-in-new-tab-support-sheet
2 parents dc2cf23 + 9f93db6 commit bce6f3d

16 files changed

+128
-29
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"@types/jest": "^27.4.1",
9595
"@types/lodash-es": "^4.17.6",
9696
"@types/mixpanel-browser": "^2.38.0",
97-
"@types/node": "^17.0.21",
97+
"@types/node": "^17.0.23",
9898
"@types/uuid": "^8.3.4",
9999
"@types/webpack-env": "^1.16.3",
100100
"codelyzer": "^6.0.2",
@@ -107,7 +107,7 @@
107107
"jest-junit": "^13.0.0",
108108
"jest-preset-angular": "^8.4.0",
109109
"lodash": "^4.17.21",
110-
"ng-mocks": "^13.2.0",
110+
"ng-mocks": "^13.3.0",
111111
"ng-packagr": "^12.2.5",
112112
"prettier": "^2.2.1",
113113
"pretty-quick": "^3.1.3",

projects/assets-library/src/icons/icon-type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export const enum IconType {
9797
Refresh = 'refresh',
9898
Remove = 'remove',
9999
RemoveCircle = 'remove_circle',
100+
Restore = 'restore',
100101
Search = 'svg:search',
101102
Settings = 'settings',
102103
Share = 'share',
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import { Pipe, PipeTransform } from '@angular/core';
2+
import { TimeDuration, TimeUnit, UnitStringType } from './../../../public-api';
23
import { durationFormatter } from './duration-formatter';
34

45
@Pipe({
56
name: 'htDisplayDuration'
67
})
78
export class DisplayDurationPipe implements PipeTransform {
8-
public transform(millis?: number): string {
9-
return durationFormatter(millis);
9+
public transform(millis?: number, unitStringType: UnitStringType = UnitStringType.Short): string {
10+
if (millis === undefined) {
11+
return '-';
12+
}
13+
14+
if (unitStringType === UnitStringType.Short) {
15+
return durationFormatter(millis);
16+
}
17+
18+
return new TimeDuration(millis, TimeUnit.Millisecond).toMultiUnitString(TimeUnit.Second, true, UnitStringType.Long);
1019
}
1120
}

projects/common/src/utilities/formatters/string/highlight.pipe.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Pipe, PipeTransform } from '@angular/core';
22
import { isArray } from 'lodash-es';
33
import { assertUnreachable } from '../../lang/lang-utils';
44

5+
// TODO: Currently htHighlight does not escape reserved regex characters
56
@Pipe({ name: 'htHighlight' })
67
export class HighlightPipe implements PipeTransform {
78
public transform(fullText: string, highlightSnippets: TextHighlightConfig | TextHighlightConfig[]): string {

projects/components/src/select/select.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ export class SelectComponent<V> implements ControlValueAccessor, AfterContentIni
341341
return undefined;
342342
}
343343

344-
return this.items.find(item => item.value === value);
344+
return this.items.find(item => isEqual(item.value, value));
345345
}
346346

347347
public getStyleClassesForSelectItem(size: SelectSize, item: SelectOptionComponent<V>): string[] {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@import 'font';
2+
3+
.duration-cell {
4+
.duration-text {
5+
@include ellipsis-overflow();
6+
@include body-1-regular();
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { DisplayDurationPipe } from '@hypertrace/common';
2+
import { createComponentFactory } from '@ngneat/spectator/jest';
3+
import { MockPipe } from 'ng-mocks';
4+
import { TableCellNoOpParser } from '../../data-parsers/table-cell-no-op-parser';
5+
import { tableCellProviders } from '../../test/cell-providers';
6+
import { DurationTableCellRendererComponent } from './duration-table-cell-renderer.component';
7+
8+
describe('Duration table cell renderer component', () => {
9+
const buildComponent = createComponentFactory({
10+
component: DurationTableCellRendererComponent,
11+
providers: [
12+
tableCellProviders(
13+
{
14+
id: 'test'
15+
},
16+
new TableCellNoOpParser(undefined!),
17+
0,
18+
14400000
19+
)
20+
],
21+
declarations: [MockPipe(DisplayDurationPipe)],
22+
shallow: true
23+
});
24+
25+
test('Should render duration text', () => {
26+
const spectator = buildComponent();
27+
28+
expect(spectator.query('.duration-cell')).toExist();
29+
expect(spectator.query('.duration-text')).toExist();
30+
});
31+
});
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';
2+
import { UnitStringType } from '@hypertrace/common';
3+
import { TableColumnConfig, TableRow } from '../../../table-api';
4+
import {
5+
TABLE_CELL_DATA,
6+
TABLE_COLUMN_CONFIG,
7+
TABLE_COLUMN_INDEX,
8+
TABLE_DATA_PARSER,
9+
TABLE_ROW_DATA
10+
} from '../../table-cell-injection';
11+
import { TableCellParserBase } from '../../table-cell-parser-base';
12+
import { TableCellRenderer } from '../../table-cell-renderer';
13+
import { TableCellRendererBase } from '../../table-cell-renderer-base';
14+
import { CoreTableCellParserType } from '../../types/core-table-cell-parser-type';
15+
import { CoreTableCellRendererType } from '../../types/core-table-cell-renderer-type';
16+
import { TableCellAlignmentType } from '../../types/table-cell-alignment-type';
17+
18+
@Component({
19+
selector: 'ht-duration-table-cell-renderer',
20+
changeDetection: ChangeDetectionStrategy.OnPush,
21+
template: `
22+
<div class="duration-cell">
23+
<span class="duration-text">{{ this.value | htDisplayDuration: this.formatter }}</span>
24+
</div>
25+
`,
26+
styleUrls: ['./duration-table-cell-renderer.component.scss']
27+
})
28+
@TableCellRenderer({
29+
type: CoreTableCellRendererType.Duration,
30+
alignment: TableCellAlignmentType.Left,
31+
parser: CoreTableCellParserType.NoOp
32+
})
33+
export class DurationTableCellRendererComponent extends TableCellRendererBase<number> {
34+
public readonly formatter: UnitStringType = UnitStringType.Long;
35+
36+
public constructor(
37+
@Inject(TABLE_COLUMN_CONFIG) columnConfig: TableColumnConfig,
38+
@Inject(TABLE_COLUMN_INDEX) index: number,
39+
@Inject(TABLE_DATA_PARSER) parser: TableCellParserBase<number, number, unknown>,
40+
@Inject(TABLE_CELL_DATA) cellData: number,
41+
@Inject(TABLE_ROW_DATA) rowData: TableRow
42+
) {
43+
super(columnConfig, index, parser, cellData, rowData);
44+
}
45+
}

projects/components/src/table/cells/data-renderers/relative-timestamp/relative-timestamp-table-cell-renderer.component.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
TooltipDirective
77
} from '@hypertrace/components';
88
import { createComponentFactory } from '@ngneat/spectator/jest';
9-
import { MockComponent, MockPipe } from 'ng-mocks';
9+
import { MockDirective, MockPipe } from 'ng-mocks';
1010
import { tableCellDataProvider } from '../../test/cell-providers';
1111
import {
1212
RelativeTimestampTableCellRendererComponent,
@@ -24,7 +24,7 @@ describe('relative timestamp table cell renderer component', () => {
2424
new TableCellNoOpParser(undefined!)
2525
)
2626
],
27-
declarations: [MockComponent(TooltipDirective), MockPipe(DisplayDatePipe)],
27+
declarations: [MockDirective(TooltipDirective), MockPipe(DisplayDatePipe)],
2828
shallow: true
2929
});
3030

0 commit comments

Comments
 (0)