diff --git a/frontend/src/components/common/account.js b/frontend/src/components/common/account.js index d7650f01ca..a8153f6f6f 100644 --- a/frontend/src/components/common/account.js +++ b/frontend/src/components/common/account.js @@ -94,8 +94,9 @@ class Account extends Component { renderMenu = () => { let data; const { isStaff, isOrgStaff, isInstAdmin } = this.state; + const { isAdminPanel = false } = this.props; - if (this.props.isAdminPanel) { + if (isAdminPanel) { if (isStaff) { data = { url: siteRoot, @@ -173,10 +174,6 @@ class Account extends Component { } } -Account.defaultProps = { - isAdminPanel: false -}; - Account.propTypes = propTypes; export default Account; diff --git a/frontend/src/components/common/notification-popover/index.js b/frontend/src/components/common/notification-popover/index.js index 1c24289a2b..1c0099ad6c 100644 --- a/frontend/src/components/common/notification-popover/index.js +++ b/frontend/src/components/common/notification-popover/index.js @@ -5,28 +5,7 @@ import { gettext } from '../../../utils/constants'; import './index.css'; -export default class NotificationPopover extends React.Component { - - static propTypes = { - headerText: PropTypes.string.isRequired, - bodyText: PropTypes.string.isRequired, - footerText: PropTypes.string.isRequired, - onNotificationListToggle: PropTypes.func, - onNotificationDialogToggle: PropTypes.func, - listNotifications: PropTypes.func, - onMarkAllNotifications: PropTypes.func, - tabItemClick: PropTypes.func, - children: PropTypes.any, - currentTab: PropTypes.string, - generalNoticeListUnseen: PropTypes.number, - discussionNoticeListUnseen: PropTypes.number, - }; - - static defaultProps = { - headerText: '', - bodyText: '', - footerText: '', - }; +class NotificationPopover extends React.Component { componentDidMount() { document.addEventListener('mousedown', this.handleOutsideClick, true); @@ -58,7 +37,7 @@ export default class NotificationPopover extends React.Component { }; render() { - const { headerText, bodyText, footerText, currentTab, generalNoticeListUnseen, discussionNoticeListUnseen } = this.props; + const { headerText = '', bodyText = '', footerText = '', currentTab, generalNoticeListUnseen, discussionNoticeListUnseen } = this.props; return ( { - return null; - }, - }; +class SeahubSelect extends React.Component { getMenuPortalTarget = () => { - return document.querySelector(this.props.menuPortalTarget); + const { menuPortalTarget = '.modal' } = this.props; + return document.querySelector(menuPortalTarget); }; render() { - const { options, onChange, value, isSearchable, placeholder, isMulti, menuPosition, isClearable, noOptionsMessage, - classNamePrefix, innerRef, isDisabled, form, className } = this.props; + const { options = [], onChange, value = {}, isSearchable = true, placeholder = '', + isMulti = false, menuPosition, isClearable = true, noOptionsMessage = (() => { return null; }), + classNamePrefix, innerRef, isDisabled = false, form, className } = this.props; return ( @@ -474,12 +462,11 @@ class FileChooser extends React.Component { ) : ( this.renderRepoListView() )} - + ); } } FileChooser.propTypes = propTypes; -FileChooser.defaultProps = defaultProps; export default FileChooser; diff --git a/frontend/src/components/file-chooser/repo-list-item.js b/frontend/src/components/file-chooser/repo-list-item.js index bd265f8653..502d6b3dc5 100644 --- a/frontend/src/components/file-chooser/repo-list-item.js +++ b/frontend/src/components/file-chooser/repo-list-item.js @@ -20,7 +20,6 @@ const propTypes = { onRepoItemClick: PropTypes.func.isRequired, fileSuffixes: PropTypes.array, selectedItemInfo: PropTypes.object, - hideLibraryName: PropTypes.bool, newFolderName: PropTypes.string, }; @@ -236,19 +235,17 @@ class RepoListItem extends React.Component { return (
  • - {!this.props.hideLibraryName && -
    -
    - - - - -
    -
    - {this.props.repo.repo_name} -
    +
    +
    + + + +
    - } +
    + {this.props.repo.repo_name} +
    +
    {this.state.isShowChildren && ( ); @@ -72,6 +60,5 @@ class RepoListView extends React.Component { } RepoListView.propTypes = propTypes; -RepoListView.defaultProps = defaultProps; export default RepoListView; diff --git a/frontend/src/components/file-uploader/file-uploader.js b/frontend/src/components/file-uploader/file-uploader.js index c6728478b5..7f85f20162 100644 --- a/frontend/src/components/file-uploader/file-uploader.js +++ b/frontend/src/components/file-uploader/file-uploader.js @@ -30,10 +30,6 @@ const propTypes = { class FileUploader extends React.Component { - static defaultProps = { - isCustomPermission: false - }; - constructor(props) { super(props); this.state = { @@ -179,7 +175,7 @@ class FileUploader extends React.Component { }; onFileAdded = (resumableFile, files) => { - const { isCustomPermission } = this.props; + const { isCustomPermission = false } = this.props; let isFile = resumableFile.fileName === resumableFile.relativePath; // uploading is file and only upload one file if (isFile && files.length === 1) { diff --git a/frontend/src/components/sdoc-wiki-page-viewer/index.js b/frontend/src/components/sdoc-wiki-page-viewer/index.js index 100c371cdf..4c1c6c4868 100644 --- a/frontend/src/components/sdoc-wiki-page-viewer/index.js +++ b/frontend/src/components/sdoc-wiki-page-viewer/index.js @@ -79,7 +79,7 @@ class SdocWikiPageViewer extends React.Component { }; renderMarkdown = () => { - let { isTOCShow, markdownContent } = this.props; + let { isTOCShow = true, markdownContent } = this.props; if (!markdownContent) return null; let document = JSON.parse(markdownContent); @@ -120,7 +120,7 @@ class SdocWikiPageViewer extends React.Component { return ; } - const { isWiki, containerClassName = '' } = this.props; + const { isWiki = false, containerClassName = '' } = this.props; const containerClass = `wiki-page-container ${containerClassName}`; // In dir-column-file width is 100%; // In wiki-viewer width isn't 100% @@ -139,12 +139,6 @@ class SdocWikiPageViewer extends React.Component { } } -const defaultProps = { - isWiki: false, - isTOCShow: true, -}; - SdocWikiPageViewer.propTypes = propTypes; -SdocWikiPageViewer.defaultProps = defaultProps; export default SdocWikiPageViewer; diff --git a/frontend/src/components/seafile-codemirror/index.js b/frontend/src/components/seafile-codemirror/index.js index 799fd388e2..4bf8d6c261 100644 --- a/frontend/src/components/seafile-codemirror/index.js +++ b/frontend/src/components/seafile-codemirror/index.js @@ -19,16 +19,12 @@ const propTypes = { class SeafileCodeMirror extends React.Component { - static defaultProps = { - readOnly: true, - }; - onChange = (value) => { this.props.onChange && this.props.onChange(value); }; render() { - const { value, readOnly, fileExt } = this.props; + const { value, readOnly = true, fileExt } = this.props; const extensions = [...getLanguageExtensions(fileExt).filter(item => item !== null)]; return (
    diff --git a/frontend/src/components/seafile-markdown-viewer/index.js b/frontend/src/components/seafile-markdown-viewer/index.js index 08c300c741..84c1c34efc 100644 --- a/frontend/src/components/seafile-markdown-viewer/index.js +++ b/frontend/src/components/seafile-markdown-viewer/index.js @@ -108,7 +108,7 @@ class SeafileMarkdownViewer extends React.Component { }; renderMarkdown = () => { - const { isTOCShow = true, isWiki, markdownContent } = this.props; + const { isTOCShow = true, isWiki = false, markdownContent } = this.props; const props = { isShowOutline: isTOCShow, mathJaxSource: `${mediaUrl}js/mathjax/tex-svg.js`, @@ -129,7 +129,7 @@ class SeafileMarkdownViewer extends React.Component { render() { const { isMarkdownEditorRenderCompleted } = this.state; - const { isFileLoading, isWiki, containerClassName = '' } = this.props; + const { isFileLoading, isWiki = false, containerClassName = '' } = this.props; if (isFileLoading) { return ; @@ -158,11 +158,6 @@ class SeafileMarkdownViewer extends React.Component { } } -const defaultProps = { - isWiki: false, -}; - SeafileMarkdownViewer.propTypes = propTypes; -SeafileMarkdownViewer.defaultProps = defaultProps; export default SeafileMarkdownViewer; diff --git a/frontend/src/components/search-input.js b/frontend/src/components/search-input.js index 6fb8a97b72..4f93f23e38 100644 --- a/frontend/src/components/search-input.js +++ b/frontend/src/components/search-input.js @@ -24,7 +24,7 @@ class SearchInput extends Component { constructor(props) { super(props); this.state = { - searchValue: props.value, + searchValue: props.value || '', }; this.isInputtingChinese = false; this.timer = null; @@ -57,7 +57,7 @@ class SearchInput extends Component { onChange = (e) => { this.timer && clearTimeout(this.timer); - const { onChange, wait } = this.props; + const { onChange, wait = 100 } = this.props; let text = e.target.value; this.setState({ searchValue: text || '' }, () => { if (this.isInputtingChinese) return; @@ -104,7 +104,7 @@ class SearchInput extends Component { }; render() { - const { placeholder, autoFocus, className, onKeyDown, disabled, style } = this.props; + const { placeholder, autoFocus, className, onKeyDown, disabled = false, style } = this.props; const { searchValue } = this.state; return ( @@ -131,10 +131,4 @@ class SearchInput extends Component { SearchInput.propTypes = propTypes; -SearchInput.defaultProps = { - wait: 100, - disabled: false, - value: '', -}; - export default SearchInput; diff --git a/frontend/src/components/search/search-result-item.js b/frontend/src/components/search/search-result-item.js index faeeba7100..67edbb4d6a 100644 --- a/frontend/src/components/search/search-result-item.js +++ b/frontend/src/components/search/search-result-item.js @@ -12,16 +12,12 @@ const propTypes = { class SearchResultItem extends React.Component { - static defaultProps = { - setRef: () => {}, - }; - onClickHandler = () => { this.props.onItemClickHandler(this.props.item); }; render() { - let item = this.props.item; + const { item, setRef = (() => {}) } = this.props; let folderIconUrl = item.link_content ? Utils.getFolderIconUrl(false, 192) : Utils.getDefaultLibIconUrl(); let fileIconUrl = item.is_dir ? folderIconUrl : Utils.getFileIconUrl(item.name); let showName = item.repo_name + '/' + item.link_content; @@ -35,7 +31,7 @@ class SearchResultItem extends React.Component {
  • this.props.setRef(ref)} + ref={ref => setRef(ref)} >
    diff --git a/frontend/src/components/select-editor/select-editor.js b/frontend/src/components/select-editor/select-editor.js index 769f28b983..53a074fec6 100644 --- a/frontend/src/components/select-editor/select-editor.js +++ b/frontend/src/components/select-editor/select-editor.js @@ -23,16 +23,10 @@ const propTypes = { class SelectEditor extends React.Component { - static defaultProps = { - enableAddCustomPermission: false, - isEditing: false, - autoFocus: false, - }; - constructor(props) { super(props); this.state = { - isEditing: props.isEditing, + isEditing: props.isEditing || false, options: [] }; this.options = []; @@ -43,7 +37,7 @@ class SelectEditor extends React.Component { } setOptions = () => { - const { enableAddCustomPermission, options } = this.props; + const { enableAddCustomPermission = false, options } = this.props; this.options = []; for (let i = 0, length = options.length; i < length; i++) { let option = {}; @@ -112,7 +106,7 @@ class SelectEditor extends React.Component { }; render() { - let { currentOption, isTextMode } = this.props; + let { currentOption, isTextMode, autoFocus = false } = this.props; return (
    {(!isTextMode || this.state.isEditing) && @@ -128,7 +122,7 @@ class SelectEditor extends React.Component { menuPortalTarget={document.querySelector('#wrapper')} styles={MenuSelectStyle} onMenuClose={this.onMenuClose} - autoFocus={this.props.autoFocus} + autoFocus={autoFocus} menuShouldScrollIntoView /> } diff --git a/frontend/src/components/select-editor/share-permission-editor.js b/frontend/src/components/select-editor/share-permission-editor.js index f65a01e7ca..201ac46a7a 100644 --- a/frontend/src/components/select-editor/share-permission-editor.js +++ b/frontend/src/components/select-editor/share-permission-editor.js @@ -24,11 +24,6 @@ const propTypes = { class SharePermissionEditor extends React.Component { - static defaultProps = { - isEditing: false, - autoFocus: false, - }; - constructor(props) { super(props); this.state = { @@ -127,18 +122,17 @@ class SharePermissionEditor extends React.Component { }; render() { - const { isLoading } = this.state; if (isLoading) { return null; } - + const { autoFocus = false, isEditing = false } = this.props; return ( { - 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 (
    { - 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, diff --git a/frontend/src/components/sf-table/table-main/records/tree-body.js b/frontend/src/components/sf-table/table-main/records/tree-body.js index 0d8bf22bbb..b1c468b500 100644 --- a/frontend/src/components/sf-table/table-main/records/tree-body.js +++ b/frontend/src/components/sf-table/table-main/records/tree-body.js @@ -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 ( <>
    0; return ( @@ -143,7 +138,7 @@ class FilterPopover extends Component { boundariesElement={document.body} > {({ update: scheduleUpdate }) => ( -
    this.dtablePopoverRef = ref} onClick={this.onPopoverInsideClick} className={this.props.filtersClassName}> +
    this.dtablePopoverRef = ref} onClick={this.onPopoverInsideClick} className={filtersClassName}> diff --git a/frontend/src/metadata/components/popover/sort-popover/index.js b/frontend/src/metadata/components/popover/sort-popover/index.js index 390ed8dfb9..207a2ebe9b 100644 --- a/frontend/src/metadata/components/popover/sort-popover/index.js +++ b/frontend/src/metadata/components/popover/sort-popover/index.js @@ -37,10 +37,6 @@ const propTypes = { class SortPopover extends Component { - static defaultProps = { - readOnly: false, - }; - constructor(props) { super(props); const { sorts, columns, type } = this.props; @@ -175,7 +171,7 @@ class SortPopover extends Component { renderSortItem = (column, sort, index) => { const { name, type } = column; - const { readOnly, type: viewType } = this.props; + const { readOnly = false, type: viewType } = this.props; const selectedColumn = { label: ( @@ -233,7 +229,7 @@ class SortPopover extends Component { }; render() { - const { target, readOnly } = this.props; + const { target, readOnly = false } = this.props; const { sorts } = this.state; const isEmpty = isSortsEmpty(sorts); return ( diff --git a/frontend/src/metadata/views/kanban/boards/board/index.js b/frontend/src/metadata/views/kanban/boards/board/index.js index d9ed93decc..f3fd970fca 100644 --- a/frontend/src/metadata/views/kanban/boards/board/index.js +++ b/frontend/src/metadata/views/kanban/boards/board/index.js @@ -75,6 +75,7 @@ const Board = ({ /> {!isCollapsed && ( { // return anchestor of container who doesn't have a transform property return document.querySelector('.sf-metadata-main'); diff --git a/frontend/src/metadata/views/kanban/dnd/container.js b/frontend/src/metadata/views/kanban/dnd/container.js index 995d5a30f0..4f37eba1ea 100755 --- a/frontend/src/metadata/views/kanban/dnd/container.js +++ b/frontend/src/metadata/views/kanban/dnd/container.js @@ -125,10 +125,4 @@ Container.propTypes = { ]), }; -Container.defaultProps = { - behaviour: 'move', - orientation: 'vertical', - className: 'react-trello-board', -}; - export default Container; diff --git a/frontend/src/metadata/views/table/masks/interaction-masks/index.js b/frontend/src/metadata/views/table/masks/interaction-masks/index.js index d79a90a7e1..ccb140affb 100644 --- a/frontend/src/metadata/views/table/masks/interaction-masks/index.js +++ b/frontend/src/metadata/views/table/masks/interaction-masks/index.js @@ -44,13 +44,6 @@ const NOT_SUPPORT_OPEN_EDITOR_COLUMN_TYPES = [ class InteractionMasks extends React.Component { - - static defaultProps = { - enableCellSelect: true, - isGroupView: false, - groupOffsetLeft: 0, - }; - throttle = null; constructor(props) { @@ -118,7 +111,7 @@ class InteractionMasks extends React.Component { } onColumnSelect = (column) => { - let { columns, isGroupView, recordsCount } = this.props; + let { columns, isGroupView = false, recordsCount } = this.props; if (isGroupView) return; let selectColumnIndex = 0; for (let i = 0; i < columns.length; i++) { @@ -337,10 +330,9 @@ class InteractionMasks extends React.Component { }; isSelectedCellEditable = () => { - const { enableCellSelect, columns, isGroupView, recordGetterByIndex, onCheckCellIsEditable } = this.props; + const { enableCellSelect = true, columns, isGroupView = false, recordGetterByIndex, onCheckCellIsEditable } = this.props; const { selectedPosition } = this.state; - const res = isSelectedCellEditable({ enableCellSelect, columns, isGroupView, recordGetterByIndex, selectedPosition, onCheckCellIsEditable }); - return res; + return isSelectedCellEditable({ enableCellSelect, columns, isGroupView, recordGetterByIndex, selectedPosition, onCheckCellIsEditable }); }; isSelectedCellIsLongText = () => { @@ -355,7 +347,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({ @@ -365,7 +357,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, @@ -392,7 +384,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) { @@ -463,7 +455,7 @@ class InteractionMasks extends React.Component { e.nativeEvent.stopImmediatePropagation(); const repoID = window.sfMetadataContext.getSetting('repoID'); const { selectedPosition } = this.state; - const { isGroupView, recordGetterByIndex } = this.props; + const { isGroupView = false, recordGetterByIndex } = this.props; const record = getSelectedRow({ selectedPosition, isGroupView, recordGetterByIndex }); openFile(repoID, record, () => { window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.OPEN_EDITOR, EDITOR_TYPE.PREVIEWER); @@ -494,7 +486,7 @@ class InteractionMasks extends React.Component { }; 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 }); @@ -615,7 +607,7 @@ class InteractionMasks extends React.Component { onPaste = (e) => { // when activeElement is not cellMask or has no permission, can't paste cell if (!this.isCellMaskActive() || !window.sfMetadataContext.canModify()) 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 @@ -668,7 +660,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 { table, columns, isGroupView, recordGetterByIndex, getCopiedRecordsAndColumnsFromRange } = this.props; + const { table, columns, isGroupView = false, recordGetterByIndex, getCopiedRecordsAndColumnsFromRange } = this.props; const { _id: copiedTableId } = table; if (rowIdx < 0 || idx < 0) { return; // can not copy when no cell select @@ -713,7 +705,7 @@ class InteractionMasks extends React.Component { }; copyRows = (event, selectedRecordIds) => { - const { table, columns, recordGetterById, isGroupView, getCopiedRecordsAndColumnsFromRange } = this.props; + const { table, columns, recordGetterById, isGroupView = false, getCopiedRecordsAndColumnsFromRange } = this.props; const copiedRowsCount = selectedRecordIds.length; toaster.success( copiedRowsCount > 1 ? gettext('{name_placeholder} rows are copied.').replace('{name_placeholder}', copiedRowsCount) : gettext('1 row is copied.') @@ -737,7 +729,7 @@ class InteractionMasks extends React.Component { }; onCopyCells = (event) => { - const { table, columns, isGroupView, recordGetterByIndex, getCopiedRecordsAndColumnsFromRange } = this.props; + const { table, columns, isGroupView = false, recordGetterByIndex, getCopiedRecordsAndColumnsFromRange } = this.props; const { selectedPosition, selectedRange } = this.state; const { _id: copiedTableId } = table; const { rowIdx, idx } = selectedPosition; @@ -831,7 +823,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) { @@ -846,7 +838,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 || []; @@ -1134,7 +1126,7 @@ class InteractionMasks extends React.Component { render() { const { selectedRange, isEditorEnabled, draggedRange, selectedPosition, firstEditorKeyDown, openEditorMode, editorPosition } = this.state; - const { table, columns, isGroupView, recordGetterByIndex, scrollTop, getScrollLeft, editorPortalTarget, contextMenu, recordMetrics } = this.props; + const { table, columns, isGroupView = false, recordGetterByIndex, scrollTop, getScrollLeft, editorPortalTarget, contextMenu, recordMetrics } = this.props; const isSelectedSingleCell = selectedRangeIsSingleCell(selectedRange); return (
    @@ -80,7 +80,7 @@ class DetailListView extends React.Component { {gettext('Tags')} - + @@ -92,7 +92,7 @@ class DetailListView extends React.Component { repoID={repoID} repoTags={repoTags} filePath={filePath} - fileTagList={this.props.fileTagList} + fileTagList={fileTagList} toggleCancel={this.onEditFileTagToggle} onFileTagChanged={this.props.onFileTagChanged} onNewRepoTagAdded={this.onNewRepoTagAdded} @@ -105,10 +105,6 @@ class DetailListView extends React.Component { } } -DetailListView.defaultProps = { - fileTagList: [], -}; - DetailListView.propTypes = propTypes; export default DetailListView; diff --git a/frontend/src/pages/markdown-editor/header-toolbar/button-item.js b/frontend/src/pages/markdown-editor/header-toolbar/button-item.js index 0a1e400dfd..12afbaeca7 100644 --- a/frontend/src/pages/markdown-editor/header-toolbar/button-item.js +++ b/frontend/src/pages/markdown-editor/header-toolbar/button-item.js @@ -17,11 +17,6 @@ const propTypes = { class ButtonItem extends React.Component { - static defaultProps = { - className: '', - isActive: false, - }; - constructor(props) { super(props); this.state = { @@ -49,8 +44,8 @@ class ButtonItem extends React.Component { }; shouldComponentUpdate(nextProps, nextState) { - const { disabled, isActive } = nextProps; - const { disabled: oldDisabled, isActive: oldIsActive } = this.props; + const { disabled, isActive = false } = nextProps; + const { disabled: oldDisabled, isActive: oldIsActive = false } = this.props; if (disabled !== oldDisabled) { this.setState({ tooltipOpen: false }); return true; @@ -78,7 +73,7 @@ class ButtonItem extends React.Component { }; getClassName = () => { - const { isRichEditor, className, disabled } = this.props; + const { isRichEditor, className = '', disabled } = this.props; let itemClass = 'btn btn-icon btn-secondary btn-active'; if (!isRichEditor) return itemClass + ' ' + className; @@ -88,15 +83,14 @@ class ButtonItem extends React.Component { render() { const { tooltipOpen } = this.state; - const { id, isActive, disabled, icon, text } = this.props; - const className = this.getClassName(); + const { id, isActive = false, disabled, icon, text } = this.props; const delay = { show: 0, hide: 0 }; return (