@buoy-gg/time-machine 7.0.22 → 7.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/TimeMachineBody.js +147 -677
- package/lib/commonjs/components/TimeMachineBody.js.map +1 -1
- package/lib/commonjs/components/TimeMachineModal.js +10 -11
- package/lib/commonjs/components/TimeMachineModal.js.map +1 -1
- package/lib/commonjs/components/confirm.js +39 -0
- package/lib/commonjs/components/confirm.js.map +1 -0
- package/lib/commonjs/components/format.js +24 -0
- package/lib/commonjs/components/format.js.map +1 -0
- package/lib/commonjs/components/list/CaptureBar.js +95 -0
- package/lib/commonjs/components/list/CaptureBar.js.map +1 -0
- package/lib/commonjs/components/list/RestoreOutcomeCard.js +162 -0
- package/lib/commonjs/components/list/RestoreOutcomeCard.js.map +1 -0
- package/lib/commonjs/components/list/SnapshotRow.js +141 -0
- package/lib/commonjs/components/list/SnapshotRow.js.map +1 -0
- package/lib/commonjs/components/list/SourcesStrip.js +126 -0
- package/lib/commonjs/components/list/SourcesStrip.js.map +1 -0
- package/lib/commonjs/components/list/UndoDeleteBar.js +81 -0
- package/lib/commonjs/components/list/UndoDeleteBar.js.map +1 -0
- package/lib/commonjs/components/list/WipeAllRow.js +46 -0
- package/lib/commonjs/components/list/WipeAllRow.js.map +1 -0
- package/lib/commonjs/components/preview/ItemDiffPanel.js +77 -0
- package/lib/commonjs/components/preview/ItemDiffPanel.js.map +1 -0
- package/lib/commonjs/components/preview/PreviewFlow.js +51 -0
- package/lib/commonjs/components/preview/PreviewFlow.js.map +1 -0
- package/lib/commonjs/components/preview/RestorePointNameRow.js +83 -0
- package/lib/commonjs/components/preview/RestorePointNameRow.js.map +1 -0
- package/lib/commonjs/components/preview/RestorePreviewScreen.js +549 -635
- package/lib/commonjs/components/preview/RestorePreviewScreen.js.map +1 -1
- package/lib/commonjs/components/preview/verdictMeta.js +8 -8
- package/lib/commonjs/components/preview/verdictMeta.js.map +1 -1
- package/lib/commonjs/components/sources.js +72 -0
- package/lib/commonjs/components/sources.js.map +1 -0
- package/lib/commonjs/store/snapshotVault.js +93 -9
- package/lib/commonjs/store/snapshotVault.js.map +1 -1
- package/lib/commonjs/store/timeMachineStore.js +125 -6
- package/lib/commonjs/store/timeMachineStore.js.map +1 -1
- package/lib/commonjs/sync/timeMachineSyncAdapter.js +41 -0
- package/lib/commonjs/sync/timeMachineSyncAdapter.js.map +1 -1
- package/lib/commonjs/ui/SwipeActionsRow.js +167 -0
- package/lib/commonjs/ui/SwipeActionsRow.js.map +1 -0
- package/lib/commonjs/ui/primitives.js +164 -0
- package/lib/commonjs/ui/primitives.js.map +1 -0
- package/lib/commonjs/ui/tmTheme.js +103 -0
- package/lib/commonjs/ui/tmTheme.js.map +1 -0
- package/lib/module/components/TimeMachineBody.js +150 -680
- package/lib/module/components/TimeMachineBody.js.map +1 -1
- package/lib/module/components/TimeMachineModal.js +11 -12
- package/lib/module/components/TimeMachineModal.js.map +1 -1
- package/lib/module/components/confirm.js +34 -0
- package/lib/module/components/confirm.js.map +1 -0
- package/lib/module/components/format.js +19 -0
- package/lib/module/components/format.js.map +1 -0
- package/lib/module/components/list/CaptureBar.js +90 -0
- package/lib/module/components/list/CaptureBar.js.map +1 -0
- package/lib/module/components/list/RestoreOutcomeCard.js +156 -0
- package/lib/module/components/list/RestoreOutcomeCard.js.map +1 -0
- package/lib/module/components/list/SnapshotRow.js +138 -0
- package/lib/module/components/list/SnapshotRow.js.map +1 -0
- package/lib/module/components/list/SourcesStrip.js +121 -0
- package/lib/module/components/list/SourcesStrip.js.map +1 -0
- package/lib/module/components/list/UndoDeleteBar.js +78 -0
- package/lib/module/components/list/UndoDeleteBar.js.map +1 -0
- package/lib/module/components/list/WipeAllRow.js +41 -0
- package/lib/module/components/list/WipeAllRow.js.map +1 -0
- package/lib/module/components/preview/ItemDiffPanel.js +72 -0
- package/lib/module/components/preview/ItemDiffPanel.js.map +1 -0
- package/lib/module/components/preview/PreviewFlow.js +46 -0
- package/lib/module/components/preview/PreviewFlow.js.map +1 -0
- package/lib/module/components/preview/RestorePointNameRow.js +78 -0
- package/lib/module/components/preview/RestorePointNameRow.js.map +1 -0
- package/lib/module/components/preview/RestorePreviewScreen.js +552 -638
- package/lib/module/components/preview/RestorePreviewScreen.js.map +1 -1
- package/lib/module/components/preview/verdictMeta.js +9 -8
- package/lib/module/components/preview/verdictMeta.js.map +1 -1
- package/lib/module/components/sources.js +66 -0
- package/lib/module/components/sources.js.map +1 -0
- package/lib/module/store/snapshotVault.js +87 -9
- package/lib/module/store/snapshotVault.js.map +1 -1
- package/lib/module/store/timeMachineStore.js +125 -7
- package/lib/module/store/timeMachineStore.js.map +1 -1
- package/lib/module/sync/timeMachineSyncAdapter.js +41 -0
- package/lib/module/sync/timeMachineSyncAdapter.js.map +1 -1
- package/lib/module/ui/SwipeActionsRow.js +162 -0
- package/lib/module/ui/SwipeActionsRow.js.map +1 -0
- package/lib/module/ui/primitives.js +156 -0
- package/lib/module/ui/primitives.js.map +1 -0
- package/lib/module/ui/tmTheme.js +99 -0
- package/lib/module/ui/tmTheme.js.map +1 -0
- package/lib/typescript/components/TimeMachineBody.d.ts.map +1 -1
- package/lib/typescript/components/TimeMachineModal.d.ts.map +1 -1
- package/lib/typescript/components/confirm.d.ts +2 -0
- package/lib/typescript/components/confirm.d.ts.map +1 -0
- package/lib/typescript/components/format.d.ts +4 -0
- package/lib/typescript/components/format.d.ts.map +1 -0
- package/lib/typescript/components/list/CaptureBar.d.ts +6 -0
- package/lib/typescript/components/list/CaptureBar.d.ts.map +1 -0
- package/lib/typescript/components/list/RestoreOutcomeCard.d.ts +11 -0
- package/lib/typescript/components/list/RestoreOutcomeCard.d.ts.map +1 -0
- package/lib/typescript/components/list/SnapshotRow.d.ts +12 -0
- package/lib/typescript/components/list/SnapshotRow.d.ts.map +1 -0
- package/lib/typescript/components/list/SourcesStrip.d.ts +5 -0
- package/lib/typescript/components/list/SourcesStrip.d.ts.map +1 -0
- package/lib/typescript/components/list/UndoDeleteBar.d.ts +8 -0
- package/lib/typescript/components/list/UndoDeleteBar.d.ts.map +1 -0
- package/lib/typescript/components/list/WipeAllRow.d.ts +5 -0
- package/lib/typescript/components/list/WipeAllRow.d.ts.map +1 -0
- package/lib/typescript/components/preview/ItemDiffPanel.d.ts +5 -0
- package/lib/typescript/components/preview/ItemDiffPanel.d.ts.map +1 -0
- package/lib/typescript/components/preview/PreviewFlow.d.ts +9 -0
- package/lib/typescript/components/preview/PreviewFlow.d.ts.map +1 -0
- package/lib/typescript/components/preview/RestorePointNameRow.d.ts +5 -0
- package/lib/typescript/components/preview/RestorePointNameRow.d.ts.map +1 -0
- package/lib/typescript/components/preview/RestorePreviewScreen.d.ts +1 -5
- package/lib/typescript/components/preview/RestorePreviewScreen.d.ts.map +1 -1
- package/lib/typescript/components/preview/verdictMeta.d.ts +5 -0
- package/lib/typescript/components/preview/verdictMeta.d.ts.map +1 -1
- package/lib/typescript/components/sources.d.ts +36 -0
- package/lib/typescript/components/sources.d.ts.map +1 -0
- package/lib/typescript/store/snapshotVault.d.ts +48 -0
- package/lib/typescript/store/snapshotVault.d.ts.map +1 -1
- package/lib/typescript/store/timeMachineStore.d.ts +35 -1
- package/lib/typescript/store/timeMachineStore.d.ts.map +1 -1
- package/lib/typescript/sync/timeMachineSyncAdapter.d.ts +17 -0
- package/lib/typescript/sync/timeMachineSyncAdapter.d.ts.map +1 -1
- package/lib/typescript/ui/SwipeActionsRow.d.ts +32 -0
- package/lib/typescript/ui/SwipeActionsRow.d.ts.map +1 -0
- package/lib/typescript/ui/primitives.d.ts +57 -0
- package/lib/typescript/ui/primitives.d.ts.map +1 -0
- package/lib/typescript/ui/tmTheme.d.ts +67 -0
- package/lib/typescript/ui/tmTheme.d.ts.map +1 -0
- package/package.json +7 -7
- package/src/components/TimeMachineBody.tsx +183 -817
- package/src/components/TimeMachineModal.tsx +10 -11
- package/src/components/confirm.ts +35 -0
- package/src/components/format.ts +17 -0
- package/src/components/list/CaptureBar.tsx +100 -0
- package/src/components/list/RestoreOutcomeCard.tsx +159 -0
- package/src/components/list/SnapshotRow.tsx +155 -0
- package/src/components/list/SourcesStrip.tsx +124 -0
- package/src/components/list/UndoDeleteBar.tsx +76 -0
- package/src/components/list/WipeAllRow.tsx +42 -0
- package/src/components/preview/ItemDiffPanel.tsx +77 -0
- package/src/components/preview/PreviewFlow.tsx +70 -0
- package/src/components/preview/RestorePointNameRow.tsx +80 -0
- package/src/components/preview/RestorePreviewScreen.tsx +535 -535
- package/src/components/preview/verdictMeta.ts +8 -8
- package/src/components/sources.ts +92 -0
- package/src/store/snapshotVault.ts +131 -9
- package/src/store/timeMachineStore.ts +136 -5
- package/src/sync/timeMachineSyncAdapter.ts +30 -0
- package/src/ui/SwipeActionsRow.tsx +199 -0
- package/src/ui/primitives.tsx +157 -0
- package/src/ui/tmTheme.ts +107 -0
- package/lib/commonjs/components/preview/ItemDetailScreen.js +0 -189
- package/lib/commonjs/components/preview/ItemDetailScreen.js.map +0 -1
- package/lib/module/components/preview/ItemDetailScreen.js +0 -184
- package/lib/module/components/preview/ItemDetailScreen.js.map +0 -1
- package/lib/typescript/components/preview/ItemDetailScreen.d.ts +0 -11
- package/lib/typescript/components/preview/ItemDetailScreen.d.ts.map +0 -1
- package/src/components/preview/ItemDetailScreen.tsx +0 -172
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The way back from a swipe-delete.
|
|
3
|
+
*
|
|
4
|
+
* Swipe-then-tap is deliberate, which is why there's no confirmation dialog —
|
|
5
|
+
* but deliberate and recoverable are different properties, and a restore
|
|
6
|
+
* point can stand for state that took ten minutes and a cooperative backend
|
|
7
|
+
* to build. The record is held in memory until this bar expires.
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect } from "react";
|
|
10
|
+
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
|
11
|
+
import { tm } from "../../ui/tmTheme";
|
|
12
|
+
|
|
13
|
+
/** Long enough to notice and react, short enough not to linger. */
|
|
14
|
+
const WINDOW_MS = 8000;
|
|
15
|
+
|
|
16
|
+
export function UndoDeleteBar({
|
|
17
|
+
name,
|
|
18
|
+
at,
|
|
19
|
+
onUndo,
|
|
20
|
+
onExpire,
|
|
21
|
+
}: {
|
|
22
|
+
name: string;
|
|
23
|
+
/** Restarts the countdown when a second delete replaces the first. */
|
|
24
|
+
at: number;
|
|
25
|
+
onUndo: () => void;
|
|
26
|
+
onExpire: () => void;
|
|
27
|
+
}) {
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const timer = setTimeout(onExpire, WINDOW_MS);
|
|
30
|
+
return () => clearTimeout(timer);
|
|
31
|
+
// `at` keyed rather than `onExpire`: a new delete must restart the clock.
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, [at]);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<View style={styles.bar}>
|
|
37
|
+
<Text style={styles.text} numberOfLines={1}>
|
|
38
|
+
Deleted “{name}”
|
|
39
|
+
</Text>
|
|
40
|
+
<TouchableOpacity
|
|
41
|
+
onPress={onUndo}
|
|
42
|
+
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
43
|
+
accessibilityRole="button"
|
|
44
|
+
testID="time-machine-undo-delete"
|
|
45
|
+
>
|
|
46
|
+
<Text style={styles.undo}>Undo</Text>
|
|
47
|
+
</TouchableOpacity>
|
|
48
|
+
</View>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const styles = StyleSheet.create({
|
|
53
|
+
bar: {
|
|
54
|
+
flexDirection: "row",
|
|
55
|
+
alignItems: "center",
|
|
56
|
+
gap: 12,
|
|
57
|
+
marginHorizontal: tm.gutter,
|
|
58
|
+
marginTop: 12,
|
|
59
|
+
minHeight: 46,
|
|
60
|
+
paddingHorizontal: tm.textInset,
|
|
61
|
+
backgroundColor: tm.color.group,
|
|
62
|
+
borderRadius: tm.radius.group,
|
|
63
|
+
},
|
|
64
|
+
text: {
|
|
65
|
+
flex: 1,
|
|
66
|
+
color: tm.color.labelSecondary,
|
|
67
|
+
fontSize: tm.font.control,
|
|
68
|
+
letterSpacing: tm.tracking.control,
|
|
69
|
+
},
|
|
70
|
+
undo: {
|
|
71
|
+
color: tm.color.accent,
|
|
72
|
+
fontSize: tm.font.control,
|
|
73
|
+
fontWeight: "600",
|
|
74
|
+
letterSpacing: tm.tracking.control,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Wipe All App State…" — the destructive utility, deliberately last, alone
|
|
3
|
+
* in its own card and with no icon competing for attention.
|
|
4
|
+
*/
|
|
5
|
+
import { StyleSheet, Text, TouchableOpacity } from "react-native";
|
|
6
|
+
import { tm } from "../../ui/tmTheme";
|
|
7
|
+
|
|
8
|
+
export function WipeAllRow({
|
|
9
|
+
disabled,
|
|
10
|
+
onWipe,
|
|
11
|
+
}: {
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
onWipe: () => void;
|
|
14
|
+
}) {
|
|
15
|
+
return (
|
|
16
|
+
<TouchableOpacity
|
|
17
|
+
style={[styles.row, disabled ? styles.disabled : null]}
|
|
18
|
+
onPress={onWipe}
|
|
19
|
+
disabled={disabled}
|
|
20
|
+
accessibilityRole="button"
|
|
21
|
+
testID="time-machine-wipe-all"
|
|
22
|
+
>
|
|
23
|
+
<Text style={styles.label}>Wipe All App State…</Text>
|
|
24
|
+
</TouchableOpacity>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
row: {
|
|
30
|
+
minHeight: tm.rowMinHeight,
|
|
31
|
+
alignItems: "center",
|
|
32
|
+
justifyContent: "center",
|
|
33
|
+
},
|
|
34
|
+
disabled: {
|
|
35
|
+
opacity: 0.4,
|
|
36
|
+
},
|
|
37
|
+
label: {
|
|
38
|
+
color: tm.color.danger,
|
|
39
|
+
fontSize: tm.font.row,
|
|
40
|
+
letterSpacing: tm.tracking.row,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One preview item's before/after, rendered INLINE under its row rather than
|
|
3
|
+
* on a screen of its own — "what changed in this key" is a glance question,
|
|
4
|
+
* and losing the list to answer it costs you the place you were reading.
|
|
5
|
+
*
|
|
6
|
+
* Split view only, with no view switcher. Side-by-side is the shape that
|
|
7
|
+
* answers the question here ("what is it now, what will it become"), and
|
|
8
|
+
* inside a list row the segmented control cost more vertical space than the
|
|
9
|
+
* diff it was switching.
|
|
10
|
+
*
|
|
11
|
+
* The render-layer viewer only handles plain JSON faithfully, so both sides
|
|
12
|
+
* pass through toDiffable (Dates→ISO, Maps→objects, BigInt→"1n", cycles→
|
|
13
|
+
* "[Circular]") and the pair is memoized ONCE per item — the storage tool's
|
|
14
|
+
* fix for the fresh-identity-every-render trap that redux/zustand still have.
|
|
15
|
+
*
|
|
16
|
+
* No scroller of its own: this sits inside the preview's FlatList, so the
|
|
17
|
+
* viewer renders at natural height with `scrollEnabled={false}` (the storage
|
|
18
|
+
* matched-pair contract).
|
|
19
|
+
*/
|
|
20
|
+
import { useMemo } from "react";
|
|
21
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
22
|
+
import type { StateSnapshotPreviewItem } from "@buoy-gg/shared-ui";
|
|
23
|
+
import {
|
|
24
|
+
ABSENT_VALUE,
|
|
25
|
+
ThemedSplitView,
|
|
26
|
+
devToolsDefaultTheme,
|
|
27
|
+
toDiffable,
|
|
28
|
+
} from "@buoy-gg/shared-ui/dataViewer";
|
|
29
|
+
import { tm } from "../../ui/tmTheme";
|
|
30
|
+
|
|
31
|
+
const EMPTY: unknown[] = [];
|
|
32
|
+
|
|
33
|
+
export function ItemDiffPanel({ item }: { item: StateSnapshotPreviewItem }) {
|
|
34
|
+
// ABSENT_VALUE keeps added/removed reading as pure additions/removals
|
|
35
|
+
// instead of diffs against the literal "null".
|
|
36
|
+
const { oldValue, newValue } = useMemo(
|
|
37
|
+
() => ({
|
|
38
|
+
oldValue:
|
|
39
|
+
item.verdict === "added" ? ABSENT_VALUE : toDiffable(item.oldValue),
|
|
40
|
+
newValue:
|
|
41
|
+
item.verdict === "removed" ? ABSENT_VALUE : toDiffable(item.newValue),
|
|
42
|
+
}),
|
|
43
|
+
[item]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<View style={styles.panel}>
|
|
48
|
+
{item.reason ? <Text style={styles.reason}>⚠ {item.reason}</Text> : null}
|
|
49
|
+
<ThemedSplitView
|
|
50
|
+
oldValue={oldValue}
|
|
51
|
+
newValue={newValue}
|
|
52
|
+
differences={EMPTY}
|
|
53
|
+
theme={devToolsDefaultTheme}
|
|
54
|
+
scrollEnabled={false}
|
|
55
|
+
/>
|
|
56
|
+
</View>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const styles = StyleSheet.create({
|
|
61
|
+
// Same fill as the rows above it: this is part of the card, not a thing
|
|
62
|
+
// floating under it.
|
|
63
|
+
panel: {
|
|
64
|
+
// Only a token indent: the viewer lays values out at their natural width
|
|
65
|
+
// and a 51pt inset (matching the checkbox column) clipped long numbers.
|
|
66
|
+
paddingLeft: 16,
|
|
67
|
+
paddingRight: 12,
|
|
68
|
+
paddingTop: 10,
|
|
69
|
+
paddingBottom: 14,
|
|
70
|
+
gap: 10,
|
|
71
|
+
backgroundColor: tm.color.group,
|
|
72
|
+
},
|
|
73
|
+
reason: {
|
|
74
|
+
color: tm.color.warning,
|
|
75
|
+
fontSize: tm.font.footnote,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The preview screen, wired to the store — the restore leg (baseline
|
|
3
|
+
* confirmation, the route prompt, landing back on the list) lives here so
|
|
4
|
+
* RestorePreviewScreen stays presentation.
|
|
5
|
+
*
|
|
6
|
+
* Kept apart from the restore-point list so each screen mounts and unmounts
|
|
7
|
+
* as a whole tree — the router in ../TimeMachineBody picks one, never swaps
|
|
8
|
+
* branches inside a live tree. (Item diffs are NOT a screen: they expand
|
|
9
|
+
* inline inside the preview's list.)
|
|
10
|
+
*/
|
|
11
|
+
import { timeMachineStore } from "../../store/timeMachineStore";
|
|
12
|
+
import type {
|
|
13
|
+
PreviewSideRef,
|
|
14
|
+
PreviewState,
|
|
15
|
+
} from "../../store/timeMachineStore";
|
|
16
|
+
import type { SnapshotMeta } from "../../store/snapshotVault";
|
|
17
|
+
import { confirmDestructive } from "../confirm";
|
|
18
|
+
import { RestorePreviewScreen } from "./RestorePreviewScreen";
|
|
19
|
+
|
|
20
|
+
function snapshotFor(
|
|
21
|
+
ref: PreviewSideRef,
|
|
22
|
+
snapshots: SnapshotMeta[]
|
|
23
|
+
): SnapshotMeta | undefined {
|
|
24
|
+
return ref === "current"
|
|
25
|
+
? undefined
|
|
26
|
+
: snapshots.find((s) => s.id === ref.snapshotId);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function PreviewScreen({
|
|
30
|
+
preview,
|
|
31
|
+
snapshots,
|
|
32
|
+
busy,
|
|
33
|
+
onClose,
|
|
34
|
+
}: {
|
|
35
|
+
preview: PreviewState;
|
|
36
|
+
snapshots: SnapshotMeta[];
|
|
37
|
+
busy: boolean;
|
|
38
|
+
onClose: () => void;
|
|
39
|
+
}) {
|
|
40
|
+
const rightMeta = snapshotFor(preview.right, snapshots);
|
|
41
|
+
|
|
42
|
+
const restore = (mode: "live" | "reload", excludeKeys?: string[]) => {
|
|
43
|
+
if (!rightMeta || busy) return;
|
|
44
|
+
if (rightMeta.baseline) {
|
|
45
|
+
confirmDestructive(
|
|
46
|
+
"Restore fresh install?",
|
|
47
|
+
"This wipes all app storage and reloads the app.",
|
|
48
|
+
"Wipe & reload",
|
|
49
|
+
() => void timeMachineStore.restore(rightMeta.id, "reload")
|
|
50
|
+
);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Land back on the list, where the outcome card reports the results —
|
|
54
|
+
// the preview's diff is stale the moment restore runs. Whether the route
|
|
55
|
+
// comes back is the restore point's own setting, toggled on its row.
|
|
56
|
+
void timeMachineStore
|
|
57
|
+
.restore(rightMeta.id, mode, excludeKeys)
|
|
58
|
+
.then(onClose);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<RestorePreviewScreen
|
|
63
|
+
preview={preview}
|
|
64
|
+
snapshots={snapshots}
|
|
65
|
+
busy={busy}
|
|
66
|
+
onBack={onClose}
|
|
67
|
+
onRestore={restore}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The restore point's name, editable in place.
|
|
3
|
+
*
|
|
4
|
+
* Renaming lives on the preview rather than behind a swipe on the list: the
|
|
5
|
+
* list is for picking one, and you rarely know a name is wrong until you're
|
|
6
|
+
* looking at what the point actually contains.
|
|
7
|
+
*
|
|
8
|
+
* Commits on blur as well as on return — tapping away from a field you have
|
|
9
|
+
* just typed into should keep the typing. Finder and iOS both treat leaving
|
|
10
|
+
* as accepting, and silently discarding an edit is the one outcome nobody
|
|
11
|
+
* wants.
|
|
12
|
+
*/
|
|
13
|
+
import { useEffect, useState } from "react";
|
|
14
|
+
import { StyleSheet, Text, TextInput, View } from "react-native";
|
|
15
|
+
import { tm } from "../../ui/tmTheme";
|
|
16
|
+
|
|
17
|
+
export function RestorePointNameRow({
|
|
18
|
+
name,
|
|
19
|
+
onRename,
|
|
20
|
+
}: {
|
|
21
|
+
name: string;
|
|
22
|
+
onRename: (name: string) => void;
|
|
23
|
+
}) {
|
|
24
|
+
const [draft, setDraft] = useState(name);
|
|
25
|
+
|
|
26
|
+
// A rename from anywhere else (MCP, the desktop) should show up here.
|
|
27
|
+
useEffect(() => setDraft(name), [name]);
|
|
28
|
+
|
|
29
|
+
const commit = () => {
|
|
30
|
+
const trimmed = draft.trim();
|
|
31
|
+
if (!trimmed) {
|
|
32
|
+
setDraft(name); // an empty name would make the row unidentifiable
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (trimmed !== name) onRename(trimmed);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<View style={styles.row}>
|
|
40
|
+
<Text style={styles.label}>Name</Text>
|
|
41
|
+
<TextInput
|
|
42
|
+
style={styles.input}
|
|
43
|
+
value={draft}
|
|
44
|
+
onChangeText={setDraft}
|
|
45
|
+
onSubmitEditing={commit}
|
|
46
|
+
onBlur={commit}
|
|
47
|
+
returnKeyType="done"
|
|
48
|
+
selectTextOnFocus
|
|
49
|
+
accessibilityLabel="Restore point name"
|
|
50
|
+
testID="tm-preview-name"
|
|
51
|
+
/>
|
|
52
|
+
</View>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const styles = StyleSheet.create({
|
|
57
|
+
row: {
|
|
58
|
+
flexDirection: "row",
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
gap: 14,
|
|
61
|
+
minHeight: tm.rowMinHeight,
|
|
62
|
+
paddingHorizontal: tm.textInset,
|
|
63
|
+
},
|
|
64
|
+
label: {
|
|
65
|
+
color: tm.color.labelSecondary,
|
|
66
|
+
fontSize: tm.font.row,
|
|
67
|
+
letterSpacing: tm.tracking.row,
|
|
68
|
+
},
|
|
69
|
+
input: {
|
|
70
|
+
flex: 1,
|
|
71
|
+
minWidth: 0,
|
|
72
|
+
color: tm.color.label,
|
|
73
|
+
fontSize: tm.font.row,
|
|
74
|
+
fontWeight: "600",
|
|
75
|
+
letterSpacing: tm.tracking.row,
|
|
76
|
+
textAlign: "right",
|
|
77
|
+
padding: 0,
|
|
78
|
+
backgroundColor: "transparent",
|
|
79
|
+
},
|
|
80
|
+
});
|