TypeScript
fix(web): find update settings from the command palette (#17396)
Sergiy Dybskiy472ea7ec5f67
diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsxindex bee57d21b25..13c525a3d88 100644--- a/apps/web/src/components/settings/SettingsPanels.tsx+++ b/apps/web/src/components/settings/SettingsPanels.tsx@@ -428,6 +428,7 @@ function AboutVersionSection() {return (<><SettingsRow+ id={searchableSetting("app-version").id}title={<AboutVersionTitle />}description={description}control={@@ -450,7 +451,7 @@ function AboutVersionSection() {/>{hasDesktopBridge ? (<SettingsRow- title="Update track"+ {...searchableSetting("update-track")}description="Use stable releases or nightly builds. Switch back anytime."control={<Select@@ -482,7 +483,7 @@ function AboutVersionSection() {/>) : selectedHostedAppChannel ? (<SettingsRow- title="Update track"+ {...searchableSetting("update-track")}description="Switches the hosted app release channel."control={<Select@@ -3345,6 +3346,7 @@ export function GeneralSettingsPanel() {) : (<><SettingsRow+ id={searchableSetting("app-version").id}title={<AboutVersionTitle />}description="Current version of the application."/>diff --git a/apps/web/src/components/settings/settingsSearch.test.ts b/apps/web/src/components/settings/settingsSearch.test.tsindex 17bc6407d14..2fd5707164b 100644--- a/apps/web/src/components/settings/settingsSearch.test.ts+++ b/apps/web/src/components/settings/settingsSearch.test.ts@@ -128,6 +128,16 @@ describe("searchSettings", () => {expect(SETTINGS_SEARCH_ITEMS.some((item) => item.id === "quit-confirmation")).toBe(true);expect(searchSettings("hold to quit")).toEqual([]);expect(searchSettings("wsl")).toEqual([]);+ expect(searchSettings("update track")).toEqual([]);+ });++ it("finds the About update rows", () => {+ expect(searchSettings("check for updates").map((item) => item.id)).toContain("app-version");+ expect(SETTINGS_SEARCH_ITEMS.find((item) => item.id === "update-track")).toMatchObject({+ title: "Update track",+ to: "/settings/general",+ releaseChannelOnly: true,+ });});it("hides macOS-only settings on other platforms", () => {diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.tsindex aff52adeb15..c23eeb8fdf0 100644--- a/apps/web/src/components/settings/settingsSearch.ts+++ b/apps/web/src/components/settings/settingsSearch.ts@@ -1,3 +1,4 @@+import { HOSTED_APP_CHANNEL } from "~/branding";import { isElectron } from "~/env";import { isMacPlatform, isWindowsPlatform, normalizeSearchText } from "~/lib/utils";import { STATIC_KEYBINDING_COMMANDS, type KeybindingCommand } from "@t3tools/contracts";@@ -53,6 +54,9 @@ export interface SettingsSearchItem {// Its row only renders on Windows desktop, so other desktop platforms must// not expose a result that points to a missing anchor.readonly windowsOnly?: boolean;+ // Its row renders only where the release channel can change: the desktop+ // app, or a hosted web build deployed with a channel.+ readonly releaseChannelOnly?: boolean;readonly cloudOnly?: boolean;readonly environmentOnly?: boolean;readonly providerSettingsOnly?: boolean;@@ -520,6 +524,19 @@ export const SETTINGS_SEARCH_ITEMS = [scope: "project-defaults",searchTerms: ["generated thread titles source control content default provider"],},+ {+ id: "app-version",+ title: "Version",+ to: "/settings/general",+ searchTerms: ["about check for updates download install upgrade release"],+ },+ {+ id: "update-track",+ title: "Update track",+ to: "/settings/general",+ searchTerms: ["release channel stable latest nightly prerelease"],+ releaseChannelOnly: true,+ },{id: "cli-command",title: "t3 command",@@ -1094,6 +1111,7 @@ export function searchSettings(return items.flatMap((item, index) => {if (!isElectron && item.desktopOnly === true) return [];+ if (item.releaseChannelOnly && !isElectron && HOSTED_APP_CHANNEL === null) return [];if (item.macOnly && !isMacPlatform(platform)) return [];if (item.windowsOnly && !isWindowsPlatform(platform)) return [];