Skip to content

Commit 899d939

Browse files
Merge branch 'main' into scoped-storage
2 parents aec5d90 + 5d2c2eb commit 899d939

File tree

5 files changed

+57
-14
lines changed

5 files changed

+57
-14
lines changed

projects/components/src/overlay/sheet/sheet-overlay.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ $box-shadow: -3px 0px 24px rgba(0, 0, 0, 0.12), -1px 0px 8px rgba(0, 0, 0, 0.08)
2828
@include header-4($gray-7);
2929
margin: 0;
3030
}
31+
32+
.action-buttons {
33+
display: flex;
34+
align-items: center;
35+
gap: 24px;
36+
}
3137
}
3238

3339
.content-wrapper {

projects/components/src/overlay/sheet/sheet-overlay.component.test.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { ChangeDetectionStrategy, Component, Inject, Injector, Optional } from '@angular/core';
2-
import { GLOBAL_HEADER_HEIGHT, LayoutChangeService } from '@hypertrace/common';
3-
import { POPOVER_DATA } from '@hypertrace/components';
2+
import {
3+
ExternalNavigationWindowHandling,
4+
GLOBAL_HEADER_HEIGHT,
5+
LayoutChangeService,
6+
NavigationParamsType
7+
} from '@hypertrace/common';
8+
import { OpenInNewTabComponent, POPOVER_DATA } from '@hypertrace/components';
49
import { createHostFactory, mockProvider, Spectator } from '@ngneat/spectator/jest';
510
import { MockComponent } from 'ng-mocks';
611
import { ButtonComponent } from '../../button/button.component';
@@ -26,7 +31,7 @@ describe('Sheet Overlay component', () => {
2631

2732
const createHost = createHostFactory({
2833
component: SheetOverlayComponent,
29-
declarations: [MockComponent(ButtonComponent), TestComponent],
34+
declarations: [MockComponent(ButtonComponent), TestComponent, MockComponent(OpenInNewTabComponent)],
3035
shallow: true,
3136
template: `
3237
<ht-sheet-overlay>
@@ -151,4 +156,26 @@ describe('Sheet Overlay component', () => {
151156

152157
expect(spectator.query(TestComponent)?.data).toBe(42);
153158
});
159+
160+
test('should show open in new tab button if applicable', () => {
161+
spectator = createConfiguredHost({
162+
pageNavParams: {
163+
navType: NavigationParamsType.External,
164+
url: '/test',
165+
windowHandling: ExternalNavigationWindowHandling.NewWindow
166+
}
167+
});
168+
169+
expect(spectator.query(OpenInNewTabComponent)?.paramsOrUrl).toEqual({
170+
navType: NavigationParamsType.External,
171+
url: '/test',
172+
windowHandling: ExternalNavigationWindowHandling.NewWindow
173+
});
174+
});
175+
176+
test('should not show open in new tab button if config is empty', () => {
177+
spectator = createConfiguredHost();
178+
179+
expect(spectator.query(OpenInNewTabComponent)).not.toExist();
180+
});
154181
});

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ChangeDetectionStrategy, Component, HostListener, Inject, Injector, TemplateRef, Type } from '@angular/core';
22
import { IconType } from '@hypertrace/assets-library';
3-
import { GLOBAL_HEADER_HEIGHT, LayoutChangeService } from '@hypertrace/common';
3+
import { ExternalNavigationParams, GLOBAL_HEADER_HEIGHT, LayoutChangeService } from '@hypertrace/common';
44
import { ButtonStyle } from '../../button/button';
55
import { IconSize } from '../../icon/icon-size';
66
import { PopoverFixedPositionLocation, POPOVER_DATA } from '../../popover/popover';
@@ -18,14 +18,20 @@ import { SheetOverlayConfig, SheetSize } from './sheet';
1818
<ng-container *ngIf="!this.isViewCollapsed">
1919
<div *ngIf="this.showHeader" class="header">
2020
<h3 class="header-title">{{ sheetTitle }}</h3>
21-
<ht-button
22-
class="close-button"
23-
icon="${IconType.CloseCircle}"
24-
display="${ButtonStyle.Outlined}"
25-
htTooltip="Close Sheet"
26-
(click)="this.close()"
27-
>
28-
</ht-button>
21+
<div class="action-buttons">
22+
<ht-open-in-new-tab
23+
*ngIf="this.navigationParams"
24+
[paramsOrUrl]="this.navigationParams"
25+
></ht-open-in-new-tab>
26+
<ht-button
27+
class="close-button"
28+
icon="${IconType.CloseCircle}"
29+
display="${ButtonStyle.Outlined}"
30+
htTooltip="Close Sheet"
31+
(click)="this.close()"
32+
>
33+
</ht-button>
34+
</div>
2935
</div>
3036
<div class="content-wrapper">
3137
<div class="content">
@@ -61,6 +67,7 @@ export class SheetOverlayComponent {
6167
public readonly closeOnEscape: boolean;
6268
public readonly attachedTriggerTemplate?: TemplateRef<unknown>;
6369
public isViewCollapsed: boolean;
70+
public navigationParams: ExternalNavigationParams | undefined;
6471

6572
public constructor(
6673
private readonly popoverRef: PopoverRef,
@@ -80,7 +87,7 @@ export class SheetOverlayComponent {
8087
this.renderer = sheetConfig.content;
8188
this.popoverRef.height(this.getHeightForPopover(globalHeaderHeight, sheetConfig.position));
8289
this.setWidth();
83-
90+
this.navigationParams = sheetConfig.pageNavParams;
8491
this.rendererInjector = Injector.create({
8592
providers: [
8693
{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { CommonModule } from '@angular/common';
22
import { NgModule } from '@angular/core';
33
import { ButtonModule } from '../../button/button.module';
44
import { IconModule } from '../../icon/icon.module';
5+
import { OpenInNewTabModule } from '../../open-in-new-tab/open-in-new-tab.module';
56
import { TooltipModule } from '../../tooltip/tooltip.module';
67
import { SheetOverlayComponent } from './sheet-overlay.component';
78

89
@NgModule({
9-
imports: [CommonModule, ButtonModule, TooltipModule, IconModule],
10+
imports: [CommonModule, ButtonModule, TooltipModule, IconModule, OpenInNewTabModule],
1011
declarations: [SheetOverlayComponent],
1112
exports: [SheetOverlayComponent]
1213
})

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { InjectionToken, TemplateRef } from '@angular/core';
2+
import { ExternalNavigationParams } from '@hypertrace/common';
23
import { Observable } from 'rxjs';
34
import { PopoverFixedPositionLocation } from '../../popover/popover';
45
import { OverlayConfig } from './../overlay';
@@ -10,6 +11,7 @@ export interface SheetOverlayConfig<TData = unknown> extends OverlayConfig {
1011
closeOnEscapeKey?: boolean;
1112
closeOnNavigation?: boolean;
1213
attachedTriggerTemplate?: TemplateRef<unknown>;
14+
pageNavParams?: ExternalNavigationParams;
1315
}
1416

1517
export const enum SheetSize {

0 commit comments

Comments
 (0)