Skip to content

Commit

Permalink
Merge pull request #19 from ameukam/fix-linting-errors
Browse files Browse the repository at this point in the history
Fix linting issues
  • Loading branch information
k8s-ci-robot authored Nov 28, 2024
2 parents a6d93a9 + 16f8f40 commit 782510e
Show file tree
Hide file tree
Showing 22 changed files with 443 additions and 338 deletions.
36 changes: 21 additions & 15 deletions web/src/tab-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,36 @@ export class TabSummary extends LitElement {
</div>
</div>
</div>
${this.info?.failuresSummary !== undefined ?
html `<testgrid-failures-summary .info=${this.info}>
</testgrid-failures-summary>`:''}
${this.info?.healthinessSummary !== undefined ?
html `<testgrid-healthiness-summary .info=${this.info}>
</testgrid-healthiness-summary>`:''}
${this.info?.failuresSummary !== undefined
? html`<testgrid-failures-summary .info=${this.info}>
</testgrid-failures-summary>`
: ''}
${this.info?.healthinessSummary !== undefined
? html`<testgrid-healthiness-summary .info=${this.info}>
</testgrid-healthiness-summary>`
: ''}
`;
}

/**
* Lets the data content element know that the tab changed
*
* @fires tab-changed
* @param tabName string
*/
private changeTab(){
window.dispatchEvent(new CustomEvent('tab-changed',{
detail: {
tabName: this.info?.name!
},
}))
private changeTab() {
window.dispatchEvent(
new CustomEvent('tab-changed', {
detail: {
tabName: this.info?.name!,
},
})
);
}

static styles = css`
.tab-name { // title/link in each Summary card
.tab-name {
// title/link in each Summary card
cursor: pointer;
position: relative;
padding: 4px 8px;
Expand All @@ -86,7 +92,8 @@ export class TabSummary extends LitElement {
align-items: center;
}
.tab-name { // title/link in each Summary card
.tab-name {
// title/link in each Summary card
cursor: pointer;
position: relative;
padding: 4px 8px;
Expand Down Expand Up @@ -136,5 +143,4 @@ export class TabSummary extends LitElement {
background-color: #000;
}
`;

}
10 changes: 5 additions & 5 deletions web/src/testgrid-app.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { LitElement, html } from "lit";
import { customElement } from "lit/decorators.js";
import './testgrid-router'
import { LitElement, html } from 'lit';
import { customElement } from 'lit/decorators.js';
import './testgrid-router';

/**
* Class definition for the `testgrid-app` element.
* Application root element.
*/
@customElement('testgrid-app')
export class TestgridApp extends LitElement{
export class TestgridApp extends LitElement {
/**
* Lit-element lifecycle method.
* Invoked on each update to perform rendering tasks.
*/
render(){
render() {
return html`<testgrid-router></testgrid-router>`;
}
}
2 changes: 1 addition & 1 deletion web/src/testgrid-dashboard-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class TestgridDashboardSummary extends LitElement {
throw new Error(`HTTP error: ${response.status}`);
}
const data = ListTabSummariesResponse.fromJson(await response.json());
var tabSummaries: Array<TabSummaryInfo> = [];
const tabSummaries: Array<TabSummaryInfo> = [];
data.tabSummaries.forEach(ts => {
const si = convertResponse(ts);
tabSummaries.push(si);
Expand Down
60 changes: 35 additions & 25 deletions web/src/testgrid-data-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import './testgrid-grid';
@customElement('testgrid-data-content')
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export class TestgridDataContent extends LitElement {

@state()
tabNames: string[] = [];

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

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

if (tabIndex === this.activeIndex){
return
if (tabIndex === this.activeIndex) {
return;
}

this.tabName = this.tabNames[tabIndex];

if (this.activeIndex === 0 || tabIndex === 0){
if (this.activeIndex === 0 || tabIndex === 0) {
this.showTab = !this.showTab;
}
this.activeIndex = tabIndex;
navigateTab(this.dashboardName, this.tabName)
navigateTab(this.dashboardName, this.tabName);
}

/**
Expand All @@ -64,36 +63,47 @@ export class TestgridDataContent extends LitElement {
navigateTab(this.dashboardName, this.tabName!);
});
window.addEventListener('popstate', () => {
console.log(location.pathname);
console.log(location.pathname.split('/'));
if (location.pathname.split('/').length === 2){
console.log(window.location.pathname);
console.log(window.location.pathname.split('/'));
if (location.pathname.split('/').length === 2) {
this.showTab = false;
this.tabName = undefined;
this.highlightIndex(this.tabName);
navigateTab(this.dashboardName, this.tabName!);
}
})
});
}

/**
* Lit-element lifecycle method.
* Invoked on each update to perform rendering tasks.
*/
render() {
var tabBar = html`${
const tabBar = html`${
// make sure we only render the tabs when there are tabs
when(this.tabNames.length > 0, () => html`
<mwc-tab-bar .activeIndex=${this.activeIndex} @MDCTabBar:activated="${this.onTabActivated}">
when(
this.tabNames.length > 0,
() => html` <mwc-tab-bar
.activeIndex=${this.activeIndex}
@MDCTabBar:activated="${this.onTabActivated}"
>
${map(
this.tabNames,(name: string) => html`<mwc-tab label=${name}></mwc-tab>`
this.tabNames,
(name: string) => html`<mwc-tab label=${name}></mwc-tab>`
)}
</mwc-tab-bar>`)
</mwc-tab-bar>`
)
}`;
return html`
${tabBar}
${!this.showTab ?
html`<testgrid-dashboard-summary .dashboardName=${this.dashboardName}></testgrid-dashboard-summary>` :
html`<testgrid-grid .dashboardName=${this.dashboardName} .tabName=${this.tabName}></testgrid-grid>`}
${!this.showTab
? html`<testgrid-dashboard-summary
.dashboardName=${this.dashboardName}
></testgrid-dashboard-summary>`
: html`<testgrid-grid
.dashboardName=${this.dashboardName}
.tabName=${this.tabName}
></testgrid-grid>`}
`;
}

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

// identify which tab to highlight on the tab bar
private highlightIndex(tabName: string | undefined) {
if (tabName === undefined){
if (tabName === undefined) {
this.activeIndex = 0;
return
return;
}
var index = this.tabNames.indexOf(tabName);
if (index > -1){
const index = this.tabNames.indexOf(tabName);
if (index > -1) {
this.activeIndex = index;
}
}

static styles = css`
mwc-tab{
mwc-tab {
--mdc-typography-button-letter-spacing: 0;
--mdc-tab-horizontal-padding: 12px;
--mdc-typography-button-font-size: 0.8rem;
}
`;
`;
}
4 changes: 3 additions & 1 deletion web/src/testgrid-failures-summary.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { LitElement, html, css } from 'lit';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { customElement, property, state } from 'lit/decorators.js';
import { TabSummaryInfo } from './testgrid-dashboard-summary';
import { map } from 'lit/directives/map.js';
import { TabSummaryInfo } from './testgrid-dashboard-summary';

@customElement('testgrid-failures-summary')
export class TestgridFailuresSummary extends LitElement {
@state() showFailureSummary = false;

@property() info?: TabSummaryInfo;

render() {
Expand Down Expand Up @@ -38,6 +39,7 @@ export class TestgridFailuresSummary extends LitElement {
</div>
`
}

private dropdownTable(){
this.showFailureSummary = !this.showFailureSummary;
}
Expand Down
1 change: 1 addition & 0 deletions web/src/testgrid-grid-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class TestgridGridCell extends LitElement{
`;

@property({reflect: true, attribute: 'status'}) status: String;

@property() icon: String;

render(){
Expand Down
30 changes: 20 additions & 10 deletions web/src/testgrid-grid.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { LitElement, html, PropertyValues } from "lit";
import { map } from "lit/directives/map.js";
import { customElement, property, state } from "lit/decorators.js";
import { ListHeadersResponse, ListRowsResponse, ListRowsResponse_Row } from './gen/pb/api/v1/data.js';
import { LitElement, html, PropertyValues } from 'lit';
import { map } from 'lit/directives/map.js';
import { customElement, property, state } from 'lit/decorators.js';
import {
ListHeadersResponse,
ListRowsResponse,
ListRowsResponse_Row,
} from './gen/pb/api/v1/data.js';
import './testgrid-grid-row';
import './testgrid-grid-header-row';

Expand All @@ -11,7 +15,6 @@ import './testgrid-grid-header-row';
*/
@customElement('testgrid-grid')
export class TestgridGrid extends LitElement {

@property({ type: String, reflect: true })
dashboardName: String = '';

Expand Down Expand Up @@ -40,10 +43,17 @@ export class TestgridGrid extends LitElement {
*/
render() {
return html`
<testgrid-grid-header-row .headers="${this.tabGridHeaders}"></testgrid-grid-header-row>
${map(this.tabGridRows,
(row: ListRowsResponse_Row) => html`<testgrid-grid-row .name="${row.name}" .rowData="${row}"></testgrid-grid-row>`
)}
<testgrid-grid-header-row
.headers="${this.tabGridHeaders}"
></testgrid-grid-header-row>
${map(
this.tabGridRows,
(row: ListRowsResponse_Row) =>
html`<testgrid-grid-row
.name="${row.name}"
.rowData="${row}"
></testgrid-grid-row>`
)}
`;
}

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

0 comments on commit 782510e

Please sign in to comment.