1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-21 19:37:28 +00:00

remove react old defaultProps (#7576)

This commit is contained in:
Michael An
2025-03-10 14:27:08 +08:00
committed by GitHub
parent 00707d1d05
commit 55719ccbdf
43 changed files with 214 additions and 438 deletions

View File

@@ -35,12 +35,6 @@ import './index.css';
class InteractionMasks extends React.Component {
static defaultProps = {
enableCellSelect: true,
isGroupView: false,
groupOffsetLeft: 0,
};
throttle = null;
constructor(props) {
@@ -107,7 +101,7 @@ class InteractionMasks extends React.Component {
}
onColumnSelect = (column) => {
const { columns, isGroupView, recordsCount } = this.props;
const { columns, isGroupView = false, recordsCount } = this.props;
if (isGroupView) return;
const selectColumnIndex = getColumnIndexByKey(column.key, columns);
this.setState({
@@ -311,7 +305,7 @@ class InteractionMasks extends React.Component {
};
checkIsSelectedCellEditable = () => {
const { enableCellSelect, columns, isGroupView, recordGetterByIndex, checkCanModifyRecord } = this.props;
const { enableCellSelect = true, columns, isGroupView = false, recordGetterByIndex, checkCanModifyRecord } = this.props;
const { selectedPosition } = this.state;
return checkIsSelectedCellEditable({ enableCellSelect, columns, isGroupView, selectedPosition, recordGetterByIndex, checkCanModifyRecord });
};
@@ -321,7 +315,7 @@ class InteractionMasks extends React.Component {
};
getSelectedDimensions = (selectedPosition) => {
const { columns, rowHeight, isGroupView, groupOffsetLeft, getRowTop: getRecordTopFromRecordsBody } = this.props;
const { columns, rowHeight, isGroupView = false, groupOffsetLeft = 0, getRowTop: getRecordTopFromRecordsBody } = this.props;
const scrollLeft = this.props.getScrollLeft();
return {
...getSelectedDimensions({
@@ -331,7 +325,7 @@ class InteractionMasks extends React.Component {
};
getSelectedRangeDimensions = (selectedRange) => {
const { columns, rowHeight, isGroupView, groups, groupMetrics, groupOffsetLeft, getRowTop: getRecordTopFromRecordsBody } = this.props;
const { columns, rowHeight, isGroupView = false, groups, groupMetrics, groupOffsetLeft = 0, getRowTop: getRecordTopFromRecordsBody } = this.props;
return {
...getSelectedRangeDimensions({
selectedRange, columns, rowHeight, isGroupView, groups, groupMetrics, groupOffsetLeft, getRecordTopFromRecordsBody,
@@ -358,7 +352,7 @@ class InteractionMasks extends React.Component {
if (mask) {
const { idx, rowIdx, groupRecordIndex } = position;
if (idx >= 0 && rowIdx >= 0) {
const { columns, getRowTop, isGroupView, groupOffsetLeft } = this.props;
const { columns, getRowTop, isGroupView = false, groupOffsetLeft = 0 } = this.props;
const column = columns[idx];
const frozen = !!column.frozen;
if (frozen) {
@@ -430,7 +424,7 @@ class InteractionMasks extends React.Component {
e.stopPropagation();
e.nativeEvent.stopImmediatePropagation();
const { selectedPosition } = this.state;
const { isGroupView, recordGetterByIndex } = this.props;
const { isGroupView = false, recordGetterByIndex } = this.props;
const record = getSelectedRow({ selectedPosition, isGroupView, recordGetterByIndex });
if (this.props.handleSpaceKeyDown) {
this.props.handleSpaceKeyDown(record);
@@ -462,7 +456,7 @@ class InteractionMasks extends React.Component {
handleSelectCellsDelete = () => {
if (this.props.handleSelectCellsDelete) {
const { isGroupView, recordGetterByIndex, columns } = this.props;
const { isGroupView = false, recordGetterByIndex, columns } = this.props;
const { selectedRange } = this.state;
const { topLeft, bottomRight } = selectedRange;
const recordsFromSelectedRange = getRecordsFromSelectedRange({ selectedRange, isGroupView, recordGetterByIndex });
@@ -519,7 +513,7 @@ class InteractionMasks extends React.Component {
onPaste = (e) => {
// when activeElement is not cellMask or has no permission, can't paste cell
if (!this.isCellMaskActive() || !this.props.canModifyRecords) return;
const { columns, isGroupView } = this.props;
const { columns, isGroupView = false } = this.props;
const { selectedPosition, selectedRange } = this.state;
const { idx, rowIdx } = selectedPosition;
if (idx === -1 || rowIdx === -1) return; // prevent paste when no cell selected
@@ -574,7 +568,7 @@ class InteractionMasks extends React.Component {
const { idx, rowIdx } = selectedPosition;
if (idx === -1 || rowIdx === -1) return; // prevent paste when no cell selected
event.preventDefault();
const { tableId: copiedTableId, columns, isGroupView, recordGetterByIndex, getCopiedRecordsAndColumnsFromRange, getClientCellValueDisplayString } = this.props;
const { tableId: copiedTableId, columns, isGroupView = false, recordGetterByIndex, getCopiedRecordsAndColumnsFromRange, getClientCellValueDisplayString } = this.props;
if (rowIdx < 0 || idx < 0) {
return; // can not copy when no cell select
}
@@ -615,7 +609,7 @@ class InteractionMasks extends React.Component {
};
copyRows = (event, selectedRecordIds) => {
const { tableId: copiedTableId, columns, recordGetterById, isGroupView, getCopiedRecordsAndColumnsFromRange, getClientCellValueDisplayString } = this.props;
const { tableId: copiedTableId, columns, recordGetterById, isGroupView = false, getCopiedRecordsAndColumnsFromRange, getClientCellValueDisplayString } = this.props;
const copiedRowsCount = selectedRecordIds.length;
toaster.success(
copiedRowsCount > 1 ? gettext('xxx rows are copied.').replace('xxx', copiedRowsCount) : gettext('1 row is copied.')
@@ -639,7 +633,7 @@ class InteractionMasks extends React.Component {
};
onCopyCells = (event) => {
const { tableId: copiedTableId, columns, isGroupView, recordGetterByIndex, getCopiedRecordsAndColumnsFromRange, getClientCellValueDisplayString } = this.props;
const { tableId: copiedTableId, columns, isGroupView = false, recordGetterByIndex, getCopiedRecordsAndColumnsFromRange, getClientCellValueDisplayString } = this.props;
const { selectedPosition, selectedRange } = this.state;
const { rowIdx, idx } = selectedPosition;
if (rowIdx < 0 || idx < 0) {
@@ -732,7 +726,7 @@ class InteractionMasks extends React.Component {
};
getLeftInterval = () => {
const { isGroupView, columns, groupOffsetLeft, frozenColumnsWidth } = this.props;
const { isGroupView = false, columns, groupOffsetLeft = 0, frozenColumnsWidth } = this.props;
const firstColumnFrozen = columns[0] ? columns[0].frozen : false;
let leftInterval = 0;
if (firstColumnFrozen) {
@@ -747,7 +741,7 @@ class InteractionMasks extends React.Component {
};
handleVerticalArrowAction = (current, actionType) => {
const { isGroupView, groupMetrics, rowHeight } = this.props;
const { isGroupView = false, groupMetrics, rowHeight } = this.props;
const step = actionType === 'ArrowDown' ? 1 : -1;
if (isGroupView) {
const groupRows = groupMetrics.groupRows || [];
@@ -1031,7 +1025,7 @@ class InteractionMasks extends React.Component {
render() {
const { selectedRange, isEditorEnabled, draggedRange, selectedPosition, firstEditorKeyDown, openEditorMode, editorPosition, selectedOperation } = this.state;
const { columns, isGroupView, recordGetterByIndex, scrollTop, getScrollLeft, editorPortalTarget, contextMenu } = this.props;
const { columns, isGroupView = false, recordGetterByIndex, scrollTop, getScrollLeft, editorPortalTarget, contextMenu } = this.props;
const isSelectedSingleCell = selectedRangeIsSingleCell(selectedRange);
return (
<div

View File

@@ -18,12 +18,6 @@ const CONTENT_HEIGHT = window.innerHeight - 174;
const { max, min, ceil, round } = Math;
class RecordsBody extends Component {
static defaultProps = {
editorPortalTarget: document.body,
scrollToRowIndex: 0,
};
constructor(props) {
super(props);
this.state = {
@@ -536,6 +530,7 @@ class RecordsBody extends Component {
};
render() {
const { editorPortalTarget = document.body } = this.props;
return (
<Fragment>
<div
@@ -562,7 +557,7 @@ class RecordsBody extends Component {
getTableContentRect={this.props.getTableContentRect}
getMobileFloatIconStyle={this.props.getMobileFloatIconStyle}
onToggleMobileMoreOperations={this.props.onToggleMobileMoreOperations}
editorPortalTarget={this.props.editorPortalTarget}
editorPortalTarget={editorPortalTarget}
onCellRangeSelectionUpdated={this.onCellRangeSelectionUpdated}
recordGetterByIndex={this.props.recordGetterByIndex}
recordGetterById={this.props.recordGetterById}
@@ -634,7 +629,6 @@ RecordsBody.propTypes = {
deleteRecordsLinks: PropTypes.func,
paste: PropTypes.func,
searchResult: PropTypes.object,
scrollToRowIndex: PropTypes.number,
frozenColumnsWidth: PropTypes.number,
editMobileCell: PropTypes.func,
reloadRecords: PropTypes.func,

View File

@@ -24,11 +24,6 @@ const { max, min } = Math;
class GroupBody extends Component {
static defaultProps = {
editorPortalTarget: document.body,
scrollToRowIndex: 0,
};
constructor(props) {
super(props);
const { groups, groupbys, allColumns } = props;
@@ -871,6 +866,7 @@ class GroupBody extends Component {
};
render() {
const { editorPortalTarget = document.body, scrollToRowIndex = 0 } = this.props;
return (
<Fragment>
<div
@@ -901,7 +897,8 @@ class GroupBody extends Component {
getMobileFloatIconStyle={this.props.getMobileFloatIconStyle}
onToggleMobileMoreOperations={this.props.onToggleMobileMoreOperations}
onToggleInsertRecordDialog={this.props.onToggleInsertRecordDialog}
editorPortalTarget={this.props.editorPortalTarget}
editorPortalTarget={editorPortalTarget}
scrollToRowIndex={scrollToRowIndex}
onCellRangeSelectionUpdated={this.onCellRangeSelectionUpdated}
recordGetterByIndex={this.props.recordGetterByIndex}
recordGetterById={this.props.recordGetterById}
@@ -991,6 +988,7 @@ GroupBody.propTypes = {
cacheDownloadFilesProps: PropTypes.func,
onCellContextMenu: PropTypes.func,
getTableCanvasContainerRect: PropTypes.func,
scrollToRowIndex: PropTypes.number,
};
export default GroupBody;

View File

@@ -27,13 +27,6 @@ import { getTreeNodeKey } from '../../utils/tree';
class Records extends Component {
static defaultProps = {
gridScroll: {
scroll_left: 0,
scroll_top: 0,
},
};
constructor(props) {
super(props);
this.scrollTop = 0;
@@ -120,7 +113,7 @@ class Records extends Component {
}
getNormalizedScroll = () => {
const { scroll_left, scroll_top } = this.props.gridScroll || {};
const { scroll_left, scroll_top } = this.props.gridScroll || { scroll_left: 0, scroll_top: 0 };
return {
scroll_left: isNumber(scroll_left) ? scroll_left : 0,
scroll_top: isNumber(scroll_top) ? scroll_top : 0,

View File

@@ -21,12 +21,6 @@ const CONTENT_HEIGHT = window.innerHeight - 174;
const { max, min, ceil, round } = Math;
class TreeBody extends Component {
static defaultProps = {
editorPortalTarget: document.body,
scrollToRowIndex: 0,
};
constructor(props) {
super(props);
const { recordsTree, treeNodeKeyRecordIdMap, keyTreeNodeFoldedMap } = props;
@@ -642,6 +636,7 @@ class TreeBody extends Component {
};
render() {
const { editorPortalTarget = document.body } = this.props;
return (
<>
<div
@@ -654,6 +649,7 @@ class TreeBody extends Component {
>
<InteractionMasks
{...this.props}
editorPortalTarget={editorPortalTarget}
showRecordAsTree
ref={this.setInteractionMaskRef}
recordsCount={this.state.nodes.length}
@@ -718,7 +714,6 @@ TreeBody.propTypes = {
getMobileFloatIconStyle: PropTypes.func,
onToggleMobileMoreOperations: PropTypes.func,
onToggleInsertRecordDialog: PropTypes.func,
editorPortalTarget: PropTypes.instanceOf(Element),
recordGetterByIndex: PropTypes.func,
recordGetterById: PropTypes.func,
modifyRecord: PropTypes.func,
@@ -729,7 +724,6 @@ TreeBody.propTypes = {
checkCanModifyRecord: PropTypes.func,
paste: PropTypes.func,
searchResult: PropTypes.object,
scrollToRowIndex: PropTypes.number,
frozenColumnsWidth: PropTypes.number,
editMobileCell: PropTypes.func,
reloadRecords: PropTypes.func,