1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 15:53: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

@@ -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;

View File

@@ -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 (
<Popover
className="notification-wrapper"
@@ -114,3 +93,20 @@ export default class NotificationPopover extends React.Component {
);
}
}
NotificationPopover.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,
};
export default NotificationPopover;

View File

@@ -54,47 +54,17 @@ Option.propTypes = {
}),
};
export default class SeahubSelect extends React.Component {
static propTypes = {
isMulti: PropTypes.bool,
options: PropTypes.array.isRequired,
value: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.string]),
isSearchable: PropTypes.bool,
isClearable: PropTypes.bool,
placeholder: PropTypes.string,
classNamePrefix: PropTypes.string,
className: PropTypes.string,
form: PropTypes.string,
onChange: PropTypes.func.isRequired,
menuPortalTarget: PropTypes.string,
menuPosition: PropTypes.string,
noOptionsMessage: PropTypes.func,
innerRef: PropTypes.object,
isDisabled: PropTypes.bool,
};
static defaultProps = {
options: [],
value: {},
isDisabled: false,
isSearchable: true,
isClearable: true,
placeholder: '',
isMulti: false,
menuPortalTarget: '.modal',
noOptionsMessage: () => {
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 (
<Select
@@ -121,3 +91,23 @@ export default class SeahubSelect extends React.Component {
);
}
}
SeahubSelect.propTypes = {
isMulti: PropTypes.bool,
options: PropTypes.array.isRequired,
value: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.string]),
isSearchable: PropTypes.bool,
isClearable: PropTypes.bool,
placeholder: PropTypes.string,
classNamePrefix: PropTypes.string,
className: PropTypes.string,
form: PropTypes.string,
onChange: PropTypes.func.isRequired,
menuPortalTarget: PropTypes.string,
menuPosition: PropTypes.string,
noOptionsMessage: PropTypes.func,
innerRef: PropTypes.object,
isDisabled: PropTypes.bool,
};
export default SeahubSelect;