Skip to content

Commit f93df50

Browse files
committed
Merge branch 'feat/domain-validator' of github.com:hypertrace/hypertrace-ui into feat/domain-validator
2 parents 669105c + 2b37e7c commit f93df50

File tree

8 files changed

+1844
-1795
lines changed

8 files changed

+1844
-1795
lines changed

package-lock.json

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

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
"@angular/platform-browser-dynamic": "^12.2.1",
3838
"@angular/router": "^12.2.1",
3939
"@apollo/client": "^3.5.8",
40-
"@fullstory/browser": "^1.4.10",
40+
"@fullstory/browser": "^1.5.0",
4141
"@hypertrace/hyperdash": "^1.2.1",
4242
"@hypertrace/hyperdash-angular": "^2.6.0",
4343
"@types/d3-hierarchy": "^2.0.2",
4444
"@types/d3-transition": "1.1.5",
4545
"apollo-angular": "^2.6.0",
46-
"core-js": "^3.20.3",
46+
"core-js": "^3.21.0",
4747
"d3-array": "^2.12.0",
4848
"d3-axis": "^2.1.0",
4949
"d3-brush": "^1.1.6",
@@ -92,26 +92,26 @@
9292
"@types/d3-shape": "^2.1.0",
9393
"@types/d3-zoom": "^1.7.5",
9494
"@types/jest": "^27.4.0",
95-
"@types/lodash-es": "^4.17.5",
96-
"@types/mixpanel-browser": "^2.36.0",
97-
"@types/node": "^17.0.13",
95+
"@types/lodash-es": "^4.17.6",
96+
"@types/mixpanel-browser": "^2.38.0",
97+
"@types/node": "^17.0.15",
9898
"@types/uuid": "^8.3.4",
9999
"@types/webpack-env": "^1.16.3",
100100
"codelyzer": "^6.0.2",
101101
"commitizen": "^4.2.4",
102102
"cz-conventional-changelog": "^3.3.0",
103103
"husky": "^7.0.4",
104104
"jest": "^26.6.3",
105-
"jest-config": "^27.4.7",
105+
"jest-config": "^27.5.0",
106106
"jest-html-reporter": "^3.4.2",
107107
"jest-junit": "^13.0.0",
108108
"jest-preset-angular": "^8.4.0",
109109
"lodash": "^4.17.21",
110-
"ng-mocks": "^13.0.0",
110+
"ng-mocks": "^13.0.2",
111111
"ng-packagr": "^12.2.5",
112112
"prettier": "^2.2.1",
113113
"pretty-quick": "^3.1.3",
114-
"ts-node": "~10.4.0",
114+
"ts-node": "~10.5.0",
115115
"tslint": "~6.1.3",
116116
"tslint-config-prettier": "^1.18.0",
117117
"typescript": "~4.3.5",

projects/common/src/utilities/validators/domain-validator.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
export const DOMAIN_REGEX = new RegExp(
2-
/^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
3-
);
1+
export const DOMAIN_REGEX = new RegExp(/^.+\.[a-zA-Z]{2,}$/);
42

