diff --git a/public/images/cursor.svg b/public/images/cursor.svg new file mode 100644 index 00000000..1f8a7c33 --- /dev/null +++ b/public/images/cursor.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 62e8f1c5..7666fea9 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -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": { @@ -308,7 +309,9 @@ } }, "authorize": { - "body": "You are logging in to the official Visual Studio Code extension.", + "body": "You are logging in to the official {{editor}} extension.", + "invalidEditor": "This editor is invalid.", + "unsupportedEditor": "This editor is not supported.", "continue": "Continue as {{username}}", "notWorking": { "text": "Not working?", diff --git a/public/locales/fi/common.json b/public/locales/fi/common.json index 759908dd..5d07b743 100644 --- a/public/locales/fi/common.json +++ b/public/locales/fi/common.json @@ -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", @@ -308,7 +309,9 @@ } }, "authorize": { - "body": "Olet kirjautumassa sisään viralliseen Visual Studio Code -lisäosaan.", + "body": "Olet kirjautumassa sisään viralliseen {{editor}} -lisäosaan.", + "invalidEditor": "Tämä editori on virheellinen.", + "unsupportedEditor": "Tätä editoria ei tueta.", "continue": "Jatka käyttäjänä {{username}}", "notWorking": { "text": "Eikö toimi?", diff --git a/src/app/[locale]/authorize/page.tsx b/src/app/[locale]/authorize/page.tsx index b12adf9a..9b4d73e1 100644 --- a/src/app/[locale]/authorize/page.tsx +++ b/src/app/[locale]/authorize/page.tsx @@ -15,16 +15,36 @@ 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
{t("authorize.unsupportedEditor")}
; + } const token = cookies().get("token")?.value; if (!token) { redirect(loginUrl); } + const redirectUrls = new Map( + Object.entries({ + vscode: `vscode://testausserveri-ry.testaustime/authorize?token=${token}`, + cursor: `cursor://testausserveri-ry.testaustime-cursor/authorize?token=${token}`, + }), + ); + const redirectUrl = redirectUrls.get(editor ?? "vscode"); + if (redirectUrl === undefined) { + // Make this prettier + return
{t("authorize.unsupportedEditor")}
; + } + const me = await getMe(); if (!me || "error" in me) { redirect(loginUrl); @@ -32,6 +52,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
{t("authorize.invalidEditor")}
; + } + return ( - {t("authorize.body")} + {t("authorize.body", { editor: editorName })} diff --git a/src/app/[locale]/extensions/page.tsx b/src/app/[locale]/extensions/page.tsx index 54451708..343058da 100644 --- a/src/app/[locale]/extensions/page.tsx +++ b/src/app/[locale]/extensions/page.tsx @@ -77,6 +77,13 @@ export default async function ExtensionsPage({ sourceCodeLink="https://github.com/Testausserveri/testaustime-vscode" text={t("extensions.vscode")} /> +