1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Use empty placeholder for all generic tables

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-02-22 07:31:15 +03:00
parent 1d99ea36c4
commit 2dd06aef5e
5 changed files with 23 additions and 10 deletions

View File

@ -201,7 +201,7 @@ export class ItemListLayoutContent<I extends ItemObject> extends React.Component
if (this.props.showEmptyTablePlaceholder && this.props.renderTableHeader && this.props.tableId) { if (this.props.showEmptyTablePlaceholder && this.props.renderTableHeader && this.props.tableId) {
return ( return (
<> <>
<Placeholder renderTableHeader={this.props.renderTableHeader} tableId={this.props.tableId}/> <Placeholder renderTableHeader={this.props.renderTableHeader} tableId={this.props.tableId} showCheckColumn={this.props.isSelectable}/>
<div className="noItemsHolder"> <div className="noItemsHolder">
<NoItems>{this.props.noItemsMessage}</NoItems> <NoItems>{this.props.noItemsMessage}</NoItems>
</div> </div>

View File

@ -38,6 +38,7 @@
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
pointer-events: none;
} }
} }

View File

@ -106,6 +106,7 @@ const defaultProps: Partial<ItemListLayoutProps<ItemObject>> = {
virtual: true, virtual: true,
customizeTableRowProps: () => ({}), customizeTableRowProps: () => ({}),
failedToLoadMessage: "Failed to load items", failedToLoadMessage: "Failed to load items",
showEmptyTablePlaceholder: true,
}; };
interface Dependencies { interface Dependencies {

View File

@ -9,7 +9,10 @@
> div { > div {
flex: 1 0; flex: 1 0;
padding: 20px var(--padding); padding-top: 20px!important;
padding-right: var(--padding);
padding-bottom: 20px;
padding-left: var(--padding);
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
align-content: space-between; align-content: space-between;
@ -23,6 +26,10 @@
width: 100%; width: 100%;
} }
} }
&.checkerColumn {
flex: 0 0 32px;
}
} }
} }

View File

@ -6,16 +6,17 @@
import styles from "./placeholder.module.scss"; import styles from "./placeholder.module.scss";
import React from "react"; import React from "react";
import type { TableCellProps } from "../table"; import { TableCell, TableCellProps } from "../table";
import { UserStore } from "../../../common/user-store"; import { UserStore } from "../../../common/user-store";
interface Props { interface Props {
renderTableHeader: TableCellProps[]; renderTableHeader: TableCellProps[];
showExtraColumn?: boolean; showActionsColumn?: boolean;
showCheckColumn?: boolean;
tableId: string; tableId: string;
} }
export function Placeholder({ renderTableHeader, showExtraColumn = true, tableId }: Props) { export function Placeholder({ renderTableHeader, showActionsColumn: showExtraColumn = true, showCheckColumn, tableId }: Props) {
const linesNumber = 3; const linesNumber = 3;
function renderLines() { function renderLines() {
@ -23,7 +24,7 @@ export function Placeholder({ renderTableHeader, showExtraColumn = true, tableId
for (let i = 0; i < linesNumber; i++) { for (let i = 0; i < linesNumber; i++) {
lines.push( lines.push(
<div className={styles.line} style={{ opacity: 1 - i * .33 }}></div>, <div className={styles.line} style={{ opacity: 1 - i * .4 }}></div>,
); );
} }
@ -38,11 +39,14 @@ export function Placeholder({ renderTableHeader, showExtraColumn = true, tableId
return ( return (
<div className={styles.placeholder} aria-hidden="true"> <div className={styles.placeholder} aria-hidden="true">
{filteredColumns.map((cellProps) => { {showCheckColumn && (
<div className={styles.checkerColumn}>{renderLines()}</div>
)}
{filteredColumns.map((cellProps, index) => {
return ( return (
<div key={cellProps.id} className={cellProps.className}> <TableCell key={cellProps.id ?? index} className={cellProps.className}>
{renderLines()} {cellProps.title && renderLines()}
</div> </TableCell>
); );
})} })}
{showExtraColumn && ( {showExtraColumn && (