From b051b109e58315e2c9558cac9bca4003907a469e Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Thu, 4 Jun 2020 23:38:21 +0200 Subject: [PATCH] Show login-buttons and boxes only if providers are configured (#122) * Hide "Sign-in via ..." box if no provider is enabled * Show sign-in buttons only if auth-providers exist * Rebase fixes * Replaced ternary operators with ShowIf * Added ShowIf on two other code positions --- .../layout/navigation/sign-in-button.tsx | 23 +++--- .../intro/cover-buttons/cover-buttons.tsx | 12 ++-- src/components/landing/pages/login/login.tsx | 70 ++++++++++--------- 3 files changed, 58 insertions(+), 47 deletions(-) diff --git a/src/components/landing/layout/navigation/sign-in-button.tsx b/src/components/landing/layout/navigation/sign-in-button.tsx index d808142ed..cdf189350 100644 --- a/src/components/landing/layout/navigation/sign-in-button.tsx +++ b/src/components/landing/layout/navigation/sign-in-button.tsx @@ -2,7 +2,10 @@ 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' type SignInButtonProps = { className?: string @@ -10,15 +13,17 @@ type SignInButtonProps = { export const SignInButton: React.FC = ({ variant, ...props }) => { const { t } = useTranslation() - + const authProviders = useSelector((state: ApplicationState) => state.backendConfig.authProviders) return ( - - - + + + + + ) } diff --git a/src/components/landing/pages/intro/cover-buttons/cover-buttons.tsx b/src/components/landing/pages/intro/cover-buttons/cover-buttons.tsx index 483f89ef8..59470444d 100644 --- a/src/components/landing/pages/intro/cover-buttons/cover-buttons.tsx +++ b/src/components/landing/pages/intro/cover-buttons/cover-buttons.tsx @@ -4,12 +4,14 @@ import { Trans, useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' import { Link } from 'react-router-dom' import { ApplicationState } from '../../../../../redux' +import { ShowIf } from '../../../../common/show-if' import { SignInButton } from '../../../layout/navigation/sign-in-button' import './cover-buttons.scss' export const CoverButtons: React.FC = () => { useTranslation() const user = useSelector((state: ApplicationState) => state.user) + const authProviders = useSelector((state: ApplicationState) => state.backendConfig.authProviders) if (user) { return null @@ -22,11 +24,11 @@ export const CoverButtons: React.FC = () => { variant="success" size="lg" /> - - - - - + + + + +