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:
parent
65f359c81c
commit
051d79fcde
@ -247,7 +247,7 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
|||||||
getRow(uid: string) {
|
getRow(uid: string) {
|
||||||
const {
|
const {
|
||||||
isSelectable, renderTableHeader, renderTableContents, renderItemMenu,
|
isSelectable, renderTableHeader, renderTableContents, renderItemMenu,
|
||||||
store, hasDetailsView, onDetails, isResizable: resizable,
|
store, hasDetailsView, onDetails, isResizable,
|
||||||
copyClassNameFromHeadCells, customizeTableRowProps, detailsItem,
|
copyClassNameFromHeadCells, customizeTableRowProps, detailsItem,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { isSelected } = store;
|
const { isSelected } = store;
|
||||||
@ -283,17 +283,12 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
|||||||
cellProps.className = cssNames(cellProps.className, headCell.className);
|
cellProps.className = cssNames(cellProps.className, headCell.className);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cellSize !== undefined) {
|
cellProps.size = cellSize;
|
||||||
cellProps.size = cellSize;
|
cellProps.onResize = width => this.handleCellResize(index, width);
|
||||||
}
|
cellProps.onResizeComplete = () => this.persistCellSizes();
|
||||||
|
|
||||||
if (resizable) {
|
|
||||||
cellProps._onResize = width => this.handleCellResize(index, width);
|
|
||||||
cellProps._onResizeComplete = () => this.persistCellSizes();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!headCell || !this.isHiddenColumn(headCell)) {
|
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 ?
|
const _cellProps = isResizable ?
|
||||||
{
|
{
|
||||||
...cellProps,
|
...cellProps,
|
||||||
_onResize: (width: number) => this.handleCellResize(index, width),
|
|
||||||
_onResizeComplete: () => this.persistCellSizes(),
|
|
||||||
size: this.cellSizes[index],
|
size: this.cellSizes[index],
|
||||||
isResizable
|
isResizable
|
||||||
} : cellProps;
|
} : cellProps;
|
||||||
|
|
||||||
if (!this.isHiddenColumn(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">
|
<TableCell className="menu">
|
||||||
|
|||||||
@ -29,12 +29,12 @@ export interface TableCellProps extends React.DOMAttributes<HTMLDivElement> {
|
|||||||
* Triggers every time this cell is resized by user
|
* Triggers every time this cell is resized by user
|
||||||
* @param width desired width of this cell
|
* @param width desired width of this cell
|
||||||
*/
|
*/
|
||||||
_onResize?(width: number): void;
|
onResize?(width: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers once the user has finished resizing this cell
|
* 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 = {
|
type ResizeHandlerState = {
|
||||||
@ -105,14 +105,14 @@ export class TableCell extends React.Component<TableCellProps> {
|
|||||||
const diffPosX = event.pageX - this.resizeHandlerState.mousePosX;
|
const diffPosX = event.pageX - this.resizeHandlerState.mousePosX;
|
||||||
const currentWidth = this.cellContainer.current.offsetWidth;
|
const currentWidth = this.cellContainer.current.offsetWidth;
|
||||||
|
|
||||||
this.props?._onResize(currentWidth + diffPosX);
|
this.props?.onResize(currentWidth + diffPosX);
|
||||||
this.resizeHandlerState.mousePosX = event.pageX;
|
this.resizeHandlerState.mousePosX = event.pageX;
|
||||||
}, ERGONOMIC_RESIZE_THROTTLE_RATE);
|
}, ERGONOMIC_RESIZE_THROTTLE_RATE);
|
||||||
|
|
||||||
private mouseUpHandler() {
|
private mouseUpHandler() {
|
||||||
TableCell.removeMouseEventListeners();
|
TableCell.removeMouseEventListeners();
|
||||||
|
|
||||||
this.props?._onResizeComplete();
|
this.props?.onResizeComplete();
|
||||||
delete this.resizeHandlerState;
|
delete this.resizeHandlerState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,8 +176,8 @@ export class TableCell extends React.Component<TableCellProps> {
|
|||||||
title,
|
title,
|
||||||
renderBoolean: displayBoolean,
|
renderBoolean: displayBoolean,
|
||||||
showWithColumn,
|
showWithColumn,
|
||||||
_onResize,
|
onResize,
|
||||||
_onResizeComplete,
|
onResizeComplete,
|
||||||
...cellProps } = this.props;
|
...cellProps } = this.props;
|
||||||
const classNames = cssNames("TableCell", className, {
|
const classNames = cssNames("TableCell", className, {
|
||||||
checkbox,
|
checkbox,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user