mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-22 11:48:06 +01:00
[Glitch] Add support for custom sign-up URLs
Port ca66e61b93
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
8f380a33fc
commit
9e5278ea7b
3 changed files with 17 additions and 8 deletions
|
@ -9,6 +9,7 @@ import { openModal, closeModal } from 'flavours/glitch/actions/modal';
|
|||
|
||||
const mapStateToProps = (state, { accountId }) => ({
|
||||
displayNameHtml: state.getIn(['accounts', accountId, 'display_name_html']),
|
||||
signupUrl: state.getIn(['server', 'server', 'registrations', 'url'], '/auth/sign_up'),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
|
@ -81,6 +82,7 @@ class InteractionModal extends PureComponent {
|
|||
url: PropTypes.string,
|
||||
type: PropTypes.oneOf(['reply', 'reblog', 'favourite', 'follow']),
|
||||
onSignupClick: PropTypes.func.isRequired,
|
||||
signupUrl: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
handleSignupClick = () => {
|
||||
|
@ -88,7 +90,7 @@ class InteractionModal extends PureComponent {
|
|||
};
|
||||
|
||||
render () {
|
||||
const { url, type, displayNameHtml } = this.props;
|
||||
const { url, type, displayNameHtml, signupUrl } = this.props;
|
||||
|
||||
const name = <bdi dangerouslySetInnerHTML={{ __html: displayNameHtml }} />;
|
||||
|
||||
|
@ -121,7 +123,7 @@ class InteractionModal extends PureComponent {
|
|||
|
||||
if (registrationsOpen) {
|
||||
signupButton = (
|
||||
<a href='/auth/sign_up' className='button button--block button-tertiary'>
|
||||
<a href={signupUrl} className='button button--block button-tertiary'>
|
||||
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
||||
</a>
|
||||
);
|
||||
|
|
|
@ -17,6 +17,10 @@ const Account = connect(state => ({
|
|||
</Permalink>
|
||||
));
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
signupUrl: state.getIn(['server', 'server', 'registrations', 'url'], '/auth/sign_up'),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
openClosedRegistrationsModal() {
|
||||
dispatch(openModal('CLOSED_REGISTRATIONS'));
|
||||
|
@ -32,11 +36,12 @@ class Header extends PureComponent {
|
|||
static propTypes = {
|
||||
openClosedRegistrationsModal: PropTypes.func,
|
||||
location: PropTypes.object,
|
||||
signupUrl: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
render () {
|
||||
const { signedIn } = this.context.identity;
|
||||
const { location, openClosedRegistrationsModal } = this.props;
|
||||
const { location, openClosedRegistrationsModal, signupUrl } = this.props;
|
||||
|
||||
let content;
|
||||
|
||||
|
@ -52,7 +57,7 @@ class Header extends PureComponent {
|
|||
|
||||
if (registrationsOpen) {
|
||||
signupButton = (
|
||||
<a href='/auth/sign_up' className='button'>
|
||||
<a href={signupUrl} className='button'>
|
||||
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
||||
</a>
|
||||
);
|
||||
|
@ -88,4 +93,4 @@ class Header extends PureComponent {
|
|||
|
||||
}
|
||||
|
||||
export default withRouter(connect(null, mapDispatchToProps)(Header));
|
||||
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Header));
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { useCallback } from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useAppDispatch, useAppSelector } from 'flavours/glitch/store';
|
||||
import { registrationsOpen } from 'flavours/glitch/initial_state';
|
||||
import { openModal } from 'flavours/glitch/actions/modal';
|
||||
|
||||
const SignInBanner = () => {
|
||||
const dispatch = useDispatch();
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const openClosedRegistrationsModal = useCallback(
|
||||
() => dispatch(openModal('CLOSED_REGISTRATIONS')),
|
||||
|
@ -14,9 +14,11 @@ const SignInBanner = () => {
|
|||
|
||||
let signupButton;
|
||||
|
||||
const signupUrl = useAppSelector((state) => state.getIn(['server', 'server', 'registrations', 'url'], '/auth/sign_up'));
|
||||
|
||||
if (registrationsOpen) {
|
||||
signupButton = (
|
||||
<a href='/auth/sign_up' className='button button--block'>
|
||||
<a href={signupUrl} className='button button--block'>
|
||||
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
||||
</a>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue