diff options
Diffstat (limited to 'frontend/src/components/modals/MultiplePluginsInstallModal.tsx')
| -rw-r--r-- | frontend/src/components/modals/MultiplePluginsInstallModal.tsx | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/frontend/src/components/modals/MultiplePluginsInstallModal.tsx b/frontend/src/components/modals/MultiplePluginsInstallModal.tsx index ba49ba92..9c86f3db 100644 --- a/frontend/src/components/modals/MultiplePluginsInstallModal.tsx +++ b/frontend/src/components/modals/MultiplePluginsInstallModal.tsx @@ -3,7 +3,7 @@ import { FC, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { FaCheck, FaDownload } from 'react-icons/fa'; -import { InstallType } from '../../plugin'; +import { InstallType, InstallTypeTranslationMapping } from '../../plugin'; interface MultiplePluginsInstallModalProps { requests: { name: string; version: string; hash: string; install_type: InstallType }[]; @@ -12,13 +12,7 @@ interface MultiplePluginsInstallModalProps { closeModal?(): void; } -// values are the JSON keys used in the translation file -const InstallTypeTranslationMapping = { - [InstallType.INSTALL]: 'install', - [InstallType.REINSTALL]: 'reinstall', - [InstallType.UPDATE]: 'update', -} as const satisfies Record<InstallType, string>; - +// IMPORTANT! Keep in sync with `t(...)` comments below type TitleTranslationMapping = 'mixed' | (typeof InstallTypeTranslationMapping)[InstallType]; const MultiplePluginsInstallModal: FC<MultiplePluginsInstallModalProps> = ({ @@ -70,6 +64,8 @@ const MultiplePluginsInstallModal: FC<MultiplePluginsInstallModalProps> = ({ if (requests.every(({ install_type }) => install_type === InstallType.INSTALL)) return 'install'; if (requests.every(({ install_type }) => install_type === InstallType.REINSTALL)) return 'reinstall'; if (requests.every(({ install_type }) => install_type === InstallType.UPDATE)) return 'update'; + if (requests.every(({ install_type }) => install_type === InstallType.DOWNGRADE)) return 'downgrade'; + if (requests.every(({ install_type }) => install_type === InstallType.OVERWRITE)) return 'overwrite'; return 'mixed'; }, [requests]); @@ -86,14 +82,35 @@ const MultiplePluginsInstallModal: FC<MultiplePluginsInstallModalProps> = ({ onCancel={async () => { await onCancel(); }} - strTitle={<div>{t(`MultiplePluginsInstallModal.title.${installTypeGrouped}`, { count: requests.length })}</div>} - strOKButtonText={t(`MultiplePluginsInstallModal.ok_button.${loading ? 'loading' : 'idle'}`)} + strTitle={ + <div> + { + // IMPORTANT! These comments are not cosmetic and are needed for `extracttext` task to work + // t('MultiplePluginsInstallModal.title.install', { count: n }) + // t('MultiplePluginsInstallModal.title.reinstall', { count: n }) + // t('MultiplePluginsInstallModal.title.update', { count: n }) + // t('MultiplePluginsInstallModal.title.downgrade', { count: n }) + // t('MultiplePluginsInstallModal.title.overwrite', { count: n }) + // t('MultiplePluginsInstallModal.title.mixed', { count: n }) + t(`MultiplePluginsInstallModal.title.${installTypeGrouped}`, { count: requests.length }) + } + </div> + } + strOKButtonText={ + loading ? t('MultiplePluginsInstallModal.ok_button.loading') : t('MultiplePluginsInstallModal.ok_button.idle') + } > <div> {t('MultiplePluginsInstallModal.confirm')} <ul style={{ listStyle: 'none', display: 'flex', flexDirection: 'column', gap: '4px' }}> {requests.map(({ name, version, install_type, hash }, i) => { const installTypeStr = InstallTypeTranslationMapping[install_type]; + // IMPORTANT! These comments are not cosmetic and are needed for `extracttext` task to work + // t('MultiplePluginsInstallModal.description.install') + // t('MultiplePluginsInstallModal.description.reinstall') + // t('MultiplePluginsInstallModal.description.update') + // t('MultiplePluginsInstallModal.description.downgrade') + // t('MultiplePluginsInstallModal.description.overwrite') const description = t(`MultiplePluginsInstallModal.description.${installTypeStr}`, { name, version, |