53
export const isDomainValid = (domain: string) => {
64
return DOMAIN_REGEX.test(domain);

projects/components/src/multi-select/multi-select.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
height: 34px;
3131
border-radius: 6px;
3232

33+
&.disabled {
34+
cursor: not-allowed;
35+
}
36+
3337
&.extra-small {
3438
height: 30px;
3539
}

projects/components/src/multi-select/multi-select.component.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ describe('Multi Select Component', () => {
8080
expectObservable(spectator.component.triggerValues$).toBe('x', {
8181
x: {
8282
label: selectionOptions[1].label,
83-
selectedItemsCount: 1 // Selected element is 1 as set in hostProps
83+
overflowItemsCount: 0,
84+
overflowLabel: undefined
8485
}
8586
});
8687
});
@@ -116,7 +117,8 @@ describe('Multi Select Component', () => {
116117
expectObservable(spectator.component.triggerValues$).toBe('x', {
117118
x: {
118119
label: selectionOptions[1].label,
119-
selectedItemsCount: 2
120+
overflowItemsCount: 1,
121+
overflowLabel: 'third'
120122
}
121123
});
122124
});
@@ -159,7 +161,8 @@ describe('Multi Select Component', () => {
159161
expectObservable(spectator.component.triggerValues$).toBe('x', {
160162
x: {
161163
label: 'second',
162-
selectedItemsCount: 2
164+
overflowItemsCount: 1,
165+
overflowLabel: 'third'
163166
}
164167
});
165168
});
@@ -232,7 +235,8 @@ describe('Multi Select Component', () => {
232235
expectObservable(spectator.component.triggerValues$).toBe('x', {
233236
x: {
234237
label: 'second',
235-
selectedItemsCount: 2
238+
overflowItemsCount: 1,
239+
overflowLabel: 'third'
236240
}
237241
});
238242
});
@@ -368,7 +372,7 @@ describe('Multi Select Component', () => {
368372
expectObservable(spectator.component.triggerValues$).toBe('(x|)', {
369373
x: {
370374
label: 'Placeholder',
371-
selectedItemsCount: 0
375+
overflowItemsCount: 0
372376
}
373377
});
374378
});
@@ -398,7 +402,7 @@ describe('Multi Select Component', () => {
398402
expectObservable(spectator.component.triggerValues$).toBe('x', {
399403
x: {
400404
label: selectionOptions[1].label,
401-
selectedItemsCount: 1
405+
overflowItemsCount: 0
402406
}
403407
});
404408
});

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,23 @@ import { MultiSelectJustify } from './multi-select-justify';
5353
<div
5454
class="trigger-content"
5555
[style.justify-content]="this.justify"
56-
[ngClass]="[this.triggerLabelDisplayMode, this.popoverOpen ? 'open' : '', this.size]"
56+
[ngClass]="[
57+
this.triggerLabelDisplayMode,
58+
this.popoverOpen ? 'open' : '',
59+
this.size,
60+
this.disabled ? 'disabled' : ''
61+
]"
5762
#triggerContainer
5863
>
5964
<ht-icon *ngIf="this.icon" [icon]="this.icon" [size]="this.iconSize"></ht-icon>
6065
<ng-container *ngIf="!this.isIconOnlyMode()">
6166
<div class="trigger-label-container" *ngIf="this.triggerValues$ | async as triggerValues">
6267
<ht-label class="trigger-label" [label]="triggerValues.label"></ht-label>
63-
<span *ngIf="triggerValues.selectedItemsCount > 1" class="trigger-more-items"
64-
>+{{ triggerValues.selectedItemsCount - 1 }}</span
68+
<span
69+
*ngIf="triggerValues.overflowItemsCount"
70+
class="trigger-more-items"
71+
[htTooltip]="triggerValues.overflowLabel"
72+
>+{{ triggerValues.overflowItemsCount }}</span
6573
>
6674
<ht-icon class="trigger-icon" icon="${IconType.ChevronDown}" [size]="this.iconSize"></ht-icon>
6775
</div>
@@ -262,6 +270,10 @@ export class MultiSelectComponent<V> implements ControlValueAccessor, AfterConte
262270
this.propagateControlValueChangeOnTouch = onTouch;
263271
}
264272

