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 { DropdownHeader } from '../dropdown-header'
import { TranslatedDropdownItem } from '../translated-dropdown-item'
import type { ReactElement } from 'react'
@ -29,15 +28,15 @@ export const LegalSubmenu: React.FC = (): null | ReactElement => {
<Fragment>
<Dropdown.Divider />
<DropdownHeader i18nKey={'appbar.help.legal.header'} />
<ShowIf condition={!!specialUrls.privacy}>
{specialUrls.privacy !== undefined && (
<TranslatedDropdownItem href={specialUrls.privacy} i18nKey={'appbar.help.legal.privacy'} />
</ShowIf>
<ShowIf condition={!!specialUrls.termsOfUse}>
)}
{specialUrls.termsOfUse !== undefined && (
<TranslatedDropdownItem href={specialUrls.termsOfUse} i18nKey={'appbar.help.legal.termsOfUse'} />
</ShowIf>
<ShowIf condition={!!specialUrls.imprint}>
)}
{specialUrls.imprint !== undefined && (
<TranslatedDropdownItem href={specialUrls.imprint} i18nKey={'appbar.help.legal.imprint'} />
</ShowIf>
)}
</Fragment>
)
}

View file

@ -5,7 +5,6 @@
*/
import { useTranslatedText } from '../../../../../hooks/common/use-translated-text'
import { UiIcon } from '../../../../common/icons/ui-icon'
import { ShowIf } from '../../../../common/show-if/show-if'
import type { TOptions } from 'i18next'
import React from 'react'
import { Dropdown } from 'react-bootstrap'
@ -36,9 +35,7 @@ export const TranslatedDropdownItem: React.FC<TranslatedDropdownItemProps> = ({
return (
<Dropdown.Item {...props} title={title} className={'d-flex align-items-center'}>
<ShowIf condition={!!icon}>
<UiIcon icon={icon} className={'me-2'} />
</ShowIf>
{icon !== undefined && <UiIcon icon={icon} className={'me-2'} />}
<span>{title}</span>
</Dropdown.Item>
)

View file

@ -9,7 +9,6 @@ import { useMayEdit } from '../../../../../hooks/common/use-may-edit'
import { useNoteTitle } from '../../../../../hooks/common/use-note-title'
import { useTranslatedText } from '../../../../../hooks/common/use-translated-text'
import { UiIcon } from '../../../../common/icons/ui-icon'
import { ShowIf } from '../../../../common/show-if/show-if'
import React from 'react'
import { Lock as IconLock } from 'react-bootstrap-icons'
@ -23,11 +22,11 @@ export const NoteTitleElement: React.FC = () => {
return (
<span className={'m-0 text-truncate'}>
<ShowIf condition={!isWriteable}>
{!isWriteable && (
<span className={'text-secondary me-2'}>
<UiIcon icon={IconLock} className={'me-2'} title={readOnlyLabel} />
</span>
</ShowIf>
)}
{noteTitle}
</span>
)