Update files

This commit is contained in:
Mohamed Boudra
2026-02-05 12:17:50 +07:00
parent ae27a14e3b
commit 45869e699f
5 changed files with 142 additions and 101 deletions
+11 -3
View File
@@ -147,10 +147,11 @@ export interface AddHostModalProps {
visible: boolean;
onClose: () => void;
targetServerId?: string;
onCancel?: () => void;
onSaved?: (result: { profile: HostProfile; serverId: string; hostname: string | null; isNewHost: boolean }) => void;
}
export function AddHostModal({ visible, onClose, onSaved, targetServerId }: AddHostModalProps) {
export function AddHostModal({ visible, onClose, onCancel, onSaved, targetServerId }: AddHostModalProps) {
const { theme } = useUnistyles();
const { daemons, upsertDirectConnection } = useDaemonRegistry();
const isMobile =
@@ -170,6 +171,13 @@ export function AddHostModal({ visible, onClose, onSaved, targetServerId }: AddH
onClose();
}, [isSaving, onClose]);
const handleCancel = useCallback(() => {
if (isSaving) return;
setEndpointRaw("");
setErrorMessage("");
(onCancel ?? onClose)();
}, [isSaving, onCancel, onClose]);
const handleSave = useCallback(async () => {
if (isSaving) return;
@@ -256,8 +264,8 @@ export function AddHostModal({ visible, onClose, onSaved, targetServerId }: AddH
</View>
<View style={styles.actions}>
<Pressable style={styles.button} onPress={handleClose} disabled={isSaving}>
<Text style={styles.buttonText}>Cancel</Text>
<Pressable style={styles.button} onPress={handleCancel} disabled={isSaving}>
<Text style={styles.buttonText}>{onCancel ? "Back" : "Cancel"}</Text>
</Pressable>
<Pressable
style={[styles.button, styles.primaryButton, isSaving ? { opacity: 0.7 } : null]}