Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 4cc16be

Browse files
committed
fix(plugins/plugin-client-common): improve display of empty watch tables
Fixes #5176
1 parent 01ff6c7 commit 4cc16be

File tree

8 files changed

+22
-20
lines changed

8 files changed

+22
-20
lines changed

packages/test/src/api/selectors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ export const TABLE_AS_LIST = (N: number) => `${OUTPUT_N(N)} .bx--data-table:not(
134134
const _TABLE_TITLE = `.kui--data-table-title`
135135
export const TABLE_TITLE = (N: number) => `${OUTPUT_N(N)} ${_TABLE_TITLE}`
136136

137-
export const TABLE_TITLE_SECONDARY = (N: number) => `${OUTPUT_N(N)} .kui--secondary-breadcrumb`
137+
export const TABLE_TITLE_SECONDARY = (N: number) => `${OUTPUT_N(N)} .kui--secondary-breadcrumb:first-child`
138+
export const TABLE_TITLE_NROWS = (N: number) => `${OUTPUT_N(N)} .kui--nrows-breadcrumb`
138139
export const BY_NAME = (name: string) => `tbody [data-name="${name}"]`
139140
export const LIST_RESULT_FIRST = 'tbody tr:first-child .clickable'
140141
export const LIST_RESULT_BY_N_AND_NAME = (N: number, name: string) =>

plugins/plugin-client-common/i18n/resources_en_US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"Status Grid": "Status Grid",
55
"No resources": "No resources",
66
"nRows": "{0} rows",
7+
"nRows1": "1 row",
78
"New Tab": "Open a new tab",
89
"Close this tab": "Close this tab",
910
"Split the Terminal": "Split the Terminal",

plugins/plugin-client-common/src/components/Content/Table/LivePaginatedTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default class LivePaginatedTable extends PaginatedTable<LiveProps, LiveSt
4848
/** Render the component */
4949
public render() {
5050
if (this.props.onRender) {
51-
setTimeout(() => this.props.onRender(this.state.rows.length > 0))
51+
setTimeout(() => this.props.onRender(true))
5252
}
5353
return (
5454
<div data-table-watching={this.state.isWatching} data-table-as-grid={this.state.asGrid}>

plugins/plugin-client-common/src/components/Content/Table/PaginatedTable.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Tab, REPL, Table as KuiTable, TableStyle, i18n } from '@kui-shell/core'
17+
import { Tab, REPL, Table as KuiTable, TableStyle, i18n, isWatchable } from '@kui-shell/core'
1818

1919
import * as React from 'react'
2020
import { DataTable, DataTableHeader, TableContainer, Table } from 'carbon-components-react'
@@ -138,8 +138,14 @@ export default class PaginatedTable<P extends Props, S extends State> extends Re
138138
? []
139139
: getBreadcrumbsFromTable(this.props.response, this.props.prefixBreadcrumbs)
140140

141-
if (this.props.response.body.length > 1 && !this.state.asGrid) {
142-
breadcrumbs.push({ label: strings('nRows', this.props.response.body.length) })
141+
if (!this.state.asGrid) {
142+
const nRows = this.props.response.body.length
143+
if (nRows > 1 || isWatchable(this.props.response)) {
144+
breadcrumbs.push({
145+
label: nRows === 1 ? strings('nRows1') : strings('nRows', nRows),
146+
className: 'kui--secondary-breadcrumb kui--nrows-breadcrumb'
147+
})
148+
}
143149
}
144150

145151
if (breadcrumbs.length > 0) {

plugins/plugin-client-common/src/components/Views/Terminal/Block/Output.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ import {
2727
eventChannelUnsafe,
2828
Tab as KuiTab,
2929
Stream,
30-
Streamable,
31-
isWatchable
30+
Streamable
3231
} from '@kui-shell/core'
3332

3433
import { BlockViewTraits } from './'
@@ -196,7 +195,7 @@ export default class Output extends React.PureComponent<Props, State> {
196195
isHTML(response) ||
197196
isMarkdownResponse(response) ||
198197
(typeof response === 'string' && response.length > 0) ||
199-
(isTable(response) && response.body.length > 0) ||
198+
isTable(response) ||
200199
isMixedResponse(response) ||
201200
this.state.streamingOutput.length > 0
202201
)
@@ -209,11 +208,6 @@ export default class Output extends React.PureComponent<Props, State> {
209208
if (isOk(this.props.model)) {
210209
if (hasContent) {
211210
return <div className="ok" />
212-
} else if (isWatchable(this.props.model.response)) {
213-
return (
214-
// <div className="kui--hero-text">{strings('No resources')}</div>
215-
<div className="ok">{strings('No resources')}</div>
216-
)
217211
} else {
218212
return <div className="ok">{strings('ok')}</div>
219213
}

plugins/plugin-client-common/web/scss/components/Table/sizing.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
$min-body-height: 2rem;
1718
$max-body-height: 36rem;
1819
$min-body-width: 22rem;
1920
$secondary-column-max-width: 9rem;

plugins/plugin-client-common/web/scss/components/Table/tables.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
@import '../Table/sizing';
17+
@import './sizing';
1818
@import '../common/narrow-window';
1919

2020
body[kui-theme-style] {
@@ -199,6 +199,7 @@ body[kui-theme-style] .kui--data-table-wrapper {
199199
.kui--data-table-container {
200200
min-width: $min-body-width;
201201
max-height: $max-body-height;
202+
min-height: $min-body-height;
202203
overflow: auto;
203204
}
204205
}

plugins/plugin-kubectl/src/test/k8s2/aaa-watch-error-handling-via-table.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019 IBM Corporation
2+
* Copyright 2019-2020 IBM Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import * as assert from 'assert'
18-
1917
import { Common, CLI, ReplExpect, Selectors } from '@kui-shell/test'
2018
import { createNS, waitForGreen, waitForRed } from '@kui-shell/plugin-kubectl/tests/lib/k8s/utils'
2119

@@ -76,11 +74,11 @@ wdescribe(`kubectl watch error handler via table ${process.env.MOCHA_RUN_TARGET
7674
await this.app.client.waitForExist(Selectors.OK_N(count), CLI.waitTimeout)
7775

7876
await this.app.client.waitUntil(async () => {
79-
const emptyWatchText = await this.app.client.getText(Selectors.OK_N(count))
77+
const emptyWatchText = await this.app.client.getText(Selectors.TABLE_TITLE_NROWS(count))
8078
if (positive) {
81-
return emptyWatchText.includes('No resources')
79+
return emptyWatchText.includes('0') // e.g. "0 rows"
8280
} else {
83-
return !emptyWatchText.includes('No resources')
81+
return !emptyWatchText.includes('0') // better not have "0 rows"
8482
}
8583
}, CLI.waitTimeout)
8684
}

0 commit comments

Comments
 (0)