Merge remote-tracking branch 'origin/next' into next-colors

This commit is contained in:
Alex Gleason
2022-03-22 13:57:09 -05:00
17 changed files with 83 additions and 103 deletions

View File

@@ -9,6 +9,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
import InlineSVG from 'react-inlinesvg';
import { defineMessages, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { openModal } from 'soapbox/actions/modals';
import Avatar from 'soapbox/components/avatar';
@@ -612,8 +613,7 @@ class Header extends ImmutablePureComponent {
return <MenuDivider key={idx} />;
} else {
const Comp = menuItem.action ? MenuItem : MenuLink;
// TODO: Add `as: Link` once React Router is upgraded.
const itemProps = menuItem.action ? { onSelect: menuItem.action } : { to: menuItem.to, target: menuItem.newTab ? '_blank' : '_self' };
const itemProps = menuItem.action ? { onSelect: menuItem.action } : { to: menuItem.to, as: Link, target: menuItem.newTab ? '_blank' : '_self' };
return (
<Comp key={idx} {...itemProps} className='group'>

View File

@@ -5,7 +5,7 @@ import * as React from 'react';
import InlineSVG from 'react-inlinesvg';
import { defineMessages, useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
import { RouteComponentProps, withRouter } from 'react-router-dom';
import { useHistory } from 'react-router-dom';
import AutosuggestAccountInput from 'soapbox/components/autosuggest_account_input';
import { useAppSelector } from 'soapbox/hooks';
@@ -32,7 +32,7 @@ function redirectToAccount(accountId: number, routerHistory: any) {
};
}
interface ISearch extends RouteComponentProps<any> {
interface ISearch {
autoFocus?: boolean,
autoSubmit?: boolean,
autosuggest?: boolean,
@@ -44,11 +44,11 @@ const Search = (props: ISearch) => {
autoFocus = false,
autoSubmit = false,
autosuggest = false,
history,
openInRoute = false,
} = props;
const dispatch = useDispatch();
const history = useHistory();
const intl = useIntl();
const value = useAppSelector((state) => state.search.get('value'));
@@ -156,4 +156,4 @@ const Search = (props: ISearch) => {
);
};
export default withRouter(Search);
export default Search;

View File

@@ -1,9 +1,8 @@
import PropTypes from 'prop-types';
import React from 'react';
import InlineSVG from 'react-inlinesvg';
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
import { Link, withRouter } from 'react-router-dom';
import { Link, useHistory } from 'react-router-dom';
import { changeSettingImmediate } from 'soapbox/actions/settings';
import snackbar from 'soapbox/actions/snackbar';
@@ -16,9 +15,10 @@ const messages = defineMessages({
leave: { id: 'developers.leave', defaultMessage: 'You have left developers' },
});
const Developers = ({ history }) => {
const intl = useIntl();
const Developers = () => {
const dispatch = useDispatch();
const history = useHistory();
const intl = useIntl();
const leaveDevelopers = (e) => {
e.preventDefault();
@@ -67,8 +67,4 @@ const Developers = ({ history }) => {
);
};
Developers.propTypes = {
history: PropTypes.object,
};
export default withRouter(Developers);
export default Developers;

View File

@@ -3,7 +3,7 @@ import React from 'react';
import { HotKeys } from 'react-hotkeys';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { FormattedMessage, useIntl } from 'react-intl';
import { withRouter } from 'react-router-dom';
import { useHistory } from 'react-router-dom';
import Icon from '../../../components/icon';
import Permalink from '../../../components/permalink';
@@ -77,9 +77,11 @@ const buildMessage = (type, account) => {
};
const Notification = (props) => {
const { hidden, history, notification, onMoveUp, onMoveDown } = props;
const { hidden, notification, onMoveUp, onMoveDown } = props;
const history = useHistory();
const intl = useIntl();
const type = notification.get('type');
const timestamp = notification.get('created_at');
const account = notification.get('account');
@@ -226,7 +228,6 @@ const Notification = (props) => {
Notification.propTypes = {
hidden: PropTypes.bool,
history: PropTypes.object.isRequired,
notification: ImmutablePropTypes.map.isRequired,
onMoveUp: PropTypes.func.isRequired,
onMoveDown: PropTypes.func.isRequired,
@@ -241,4 +242,4 @@ Notification.propTypes = {
siteTitle: PropTypes.string,
};
export default withRouter(Notification);
export default Notification;

View File

@@ -111,11 +111,17 @@ const Preferences = () => {
return (
<Form>
<List>
<ListItem label={<FormattedMessage id='home.column_settings.show_reblogs' defaultMessage='Show reTRUTHs' />}>
<ListItem
label={<FormattedMessage id='home.column_settings.show_reblogs' defaultMessage='Show reTRUTHs' />}
hint={<FormattedMessage id='preferences.hints.feed' defaultMessage='In your home feed' />}
>
<SettingToggle settings={settings} settingPath={['home', 'shows', 'reblog']} onChange={onToggleChange} />
</ListItem>
<ListItem label={<FormattedMessage id='home.column_settings.show_replies' defaultMessage='Show replies' />}>
<ListItem
label={<FormattedMessage id='home.column_settings.show_replies' defaultMessage='Show replies' />}
hint={<FormattedMessage id='preferences.hints.feed' defaultMessage='In your home feed' />}
>
<SettingToggle settings={settings} settingPath={['home', 'shows', 'reply']} onChange={onToggleChange} />
</ListItem>

View File

@@ -1,8 +1,7 @@
import PropTypes from 'prop-types';
import * as React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { useDispatch, useSelector } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { useHistory } from 'react-router-dom';
import { fetchMfa } from 'soapbox/actions/mfa';
@@ -22,9 +21,11 @@ const messages = defineMessages({
deleteAccount: { id: 'settings.delete_account', defaultMessage: 'Delete Account' },
});
const Settings = ({ history }) => {
const intl = useIntl();
const Settings = () => {
const dispatch = useDispatch();
const history = useHistory();
const intl = useIntl();
const mfa = useSelector((state) => state.getIn(['security', 'mfa']));
const me = useSelector((state) => state.get('me'));
const account = useSelector((state) => state.getIn(['accounts', me]));
@@ -92,8 +93,4 @@ const Settings = ({ history }) => {
);
};
Settings.propTypes = {
history: PropTypes.object,
};
export default withRouter(Settings);
export default Settings;

View File

@@ -1,15 +1,13 @@
import PropTypes from 'prop-types';
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { defineMessages, useIntl } from 'react-intl';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { getSettings, changeSettingImmediate } from 'soapbox/actions/settings';
import {
SimpleForm,
SelectDropdown,
} from 'soapbox/features/forms';
import { useAppSelector } from 'soapbox/hooks';
import List, { ListItem } from '../../components/list';
import { Card, CardBody, CardHeader, CardTitle } from '../../components/ui';
@@ -21,15 +19,12 @@ const messages = defineMessages({
display_media_show_all: { id: 'preferences.fields.display_media.show_all', defaultMessage: 'Always show media' },
});
const mapStateToProps = state => {
return {
settings: getSettings(state),
};
};
const MediaDisplay = ({ history, settings, dispatch }) => {
const MediaDisplay = () => {
const dispatch = useDispatch();
const intl = useIntl();
const settings = useAppSelector((state) => getSettings(state));
const displayMediaOptions = {
default: intl.formatMessage(messages.display_media_default),
hide_all: intl.formatMessage(messages.display_media_hide_all),
@@ -65,10 +60,4 @@ const MediaDisplay = ({ history, settings, dispatch }) => {
);
};
MediaDisplay.propTypes = {
history: PropTypes.object,
dispatch: PropTypes.func.isRequired,
settings: ImmutablePropTypes.map,
};
export default withRouter(connect(mapStateToProps)(MediaDisplay));
export default MediaDisplay;

View File

@@ -2,6 +2,7 @@ import throttle from 'lodash/throttle';
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
import { Link } from 'react-router-dom';
import { logOut, switchAccount } from 'soapbox/actions/auth';
import { fetchOwnAccounts } from 'soapbox/actions/auth';
@@ -42,16 +43,13 @@ const ProfileDropdown: React.FC<IProfileDropdown> = ({ account, children }) => {
const isCurrentAccountStaff = isStaff(currentAccount) || false;
const otherAccounts = useAppSelector((state) => authUsers.map((authUser: any) => getAccount(state, authUser.get('id'))));
const handleLogOut = (event: React.MouseEvent) => {
event.preventDefault();
const handleLogOut = () => {
dispatch(logOut(intl));
};
const handleSwitchAccount = (account: AccountEntity) => {
return (event: React.MouseEvent) => {
return () => {
dispatch(switchAccount(account.id));
event.preventDefault();
};
};
@@ -115,7 +113,7 @@ const ProfileDropdown: React.FC<IProfileDropdown> = ({ account, children }) => {
return <MenuDivider key={idx} />;
} else {
const Comp: any = menuItem.action ? MenuItem : MenuLink;
const itemProps = menuItem.action ? { onSelect: menuItem.action } : { href: menuItem.to };
const itemProps = menuItem.action ? { onSelect: menuItem.action } : { to: menuItem.to, as: Link };
return (
<Comp key={idx} {...itemProps}>

View File

@@ -2,7 +2,6 @@ import PropTypes from 'prop-types';
import * as React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
import { withRouter } from 'react-router-dom';
import snackbar from 'soapbox/actions/snackbar';
import { confirmEmailVerification } from 'soapbox/actions/verification';
@@ -95,8 +94,8 @@ const TokenExpired = () => {
const EmailPassThru = ({ match }) => {
const { token } = match.params;
const intl = useIntl();
const dispatch = useDispatch();
const intl = useIntl();
const [status, setStatus] = React.useState(Statuses.IDLE);
@@ -160,4 +159,4 @@ EmailPassThru.propTypes = {
match: PropTypes.object,
};
export default withRouter(EmailPassThru);
export default EmailPassThru;