GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mobile): a settings row an older environment left mixed can be se… · pingdotgg/t3code@7085c47

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/mobile
    • src
      • components/ui
        • ListToggleRow.test.tsx
        • ListToggleRow.tsx
      • i18n/translations
        • de.json
        • en.json
        • es.json
        • fr.json
        • ja.json
        • ko.json
        • pt-BR.json
        • ru.json
        • sv.json
        • zh.json
    • vite.config.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/mobile/src/components/ui/ListToggleRow.test.tsx‎

Copy file name to clipboard
+55Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { act, type ReactNode } from "react";
2+
import { createRoot } from "react-dom/client";
3+
import { expect, it, vi } from "vite-plus/test";
4+
5+
vi.mock("react-native", () => ({
6+
Pressable: (props: {
7+
readonly children?: ReactNode;
8+
readonly accessibilityLabel?: string;
9+
readonly onPress: () => void;
10+
}) => (
11+
<button aria-label={props.accessibilityLabel} onClick={props.onPress}>
12+
{props.children}
13+
</button>
14+
),
15+
}));
16+
vi.mock("./AppText", () => ({ AppText: (props: { children?: ReactNode }) => props.children }));
17+
vi.mock("./ListRowLayout", () => ({
18+
ListRowLayout: (props: { accessory?: ReactNode }) => props.accessory,
19+
}));
20+
vi.mock("./ThemedSwitch", () => ({ ThemedSwitch: () => null }));
21+
22+
import { ListToggleRow } from "./ListToggleRow";
23+
24+
it("sets a mixed row on, then off when an older environment drops it", () => {
25+
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
26+
const container = document.createElement("div");
27+
const root = createRoot(container);
28+
const saves: boolean[] = [];
29+
try {
30+
// The older environment dropped the unknown key, so the row stays mixed after every save.
31+
act(() =>
32+
root.render(
33+
<ListToggleRow
34+
label="Clone into host folders"
35+
value={null}
36+
onValueChange={(value) => saves.push(value)}
37+
/>,
38+
),
39+
);
40+
const button = () => container.querySelector("button")!;
41+
42+
act(() => button().click());
43+
const offer = { text: button().textContent, label: button().getAttribute("aria-label") };
44+
act(() => button().click());
45+
46+
expect(saves).toEqual([true, false]);
47+
expect(offer).toEqual({
48+
text: "Mixed · Set off",
49+
label: "Set Clone into host folders off for selected environments",
50+
});
51+
} finally {
52+
act(() => root.unmount());
53+
vi.unstubAllGlobals();
54+
}
55+
});
Collapse file

‎apps/mobile/src/components/ui/ListToggleRow.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/components/ui/ListToggleRow.tsx
+18-6Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
import { T, useGT } from "gt-react-native";
2+
import { useState } from "react";
23
import { Pressable } from "react-native";
34

45
import { AppText } from "./AppText";
56
import { ListRowLayout, type ListRowContentProps } from "./ListRowLayout";
67
import { ThemedSwitch } from "./ThemedSwitch";
78

9+
/**
10+
* A mixed row flips the value last picked on it, so a pick that some environments dropped can be
11+
* undone. Before any pick, it sets the value on everywhere.
12+
*/
813
export function ListToggleRow(
914
props: Omit<ListRowContentProps, "detail"> & {
1015
readonly value: boolean | null;
1116
readonly onValueChange: (value: boolean) => void;
1217
},
1318
) {
1419
const gt = useGT();
20+
const [picked, setPicked] = useState(false);
21+
const pick = (value: boolean) => {
22+
setPicked(value);
23+
props.onValueChange(value);
24+
};
1525
return (
1626
<ListRowLayout
1727
icon={props.icon}
@@ -21,26 +31,28 @@ export function ListToggleRow(
2131
accessory={
2232
props.value === null ? (
2333
<Pressable
24-
accessibilityLabel={gt("Set {label} on for selected environments", {
25-
label: props.label,
26-
})}
34+
accessibilityLabel={
35+
picked
36+
? gt("Set {label} off for selected environments", { label: props.label })
37+
: gt("Set {label} on for selected environments", { label: props.label })
38+
}
2739
accessibilityRole="button"
2840
accessibilityHint={props.description}
2941
accessibilityState={{ disabled: Boolean(props.disabled) }}
3042
disabled={props.disabled}
3143
className="rounded-full bg-subtle px-3 py-2 active:opacity-70"
32-
onPress={() => props.onValueChange(true)}
44+
onPress={() => pick(!picked)}
3345
>
3446
<AppText className="text-sm font-t3-medium text-foreground">
35-
<T>Mixed · Set on</T>
47+
{picked ? <T>Mixed · Set off</T> : <T>Mixed · Set on</T>}
3648
</AppText>
3749
</Pressable>
3850
) : (
3951
<ThemedSwitch
4052
accessibilityLabel={props.label}
4153
accessibilityHint={props.description}
4254
disabled={props.disabled}
43-
onValueChange={props.onValueChange}
55+
onValueChange={pick}
4456
value={props.value}
4557
/>
4658
)
Collapse file

‎apps/mobile/src/i18n/translations/de.json‎

Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/de.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,9 @@
17121712
"0efe7ba6d7f681f1": "Verbinde dich erneut mit dieser Umgebung und versuch es noch einmal. Die Datei wurde möglicherweise verschoben oder gelöscht.",
17131713
"2b29584d2bcea749": "Die Datei wurde unter {path} nicht gefunden.",
17141714
"61026d122846876c": "Hänge die Datei erneut an und versuch es noch einmal.",
1715+
"d0872cb98b34eae8": "{label} für ausgewählte Umgebungen ausschalten",
17151716
"a9129aaa7c955e46": "{label} für ausgewählte Umgebungen einschalten",
1717+
"53207498f814efe0": "Gemischt · Ausschalten",
17161718
"fd569def3acc6750": "Gemischt · Einschalten",
17171719
"8eebcd051255ba20": "Nachricht schließen",
17181720
"8711a1de99862971": "{label} verringern",
Collapse file

‎apps/mobile/src/i18n/translations/en.json‎

Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/en.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,9 @@
17121712
"0efe7ba6d7f681f1": "Reconnect to this environment and try again. The file may have been moved or deleted.",
17131713
"2b29584d2bcea749": "The file was not found at {path}.",
17141714
"61026d122846876c": "Attach the file again and retry.",
1715+
"d0872cb98b34eae8": "Set {label} off for selected environments",
17151716
"a9129aaa7c955e46": "Set {label} on for selected environments",
1717+
"53207498f814efe0": "Mixed · Set off",
17161718
"fd569def3acc6750": "Mixed · Set on",
17171719
"8eebcd051255ba20": "Dismiss message",
17181720
"8711a1de99862971": "Decrease {label}",
Collapse file

‎apps/mobile/src/i18n/translations/es.json‎

Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/es.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,9 @@
17121712
"0efe7ba6d7f681f1": "Vuelve a conectarte a este entorno e inténtalo de nuevo. Puede que el archivo se haya movido o eliminado.",
17131713
"2b29584d2bcea749": "No se encontró el archivo en {path}.",
17141714
"61026d122846876c": "Vuelve a adjuntar el archivo y reinténtalo.",
1715+
"d0872cb98b34eae8": "Desactivar {label} en los entornos seleccionados",
17151716
"a9129aaa7c955e46": "Activar {label} en los entornos seleccionados",
1717+
"53207498f814efe0": "Mixto · Desactivar",
17161718
"fd569def3acc6750": "Mixto · Activar",
17171719
"8eebcd051255ba20": "Descartar mensaje",
17181720
"8711a1de99862971": "Reducir {label}",
Collapse file

‎apps/mobile/src/i18n/translations/fr.json‎

Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/fr.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,9 @@
17121712
"0efe7ba6d7f681f1": "Reconnectez-vous à cet environnement et réessayez. Le fichier a peut-être été déplacé ou supprimé.",
17131713
"2b29584d2bcea749": "Le fichier est introuvable dans {path}.",
17141714
"61026d122846876c": "Joignez à nouveau le fichier et réessayez.",
1715+
"d0872cb98b34eae8": "Désactiver {label} pour les environnements sélectionnés",
17151716
"a9129aaa7c955e46": "Activer {label} pour les environnements sélectionnés",
1717+
"53207498f814efe0": "Mixte · Désactiver",
17161718
"fd569def3acc6750": "Mixte · Activer",
17171719
"8eebcd051255ba20": "Ignorer le message",
17181720
"8711a1de99862971": "Diminuer {label}",
Collapse file

‎apps/mobile/src/i18n/translations/ja.json‎

Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/ja.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,9 @@
17121712
"0efe7ba6d7f681f1": "この環境に再接続して、もう一度お試しください。ファイルが移動または削除された可能性があります。",
17131713
"2b29584d2bcea749": "{path} にファイルが見つかりませんでした。",
17141714
"61026d122846876c": "ファイルをもう一度添付して再試行してください。",
1715+
"d0872cb98b34eae8": "選択した環境で {label} をオフにする",
17151716
"a9129aaa7c955e46": "選択した環境で {label} をオンにする",
1717+
"53207498f814efe0": "混在 · オフにする",
17161718
"fd569def3acc6750": "混在 · オンにする",
17171719
"8eebcd051255ba20": "メッセージを閉じる",
17181720
"8711a1de99862971": "{label} を減らす",
Collapse file

‎apps/mobile/src/i18n/translations/ko.json‎

Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/ko.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,9 @@
17121712
"0efe7ba6d7f681f1": "이 환경에 다시 연결한 뒤 시도하세요. 파일이 이동되었거나 삭제되었을 수 있습니다.",
17131713
"2b29584d2bcea749": "{path}에서 파일을 찾을 수 없습니다.",
17141714
"61026d122846876c": "파일을 다시 첨부한 뒤 다시 시도하세요.",
1715+
"d0872cb98b34eae8": "선택한 환경에서 {label} 끄기",
17151716
"a9129aaa7c955e46": "선택한 환경에서 {label} 켜기",
1717+
"53207498f814efe0": "혼합 · 끄기",
17161718
"fd569def3acc6750": "혼합 · 켜기",
17171719
"8eebcd051255ba20": "메시지 닫기",
17181720
"8711a1de99862971": "{label} 줄이기",
Collapse file

‎apps/mobile/src/i18n/translations/pt-BR.json‎

Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/pt-BR.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,9 @@
17121712
"0efe7ba6d7f681f1": "Reconecte a este ambiente e tente novamente. O arquivo pode ter sido movido ou excluído.",
17131713
"2b29584d2bcea749": "O arquivo não foi encontrado em {path}.",
17141714
"61026d122846876c": "Anexe o arquivo novamente e tente de novo.",
1715+
"d0872cb98b34eae8": "Desativar {label} nos ambientes selecionados",
17151716
"a9129aaa7c955e46": "Ativar {label} nos ambientes selecionados",
1717+
"53207498f814efe0": "Misto · Desativar",
17161718
"fd569def3acc6750": "Misto · Ativar",
17171719
"8eebcd051255ba20": "Dispensar mensagem",
17181720
"8711a1de99862971": "Diminuir {label}",
Collapse file

‎apps/mobile/src/i18n/translations/ru.json‎

Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/ru.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,9 @@
17121712
"0efe7ba6d7f681f1": "Переподключитесь к этому окружению и попробуйте снова. Возможно, файл перемещён или удалён.",
17131713
"2b29584d2bcea749": "Файл не найден по пути {path}.",
17141714
"61026d122846876c": "Прикрепите файл снова и повторите.",
1715+
"d0872cb98b34eae8": "Выключить {label} для выбранных окружений",
17151716
"a9129aaa7c955e46": "Включить {label} для выбранных окружений",
1717+
"53207498f814efe0": "По-разному · Выключить",
17161718
"fd569def3acc6750": "По-разному · Включить",
17171719
"8eebcd051255ba20": "Скрыть сообщение",
17181720
"8711a1de99862971": "Уменьшить {label}",

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.