Skip to content

Commit df7f8cd

Browse files
Merge branch 'i-frame' of github.com:razorpay/hypertrace-ui into i-frame
2 parents 1f212c6 + 59b161a commit df7f8cd

26 files changed

+2373
-1968
lines changed

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
CHUNKS: ${{ needs['setup-test-batches'].outputs['test-chunks'] }}
120120

121121
- name: Upload coverage to Codecov
122-
uses: codecov/codecov-action@v1
122+
uses: codecov/codecov-action@v2
123123
with:
124124
fail_ci_if_error: true
125125

package-lock.json

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

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
"@angular/platform-browser": "^12.2.1",
3737
"@angular/platform-browser-dynamic": "^12.2.1",
3838
"@angular/router": "^12.2.1",
39-
"@apollo/client": "^3.5.7",
40-
"@fullstory/browser": "^1.4.10",
39+
"@apollo/client": "^3.5.8",
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",
@@ -76,8 +76,8 @@
7676
"@angular/cli": "12.2.1",
7777
"@angular/compiler-cli": "~12.2.1",
7878
"@angular/language-service": "~12.2.1",
79-
"@commitlint/cli": "^16.1.0",
80-
"@commitlint/config-conventional": "^16.0.0",
79+
"@commitlint/cli": "^16.2.1",
80+
"@commitlint/config-conventional": "^16.2.1",
8181
"@compodoc/compodoc": "^1.1.18",
8282
"@ngneat/spectator": "^8.3.2",
8383
"@types/d3-array": "^2.9.0",
@@ -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.10",
95+
"@types/lodash-es": "^4.17.6",
96+
"@types/mixpanel-browser": "^2.38.0",
97+
"@types/node": "^17.0.17",
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.1",
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/public-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,4 @@ export * from './time/time-unit.type';
122122
export * from './time/time';
123123

