()
| 20 | type?: NotificationType |
| 21 | } |
| 22 | export const HeaderNotifications = () => { |
| 23 | const router = useRouter() |
| 24 | const { currentVersion } = useVersion() |
| 25 | const { relativePath, allVersions, data, currentPathWithoutLanguage, page } = useMainContext() |
| 26 | const { userLanguage } = useUserLanguage() |
| 27 | const { languages } = useLanguages() |
| 28 | |
| 29 | const { t } = useTranslation('header') |
| 30 | |
| 31 | const translationNotices: Array<Notif> = [] |
| 32 | if (router.locale === 'en') { |
| 33 | if (userLanguage && userLanguage !== 'en' && languages[userLanguage]) { |
| 34 | let href = `/${userLanguage}` |
| 35 | if (currentPathWithoutLanguage !== '/') { |
| 36 | href += currentPathWithoutLanguage |
| 37 | } |
| 38 | translationNotices.push({ |
| 39 | type: NotificationType.TRANSLATION, |
| 40 | content: `This article is also available in <a href="${href}">${languages[userLanguage]?.name}</a>.`, |
| 41 | }) |
| 42 | } |
| 43 | } else { |
| 44 | if (relativePath?.includes('/site-policy')) { |
| 45 | translationNotices.push({ |
| 46 | type: NotificationType.TRANSLATION, |
| 47 | content: data.reusables.policies.translation, |
| 48 | }) |
| 49 | } else if (router.locale) { |
| 50 | translationNotices.push({ |
| 51 | type: NotificationType.TRANSLATION, |
| 52 | content: t('notices.localization_complete'), |
| 53 | }) |
| 54 | } |
| 55 | } |
| 56 | const releaseNotices: Array<Notif> = [] |
| 57 | if (currentVersion === 'github-ae@latest') { |
| 58 | releaseNotices.push({ |
| 59 | type: NotificationType.RELEASE, |
| 60 | content: t('notices.ghae_silent_launch'), |
| 61 | }) |
| 62 | } else if (currentVersion === data.variables.release_candidate.version) { |
| 63 | releaseNotices.push({ |
| 64 | type: NotificationType.RELEASE, |
| 65 | content: `${allVersions[currentVersion].versionTitle}${t('notices.release_candidate')}`, |
| 66 | }) |
| 67 | } |
| 68 | |
| 69 | const allNotifications: Array<Notif> = [ |
| 70 | ...translationNotices, |
| 71 | ...releaseNotices, |
| 72 | // ONEOFF EARLY ACCESS NOTICE |
| 73 | (relativePath || '').includes('early-access/') && !page.noEarlyAccessBanner |
| 74 | ? { |
| 75 | type: NotificationType.EARLY_ACCESS, |
| 76 | content: t('notices.early_access'), |
| 77 | } |
| 78 | : null, |
| 79 | // ONEOFF DESKTOP NOTICE |
nothing calls this directly
no test coverage detected