Skip to content

Commit 16f8f40

Browse files
committed
Fix linting issues
Fix some linting issues and improve readability of the codebase Signed-off-by: Arnaud Meukam <[email protected]>
1 parent a6d93a9 commit 16f8f40

22 files changed

+443
-338
lines changed

web/src/tab-summary.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,36 @@ export class TabSummary extends LitElement {
4444
</div>
4545
</div>
4646
</div>
47-
${this.info?.failuresSummary !== undefined ?
48-
html `<testgrid-failures-summary .info=${this.info}>
49-
</testgrid-failures-summary>`:''}
50-
${this.info?.healthinessSummary !== undefined ?
51-
html `<testgrid-healthiness-summary .info=${this.info}>
52-
</testgrid-healthiness-summary>`:''}
47+
${this.info?.failuresSummary !== undefined
48+
? html`<testgrid-failures-summary .info=${this.info}>
49+
</testgrid-failures-summary>`
50+
: ''}
51+
${this.info?.healthinessSummary !== undefined
52+
? html`<testgrid-healthiness-summary .info=${this.info}>
53+
</testgrid-healthiness-summary>`
54+
: ''}
5355
`;
5456
}
57+
5558
/**
5659
* Lets the data content element know that the tab changed
5760
*
5861
* @fires tab-changed
5962
* @param tabName string
6063
*/
61-
private changeTab(){
62-
window.dispatchEvent(new CustomEvent('tab-changed',{
63-
detail: {
64-
tabName: this.info?.name!
65-
},
66-
}))
64+
private changeTab() {
65+
window.dispatchEvent(
66+
new CustomEvent('tab-changed', {
67+
detail: {
68+
tabName: this.info?.name!,
69+
},
70+
})
71+
);
6772
}
6873

6974
static styles = css`
70-
.tab-name { // title/link in each Summary card
75+
.tab-name {
76+
// title/link in each Summary card
7177
cursor: pointer;
7278
position: relative;
7379
padding: 4px 8px;
@@ -86,7 +92,8 @@ export class TabSummary extends LitElement {
8692
align-items: center;
8793
}
8894
89-
.tab-name { // title/link in each Summary card
95+
.tab-name {
96+
// title/link in each Summary card
9097
cursor: pointer;
9198
position: relative;
9299
padding: 4px 8px;
@@ -136,5 +143,4 @@ export class TabSummary extends LitElement {
136143
background-color: #000;
137144
}
138145
`;
139-
140146
}

web/src/testgrid-app.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { LitElement, html } from "lit";
2-
import { customElement } from "lit/decorators.js";
3-
import './testgrid-router'
1+
import { LitElement, html } from 'lit';
2+
import { customElement } from 'lit/decorators.js';
3+
import './testgrid-router';
44

55
/**
66
* Class definition for the `testgrid-app` element.
77
* Application root element.
88
*/
99
@customElement('testgrid-app')
10-
export class TestgridApp extends LitElement{
10+
export class TestgridApp extends LitElement {
1111
/**
1212
* Lit-element lifecycle method.
1313
* Invoked on each update to perform rendering tasks.
1414
*/
15-
render(){
15+
render() {
1616
return html`<testgrid-router></testgrid-router>`;
1717
}
1818
}

web/src/testgrid-dashboard-summary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class TestgridDashboardSummary extends LitElement {
162162
throw new Error(`HTTP error: ${response.status}`);
163163
}
164164
const data = ListTabSummariesResponse.fromJson(await response.json());
165-
var tabSummaries: Array<TabSummaryInfo> = [];
165+
const tabSummaries: Array<TabSummaryInfo> = [];
166166
data.tabSummaries.forEach(ts => {
167167
const si = convertResponse(ts);
168168
tabSummaries.push(si);

web/src/testgrid-data-content.ts

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import './testgrid-grid';
1717
@customElement('testgrid-data-content')
1818
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1919
export class TestgridDataContent extends LitElement {
20-
2120
@state()
2221
tabNames: string[] = [];
2322

@@ -34,20 +33,20 @@ export class TestgridDataContent extends LitElement {
3433
tabName?: string;
3534

3635
// set the functionality when any tab is clicked on
37-
private onTabActivated(event: CustomEvent<{index: number}>) {
36+
private onTabActivated(event: CustomEvent<{ index: number }>) {
3837
const tabIndex = event.detail.index;
3938

40-
if (tabIndex === this.activeIndex){
41-
return
39+
if (tabIndex === this.activeIndex) {
40+
return;
4241
}
4342

4443
this.tabName = this.tabNames[tabIndex];
4544

46-
if (this.activeIndex === 0 || tabIndex === 0){
45+
if (this.activeIndex === 0 || tabIndex === 0) {
4746
this.showTab = !this.showTab;
4847
}
4948
this.activeIndex = tabIndex;
50-
navigateTab(this.dashboardName, this.tabName)
49+
navigateTab(this.dashboardName, this.tabName);
5150
}
5251

5352
/**
@@ -64,36 +63,47 @@ export class TestgridDataContent extends LitElement {
6463
navigateTab(this.dashboardName, this.tabName!);
6564
});
6665
window.addEventListener('popstate', () => {
67-
console.log(location.pathname);
68-
console.log(location.pathname.split('/'));
69-
if (location.pathname.split('/').length === 2){
66+
console.log(window.location.pathname);
67+
console.log(window.location.pathname.split('/'));
68+
if (location.pathname.split('/').length === 2) {
7069
this.showTab = false;
7170
this.tabName = undefined;
7271
this.highlightIndex(this.tabName);
7372
navigateTab(this.dashboardName, this.tabName!);
7473
}
75-
})
74+
});
7675
}
7776

7877
/**
7978
* Lit-element lifecycle method.
8079
* Invoked on each update to perform rendering tasks.
8180
*/
8281
render() {
83-
var tabBar = html`${
82+
const tabBar = html`${
8483
// make sure we only render the tabs when there are tabs
85-
when(this.tabNames.length > 0, () => html`
86-
<mwc-tab-bar .activeIndex=${this.activeIndex} @MDCTabBar:activated="${this.onTabActivated}">
84+
when(
85+
this.tabNames.length > 0,
86+
() => html` <mwc-tab-bar
87+
.activeIndex=${this.activeIndex}
88+
@MDCTabBar:activated="${this.onTabActivated}"
89+
>
8790
${map(
88-
this.tabNames,(name: string) => html`<mwc-tab label=${name}></mwc-tab>`
91+
this.tabNames,
92+
(name: string) => html`<mwc-tab label=${name}></mwc-tab>`
8993
)}
90-
</mwc-tab-bar>`)
94+
</mwc-tab-bar>`
95+
)
9196
}`;
9297
return html`
9398
${tabBar}
94-
${!this.showTab ?
95-
html`<testgrid-dashboard-summary .dashboardName=${this.dashboardName}></testgrid-dashboard-summary>` :
96-
html`<testgrid-grid .dashboardName=${this.dashboardName} .tabName=${this.tabName}></testgrid-grid>`}
99+
${!this.showTab
100+
? html`<testgrid-dashboard-summary
101+
.dashboardName=${this.dashboardName}
102+
></testgrid-dashboard-summary>`
103+
: html`<testgrid-grid
104+
.dashboardName=${this.dashboardName}
105+
.tabName=${this.tabName}
106+
></testgrid-grid>`}
97107
`;
98108
}
99109

@@ -107,7 +117,7 @@ export class TestgridDataContent extends LitElement {
107117
throw new Error(`HTTP error: ${response.status}`);
108118
}
109119
const data = ListDashboardTabsResponse.fromJson(await response.json());
110-
var tabNames: string[] = ['Summary'];
120+
const tabNames: string[] = ['Summary'];
111121
data.dashboardTabs.forEach(tab => {
112122
tabNames.push(tab.name);
113123
});
@@ -120,21 +130,21 @@ export class TestgridDataContent extends LitElement {
120130

121131
// identify which tab to highlight on the tab bar
122132
private highlightIndex(tabName: string | undefined) {
123-
if (tabName === undefined){
133+
if (tabName === undefined) {
124134
this.activeIndex = 0;
125-
return
135+
return;
126136
}
127-
var index = this.tabNames.indexOf(tabName);
128-
if (index > -1){
137+
const index = this.tabNames.indexOf(tabName);
138+
if (index > -1) {
129139
this.activeIndex = index;
130140
}
131141
}
132142

133143
static styles = css`
134-
mwc-tab{
144+
mwc-tab {
135145
--mdc-typography-button-letter-spacing: 0;
136146
--mdc-tab-horizontal-padding: 12px;
137147
--mdc-typography-button-font-size: 0.8rem;
138148
}
139-
`;
149+
`;
140150
}

web/src/testgrid-failures-summary.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { LitElement, html, css } from 'lit';
22
// eslint-disable-next-line @typescript-eslint/no-unused-vars
33
import { customElement, property, state } from 'lit/decorators.js';
4-
import { TabSummaryInfo } from './testgrid-dashboard-summary';
54
import { map } from 'lit/directives/map.js';
5+
import { TabSummaryInfo } from './testgrid-dashboard-summary';
66

77
@customElement('testgrid-failures-summary')
88
export class TestgridFailuresSummary extends LitElement {
99
@state() showFailureSummary = false;
10+
1011
@property() info?: TabSummaryInfo;
1112

1213
render() {
@@ -38,6 +39,7 @@ export class TestgridFailuresSummary extends LitElement {
3839
</div>
3940
`
4041
}
42+
4143
private dropdownTable(){
4244
this.showFailureSummary = !this.showFailureSummary;
4345
}

web/src/testgrid-grid-cell.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class TestgridGridCell extends LitElement{
5959
`;
6060

6161
@property({reflect: true, attribute: 'status'}) status: String;
62+
6263
@property() icon: String;
6364

6465
render(){

web/src/testgrid-grid.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { LitElement, html, PropertyValues } from "lit";
2-
import { map } from "lit/directives/map.js";
3-
import { customElement, property, state } from "lit/decorators.js";
4-
import { ListHeadersResponse, ListRowsResponse, ListRowsResponse_Row } from './gen/pb/api/v1/data.js';
1+
import { LitElement, html, PropertyValues } from 'lit';
2+
import { map } from 'lit/directives/map.js';
3+
import { customElement, property, state } from 'lit/decorators.js';
4+
import {
5+
ListHeadersResponse,
6+
ListRowsResponse,
7+
ListRowsResponse_Row,
8+
} from './gen/pb/api/v1/data.js';
59
import './testgrid-grid-row';
610
import './testgrid-grid-header-row';
711

@@ -11,7 +15,6 @@ import './testgrid-grid-header-row';
1115
*/
1216
@customElement('testgrid-grid')
1317
export class TestgridGrid extends LitElement {
14-
1518
@property({ type: String, reflect: true })
1619
dashboardName: String = '';
1720

@@ -40,10 +43,17 @@ export class TestgridGrid extends LitElement {
4043
*/
4144
render() {
4245
return html`
43-
<testgrid-grid-header-row .headers="${this.tabGridHeaders}"></testgrid-grid-header-row>
44-
${map(this.tabGridRows,
45-
(row: ListRowsResponse_Row) => html`<testgrid-grid-row .name="${row.name}" .rowData="${row}"></testgrid-grid-row>`
46-
)}
46+
<testgrid-grid-header-row
47+
.headers="${this.tabGridHeaders}"
48+
></testgrid-grid-header-row>
49+
${map(
50+
this.tabGridRows,
51+
(row: ListRowsResponse_Row) =>
52+
html`<testgrid-grid-row
53+
.name="${row.name}"
54+
.rowData="${row}"
55+
></testgrid-grid-row>`
56+
)}
4757
`;
4858
}
4959

@@ -62,7 +72,7 @@ export class TestgridGrid extends LitElement {
6272
throw new Error(`HTTP error: ${response.status}`);
6373
}
6474
const data = ListRowsResponse.fromJson(await response.json());
65-
var rows: Array<ListRowsResponse_Row> = [];
75+
const rows: Array<ListRowsResponse_Row> = [];
6676
data.rows.forEach(row => rows.push(row));
6777
this.tabGridRows = rows;
6878
} catch (error) {

0 commit comments

Comments
 (0)