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

Minor code style fixes

Signed-off-by: Alex Culliere <alozhkin@mirantis.com>
This commit is contained in:
Alex Culliere 2021-03-12 17:41:41 +02:00
parent 65f359c81c
commit 051d79fcde
2 changed files with 16 additions and 19 deletions

View File

@ -247,7 +247,7 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
getRow(uid: string) {
const {
isSelectable, renderTableHeader, renderTableContents, renderItemMenu,
store, hasDetailsView, onDetails, isResizable: resizable,
store, hasDetailsView, onDetails, isResizable,
copyClassNameFromHeadCells, customizeTableRowProps, detailsItem,
} = this.props;
const { isSelected } = store;
@ -283,17 +283,12 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
cellProps.className = cssNames(cellProps.className, headCell.className);
}
if (cellSize !== undefined) {
cellProps.size = cellSize;
}
if (resizable) {
cellProps._onResize = width => this.handleCellResize(index, width);
cellProps._onResizeComplete = () => this.persistCellSizes();
}
cellProps.size = cellSize;
cellProps.onResize = width => this.handleCellResize(index, width);
cellProps.onResizeComplete = () => this.persistCellSizes();
if (!headCell || !this.isHiddenColumn(headCell)) {
return <TableCell isResizable={resizable} key={index} {...cellProps} />;
return <TableCell isResizable={isResizable} key={index} {...cellProps} />;
}
})
}
@ -447,14 +442,16 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
const _cellProps = isResizable ?
{
...cellProps,
_onResize: (width: number) => this.handleCellResize(index, width),
_onResizeComplete: () => this.persistCellSizes(),
size: this.cellSizes[index],
isResizable
} : cellProps;
if (!this.isHiddenColumn(cellProps)) {
return <TableCell key={cellProps.id ?? index} {..._cellProps} />;
return <TableCell
key={cellProps.id ?? index}
onResize={ width => this.handleCellResize(index, width) }
onResizeComplete={ () => this.persistCellSizes() }
{..._cellProps} />;
}
})}
<TableCell className="menu">

View File

@ -29,12 +29,12 @@ export interface TableCellProps extends React.DOMAttributes<HTMLDivElement> {
* Triggers every time this cell is resized by user
* @param width desired width of this cell
*/
_onResize?(width: number): void;
onResize?(width: number): void;
/**
* Triggers once the user has finished resizing this cell
*/
_onResizeComplete?(): void; // triggers a callback when user stops resizing
onResizeComplete?(): void; // triggers a callback when user stops resizing
}
type ResizeHandlerState = {
@ -105,14 +105,14 @@ export class TableCell extends React.Component<TableCellProps> {
const diffPosX = event.pageX - this.resizeHandlerState.mousePosX;
const currentWidth = this.cellContainer.current.offsetWidth;
this.props?._onResize(currentWidth + diffPosX);
this.props?.onResize(currentWidth + diffPosX);
this.resizeHandlerState.mousePosX = event.pageX;
}, ERGONOMIC_RESIZE_THROTTLE_RATE);
private mouseUpHandler() {
TableCell.removeMouseEventListeners();
this.props?._onResizeComplete();
this.props?.onResizeComplete();
delete this.resizeHandlerState;
}
@ -176,8 +176,8 @@ export class TableCell extends React.Component<TableCellProps> {
title,
renderBoolean: displayBoolean,
showWithColumn,
_onResize,
_onResizeComplete,
onResize,
onResizeComplete,
...cellProps } = this.props;
const classNames = cssNames("TableCell", className, {
checkbox,