Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/tree/browser/tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import '../../../style/tree/tree-common.css';
import '../../../style/tree/tree.css';

import { ConfigProvider, Table } from 'antd';
import { ConfigProvider, Spin, Table } from 'antd';
import { ColumnType, ExpandableConfig } from 'antd/es/table/interface';
import classNames from 'classnames';
import { Resizable } from 're-resizable';
Expand Down Expand Up @@ -56,6 +56,11 @@ export type CDTTreeProps<T extends CDTTreeItemResource = CDTTreeItemResource> =
* Data source to be rendered.
*/
dataSource?: CDTTreeItem<T>[];
/**
* Whether the tree data is still loading.
* Defaults to true while the data source or column definitions are undefined.
*/
loading?: boolean;
/**
* Function to sort the data source.
*/
Expand Down Expand Up @@ -230,6 +235,7 @@ export const CDTTree = <T extends CDTTreeItemResource>(props: CDTTreeProps<T>) =
const tblRef: Parameters<typeof Table>[0]['ref'] = React.useRef(null);

const isBackendSearch = props.search?.mode === 'backend';
const loading = props.loading ?? (props.dataSource === undefined || props.columnDefinitions === undefined);

// ==== Data ====

Expand Down Expand Up @@ -661,7 +667,15 @@ export const CDTTree = <T extends CDTTreeItemResource>(props: CDTTreeProps<T>) =
cssVar: true,
hashed: false
}}
renderEmpty={() => <div className={'empty-message'}>No data available.</div>}
renderEmpty={() =>
loading ? (
<div className={'empty-message loading-message'} role='status' aria-label='Loading data'>
<Spin size='small' />
</div>
) : (
<div className={'empty-message'}>No data available.</div>
)
}
Comment on lines +670 to +678
Comment on lines +670 to +678
>
<div ref={ref} tabIndex={-1} style={{ outline: 'none' }} onKeyDown={onTableKeyDown}>
<Table<CDTTreeItem<T>>
Expand Down
8 changes: 6 additions & 2 deletions style/tree/tree.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
padding-right: 8px;
}

.ant-table .tree-actions > i {
.ant-table .tree-actions>i {
cursor: pointer;
}

Expand All @@ -108,6 +108,10 @@
color: var(--vscode-editor-foreground);
}

.ant-table-empty .loading-message .ant-spin-dot-item {
background-color: var(--vscode-progressBar-background, var(--vscode-editor-foreground));
}

.ant-table-empty .ant-table-body {
overflow: hidden !important;
}
Expand All @@ -128,4 +132,4 @@

.ant-table .ant-table-row.ant-table-row-resizing .tree-actions {
display: none;
}
}
Loading