mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 08:39:02 +03:00
feat(console): enable marketing nav in dev (#53421)
This commit is contained in:
@@ -295,6 +295,7 @@ new sst.cloudflare.x.SolidStart("Console", {
|
||||
//VITE_API_URL: gateway.url.apply((url) => url!),
|
||||
VITE_AUTH_URL: auth.url.apply((url) => url!),
|
||||
VITE_STRIPE_PUBLISHABLE_KEY: STRIPE_PUBLISHABLE_KEY.value,
|
||||
VITE_CONSOLE_MARKETING_ENABLED: $app.stage === "dev" ? "true" : "false",
|
||||
},
|
||||
transform: {
|
||||
server: {
|
||||
|
||||
@@ -14,7 +14,7 @@ import copyLogoSvgDark from "../asset/lander/opencode-logo-dark.svg"
|
||||
import copyWordmarkSvgLight from "../asset/lander/opencode-wordmark-light.svg"
|
||||
import copyWordmarkSvgDark from "../asset/lander/opencode-wordmark-dark.svg"
|
||||
import { A, useNavigate } from "@solidjs/router"
|
||||
import { createMemo, Match, Show, Switch } from "solid-js"
|
||||
import { Match, Show, Switch } from "solid-js"
|
||||
import { createStore } from "solid-js/store"
|
||||
import { createEffect, onCleanup } from "solid-js"
|
||||
import { config } from "~/config"
|
||||
@@ -154,13 +154,28 @@ export function Header(props: { zen?: boolean; go?: boolean; hideGetStarted?: bo
|
||||
<a href={language.route("/data")}>{i18n.t("nav.data")}</a>
|
||||
</li>
|
||||
<li>
|
||||
<A href={language.route("/zen")}>{i18n.t("nav.zen")}</A>
|
||||
{/* Console links use a full page load into its separate application. */}
|
||||
<Show
|
||||
when={config.consoleMarketingEnabled}
|
||||
fallback={<A href={language.route("/zen")}>{i18n.t("nav.zen")}</A>}
|
||||
>
|
||||
<a href="/console/models" target="_self">
|
||||
{i18n.t("nav.models")}
|
||||
</a>
|
||||
</Show>
|
||||
</li>
|
||||
<li>
|
||||
<A href={language.route("/go")}>{i18n.t("nav.go")}</A>
|
||||
</li>
|
||||
<li>
|
||||
<A href={language.route("/enterprise")}>{i18n.t("nav.enterprise")}</A>
|
||||
<Show
|
||||
when={config.consoleMarketingEnabled}
|
||||
fallback={<A href={language.route("/enterprise")}>{i18n.t("nav.enterprise")}</A>}
|
||||
>
|
||||
<a href="/console/teams" target="_self">
|
||||
{i18n.t("nav.teams")}
|
||||
</a>
|
||||
</Show>
|
||||
</li>
|
||||
<Show when={props.zen || props.go}>
|
||||
<li>
|
||||
@@ -255,7 +270,14 @@ export function Header(props: { zen?: boolean; go?: boolean; hideGetStarted?: bo
|
||||
</li>
|
||||
<Show when={!props.zen}>
|
||||
<li>
|
||||
<A href={language.route("/zen")}>{i18n.t("nav.zen")}</A>
|
||||
<Show
|
||||
when={config.consoleMarketingEnabled}
|
||||
fallback={<A href={language.route("/zen")}>{i18n.t("nav.zen")}</A>}
|
||||
>
|
||||
<a href="/console/models" target="_self">
|
||||
{i18n.t("nav.models")}
|
||||
</a>
|
||||
</Show>
|
||||
</li>
|
||||
</Show>
|
||||
<Show when={!props.go}>
|
||||
@@ -264,7 +286,14 @@ export function Header(props: { zen?: boolean; go?: boolean; hideGetStarted?: bo
|
||||
</li>
|
||||
</Show>
|
||||
<li>
|
||||
<A href={language.route("/enterprise")}>{i18n.t("nav.enterprise")}</A>
|
||||
<Show
|
||||
when={config.consoleMarketingEnabled}
|
||||
fallback={<A href={language.route("/enterprise")}>{i18n.t("nav.enterprise")}</A>}
|
||||
>
|
||||
<a href="/console/teams" target="_self">
|
||||
{i18n.t("nav.teams")}
|
||||
</a>
|
||||
</Show>
|
||||
</li>
|
||||
<Show when={props.zen || props.go}>
|
||||
<li>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Application-wide constants and configuration
|
||||
*/
|
||||
export const config = {
|
||||
consoleMarketingEnabled: import.meta.env.VITE_CONSOLE_MARKETING_ENABLED === "true",
|
||||
|
||||
// Base URL
|
||||
baseUrl: "https://opencode.ai",
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ export const dict = {
|
||||
"nav.x": "X",
|
||||
"nav.enterprise": "Enterprise",
|
||||
"nav.zen": "Zen",
|
||||
"nav.models": "Models",
|
||||
"nav.teams": "Teams",
|
||||
"nav.go": "Go",
|
||||
"nav.login": "Login",
|
||||
"nav.free": "Download",
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { i18n } from "../src/i18n"
|
||||
import { LOCALES } from "../src/lib/language"
|
||||
|
||||
describe("Console marketing navigation gate", () => {
|
||||
test.each([
|
||||
["missing", undefined, false],
|
||||
["false", "false", false],
|
||||
["invalid", "1", false],
|
||||
["true", "true", true],
|
||||
] as const)("handles the %s flag", (_name, value, enabled) => {
|
||||
const result = Bun.spawnSync({
|
||||
cmd: [
|
||||
process.execPath,
|
||||
"--eval",
|
||||
'import { config } from "./src/config.ts"; console.log(config.consoleMarketingEnabled)',
|
||||
],
|
||||
cwd: new URL("..", import.meta.url).pathname,
|
||||
env: {
|
||||
...Object.fromEntries(Object.entries(process.env).filter(([key]) => key !== "VITE_CONSOLE_MARKETING_ENABLED")),
|
||||
...(value === undefined ? {} : { VITE_CONSOLE_MARKETING_ENABLED: value }),
|
||||
},
|
||||
})
|
||||
|
||||
expect(result.exitCode).toBe(0)
|
||||
expect(result.stdout.toString().trim()).toBe(String(enabled))
|
||||
})
|
||||
|
||||
test.each([...LOCALES])("provides navigation labels through the English fallback for %s", (locale) => {
|
||||
expect(i18n(locale)["nav.models"]).toBe("Models")
|
||||
expect(i18n(locale)["nav.teams"]).toBe("Teams")
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user