Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions public/images/cursor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"neovim": "Download Testaustime for Neovim",
"title": "Extensions",
"vscode": "Download Testaustime for Visual Studio Code",
"cursor": "Download Testaustime for Cursor",
"sublime": "Download Testaustime for Sublime Text"
},
"footer": {
Expand Down Expand Up @@ -308,7 +309,7 @@
}
},
"authorize": {
"body": "You are logging in to the official Visual Studio Code extension.",
"body": "You are logging in to the official {{editor}} extension.",
"continue": "Continue as {{username}}",
"notWorking": {
"text": "Not working?",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"extensions": {
"body": "Lataa Testaustime-laajennus suosikkieditorillesi!",
"cursor": "Lataa Testaustime Cursor:lle",
"intellij": "Lataa Testaustime IntelliJ:lle",
"micro": "Lataa Testaustime Micro:lle",
"neovim": "Lataa Testaustime Neovim:lle",
Expand Down Expand Up @@ -308,7 +309,7 @@
}
},
"authorize": {
"body": "Olet kirjautumassa sisään viralliseen Visual Studio Code -lisäosaan.",
"body": "Olet kirjautumassa sisään viralliseen {{editor}} -lisäosaan.",
"continue": "Jatka käyttäjänä {{username}}",
"notWorking": {
"text": "Eikö toimi?",
Expand Down
32 changes: 26 additions & 6 deletions src/app/[locale]/authorize/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ export default async function AuthorizePage({
}) {
const { t } = await initTranslations(locale, ["common"]);

const loginUrl =
editor == "vscode"
? `/login?redirect=${encodeURIComponent("/authorize?editor=vscode")}`
: "/login";
const loginUrls = new Map(
Object.entries({
vscode: `/login?redirect=${encodeURIComponent("/authorize?editor=vscode")}`,
cursor: `/login?redirect=${encodeURIComponent("/authorize?editor=cursor")}`,
}),
);
const loginUrl = loginUrls.get(editor ?? "vscode");

if (loginUrl === undefined) {
// Make this prettier
return <div>Unsupported editor</div>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add translation

}

const token = cookies().get("token")?.value;
if (!token) {
Expand All @@ -32,6 +40,18 @@ export default async function AuthorizePage({

const { username } = me;

const editorNames = new Map(
Object.entries({
vscode: "Visual Studio Code",
cursor: "Cursor",
}),
);
const editorName = editorNames.get(editor ?? "vscode");

if (editorName === undefined) {
return <div>Invalid editor</div>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the same text as above, with translation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. it should be fixed now.

}

return (
<Stack align="center" gap="xl">
<Image
Expand All @@ -40,10 +60,10 @@ export default async function AuthorizePage({
width={40}
height={40}
/>
<Text>{t("authorize.body")}</Text>
<Text>{t("authorize.body", { editor: editorName })}</Text>
<Button
component="a"
href={`vscode://testausserveri-ry.testaustime/authorize?token=${token}`}
href={loginUrl}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct, loginUrl is a path in the frontend, not a path in the extension. You need to create a new map for the extension urls too.

>
{t("authorize.continue", { username })}
</Button>
Expand Down
7 changes: 7 additions & 0 deletions src/app/[locale]/extensions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ export default async function ExtensionsPage({
sourceCodeLink="https://github.com/Testausserveri/testaustime-vscode"
text={t("extensions.vscode")}
/>
<ExtensionBlock
logo="/images/cursor.svg"
alt="Cursor logo"
downloadLink="https://marketplace.visualstudio.com/items?itemName=testausserveri-ry.testaustime-cursor"
sourceCodeLink="https://github.com/Testausserveri/testaustime-cursor"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the repo in process of being moved under Testaustime (or at least Testausserveri) organization? At least I didn't see any messages in Discord about that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. we'll talk about that in discord.

text={t("extensions.cursor")}
/>
<ExtensionBlock
logo="/images/neovim.svg"
alt="Neovim logo"
Expand Down
1 change: 1 addition & 0 deletions src/components/LoginForm/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const allowedRedirects = [
"/friends",
"/leaderboards",
"/authorize?editor=vscode",
"/authorize?editor=cursor",
];

export const logIn = async (
Expand Down