Skip to content

Commit 36af83c

Browse files
committed
Merge branch 'DateRangeOverflowing' of github.com:hypertrace/hypertrace-ui into DateRangeOverflowing
2 parents 7f8ab4b + c0ff17d commit 36af83c

File tree

7 files changed

+63
-5
lines changed

7 files changed

+63
-5
lines changed

projects/components/src/filtering/filter/filter-url.service.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,28 @@ export class FilterUrlService {
2323
private readonly filterParserLookupService: FilterParserLookupService
2424
) {}
2525

26+
public getUrlFilteringStateChanges$(attributes: FilterAttribute[]): Observable<UrlFilteringState> {
27+
return this.navigationService.navigation$.pipe(map(() => this.getUrlFilteringState(attributes)));
28+
}
29+
30+
public getUrlFilteringState(attributes: FilterAttribute[]): UrlFilteringState {
31+
const attributeMap = new Map(attributes.map(attribute => [attribute.name, attribute]));
32+
33+
return {
34+
filters: this.getUrlFilters(attributes),
35+
groupBy: this.getUrlGroupBy()
36+
.map(attributeName => attributeMap.get(attributeName))
37+
.filter((attribute): attribute is FilterAttribute => attribute !== undefined)
38+
};
39+
}
40+
41+
public setUrlFiltersAndGroupBy(filters: Filter[], groupBy: FilterAttribute[]): void {
42+
this.navigationService.addQueryParametersToUrl({
43+
[FilterUrlService.FILTER_QUERY_PARAM]: filters.length === 0 ? undefined : filters.map(f => f.urlString),
44+
[FilterUrlService.GROUP_BY_QUERY_PARAM]: isEmpty(groupBy) ? undefined : [groupBy.map(g => g.name).toString()]
45+
});
46+
}
47+
2648
public getUrlFiltersChanges$(attributes: FilterAttribute[]): Observable<Filter[]> {
2749
return this.navigationService.navigation$.pipe(map(() => this.getUrlFilters(attributes)));
2850
}
@@ -119,3 +141,8 @@ export class FilterUrlService {
119141
.find(splitFilter => splitFilter !== undefined);
120142
}
121143
}
144+
145+
export interface UrlFilteringState {
146+
filters: Filter[];
147+
groupBy: FilterAttribute[];
148+
}

projects/components/src/filtering/filter/parser/filter-parser-lookup.service.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ describe('Filter Parser Lookup service', () => {
180180
value: 'myString'
181181
});
182182

183+
expect(
184+
spectator.service.lookup(FilterOperator.In).parseSplitFilter({
185+
attribute: getTestFilterAttribute(FilterAttributeType.StringArray),
186+
operator: FilterOperator.In,
187+
rhs: 'myStr, myString'
188+
})
189+
).toEqual({
190+
field: 'stringArrayAttribute',
191+
operator: FilterOperator.In,
192+
value: ['myStr', 'myString']
193+
});
194+
183195
expect(
184196
spectator.service.lookup(FilterOperator.In).parseSplitFilter({
185197
attribute: getTestFilterAttribute(FilterAttributeType.String),

projects/components/src/filtering/filter/parser/types/in-filter-parser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export class InFilterParser extends AbstractFilterParser<PossibleValuesTypes> {
2222
case FilterAttributeType.Number:
2323
return this.parseNumberArrayValue(splitFilter.rhs);
2424
case FilterAttributeType.Boolean: // Unsupported
25-
case FilterAttributeType.StringArray: // Unsupported
25+
case FilterAttributeType.StringArray:
26+
return this.parseStringArrayValue(splitFilter.rhs);
2627
case FilterAttributeType.Timestamp: // Unsupported
2728
return undefined;
2829
default:

projects/components/src/overlay/overlay.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ export class OverlayService {
3535
data: metadata
3636
});
3737

38-
popover.closeOnNavigation();
38+
if (config.closeOnNavigation !== false) {
39+
popover.closeOnNavigation();
40+
}
41+
3942
sheetRef.initialize(popover);
4043

4144
this.setActiveSheetPopover(popover);
@@ -71,7 +74,6 @@ export class OverlayService {
7174
this.activeSheetPopover?.close();
7275

7376
this.activeSheetPopover = popover;
74-
this.activeSheetPopover.closeOnNavigation();
7577
this.sheetCloseSubscription = this.activeSheetPopover.closed$.subscribe(
7678
() => (this.activeSheetPopover = undefined)
7779
);

projects/components/src/overlay/sheet/default-sheet-ref.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,12 @@ export class DefaultSheetRef extends SheetRef {
2929
}
3030
this.popoverRef?.close();
3131
}
32+
33+
public show(): void {
34+
this.popoverRef?.show();
35+
}
36+
37+
public hide(): void {
38+
this.popoverRef?.hide();
39+
}
3240
}

projects/components/src/overlay/sheet/sheet.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface SheetOverlayConfig<TData = unknown> extends OverlayConfig {
88
data?: TData;
99
position?: PopoverFixedPositionLocation.Right | PopoverFixedPositionLocation.RightUnderHeader;
1010
closeOnEscapeKey?: boolean;
11+
closeOnNavigation?: boolean;
1112
attachedTriggerTemplate?: TemplateRef<unknown>;
1213
}
1314

@@ -24,4 +25,6 @@ export const SHEET_DATA = new InjectionToken<unknown>('SHEET_DATA');
2425
export abstract class SheetRef<TResult = unknown> {
2526
public abstract readonly closed$: Observable<TResult>;
2627
public abstract close(result?: TResult): void;
28+
public abstract show(): void;
29+
public abstract hide(): void;
2730
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,12 @@ export class SelectComponent<V> implements ControlValueAccessor, AfterContentIni
321321
}
322322

323323
this.setSelection(item.value);
324-
this.selectedChange.emit(this.selected);
325-
this.propagateValueChangeToFormControl(this.selected);
324+
this.propagateValue();
326325
}
327326

328327
public onClearSelected(): void {
329328
this.setSelection();
329+
this.propagateValue();
330330
}
331331

332332
private setSelection(value?: V): void {
@@ -371,6 +371,11 @@ export class SelectComponent<V> implements ControlValueAccessor, AfterContentIni
371371
this.disabled = isDisabled ?? false;
372372
}
373373

374+
private propagateValue(): void {
375+
this.selectedChange.emit(this.selected);
376+
this.propagateValueChangeToFormControl(this.selected);
377+
}
378+
374379
private propagateValueChangeToFormControl(value: V | undefined): void {
375380
this.propagateControlValueChange?.(value);
376381
this.propagateControlValueChangeOnTouch?.(value);

0 commit comments

Comments
 (0)