diff --git a/src/components/application-loader/loading-screen.tsx b/src/components/application-loader/loading-screen.tsx index f157b7985..08697a052 100644 --- a/src/components/application-loader/loading-screen.tsx +++ b/src/components/application-loader/loading-screen.tsx @@ -1,6 +1,7 @@ import React from 'react' import { Alert } from 'react-bootstrap' import { ForkAwesomeIcon } from '../../fork-awesome/fork-awesome-icon' +import { ShowIf } from '../common/show-if' export interface LoadingScreenProps { failedTitle: string @@ -13,16 +14,12 @@ export const LoadingScreen: React.FC = ({ failedTitle }) => - { - failedTitle !== '' - ? ( - - The task '{failedTitle}' failed.
- For further information look into the browser console. -
- ) - : null - } + + + The task '{failedTitle}' failed.
+ For further information look into the browser console. +
+
) } diff --git a/src/components/editor/editor.tsx b/src/components/editor/editor.tsx index e8cfae3f4..f94317267 100644 --- a/src/components/editor/editor.tsx +++ b/src/components/editor/editor.tsx @@ -2,6 +2,7 @@ import React from 'react' import { useSelector } from 'react-redux' import { useParams } from 'react-router' import { ApplicationState } from '../../redux' +import { ShowIf } from '../common/show-if' import { EditorWindow } from './editor-window/editor-window' import { MarkdownPreview } from './markdown-preview/markdown-preview' import { EditorMode } from './task-bar/editor-view-mode' @@ -20,8 +21,12 @@ const Editor: React.FC = () => {

{id}

- { editorMode === EditorMode.EDITOR || editorMode === EditorMode.BOTH ? : null } - { editorMode === EditorMode.PREVIEW || editorMode === EditorMode.BOTH ? : null } + + + + + +
) diff --git a/src/components/element-separator/element-separator.tsx b/src/components/element-separator/element-separator.tsx index 266ab8cd2..b850d32b4 100644 --- a/src/components/element-separator/element-separator.tsx +++ b/src/components/element-separator/element-separator.tsx @@ -1,4 +1,5 @@ import React, { Fragment } from 'react' +import { ShowIf } from '../common/show-if' export interface ElementSeparatorProps { separator: React.ReactElement @@ -14,9 +15,9 @@ export const ElementSeparator: React.FC = ({ children, se .map((child, index) => { return ( - { - (index > 0) ? separator : null - } + 0}> + {separator} + {child} ) diff --git a/src/components/landing/layout/version-info/version-info.tsx b/src/components/landing/layout/version-info/version-info.tsx index eb1a4d28d..670ff6ed5 100644 --- a/src/components/landing/layout/version-info/version-info.tsx +++ b/src/components/landing/layout/version-info/version-info.tsx @@ -5,6 +5,7 @@ import { useSelector } from 'react-redux' import { Link } from 'react-router-dom' import { ApplicationState } from '../../../../redux' import frontendVersion from '../../../../version.json' +import { ShowIf } from '../../../common/show-if' import { TranslatedExternalLink } from '../../../links/translated-external-link' import { VersionInputField } from './version-input-field' @@ -22,10 +23,12 @@ export const VersionInfo: React.FC = () => {
{title}
- {sourceCodeLink - ? : null} - {issueTrackerLink - ? : null} + + + + + + ) diff --git a/src/components/landing/pages/login/login.tsx b/src/components/landing/pages/login/login.tsx index 046c791be..d4471dffd 100644 --- a/src/components/landing/pages/login/login.tsx +++ b/src/components/landing/pages/login/login.tsx @@ -15,9 +15,6 @@ export const Login: React.FC = () => { const authProviders = useSelector((state: ApplicationState) => state.backendConfig.authProviders) const customAuthNames = useSelector((state: ApplicationState) => state.backendConfig.customAuthNames) const userLoginState = useSelector((state: ApplicationState) => state.user) - const emailForm = authProviders.email ? : null - const ldapForm = authProviders.ldap ? : null - const openIdForm = authProviders.openid ? : null const oneClickProviders = [authProviders.dropbox, authProviders.facebook, authProviders.github, authProviders.gitlab, authProviders.google, authProviders.oauth2, authProviders.saml, authProviders.twitter] @@ -45,9 +42,9 @@ export const Login: React.FC = () => { - {emailForm} - {ldapForm} - {openIdForm} + + + diff --git a/src/components/landing/pages/profile/profile.tsx b/src/components/landing/pages/profile/profile.tsx index b24bb6055..49248dc99 100644 --- a/src/components/landing/pages/profile/profile.tsx +++ b/src/components/landing/pages/profile/profile.tsx @@ -4,6 +4,7 @@ import { useSelector } from 'react-redux' import { Redirect } from 'react-router' import { ApplicationState } from '../../../../redux' import { LoginProvider } from '../../../../redux/user/types' +import { ShowIf } from '../../../common/show-if' import { ProfileAccountManagement } from './settings/profile-account-management' import { ProfileChangePassword } from './settings/profile-change-password' import { ProfileDisplayName } from './settings/profile-display-name' @@ -22,7 +23,9 @@ export const Profile: React.FC = () => { - {user.provider === LoginProvider.EMAIL ? : null} + + + diff --git a/src/components/links/external-link.tsx b/src/components/links/external-link.tsx index 4df46ee3f..8fae3ce66 100644 --- a/src/components/links/external-link.tsx +++ b/src/components/links/external-link.tsx @@ -1,5 +1,6 @@ -import React, { Fragment } from 'react' -import { ForkAwesomeIcon } from '../../fork-awesome/fork-awesome-icon' +import React from 'react' +import { ForkAwesomeIcon, IconName } from '../../fork-awesome/fork-awesome-icon' +import { ShowIf } from '../common/show-if' import { LinkWithTextProps } from './types' export const ExternalLink: React.FC = ({ href, text, icon, className = 'text-light' }) => { @@ -8,13 +9,9 @@ export const ExternalLink: React.FC = ({ href, text, icon, cl target="_blank" rel="noopener noreferrer" className={className}> - { - icon - ? -   - - : null - } + +   + {text} ) diff --git a/src/components/links/internal-link.tsx b/src/components/links/internal-link.tsx index 08520df54..88daf9af8 100644 --- a/src/components/links/internal-link.tsx +++ b/src/components/links/internal-link.tsx @@ -1,22 +1,17 @@ -import React, { Fragment } from 'react' +import React from 'react' import { Link } from 'react-router-dom' -import { ForkAwesomeIcon } from '../../fork-awesome/fork-awesome-icon' +import { ForkAwesomeIcon, IconName } from '../../fork-awesome/fork-awesome-icon' +import { ShowIf } from '../common/show-if' import { LinkWithTextProps } from './types' export const InternalLink: React.FC = ({ href, text, icon, className = 'text-light' }) => { return ( - - { - icon - ? -   - - : null - } - {text} - + +   + + {text} ) } diff --git a/src/components/pagination/pager-pagination.tsx b/src/components/pagination/pager-pagination.tsx index a8009fc8e..2ba344c6c 100644 --- a/src/components/pagination/pager-pagination.tsx +++ b/src/components/pagination/pager-pagination.tsx @@ -1,11 +1,12 @@ -import React, { Fragment, useEffect, useState } from 'react' +import React, { useEffect, useState } from 'react' import { Pagination } from 'react-bootstrap' +import { ShowIf } from '../common/show-if' import { PagerItem } from './pager-item' export interface PaginationProps { - numberOfPageButtonsToShowAfterAndBeforeCurrent: number - onPageChange: (pageIndex: number) => void - lastPageIndex: number + numberOfPageButtonsToShowAfterAndBeforeCurrent: number + onPageChange: (pageIndex: number) => void + lastPageIndex: number } export const PagerPagination: React.FC = ({ numberOfPageButtonsToShowAfterAndBeforeCurrent, onPageChange, lastPageIndex }) => { @@ -23,28 +24,28 @@ export const PagerPagination: React.FC = ({ numberOfPageButtons }, [onPageChange, pageIndex]) const correctedLowerPageIndex = - Math.min( - Math.max( - Math.min( - wantedLowerPageIndex, - wantedLowerPageIndex + lastPageIndex - wantedUpperPageIndex - ), - 0 - ), - lastPageIndex - ) - - const correctedUpperPageIndex = + Math.min( Math.max( Math.min( - Math.max( - wantedUpperPageIndex, - wantedUpperPageIndex - wantedLowerPageIndex - ), - lastPageIndex + wantedLowerPageIndex, + wantedLowerPageIndex + lastPageIndex - wantedUpperPageIndex ), 0 - ) + ), + lastPageIndex + ) + + const correctedUpperPageIndex = + Math.max( + Math.min( + Math.max( + wantedUpperPageIndex, + wantedUpperPageIndex - wantedLowerPageIndex + ), + lastPageIndex + ), + 0 + ) const paginationItemsBefore = Array.from(new Array(correctedPageIndex - correctedLowerPageIndex)).map((k, index) => { const itemIndex = correctedLowerPageIndex + index @@ -58,25 +59,17 @@ export const PagerPagination: React.FC = ({ numberOfPageButtons return ( - { - correctedLowerPageIndex > 0 - ? - - - - : null - } + 0}> + + + {paginationItemsBefore} {correctedPageIndex + 1} {paginationItemsAfter} - { - correctedUpperPageIndex < lastPageIndex - ? - - - - : null - } + + + + ) }