refactor: remove show-if in favour of conditionals

This prevents a problem where show-if can trigger an error if a value is checked to exist with it.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2023-10-30 12:23:24 +01:00
parent 8884bbb428
commit f701f8d05f
52 changed files with 239 additions and 352 deletions

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { ShowIf } from '../../common/show-if/show-if'
import { AltKey } from './alt-key'
import { ModifierKey } from './modifier-key'
import React from 'react'
@ -39,15 +38,19 @@ export const ShortcutLine: React.FC<ShortcutLineProps> = ({
<Trans i18nKey={functionNameI18nKey} />
</span>
<span>
<ShowIf condition={showModifierKey}>
<ModifierKey />
<span> + </span>
</ShowIf>
{showModifierKey && (
<>
<ModifierKey />
<span> + </span>
</>
)}
<ShowIf condition={showAltKey}>
<AltKey />
<span> + </span>
</ShowIf>
{showAltKey && (
<>
<AltKey />
<span> + </span>
</>
)}
<kbd>{functionKeyCode.toUpperCase()}</kbd>
</span>

View file

@ -11,7 +11,6 @@ import { useFrontendConfig } from '../../common/frontend-config-context/use-fron
import { TranslatedExternalLink } from '../../common/links/translated-external-link'
import type { CommonModalProps } from '../../common/modals/common-modal'
import { CommonModal } from '../../common/modals/common-modal'
import { ShowIf } from '../../common/show-if/show-if'
import React, { useMemo } from 'react'
import { Modal } from 'react-bootstrap'
@ -46,20 +45,20 @@ export const VersionInfoModal: React.FC<CommonModalProps> = ({ onHide, show }) =
<Modal.Body>
<CopyableField content={backendVersion} />
<div className='d-flex justify-content-between mt-3'>
<ShowIf condition={!!links.sourceCode}>
{links.sourceCode !== undefined && (
<TranslatedExternalLink
i18nKey={'landing.versionInfo.sourceCode'}
className={'btn btn-primary d-block mb-2'}
href={links.sourceCode}
/>
</ShowIf>
<ShowIf condition={!!links.issues}>
)}
{links.issues !== undefined && (
<TranslatedExternalLink
i18nKey={'landing.versionInfo.issueTracker'}
className={'btn btn-primary d-block mb-2'}
href={links.issues}
/>
</ShowIf>
)}
</div>
</Modal.Body>
</CommonModal>