273+
public setDisabledState(isDisabled?: boolean): void {
274+
this.disabled = isDisabled ?? false;
275+
}
276+
265277
private setSelection(selected: V[]): void {
266278
this.selected = selected;
267279
this.setTriggerLabel();
@@ -273,7 +285,7 @@ export class MultiSelectComponent<V> implements ControlValueAccessor, AfterConte
273285
if (this.triggerLabelDisplayMode === TriggerLabelDisplayMode.Placeholder) {
274286
this.triggerValues$ = of({
275287
label: this.placeholder,
276-
selectedItemsCount: 0
288+
overflowItemsCount: 0
277289
});
278290

279291
return;
@@ -282,10 +294,17 @@ export class MultiSelectComponent<V> implements ControlValueAccessor, AfterConte
282294
this.triggerValues$ = this.allOptions$?.pipe(
283295
map(options => {
284296
const selectedItems: SelectOptionComponent<V>[] = options.filter(item => this.isSelectedItem(item));
297+
const isMultiSelection = selectedItems.length > 1;
285298

286299
return {
287300
label: this.getLabel(selectedItems),
288-
selectedItemsCount: selectedItems.length
301+
overflowItemsCount: isMultiSelection ? selectedItems.length - 1 : 0,
302+
overflowLabel: isMultiSelection
303+
? selectedItems
304+
.slice(1)
305+
.map(item => item.label)
306+
.join(', ')
307+
: undefined
289308
};
290309
})
291310
);
@@ -307,7 +326,8 @@ export class MultiSelectComponent<V> implements ControlValueAccessor, AfterConte
307326

308327
interface TriggerValues {
309328
label: string | undefined;
310-
selectedItemsCount: number;
329+
overflowItemsCount: number;
330+
overflowLabel?: string;
311331
}
312332

313333
export const enum TriggerLabelDisplayMode {

projects/components/src/multi-select/multi-select.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { LabelModule } from '../label/label.module';
88
import { LoadAsyncModule } from '../load-async/load-async.module';
99
import { PopoverModule } from '../popover/popover.module';
1010
import { TraceSearchBoxModule } from '../search-box/search-box.module';
11+
import { TooltipModule } from '../tooltip/tooltip.module';
1112
import { MultiSelectComponent } from './multi-select.component';
1213

1314
@NgModule({
@@ -20,7 +21,8 @@ import { MultiSelectComponent } from './multi-select.component';
2021
TraceSearchBoxModule,
2122
ButtonModule,
2223
LoadAsyncModule,
23-
TraceCheckboxModule
24+
TraceCheckboxModule,
25+
TooltipModule
2426
],
2527
declarations: [MultiSelectComponent],
2628
exports: [MultiSelectComponent]

projects/components/src/tabs/navigable/navigable-tab-group.component.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ import {
88
QueryList
99
} from '@angular/core';
1010
import { ActivatedRoute } from '@angular/router';
11-
import { Color, FeatureState, NavigationParams, NavigationParamsType, NavigationService } from '@hypertrace/common';
11+
import {
12+
Color,
13+
FeatureState,
14+
NavigationParams,
15+
NavigationParamsType,
16+
NavigationService,
17+
queryListAndChanges$
18+
} from '@hypertrace/common';
1219
import { merge, Observable } from 'rxjs';
1320
import { distinctUntilChanged, map, startWith, tap } from 'rxjs/operators';
1421
import { NavigableTabComponent } from './navigable-tab.component';
@@ -20,7 +27,7 @@ import { NavigableTabComponent } from './navigable-tab.component';
2027
template: `
2128
<div class="tab-group">
2229
<nav mat-tab-nav-bar *htLetAsync="this.activeTab$ as activeTab" disableRipple>
23-
<ng-container *ngFor="let tab of this.tabs">
30+
<ng-container *ngFor="let tab of this.tabs$ | async">
2431
<ng-container *ngIf="!tab.hidden">
2532
<div class="tab-button" *htIfFeature="tab.featureFlags | htFeature as featureState">
2633
<ht-link
@@ -53,19 +60,21 @@ import { NavigableTabComponent } from './navigable-tab.component';
5360
})
5461
export class NavigableTabGroupComponent implements AfterContentInit {
5562
@ContentChildren(NavigableTabComponent)
56-
public tabs!: QueryList<NavigableTabComponent>;
63+
private readonly tabs!: QueryList<NavigableTabComponent>;
5764

5865
@Output()
5966
public readonly tabChange: EventEmitter<string | undefined> = new EventEmitter<string | undefined>();
6067

6168
public activeTab$?: Observable<NavigableTabComponent | undefined>;
69+
public tabs$!: Observable<NavigableTabComponent[]>;
6270

6371
public constructor(
6472
public readonly navigationService: NavigationService,
6573
private readonly activatedRoute: ActivatedRoute
6674
) {}
6775

6876
public ngAfterContentInit(): void {
77+
this.tabs$ = queryListAndChanges$(this.tabs).pipe(map(list => list.toArray()));
6978
this.activeTab$ = merge(this.navigationService.navigation$, this.tabs.changes).pipe(
7079
startWith(undefined),
7180
map(() => this.findActiveTab()),

0 commit comments

Comments
 (0)