CryptoDonate: add donate button to mobile sidebar

This commit is contained in:
Alex Gleason 2021-06-10 14:05:07 -05:00
parent 8a2d436d31
commit ef53cd2de1
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -18,6 +18,7 @@ import { logOut, switchAccount } from 'soapbox/actions/auth';
import ThemeToggle from '../features/ui/components/theme_toggle_container'; import ThemeToggle from '../features/ui/components/theme_toggle_container';
import { fetchOwnAccounts } from 'soapbox/actions/auth'; import { fetchOwnAccounts } from 'soapbox/actions/auth';
import { List as ImmutableList, is as ImmutableIs } from 'immutable'; import { List as ImmutableList, is as ImmutableIs } from 'immutable';
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
const messages = defineMessages({ const messages = defineMessages({
followers: { id: 'account.followers', defaultMessage: 'Followers' }, followers: { id: 'account.followers', defaultMessage: 'Followers' },
@ -39,6 +40,7 @@ const messages = defineMessages({
apps: { id: 'tabs_bar.apps', defaultMessage: 'Apps' }, apps: { id: 'tabs_bar.apps', defaultMessage: 'Apps' },
news: { id: 'tabs_bar.news', defaultMessage: 'News' }, news: { id: 'tabs_bar.news', defaultMessage: 'News' },
donate: { id: 'donate', defaultMessage: 'Donate' }, donate: { id: 'donate', defaultMessage: 'Donate' },
donate_crypto: { id: 'donate_crypto', defaultMessage: 'Donate cryptocurrency' },
info: { id: 'column.info', defaultMessage: 'Server information' }, info: { id: 'column.info', defaultMessage: 'Server information' },
add_account: { id: 'profile_dropdown.add_account', defaultMessage: 'Add an existing account' }, add_account: { id: 'profile_dropdown.add_account', defaultMessage: 'Add an existing account' },
}); });
@ -46,6 +48,7 @@ const messages = defineMessages({
const mapStateToProps = state => { const mapStateToProps = state => {
const me = state.get('me'); const me = state.get('me');
const getAccount = makeGetAccount(); const getAccount = makeGetAccount();
const soapbox = getSoapboxConfig(state);
const otherAccounts = const otherAccounts =
state state
@ -61,6 +64,7 @@ const mapStateToProps = state => {
account: getAccount(state, me), account: getAccount(state, me),
sidebarOpen: state.get('sidebar').sidebarOpen, sidebarOpen: state.get('sidebar').sidebarOpen,
donateUrl: state.getIn(['patron', 'instance', 'url']), donateUrl: state.getIn(['patron', 'instance', 'url']),
hasCrypto: typeof soapbox.getIn(['cryptoAddresses', 0, 'ticker']) === 'string',
isStaff: isStaff(state.getIn(['accounts', me])), isStaff: isStaff(state.getIn(['accounts', me])),
otherAccounts, otherAccounts,
}; };
@ -153,7 +157,7 @@ class SidebarMenu extends ImmutablePureComponent {
} }
render() { render() {
const { sidebarOpen, intl, account, onClickLogOut, donateUrl, isStaff, otherAccounts } = this.props; const { sidebarOpen, intl, account, onClickLogOut, donateUrl, isStaff, otherAccounts, hasCrypto } = this.props;
const { switcher } = this.state; const { switcher } = this.state;
if (!account) return null; if (!account) return null;
const acct = account.get('acct'); const acct = account.get('acct');
@ -206,12 +210,14 @@ class SidebarMenu extends ImmutablePureComponent {
<Icon id='user' /> <Icon id='user' />
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.profile)}</span> <span className='sidebar-menu-item__title'>{intl.formatMessage(messages.profile)}</span>
</NavLink> </NavLink>
{donateUrl ? {donateUrl && <a className='sidebar-menu-item' href={donateUrl} onClick={this.handleClose}>
<a className='sidebar-menu-item' href={donateUrl} onClick={this.handleClose}> <Icon id='dollar' />
<Icon id='dollar' /> <span className='sidebar-menu-item__title'>{intl.formatMessage(messages.donate)}</span>
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.donate)}</span> </a>}
</a> {hasCrypto && <NavLink className='sidebar-menu-item' to='/donate/crypto' onClick={this.handleClose}>
: ''} <Icon id='bitcoin' />
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.donate_crypto)}</span>
</NavLink>}
<NavLink className='sidebar-menu-item' to='/lists' onClick={this.handleClose}> <NavLink className='sidebar-menu-item' to='/lists' onClick={this.handleClose}>
<Icon id='list' /> <Icon id='list' />
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.lists)}</span> <span className='sidebar-menu-item__title'>{intl.formatMessage(messages.lists)}</span>