Upgrade to react-router v5 (#25047)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
		
					parent
					
						
							
								126cd7705d
							
						
					
				
			
			
				commit
				
					
						1b70d7ed7c
					
				
			
		
					 42 changed files with 419 additions and 361 deletions
				
			
		|  | @ -4,11 +4,13 @@ import { PureComponent } from 'react'; | |||
| import { defineMessages, injectIntl } from 'react-intl'; | ||||
| 
 | ||||
| import classNames from 'classnames'; | ||||
| import { withRouter } from 'react-router-dom'; | ||||
| 
 | ||||
| import ImmutablePropTypes from 'react-immutable-proptypes'; | ||||
| import { connect } from 'react-redux'; | ||||
| 
 | ||||
| import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'mastodon/permissions'; | ||||
| import { WithRouterPropTypes } from 'mastodon/utils/react_router'; | ||||
| 
 | ||||
| import { IconButton } from '../../../components/icon_button'; | ||||
| import DropdownMenuContainer from '../../../containers/dropdown_menu_container'; | ||||
|  | @ -55,7 +57,6 @@ const mapStateToProps = (state, { status }) => ({ | |||
| class ActionBar extends PureComponent { | ||||
| 
 | ||||
|   static contextTypes = { | ||||
|     router: PropTypes.object, | ||||
|     identity: PropTypes.object, | ||||
|   }; | ||||
| 
 | ||||
|  | @ -81,6 +82,7 @@ class ActionBar extends PureComponent { | |||
|     onPin: PropTypes.func, | ||||
|     onEmbed: PropTypes.func, | ||||
|     intl: PropTypes.object.isRequired, | ||||
|     ...WithRouterPropTypes, | ||||
|   }; | ||||
| 
 | ||||
|   handleReplyClick = () => { | ||||
|  | @ -100,23 +102,23 @@ class ActionBar extends PureComponent { | |||
|   }; | ||||
| 
 | ||||
|   handleDeleteClick = () => { | ||||
|     this.props.onDelete(this.props.status, this.context.router.history); | ||||
|     this.props.onDelete(this.props.status, this.props.history); | ||||
|   }; | ||||
| 
 | ||||
|   handleRedraftClick = () => { | ||||
|     this.props.onDelete(this.props.status, this.context.router.history, true); | ||||
|     this.props.onDelete(this.props.status, this.props.history, true); | ||||
|   }; | ||||
| 
 | ||||
|   handleEditClick = () => { | ||||
|     this.props.onEdit(this.props.status, this.context.router.history); | ||||
|     this.props.onEdit(this.props.status, this.props.history); | ||||
|   }; | ||||
| 
 | ||||
|   handleDirectClick = () => { | ||||
|     this.props.onDirect(this.props.status.get('account'), this.context.router.history); | ||||
|     this.props.onDirect(this.props.status.get('account'), this.props.history); | ||||
|   }; | ||||
| 
 | ||||
|   handleMentionClick = () => { | ||||
|     this.props.onMention(this.props.status.get('account'), this.context.router.history); | ||||
|     this.props.onMention(this.props.status.get('account'), this.props.history); | ||||
|   }; | ||||
| 
 | ||||
|   handleMuteClick = () => { | ||||
|  | @ -303,4 +305,4 @@ class ActionBar extends PureComponent { | |||
| 
 | ||||
| } | ||||
| 
 | ||||
| export default connect(mapStateToProps)(injectIntl(ActionBar)); | ||||
| export default withRouter(connect(mapStateToProps)(injectIntl(ActionBar))); | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import PropTypes from 'prop-types'; | |||
| import { injectIntl, defineMessages, FormattedDate, FormattedMessage } from 'react-intl'; | ||||
| 
 | ||||
| import classNames from 'classnames'; | ||||
| import { Link } from 'react-router-dom'; | ||||
| import { Link, withRouter } from 'react-router-dom'; | ||||
| 
 | ||||
| import ImmutablePropTypes from 'react-immutable-proptypes'; | ||||
| import ImmutablePureComponent from 'react-immutable-pure-component'; | ||||
|  | @ -13,6 +13,7 @@ import EditedTimestamp from 'mastodon/components/edited_timestamp'; | |||
| import { getHashtagBarForStatus } from 'mastodon/components/hashtag_bar'; | ||||
| import { Icon }  from 'mastodon/components/icon'; | ||||
| import PictureInPicturePlaceholder from 'mastodon/components/picture_in_picture_placeholder'; | ||||
| import { WithRouterPropTypes } from 'mastodon/utils/react_router'; | ||||
| 
 | ||||
| import { Avatar } from '../../../components/avatar'; | ||||
| import { DisplayName } from '../../../components/display_name'; | ||||
|  | @ -33,10 +34,6 @@ const messages = defineMessages({ | |||
| 
 | ||||
| class DetailedStatus extends ImmutablePureComponent { | ||||
| 
 | ||||
|   static contextTypes = { | ||||
|     router: PropTypes.object, | ||||
|   }; | ||||
| 
 | ||||
|   static propTypes = { | ||||
|     status: ImmutablePropTypes.map, | ||||
|     onOpenMedia: PropTypes.func.isRequired, | ||||
|  | @ -53,6 +50,7 @@ class DetailedStatus extends ImmutablePureComponent { | |||
|       available: PropTypes.bool, | ||||
|     }), | ||||
|     onToggleMediaVisibility: PropTypes.func, | ||||
|     ...WithRouterPropTypes, | ||||
|   }; | ||||
| 
 | ||||
|   state = { | ||||
|  | @ -60,9 +58,9 @@ class DetailedStatus extends ImmutablePureComponent { | |||
|   }; | ||||
| 
 | ||||
|   handleAccountClick = (e) => { | ||||
|     if (e.button === 0 && !(e.ctrlKey || e.metaKey) && this.context.router) { | ||||
|     if (e.button === 0 && !(e.ctrlKey || e.metaKey) && this.props.history) { | ||||
|       e.preventDefault(); | ||||
|       this.context.router.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`); | ||||
|       this.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`); | ||||
|     } | ||||
| 
 | ||||
|     e.stopPropagation(); | ||||
|  | @ -237,7 +235,7 @@ class DetailedStatus extends ImmutablePureComponent { | |||
| 
 | ||||
|     if (['private', 'direct'].includes(status.get('visibility'))) { | ||||
|       reblogLink = ''; | ||||
|     } else if (this.context.router) { | ||||
|     } else if (this.props.history) { | ||||
|       reblogLink = ( | ||||
|         <> | ||||
|           {' · '} | ||||
|  | @ -263,7 +261,7 @@ class DetailedStatus extends ImmutablePureComponent { | |||
|       ); | ||||
|     } | ||||
| 
 | ||||
|     if (this.context.router) { | ||||
|     if (this.props.history) { | ||||
|       favouriteLink = ( | ||||
|         <Link to={`/@${status.getIn(['account', 'acct'])}/${status.get('id')}/favourites`} className='detailed-status__link'> | ||||
|           <Icon id='star' /> | ||||
|  | @ -333,4 +331,4 @@ class DetailedStatus extends ImmutablePureComponent { | |||
| 
 | ||||
| } | ||||
| 
 | ||||
| export default injectIntl(DetailedStatus); | ||||
| export default withRouter(injectIntl(DetailedStatus)); | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; | |||
| 
 | ||||
| import classNames from 'classnames'; | ||||
| import { Helmet } from 'react-helmet'; | ||||
| import { withRouter } from 'react-router-dom'; | ||||
| 
 | ||||
| import Immutable from 'immutable'; | ||||
| import ImmutablePropTypes from 'react-immutable-proptypes'; | ||||
|  | @ -17,6 +18,7 @@ import { Icon }  from 'mastodon/components/icon'; | |||
| import { LoadingIndicator } from 'mastodon/components/loading_indicator'; | ||||
| import ScrollContainer from 'mastodon/containers/scroll_container'; | ||||
| import BundleColumnError from 'mastodon/features/ui/components/bundle_column_error'; | ||||
| import { WithRouterPropTypes } from 'mastodon/utils/react_router'; | ||||
| 
 | ||||
| import { | ||||
|   unblockAccount, | ||||
|  | @ -68,6 +70,7 @@ import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from | |||
| import ActionBar from './components/action_bar'; | ||||
| import DetailedStatus from './components/detailed_status'; | ||||
| 
 | ||||
| 
 | ||||
| const messages = defineMessages({ | ||||
|   deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, | ||||
|   deleteMessage: { id: 'confirmations.delete.message', defaultMessage: 'Are you sure you want to delete this status?' }, | ||||
|  | @ -187,7 +190,6 @@ const titleFromStatus = (intl, status) => { | |||
| class Status extends ImmutablePureComponent { | ||||
| 
 | ||||
|   static contextTypes = { | ||||
|     router: PropTypes.object, | ||||
|     identity: PropTypes.object, | ||||
|   }; | ||||
| 
 | ||||
|  | @ -206,6 +208,7 @@ class Status extends ImmutablePureComponent { | |||
|       inUse: PropTypes.bool, | ||||
|       available: PropTypes.bool, | ||||
|     }), | ||||
|     ...WithRouterPropTypes | ||||
|   }; | ||||
| 
 | ||||
|   state = { | ||||
|  | @ -279,11 +282,11 @@ class Status extends ImmutablePureComponent { | |||
|           modalProps: { | ||||
|             message: intl.formatMessage(messages.replyMessage), | ||||
|             confirm: intl.formatMessage(messages.replyConfirm), | ||||
|             onConfirm: () => dispatch(replyCompose(status, this.context.router.history)), | ||||
|             onConfirm: () => dispatch(replyCompose(status, this.props.history)), | ||||
|           }, | ||||
|         })); | ||||
|       } else { | ||||
|         dispatch(replyCompose(status, this.context.router.history)); | ||||
|         dispatch(replyCompose(status, this.props.history)); | ||||
|       } | ||||
|     } else { | ||||
|       dispatch(openModal({ | ||||
|  | @ -501,7 +504,7 @@ class Status extends ImmutablePureComponent { | |||
|   }; | ||||
| 
 | ||||
|   handleHotkeyOpenProfile = () => { | ||||
|     this.context.router.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`); | ||||
|     this.props.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`); | ||||
|   }; | ||||
| 
 | ||||
|   handleHotkeyToggleHidden = () => { | ||||
|  | @ -745,4 +748,4 @@ class Status extends ImmutablePureComponent { | |||
| 
 | ||||
| } | ||||
| 
 | ||||
| export default injectIntl(connect(makeMapStateToProps)(Status)); | ||||
| export default withRouter(injectIntl(connect(makeMapStateToProps)(Status))); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue