Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 65x 65x 65x 65x 65x 9x 65x 9x 9x 9x 8x 1x 1x 9x 65x 4x 4x 4x 3x 1x 1x 4x 65x 34x | import { useState, useEffect } from 'react';
import Typography from '@mui/material/Typography';
import TextField from '@mui/material/TextField';
import Button from '@mui/material/Button';
import Box from '@mui/material/Box';
import { getInstanceSetting, updateInstanceSettings } from '../../api';
import { useSnackbar } from '../../contexts/SnackbarContext';
function PrefsGit() {
const { addSnackMessage } = useSnackbar();
const [gitBinaryPath, setGitBinaryPath] = useState<string>('');
const [loading, setLoading] = useState<boolean>(true);
const [saving, setSaving] = useState<boolean>(false);
// Load Git binary path on mount
useEffect(() => {
loadGitBinaryPath();
}, []);
const loadGitBinaryPath = async () => {
try {
setLoading(true);
const path = await getInstanceSetting('git.binaryPath');
setGitBinaryPath((path as string | null) ?? '');
} catch (error) {
console.error('Failed to load Git binary path:', error);
addSnackMessage('Failed to load Git binary path', { severity: 'error' });
} finally {
setLoading(false);
}
};
const handleSave = async () => {
try {
setSaving(true);
await updateInstanceSettings({
git: { binaryPath: gitBinaryPath.trim() || null }
});
addSnackMessage('Git binary path updated', {
severity: 'success'
});
} catch (error) {
console.error('Failed to save Git binary path:', error);
addSnackMessage(`Failed to update Git binary path: ${(error as Error).message}`, {
severity: 'error'
});
} finally {
setSaving(false);
}
};
return (
<Box sx={{ padding: '20px', height: '100%' }}>
<Typography variant="h4">Git Configuration</Typography>
<Box my={2} mx={1}>
<Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
Configure the path to the Git binary used by Quiqr for Git operations.
</Typography>
<Box sx={{ mb: 2 }}>
<TextField
label="Git Binary Path"
value={gitBinaryPath}
onChange={(e) => setGitBinaryPath(e.target.value)}
disabled={loading}
fullWidth
placeholder="Leave empty to use system Git"
sx={{ mb: 1 }}
/>
<Typography variant="caption" color="text.secondary">
If empty, Quiqr will use the system Git binary from PATH.
Specify a custom path if you want to use a specific Git installation.
</Typography>
</Box>
<Button
variant="contained"
onClick={handleSave}
disabled={loading || saving}
>
Save
</Button>
<Typography variant="caption" color="text.secondary" sx={{ display: 'block', mt: 2 }}>
Note: This is an application-level setting that affects all Git operations.
</Typography>
</Box>
</Box>
);
}
export default PrefsGit;
|