mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-04 08:25:26 +03:00
fix(nodes): show the empty state when no node is registered
An empty list page says so. ef99e675 (#7342) replaced the Ant Design
table with a hand-rolled one and rendered it only when a remote node
exists, so the Nodes page lost its "Nothing here yet" row and showed a
blank body under the heading.
The table now always renders its column headings, with the empty state
as a row beneath them. The Master and All nodes rows stay hidden until
a remote is registered; that part of #7342 was deliberate.
The test that pinned "no table at all" asserted the regression together
with the deliberate rule, so it now pins only the system rows.
This commit is contained in:
@@ -172,6 +172,17 @@
|
||||
border-radius: 12px;
|
||||
background: var(--node-card);
|
||||
}
|
||||
/* Global class shared with the other list pages: re-declared here so a direct
|
||||
/nodes load styles it, and kept identical so no page restyles another's. */
|
||||
.card-empty {
|
||||
text-align: center;
|
||||
color: var(--ant-color-text-secondary);
|
||||
padding: 24px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.nodes-table-scroll {
|
||||
overflow-x: auto;
|
||||
container-type: inline-size;
|
||||
|
||||
@@ -16,6 +16,7 @@ import type { BadgeProps } from 'antd';
|
||||
import {
|
||||
ApartmentOutlined,
|
||||
CloudDownloadOutlined,
|
||||
ClusterOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
ExclamationCircleOutlined,
|
||||
@@ -667,6 +668,16 @@ export default function NodeList({
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.length === 0 && (
|
||||
<tr className="node-empty-row">
|
||||
<td colSpan={headers.length}>
|
||||
<div className="card-empty">
|
||||
<ClusterOutlined aria-hidden style={{ fontSize: 32 }} />
|
||||
<div>{t('noData')}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{rows.map((row) => {
|
||||
const remote = row.kind === 'remote' ? row.node : undefined;
|
||||
const managed = remote && !remote.transitive ? remote : undefined;
|
||||
@@ -1049,58 +1060,58 @@ export default function NodeList({
|
||||
</div>
|
||||
</header>
|
||||
{hasNodes && (
|
||||
<>
|
||||
<div className="nodes-toolbar">
|
||||
<Input
|
||||
type="search"
|
||||
prefix={<SearchOutlined aria-hidden />}
|
||||
aria-label={t('search')}
|
||||
placeholder={t('pages.nodes.fleet.searchNodes')}
|
||||
allowClear
|
||||
value={search}
|
||||
onChange={(event) => setSearch(event.target.value)}
|
||||
/>
|
||||
<Select
|
||||
aria-label={t('pages.nodes.status')}
|
||||
options={filterOptions}
|
||||
value={filter}
|
||||
onChange={setFilter}
|
||||
/>
|
||||
{selectedIds.length > 0 && (
|
||||
<Button icon={<CloudDownloadOutlined aria-hidden />} onClick={onUpdateSelected}>
|
||||
{t('pages.nodes.updateSelected', { count: selectedIds.length })}
|
||||
</Button>
|
||||
)}
|
||||
<span className="node-registered">
|
||||
{t('pages.nodes.fleet.registered', {
|
||||
remotes: nodes.length,
|
||||
total: nodes.length + 1,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
{table}
|
||||
<div className="nodes-footnote">
|
||||
<span>
|
||||
{t('pages.nodes.fleet.footnote', {
|
||||
coverage: summary
|
||||
? summary.reporting + '/' + summary.registered
|
||||
: rows.some((row) => row.kind === 'master' && reportingSample(row.telemetry))
|
||||
? '1/1'
|
||||
: '0/1',
|
||||
})}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
className="node-icon-action"
|
||||
aria-label={t('pages.index.toggleIpVisibility')}
|
||||
aria-pressed={showAddress}
|
||||
title={t('pages.index.toggleIpVisibility')}
|
||||
onClick={() => setShowAddress((visible) => !visible)}
|
||||
>
|
||||
{showAddress ? <EyeOutlined aria-hidden /> : <EyeInvisibleOutlined aria-hidden />}
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
<div className="nodes-toolbar">
|
||||
<Input
|
||||
type="search"
|
||||
prefix={<SearchOutlined aria-hidden />}
|
||||
aria-label={t('search')}
|
||||
placeholder={t('pages.nodes.fleet.searchNodes')}
|
||||
allowClear
|
||||
value={search}
|
||||
onChange={(event) => setSearch(event.target.value)}
|
||||
/>
|
||||
<Select
|
||||
aria-label={t('pages.nodes.status')}
|
||||
options={filterOptions}
|
||||
value={filter}
|
||||
onChange={setFilter}
|
||||
/>
|
||||
{selectedIds.length > 0 && (
|
||||
<Button icon={<CloudDownloadOutlined aria-hidden />} onClick={onUpdateSelected}>
|
||||
{t('pages.nodes.updateSelected', { count: selectedIds.length })}
|
||||
</Button>
|
||||
)}
|
||||
<span className="node-registered">
|
||||
{t('pages.nodes.fleet.registered', {
|
||||
remotes: nodes.length,
|
||||
total: nodes.length + 1,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{table}
|
||||
{hasNodes && (
|
||||
<div className="nodes-footnote">
|
||||
<span>
|
||||
{t('pages.nodes.fleet.footnote', {
|
||||
coverage: summary
|
||||
? summary.reporting + '/' + summary.registered
|
||||
: rows.some((row) => row.kind === 'master' && reportingSample(row.telemetry))
|
||||
? '1/1'
|
||||
: '0/1',
|
||||
})}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
className="node-icon-action"
|
||||
aria-label={t('pages.index.toggleIpVisibility')}
|
||||
aria-pressed={showAddress}
|
||||
title={t('pages.index.toggleIpVisibility')}
|
||||
onClick={() => setShowAddress((visible) => !visible)}
|
||||
>
|
||||
{showAddress ? <EyeOutlined aria-hidden /> : <EyeInvisibleOutlined aria-hidden />}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -43,7 +43,7 @@ it('hides Master and All nodes without a remote, even with fresh Master telemetr
|
||||
);
|
||||
}
|
||||
const view = renderWithProviders(list([]));
|
||||
expect(screen.queryByRole('table')).toBeNull();
|
||||
expect(screen.getAllByRole('row')).toHaveLength(2);
|
||||
expect(screen.queryByRole('searchbox')).toBeNull();
|
||||
expect(screen.queryByText('All nodes')).toBeNull();
|
||||
expect(screen.queryByRole('rowheader', { name: 'Master' })).toBeNull();
|
||||
@@ -60,10 +60,32 @@ it('hides Master and All nodes without a remote, even with fresh Master telemetr
|
||||
expect(screen.getAllByRole('row')).toHaveLength(3);
|
||||
expect(screen.getByText('1/2 reporting')).toBeTruthy();
|
||||
view.rerender(list([]));
|
||||
expect(screen.queryByRole('table')).toBeNull();
|
||||
expect(screen.getAllByRole('row')).toHaveLength(2);
|
||||
expect(screen.queryByText(/totals use reporting nodes/)).toBeNull();
|
||||
});
|
||||
|
||||
it('keeps the column headings over an empty-state row until a remote is registered', () => {
|
||||
function list(nodes: NodeRecord[]) {
|
||||
return (
|
||||
<NodeList
|
||||
{...actions}
|
||||
nodes={nodes}
|
||||
master={{ counts }}
|
||||
fleet={counts}
|
||||
selectedIds={[]}
|
||||
onSelectionChange={noop}
|
||||
/>
|
||||
);
|
||||
}
|
||||
const view = renderWithProviders(list([]));
|
||||
const table = within(screen.getByRole('table'));
|
||||
expect(table.getByRole('columnheader', { name: 'Status' })).toBeTruthy();
|
||||
expect(table.getByRole('cell', { name: 'Nothing here yet' })).toBeTruthy();
|
||||
view.rerender(list([{ id: 1, name: 'edge', enable: true, status: 'online' }]));
|
||||
expect(screen.queryByText('Nothing here yet')).toBeNull();
|
||||
expect(screen.getByRole('rowheader', { name: 'edge' })).toBeTruthy();
|
||||
});
|
||||
|
||||
it('expires only the stale host and keeps weighted RAM and live byte rates separate', () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user