mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-16 08:04:45 -04:00
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import React from 'react'
|
|
import { Button } from 'react-bootstrap'
|
|
import { ButtonProps } from 'react-bootstrap/Button'
|
|
import { Trans, useTranslation } from 'react-i18next'
|
|
import { useSelector } from 'react-redux'
|
|
import { LinkContainer } from 'react-router-bootstrap'
|
|
import { ApplicationState } from '../../../redux'
|
|
import { ShowIf } from '../../common/show-if/show-if'
|
|
|
|
export type SignInButtonProps = Omit<ButtonProps, 'href'>
|
|
|
|
export const SignInButton: React.FC<SignInButtonProps> = ({ variant, ...props }) => {
|
|
const { t } = useTranslation()
|
|
const anyAuthProviderActive = useSelector((state: ApplicationState) => Object.values(state.config.authProviders)
|
|
.includes(true))
|
|
return (
|
|
<ShowIf condition={ anyAuthProviderActive }>
|
|
<LinkContainer to="/login" title={ t('login.signIn') }>
|
|
<Button
|
|
data-cy={ 'sign-in-button' }
|
|
variant={ variant || 'success' }
|
|
{ ...props }>
|
|
<Trans i18nKey="login.signIn"/>
|
|
</Button>
|
|
</LinkContainer>
|
|
</ShowIf>
|
|
)
|
|
}
|