mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Add git proxy config
This commit is contained in:
3 files changed
+39
No files matched your search
@@ -6,6 +6,7 @@ export interface GitCredential {
|
||||
origin: string; // Full origin URL (e.g., "https://github.com")
|
||||
username: string;
|
||||
password: string;
|
||||
proxy?: boolean; // Whether to use a proxy for this credential
|
||||
}
|
||||
|
||||
export interface GitSettings {
|
||||
|
||||
@@ -64,6 +64,7 @@ const gitCredentialSchema = z.object({
|
||||
origin: z.string(),
|
||||
username: z.string(),
|
||||
password: z.string(),
|
||||
proxy: z.boolean().optional(),
|
||||
});
|
||||
|
||||
// Old format (map of origins to credentials)
|
||||
@@ -283,6 +284,13 @@ export async function readGitSettings(fs: JSRuntimeFS, configPath = '/config'):
|
||||
credentials = convertCredentialsToNewFormat(parsed.credentials);
|
||||
}
|
||||
|
||||
// Set default proxy settings if missing
|
||||
for (const cred of credentials) {
|
||||
if (!('proxy' in cred)) {
|
||||
cred.proxy = ['https://github.com', 'https://gitlab.com'].includes(cred.origin);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...parsed,
|
||||
credentials,
|
||||
|
||||
@@ -24,6 +24,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
@@ -48,6 +49,7 @@ interface PresetProvider {
|
||||
origin: string;
|
||||
username: string;
|
||||
tokenURL?: string;
|
||||
proxy?: boolean;
|
||||
}
|
||||
|
||||
const PRESET_PROVIDERS: PresetProvider[] = [
|
||||
@@ -57,6 +59,7 @@ const PRESET_PROVIDERS: PresetProvider[] = [
|
||||
origin: "https://github.com",
|
||||
username: "git",
|
||||
tokenURL: "https://github.com/settings/tokens",
|
||||
proxy: true,
|
||||
},
|
||||
{
|
||||
id: "gitlab",
|
||||
@@ -64,6 +67,7 @@ const PRESET_PROVIDERS: PresetProvider[] = [
|
||||
origin: "https://gitlab.com",
|
||||
username: "git",
|
||||
tokenURL: "https://gitlab.com/-/user_settings/personal_access_tokens",
|
||||
proxy: true,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -173,6 +177,18 @@ function SortableCredentialItem({ credential, onUpdate, onRemove, showDragHandle
|
||||
onChange={(e) => updateCredential({ password: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
id={`credential-${credential.id}-proxy`}
|
||||
checked={credential.proxy || false}
|
||||
onCheckedChange={(checked) => updateCredential({
|
||||
proxy: checked === true || undefined
|
||||
})}
|
||||
/>
|
||||
<Label htmlFor={`credential-${credential.id}-proxy`} className="cursor-pointer">
|
||||
{t('useCorsProxy')}
|
||||
</Label>
|
||||
</div>
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
@@ -195,6 +211,7 @@ export function GitSettings() {
|
||||
const [customOrigin, setCustomOrigin] = useState('');
|
||||
const [customUsername, setCustomUsername] = useState('');
|
||||
const [customPassword, setCustomPassword] = useState('');
|
||||
const [customProxy, setCustomProxy] = useState(false);
|
||||
const [presetTokens, setPresetTokens] = useState<Record<string, string>>({});
|
||||
const [forceManualEntry, setForceManualEntry] = useState<Record<string, boolean>>({});
|
||||
|
||||
@@ -216,6 +233,7 @@ export function GitSettings() {
|
||||
origin: preset.origin,
|
||||
username: preset.username,
|
||||
password: token.trim(),
|
||||
proxy: preset.proxy,
|
||||
};
|
||||
|
||||
// Auto-save: Add credential immediately to persistent storage
|
||||
@@ -237,6 +255,7 @@ export function GitSettings() {
|
||||
origin: customOrigin.trim(),
|
||||
username: customUsername.trim(),
|
||||
password: customPassword.trim(),
|
||||
proxy: customProxy || undefined,
|
||||
};
|
||||
|
||||
// Auto-save: Add credential immediately to persistent storage
|
||||
@@ -246,6 +265,7 @@ export function GitSettings() {
|
||||
setCustomOrigin('');
|
||||
setCustomUsername('');
|
||||
setCustomPassword('');
|
||||
setCustomProxy(false);
|
||||
};
|
||||
|
||||
const handleRemoveCredential = (id: string) => {
|
||||
@@ -539,6 +559,16 @@ export function GitSettings() {
|
||||
onChange={(e) => setCustomPassword(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
id="custom-proxy"
|
||||
checked={customProxy}
|
||||
onCheckedChange={(checked) => setCustomProxy(checked === true)}
|
||||
/>
|
||||
<Label htmlFor="custom-proxy" className="cursor-pointer">
|
||||
{t('useCorsProxy')}
|
||||
</Label>
|
||||
</div>
|
||||
<Button
|
||||
onClick={handleAddCustomProvider}
|
||||
disabled={
|
||||
|
||||
Reference in new issue
Block a user