From a4ec708390026ed72418376d693c90d1b01c30ff Mon Sep 17 00:00:00 2001 From: Irina Sorokina Date: Wed, 7 Aug 2024 23:23:22 +0400 Subject: [PATCH 1/6] Added `IonChip` component --- src/modals/Menu.tsx | 47 ++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/modals/Menu.tsx b/src/modals/Menu.tsx index 7285773..a9a3dbb 100644 --- a/src/modals/Menu.tsx +++ b/src/modals/Menu.tsx @@ -1,5 +1,6 @@ import { useContext, useEffect, useState } from "react"; import { + IonChip, IonIcon, IonItem, IonLabel, @@ -16,6 +17,7 @@ import { cloudUploadOutline, globeOutline, colorFillOutline, + logoGithub, } from "ionicons/icons"; import { useTranslation } from "react-i18next"; import { storage } from "../data/Storage"; @@ -267,24 +269,37 @@ export const Menu = (props: MenuProps) => { )} - - - Peri - The Period Tracker App - - + + We are on GitHub + + - {configuration.app.version} - - + + Peri - The Period Tracker App + + + {configuration.app.version} + + + ); }; From 3d88a8568f7661f2131318882e5b25d0aff7b19c Mon Sep 17 00:00:00 2001 From: Irina Sorokina Date: Wed, 7 Aug 2024 23:31:58 +0400 Subject: [PATCH 2/6] Changed styles --- src/modals/Menu.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modals/Menu.tsx b/src/modals/Menu.tsx index a9a3dbb..2681bdb 100644 --- a/src/modals/Menu.tsx +++ b/src/modals/Menu.tsx @@ -276,8 +276,14 @@ export const Menu = (props: MenuProps) => { alignItems: "center", }} > - - + + We are on GitHub Date: Thu, 8 Aug 2024 00:01:22 +0400 Subject: [PATCH 3/6] Added link to GitHub page --- src/data/AppVersion.ts | 5 +++++ src/modals/Menu.tsx | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/data/AppVersion.ts b/src/data/AppVersion.ts index 71ab3fd..20abf2a 100644 --- a/src/data/AppVersion.ts +++ b/src/data/AppVersion.ts @@ -70,3 +70,8 @@ export async function downloadLatestRelease() { const latestRelease = await getLatestReleaseInfo(); window.open(latestRelease.htmlUrl, "_system", "location=yes"); } + +const homepageURL = "https://github.com/IraSoro/peri"; +export function openGitHubPage() { + window.open(homepageURL, "_system", "location=yes"); +} diff --git a/src/modals/Menu.tsx b/src/modals/Menu.tsx index 2681bdb..9f3acfb 100644 --- a/src/modals/Menu.tsx +++ b/src/modals/Menu.tsx @@ -26,6 +26,7 @@ import { exportConfig, importConfig } from "../data/Config"; import { downloadLatestRelease, isNewVersionAvailable, + openGitHubPage, } from "../data/AppVersion"; import { CyclesContext, ThemeContext } from "../state/Context"; import { @@ -279,6 +280,7 @@ export const Menu = (props: MenuProps) => { openGitHubPage()} > Date: Thu, 8 Aug 2024 00:07:51 +0400 Subject: [PATCH 4/6] Added translation --- src/modals/Menu.tsx | 2 +- src/utils/translations/es.ts | 1 + src/utils/translations/ru.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modals/Menu.tsx b/src/modals/Menu.tsx index 9f3acfb..5192c7b 100644 --- a/src/modals/Menu.tsx +++ b/src/modals/Menu.tsx @@ -286,7 +286,7 @@ export const Menu = (props: MenuProps) => { icon={logoGithub} color={`text-${theme}`} /> - We are on GitHub + {t("We are on GitHub")} Date: Thu, 8 Aug 2024 17:29:53 +0400 Subject: [PATCH 5/6] Added opening tab instead of window in desktop --- src/data/AppVersion.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/data/AppVersion.ts b/src/data/AppVersion.ts index 20abf2a..a65470e 100644 --- a/src/data/AppVersion.ts +++ b/src/data/AppVersion.ts @@ -73,5 +73,9 @@ export async function downloadLatestRelease() { const homepageURL = "https://github.com/IraSoro/peri"; export function openGitHubPage() { + if (isPlatform("desktop")) { + window.open(homepageURL, "_blank")?.focus(); + return; + } window.open(homepageURL, "_system", "location=yes"); } From c85951769a5286a75712442ea39aadfc706293be Mon Sep 17 00:00:00 2001 From: Irina Sorokina Date: Thu, 8 Aug 2024 17:55:51 +0400 Subject: [PATCH 6/6] Added tests --- src/data/AppVersion.ts | 2 +- src/tests/AppVersion.test.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/data/AppVersion.ts b/src/data/AppVersion.ts index a65470e..d9e6c72 100644 --- a/src/data/AppVersion.ts +++ b/src/data/AppVersion.ts @@ -71,7 +71,7 @@ export async function downloadLatestRelease() { window.open(latestRelease.htmlUrl, "_system", "location=yes"); } -const homepageURL = "https://github.com/IraSoro/peri"; +export const homepageURL = "https://github.com/IraSoro/peri"; export function openGitHubPage() { if (isPlatform("desktop")) { window.open(homepageURL, "_blank")?.focus(); diff --git a/src/tests/AppVersion.test.ts b/src/tests/AppVersion.test.ts index a8dbe3c..ce31c19 100644 --- a/src/tests/AppVersion.test.ts +++ b/src/tests/AppVersion.test.ts @@ -3,7 +3,9 @@ import { GithubReleaseAsset, GithubReleaseInfo, downloadLatestRelease, + homepageURL, isNewVersionAvailable, + openGitHubPage, } from "../data/AppVersion"; import { configuration } from "../data/AppConfiguration"; @@ -153,3 +155,28 @@ test("Download latest release", async () => { "location=yes", ); }); + +test("Open Github page on desktop", () => { + jest.spyOn(mockedIonicCore, "isPlatform").mockReturnValueOnce(true); + // @ts-expect-error Mock + const mockedWindowOpen = jest.spyOn(window, "open").mockReturnValue({ + focus: jest.fn().mockReturnValue(0), + }); + + openGitHubPage(); + expect(mockedWindowOpen).toHaveBeenNthCalledWith(1, homepageURL, "_blank"); +}); + +test("Open Github page on android", () => { + jest.spyOn(mockedIonicCore, "isPlatform").mockReturnValueOnce(false); + // @ts-expect-error Mock + const mockedWindowOpen = jest.spyOn(window, "open").mockReturnValue({}); + + openGitHubPage(); + expect(mockedWindowOpen).toHaveBeenNthCalledWith( + 1, + homepageURL, + "_system", + "location=yes", + ); +});