From 86191f3ce149a343f33caa91f526a5f189601fea Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 15 Jun 2025 01:03:30 -0400 Subject: [PATCH] Footer --- .../features/ui/components/link_footer.tsx | 170 ++++++++---------- 1 file changed, 75 insertions(+), 95 deletions(-) diff --git a/app/javascript/mastodon/features/ui/components/link_footer.tsx b/app/javascript/mastodon/features/ui/components/link_footer.tsx index cbfb6a3114..ec62c16ff8 100644 --- a/app/javascript/mastodon/features/ui/components/link_footer.tsx +++ b/app/javascript/mastodon/features/ui/components/link_footer.tsx @@ -1,101 +1,81 @@ -import { FormattedMessage } from 'react-intl'; +import PropTypes from 'prop-types'; +import { PureComponent } from 'react'; + +import { FormattedMessage, injectIntl } from 'react-intl'; import { Link } from 'react-router-dom'; -import { - domain, - version, - source_url, - statusPageUrl, - profile_directory as canProfileDirectory, - termsOfServiceEnabled, -} from 'mastodon/initial_state'; +import { connect } from 'react-redux'; -const DividingCircle: React.FC = () => {' · '}; +import { openModal } from 'mastodon/actions/modal'; +import { identityContextPropShape, withIdentity } from 'mastodon/identity_context'; +import { domain, version, source_url, statusPageUrl, profile_directory as profileDirectory } from 'mastodon/initial_state'; +import { PERMISSION_INVITE_USERS } from 'mastodon/permissions'; -export const LinkFooter: React.FC<{ - multiColumn: boolean; -}> = ({ multiColumn }) => { - return ( -
-

- {domain}:{' '} - - - - {statusPageUrl && ( - <> - - - - - - )} - {canProfileDirectory && ( - <> - - - - - - )} - - - - - {termsOfServiceEnabled && ( - <> - - - - - - )} -

+const mapDispatchToProps = (dispatch) => ({ + onLogout () { + dispatch(openModal({ modalType: 'CONFIRM_LOG_OUT' })); -

- Mastodon:{' '} - - - - - - - - - - - - - - - - - v{version} -

-
- ); -}; + }, +}); + +class LinkFooter extends PureComponent { + static propTypes = { + identity: identityContextPropShape, + multiColumn: PropTypes.bool, + onLogout: PropTypes.func.isRequired, + intl: PropTypes.object.isRequired, + }; + + handleLogoutClick = e => { + e.preventDefault(); + e.stopPropagation(); + + this.props.onLogout(); + + return false; + }; + + render () { + const { signedIn, permissions } = this.props.identity; + const { multiColumn } = this.props; + + const canInvite = signedIn && ((permissions & PERMISSION_INVITE_USERS) === PERMISSION_INVITE_USERS); + const canProfileDirectory = profileDirectory; + + const DividingCircle = {' · '}; + + return ( +
+

+ {domain}: + {' '} + + {statusPageUrl && ( + <> + {DividingCircle} + + + )} + {canInvite && ( + <> + {DividingCircle} + + + )} + {DividingCircle} + + {DividingCircle} + + {DividingCircle} + + {DividingCircle} + v{version} +

+
+ ); + } + +} + +export default injectIntl(withIdentity(connect(null, mapDispatchToProps)(LinkFooter))); \ No newline at end of file