124124
// Validators
125-
export * from './utilities/validators/email-validator';
125+
export * from './utilities/validators';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { isDomainValid } from './domain-validator';
2+
3+
const VALID_DOMAINS = [
4+
'google.com',
5+
'fig.io',
6+
'hypertrace.org',
7+
'f4ncy-domain.cc',
8+
'hypertrace.co.uk',
9+
'HYPERTRACE.ORG',
10+
'HYPER.TRACE.ORG',
11+
'hyper.trace.org'
12+
];
13+
const INVALID_DOMAINS = ['.hypertrace.org.', 'hypertrace.42', 'hyper.$trace', 'hyper-trac.e'];
14+
describe('Domain validator', () => {
15+
test('can validate email lists correctly', () => {
16+
VALID_DOMAINS.forEach(domain => {
17+
expect(isDomainValid(domain)).toBeTruthy();
18+
});
19+
INVALID_DOMAINS.forEach(domain => {
20+
expect(isDomainValid(domain)).toBeFalsy();
21+
});
22+
});
23+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const DOMAIN_REGEX = new RegExp(/^.+\.[a-zA-Z]{2,}$/);
2+
3+
export const isDomainValid = (domain: string) => DOMAIN_REGEX.test(domain);
4+
5+
export const areDomainsValid = (domains: string[]) => domains.every(isDomainValid);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './domain-validator';
2+
export * from './email-validator';
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@import 'mixins';
2+
3+
.collapsible-sidebar {
4+
height: inherit;
5+
width: 220px;
6+
position: relative;
7+
border: 1px solid $gray-2;
8+
border-radius: 8px;
9+
padding: 8px;
10+
11+
.content {
12+
@include fill-container;
13+
}
14+
15+
&.collapsed {
16+
width: 40px;
17+
18+
.content {
19+
@include center-contents;
20+
21+
* {
22+
transform: rotate(-90deg);
23+
}
24+
}
25+
}
26+
27+
.string-label {
28+
@include body-1-medium($gray-7);
29+
}
30+
31+
.toggle {
32+
position: absolute;
33+
display: flex;
34+
align-items: center;
35+
bottom: clamp(10px, 10%, 72px);
36+
right: -12px;
37+
height: 28px;
38+
width: 12px;
39+
border: 1px solid $gray-2;
40+
border-left-color: white;
41+
border-radius: 0 6px 6px 0;
42+
cursor: pointer;
43+
background: white;
44+
padding-right: 4px;
45+
46+
.icon {
47+
position: relative;
48+
right: 6px;
49+
}
50+
}
51+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { fakeAsync } from '@angular/core/testing';
2+
import { IconType } from '@hypertrace/assets-library';
3+
import { createHostFactory } from '@ngneat/spectator/jest';
4+
import { MockComponent } from 'ng-mocks';
5+
import { IconComponent } from '../icon/icon.component';
6+
import { CollapsibleSidebarComponent } from './collapsible-sidebar.component';
7+
8+
describe('Collapsible Sidebar Component', () => {
9+
const createHost = createHostFactory({
10+
component: CollapsibleSidebarComponent,
11+
shallow: true,
12+
declarations: [MockComponent(IconComponent)]
13+
});
14+
15+
test('should render content correclty', fakeAsync(() => {
16+
const spectator = createHost(
17+
`<ht-collapsible-sidebar label="test-label"><div class="test-content"></div></ht-collapsible-sidebar>`
18+
);
19+
20+
expect(spectator.query(IconComponent)?.icon).toBe(IconType.TriangleRight);
21+
expect(spectator.query('.test-content')).not.toExist();
22+
expect(spectator.query('.string-label')).toHaveText('test-label');
23+
24+
spectator.click(spectator.query('.toggle') as Element);
25+
spectator.tick();
26+
27+
expect(spectator.query(IconComponent)?.icon).toBe(IconType.TriangleLeft);
28+
expect(spectator.query('.test-content')).toExist();
29+
expect(spectator.query('.string-label')).not.toExist();
30+
}));
31+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { ChangeDetectionStrategy, Component, Input, OnChanges, TemplateRef } from '@angular/core';
2+
import { IconType } from '@hypertrace/assets-library';
3+
import { IconSize } from '../icon/icon-size';
4+
5+
@Component({
6+
selector: 'ht-collapsible-sidebar',
7+
styleUrls: ['./collapsible-sidebar.component.scss'],
8+
changeDetection: ChangeDetectionStrategy.OnPush,
9+
template: `
10+
<div class="collapsible-sidebar" [ngClass]="{ collapsed: !this.isExpanded }">
11+
<div class="content">
12+
<ng-container *ngIf="this.isExpanded; else labelTemplate"><ng-content></ng-content></ng-container>
13+
</div>
14+
<ng-template #stringLabelTemplate
15+
><span class="string-label">{{ this.label }}</span></ng-template
16+
>
17+
<ng-template #labelTemplate
18+
><ng-container *ngTemplateOutlet="this.isLabelATemplate ? this.label : stringLabelTemplate"></ng-container
19+
></ng-template>
20+
<div class="toggle" (click)="this.toggleCollapseExpand()">
21+
<ht-icon
22+
class="icon"
23+
[icon]="this.isExpanded ? '${IconType.TriangleLeft}' : '${IconType.TriangleRight}'"
24+
size="${IconSize.Small}"
25+
></ht-icon>
26+
</div>
27+
</div>
28+
`
29+
})
30+
export class CollapsibleSidebarComponent implements OnChanges {
31+
@Input()
32+
public label: string | TemplateRef<unknown> = '';
33+
34+
@Input()
35+
public expanded: boolean = false;
36+
37+
public isExpanded: boolean = false;
38+
39+
public ngOnChanges(): void {
40+
this.isExpanded = this.expanded;
41+
}
42+
43+
public get isLabelATemplate(): boolean {
44+
return typeof this.label !== 'string';
45+
}
46+
47+
public toggleCollapseExpand(): void {
48+
this.isExpanded = !this.isExpanded;
49+
}
50+
}

0 commit comments

Comments
 (0)