diff --git a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/archive-project-button.tsx b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/archive-project-button.tsx index 14b8bd4c8c..d5183f2f7e 100644 --- a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/archive-project-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/archive-project-button.tsx @@ -78,12 +78,7 @@ const ArchiveProjectButtonTooltip = memo(function ArchiveProjectButtonTooltip({ variant="link" accessibilityLabel={text} className="action-btn" - icon={ - bsVersion({ - bs5: 'inbox', - bs3: 'inbox', - }) as string - } + icon={bsVersion({ bs5: 'inbox', bs3: 'inbox' })} bs3Props={{ fw: true }} /> diff --git a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/compile-and-download-project-pdf-button.tsx b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/compile-and-download-project-pdf-button.tsx index 2d17174cd3..feb5ecccbe 100644 --- a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/compile-and-download-project-pdf-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/compile-and-download-project-pdf-button.tsx @@ -159,12 +159,7 @@ const CompileAndDownloadProjectPDFButtonTooltip = memo( loadingLabel={text} isLoading={pendingCompile} className="action-btn" - icon={ - bsVersion({ - bs5: 'picture_as_pdf', - bs3: 'file-pdf-o', - }) as string - } + icon={bsVersion({ bs5: 'picture_as_pdf', bs3: 'file-pdf-o' })} bs3Props={{ fw: true, loading: pendingCompile ? ( diff --git a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/copy-project-button.tsx b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/copy-project-button.tsx index e5184eac12..e5d34abb24 100644 --- a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/copy-project-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/copy-project-button.tsx @@ -111,12 +111,7 @@ const CopyProjectButtonTooltip = memo(function CopyProjectButtonTooltip({ variant="link" accessibilityLabel={text} className="action-btn" - icon={ - bsVersion({ - bs5: 'file_copy', - bs3: 'files-o', - }) as string - } + icon={bsVersion({ bs5: 'file_copy', bs3: 'files-o' })} bs3Props={{ fw: true }} /> diff --git a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/delete-project-button.tsx b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/delete-project-button.tsx index e5d0f9a621..cfb62d6b59 100644 --- a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/delete-project-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/delete-project-button.tsx @@ -76,12 +76,7 @@ const DeleteProjectButtonTooltip = memo(function DeleteProjectButtonTooltip({ variant="link" accessibilityLabel={text} className="action-btn" - icon={ - bsVersion({ - bs5: 'block', - bs3: 'ban', - }) as string - } + icon={bsVersion({ bs5: 'block', bs3: 'ban' })} bs3Props={{ fw: true }} /> diff --git a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/download-project-button.tsx b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/download-project-button.tsx index 678e915ab7..568c6f5887 100644 --- a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/download-project-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/download-project-button.tsx @@ -52,12 +52,7 @@ const DownloadProjectButtonTooltip = memo( variant="link" accessibilityLabel={text} className="action-btn" - icon={ - bsVersion({ - bs5: 'download', - bs3: 'cloud-download', - }) as string - } + icon={bsVersion({ bs5: 'download', bs3: 'cloud-download' })} bs3Props={{ fw: true }} /> diff --git a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/leave-project-button.tsx b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/leave-project-button.tsx index c279fbb292..f50797007f 100644 --- a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/leave-project-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/leave-project-button.tsx @@ -75,12 +75,7 @@ const LeaveProjectButtonTooltip = memo(function LeaveProjectButtonTooltip({ variant="link" accessibilityLabel={text} className="action-btn" - icon={ - bsVersion({ - bs5: 'logout', - bs3: 'sign-out', - }) as string - } + icon={bsVersion({ bs5: 'logout', bs3: 'sign-out' })} bs3Props={{ fw: true }} /> diff --git a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/trash-project-button.tsx b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/trash-project-button.tsx index e7384f44a3..f81712a8d2 100644 --- a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/trash-project-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/trash-project-button.tsx @@ -75,12 +75,7 @@ const TrashProjectButtonTooltip = memo(function TrashProjectButtonTooltip({ variant="link" accessibilityLabel={text} className="action-btn" - icon={ - bsVersion({ - bs5: 'delete', - bs3: 'trash', - }) as string - } + icon={bsVersion({ bs5: 'delete', bs3: 'trash' })} bs3Props={{ fw: true }} /> diff --git a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/unarchive-project-button.tsx b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/unarchive-project-button.tsx index 9cb99b2075..17aec589cf 100644 --- a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/unarchive-project-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/unarchive-project-button.tsx @@ -54,12 +54,7 @@ const UnarchiveProjectButtonTooltip = memo( variant="link" accessibilityLabel={text} className="action-btn" - icon={ - bsVersion({ - bs5: 'restore_page', - bs3: 'reply', - }) as string - } + icon={bsVersion({ bs5: 'restore_page', bs3: 'reply' })} bs3Props={{ fw: true }} /> diff --git a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/untrash-project-button.tsx b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/untrash-project-button.tsx index ce3db4b665..0e56ba6f98 100644 --- a/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/untrash-project-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/cells/action-buttons/untrash-project-button.tsx @@ -53,12 +53,7 @@ const UntrashProjectButtonTooltip = memo(function UntrashProjectButtonTooltip({ variant="link" accessibilityLabel={text} className="action-btn" - icon={ - bsVersion({ - bs5: 'restore_page', - bs3: 'reply', - }) as string - } + icon={bsVersion({ bs5: 'restore_page', bs3: 'reply' })} bs3Props={{ fw: true }} /> diff --git a/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/archive-projects-button.tsx b/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/archive-projects-button.tsx index 1a76239ee5..b60dd3402e 100644 --- a/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/archive-projects-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/archive-projects-button.tsx @@ -50,12 +50,7 @@ function ArchiveProjectsButton() { onClick={handleOpenModal} variant="secondary" accessibilityLabel={text} - icon={ - bsVersion({ - bs5: 'inbox', - bs3: 'inbox', - }) as string - } + icon={bsVersion({ bs5: 'inbox', bs3: 'inbox' })} /> ) diff --git a/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/trash-projects-button.tsx b/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/trash-projects-button.tsx index b12d036938..dc56b6b0ab 100644 --- a/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/trash-projects-button.tsx +++ b/services/web/frontend/js/features/project-list/components/table/project-tools/buttons/trash-projects-button.tsx @@ -50,12 +50,7 @@ function TrashProjectsButton() { onClick={handleOpenModal} variant="secondary" accessibilityLabel={text} - icon={ - bsVersion({ - bs5: 'delete', - bs3: 'trash', - }) as string - } + icon={bsVersion({ bs5: 'delete', bs3: 'trash' })} /> ) diff --git a/services/web/frontend/js/features/source-editor/components/codemirror-toolbar.tsx b/services/web/frontend/js/features/source-editor/components/codemirror-toolbar.tsx index 24caa9eb7e..985c552216 100644 --- a/services/web/frontend/js/features/source-editor/components/codemirror-toolbar.tsx +++ b/services/web/frontend/js/features/source-editor/components/codemirror-toolbar.tsx @@ -187,7 +187,7 @@ const Toolbar = memo(function Toolbar() { label="Toggle Search" command={commands.toggleSearch} active={searchPanelOpen(state)} - icon={bsVersion({ bs5: 'search', bs3: 'search' }) as string} + icon={bsVersion({ bs5: 'search', bs3: 'search' })} /> @@ -202,7 +202,7 @@ const Toolbar = memo(function Toolbar() { id="toolbar-expand-less" label="Hide Toolbar" command={toggleToolbar} - icon={bsVersion({ bs5: 'arrow_drop_up', bs3: 'caret-up' }) as string} + icon={bsVersion({ bs5: 'arrow_drop_up', bs3: 'caret-up' })} hidden // enable this once there's a way to show the toolbar again /> diff --git a/services/web/frontend/js/features/source-editor/components/figure-modal/figure-modal-source-picker.tsx b/services/web/frontend/js/features/source-editor/components/figure-modal/figure-modal-source-picker.tsx index 06af11e461..e9ba17502c 100644 --- a/services/web/frontend/js/features/source-editor/components/figure-modal/figure-modal-source-picker.tsx +++ b/services/web/frontend/js/features/source-editor/components/figure-modal/figure-modal-source-picker.tsx @@ -22,25 +22,25 @@ export const FigureModalSourcePicker: FC = () => { {(hasLinkedProjectFileFeature || hasLinkedProjectOutputFileFeature) && ( )} {hasLinkUrlFeature && ( )} diff --git a/services/web/frontend/js/features/source-editor/components/toolbar/toolbar-items.tsx b/services/web/frontend/js/features/source-editor/components/toolbar/toolbar-items.tsx index afaa43c3e1..5ecb7baf93 100644 --- a/services/web/frontend/js/features/source-editor/components/toolbar/toolbar-items.tsx +++ b/services/web/frontend/js/features/source-editor/components/toolbar/toolbar-items.tsx @@ -46,14 +46,14 @@ export const ToolbarItems: FC<{ id="toolbar-undo" label={t('toolbar_undo')} command={undo} - icon={bsVersion({ bs5: 'undo', bs3: 'undo' }) as string} + icon={bsVersion({ bs5: 'undo', bs3: 'undo' })} shortcut={isMac ? '⌘Z' : 'Ctrl+Z'} /> @@ -79,7 +79,7 @@ export const ToolbarItems: FC<{ label={t('toolbar_format_bold')} command={commands.toggleBold} active={isActive('\\textbf')} - icon={bsVersion({ bs5: 'format_bold', bs3: 'bold' }) as string} + icon={bsVersion({ bs5: 'format_bold', bs3: 'bold' })} shortcut={isMac ? '⌘B' : 'Ctrl+B'} /> @@ -124,19 +122,19 @@ export const ToolbarItems: FC<{ id="toolbar-href" label={t('toolbar_insert_link')} command={commands.wrapInHref} - icon={bsVersion({ bs5: 'link', bs3: 'link' }) as string} + icon={bsVersion({ bs5: 'link', bs3: 'link' })} /> @@ -152,34 +150,28 @@ export const ToolbarItems: FC<{ id="toolbar-bullet-list" label={t('toolbar_bullet_list')} command={commands.toggleBulletList} - icon={ - bsVersion({ - bs5: 'format_list_bulleted', - bs3: 'list-ul', - }) as string - } + icon={bsVersion({ + bs5: 'format_list_bulleted', + bs3: 'list-ul', + })} /> @@ -187,12 +179,10 @@ export const ToolbarItems: FC<{ id="toolbar-format-indent-increase" label={t('toolbar_increase_indent')} command={commands.indentIncrease} - icon={ - bsVersion({ - bs5: 'format_indent_increase', - bs3: 'indent', - }) as string - } + icon={bsVersion({ + bs5: 'format_indent_increase', + bs3: 'indent', + })} shortcut={visual ? (isMac ? '⌘]' : 'Ctrl+]') : undefined} disabled={listDepth < 1} /> diff --git a/services/web/frontend/js/features/utils/bootstrap-5.ts b/services/web/frontend/js/features/utils/bootstrap-5.ts index b201c6a1fa..7b55c89a6a 100644 --- a/services/web/frontend/js/features/utils/bootstrap-5.ts +++ b/services/web/frontend/js/features/utils/bootstrap-5.ts @@ -4,7 +4,11 @@ import getMeta from '@/utils/meta' // any isBootstrap5 check is performed export const isBootstrap5 = () => getMeta('ol-bootstrapVersion') === 5 -export const bsVersion = ({ bs5, bs3 }: { bs5?: string; bs3?: string }) => { +/* eslint-disable no-redeclare */ +export function bsVersion({ bs5 }: { bs5: A }): A | undefined +export function bsVersion({ bs3 }: { bs3: B }): B | undefined +export function bsVersion({ bs5, bs3 }: { bs5: A; bs3: B }): A | B +export function bsVersion({ bs5, bs3 }: { bs5?: unknown; bs3?: unknown }) { return isBootstrap5() ? bs5 : bs3 } diff --git a/services/web/frontend/js/shared/components/copy-to-clipboard.tsx b/services/web/frontend/js/shared/components/copy-to-clipboard.tsx index c83ff36ec2..1395ed5998 100644 --- a/services/web/frontend/js/shared/components/copy-to-clipboard.tsx +++ b/services/web/frontend/js/shared/components/copy-to-clipboard.tsx @@ -77,12 +77,10 @@ const IconButton: FC<{ accessibilityLabel={t('copy')} className="copy-button" bs3Props={{ bsSize: 'xsmall' }} - icon={ - bsVersion({ - bs5: copied ? 'check' : 'content_copy', - bs3: copied ? 'check' : 'clipboard', - }) || '' - } + icon={bsVersion({ + bs5: copied ? 'check' : 'content_copy', + bs3: copied ? 'check' : 'clipboard', + })} /> ) }