TypeScript
refactor(mobile): use shared project settings actions (#21915)
Julius Marmingebcccdd8a3a0d
diff --git a/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsxindex bf5b9ba9cdf..1838c32e985 100644--- a/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx+++ b/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx@@ -1,10 +1,11 @@import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";import { AppText as Text, AppTextInput } from "../../components/ui/AppText";+import { Button } from "../../components/ui/Button";import { ProjectFavicon } from "../../components/ProjectFavicon";import { deriveProjectGroupLabel } from "@t3tools/client-runtime/state/project-grouping";import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";import { useState } from "react";-import { Platform, Pressable, View } from "react-native";+import { Platform, View } from "react-native";import { useSafeAreaInsets } from "react-native-safe-area-context";import { projectEnvironment } from "../../state/projects";@@ -123,14 +124,12 @@ function ProjectOverviewContent(props: {editable={!isSaving}/>{canSave ? (- <Pressable- accessibilityRole="button"- accessibilityLabel="Save project name"+ <Button+ label="Save"+ accessibilityHint="Save project name"+ tone="secondary"onPress={saveName}- className="rounded-full bg-subtle-strong px-4 py-2 active:opacity-70"- >- <Text className="text-sm font-t3-medium text-foreground">Save</Text>- </Pressable>+ />) : null}</View></View>diff --git a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsxindex 65fdc476dd4..d9eba4a4e18 100644--- a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx+++ b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx@@ -58,6 +58,21 @@ vi.mock("../../state/use-atom-command", () => ({vi.mock("../threads/thread-settings-options", () => ({ RUNTIME_MODE_CHOICES: [] }));vi.mock("../../components/ui/ScreenScrollView", () => ({ ScreenScrollView: Children }));vi.mock("../../components/ui/AppText", () => ({ AppText: Children }));+vi.mock("../../components/ui/Button", () => ({+ Button: ({+ label,+ disabled,+ onPress,+ }: {+ label: string;+ disabled?: boolean;+ onPress: () => void;+ }) => (+ <button disabled={disabled} onClick={onPress}>+ {label}+ </button>+ ),+}));vi.mock("./components/SettingsScreen", () => ({ SettingsScreen: Children }));vi.mock("./components/SettingsEnvironmentFilterHeader", () => ({AndroidSettingsEnvironmentFilter: () => null,@@ -271,15 +286,15 @@ describe.each([}));act(() => root.render(<Screen />));- await act(async () => button("Use environment defaults").click());+ await act(async () => button("Use defaults").click());expectFailures();expect(button(label).getAttribute("aria-checked")).toBe("true");- expect(button("Use environment defaults").disabled).toBe(false);+ expect(button("Use defaults").disabled).toBe(false);mocks.alert.mockClear();mocks.updateSettings.mockResolvedValue(AsyncResult.success(undefined));- await act(async () => button("Use environment defaults").click());+ await act(async () => button("Use defaults").click());expect(mocks.updateSettings).toHaveBeenCalledTimes(6);expect(mocks.alert).not.toHaveBeenCalled();expect(button(label).getAttribute("aria-checked")).toBe("true");diff --git a/apps/mobile/src/features/settings/components/SettingsProjectOverridesSection.tsx b/apps/mobile/src/features/settings/components/SettingsProjectOverridesSection.tsxindex 21570eafe25..1bd899dc4d6 100644--- a/apps/mobile/src/features/settings/components/SettingsProjectOverridesSection.tsx+++ b/apps/mobile/src/features/settings/components/SettingsProjectOverridesSection.tsx@@ -1,5 +1,6 @@-import { Pressable, View } from "react-native";+import { View } from "react-native";+import { Button } from "../../../components/ui/Button";import { AppText as Text } from "../../../components/ui/AppText";import { SettingsSection } from "./SettingsSection";@@ -18,15 +19,13 @@ export function SettingsProjectOverridesSection(props: {{props.projectLabel}</Text>{!props.pending && props.supportsOverrides && props.hasOverrides ? (- <Pressable- accessibilityRole="button"- accessibilityLabel="Use environment defaults"+ <Button+ label="Use defaults"+ accessibilityHint="Use environment defaults for this project"+ tone="text"disabled={props.disabled}onPress={props.onClear}- className="px-2 py-2 active:opacity-70"- >- <Text className="text-sm font-t3-medium text-primary-text">Use defaults</Text>- </Pressable>+ />) : null}</View>{!props.supportsOverrides ? (