Skip to content

Commit

Permalink
Merge pull request #274 from IraSoro/271-add-link-to-github
Browse files Browse the repository at this point in the history
Link to GitHub
  • Loading branch information
IraSoro authored Aug 8, 2024
2 parents f02568d + c859517 commit 6ca75f9
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 15 deletions.
9 changes: 9 additions & 0 deletions src/data/AppVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,12 @@ export async function downloadLatestRelease() {
const latestRelease = await getLatestReleaseInfo();
window.open(latestRelease.htmlUrl, "_system", "location=yes");
}

export 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");
}
53 changes: 38 additions & 15 deletions src/modals/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useContext, useEffect, useState } from "react";
import {
IonChip,
IonIcon,
IonItem,
IonLabel,
Expand All @@ -16,6 +17,7 @@ import {
cloudUploadOutline,
globeOutline,
colorFillOutline,
logoGithub,
} from "ionicons/icons";
import { useTranslation } from "react-i18next";
import { storage } from "../data/Storage";
Expand All @@ -24,6 +26,7 @@ import { exportConfig, importConfig } from "../data/Config";
import {
downloadLatestRelease,
isNewVersionAvailable,
openGitHubPage,
} from "../data/AppVersion";
import { CyclesContext, ThemeContext } from "../state/Context";
import {
Expand Down Expand Up @@ -267,24 +270,44 @@ export const Menu = (props: MenuProps) => {
</IonItem>
)}
</IonList>
<IonItem
color="none"
lines="none"
<IonList
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
}}
>
<IonLabel
style={{ fontSize: "13px" }}
color="medium"
<IonChip
outline
color={`text-${theme}`}
onClick={() => openGitHubPage()}
>
Peri - The Period Tracker App
</IonLabel>
<IonLabel
style={{ fontSize: "13px" }}
color="medium"
slot="end"
<IonIcon
icon={logoGithub}
color={`text-${theme}`}
/>
<IonLabel>{t("We are on GitHub")}</IonLabel>
</IonChip>
<IonItem
color="none"
lines="none"
style={{ width: "100%" }}
>
{configuration.app.version}
</IonLabel>
</IonItem>
<IonLabel
style={{ fontSize: "13px" }}
color="medium"
>
Peri - The Period Tracker App
</IonLabel>
<IonLabel
style={{ fontSize: "13px" }}
color="medium"
slot="end"
>
{configuration.app.version}
</IonLabel>
</IonItem>
</IonList>
</IonMenu>
);
};
27 changes: 27 additions & 0 deletions src/tests/AppVersion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import {
GithubReleaseAsset,
GithubReleaseInfo,
downloadLatestRelease,
homepageURL,
isNewVersionAvailable,
openGitHubPage,
} from "../data/AppVersion";
import { configuration } from "../data/AppConfiguration";

Expand Down Expand Up @@ -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",
);
});
1 change: 1 addition & 0 deletions src/utils/translations/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const es = {
"This is just a demo": "Esto es solo una demostración",
"You can download the application ": "Puedes descargar la aplicación ",
here: "Aquí",
"We are on GitHub": "Estamos en GitHub",
};

export default es;
1 change: 1 addition & 0 deletions src/utils/translations/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const ru = {
"This is just a demo": "Это только demo",
"You can download the application ": "Загрузить приложение можно ",
here: "тут",
"We are on GitHub": "Мы в GitHub",
};

export default ru;

0 comments on commit 6ca75f9

Please sign in to comment.