mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
Add GitHub token environment variable support and improve git operations
This commit is contained in:
1 parent
025b2990ed
commit
af0dcac7c8
11 files changed
+125
-21
No files matched your search
@@ -46,6 +46,7 @@ export interface UserPreferences {
|
||||
export interface SettingsResponse {
|
||||
preferences: UserPreferences
|
||||
updatedAt: number
|
||||
serverRestarted?: boolean
|
||||
}
|
||||
|
||||
export interface UpdateSettingsRequest {
|
||||
|
||||
@@ -6,9 +6,10 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
|
||||
import { Switch } from '@/components/ui/switch'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { TTSSettings } from './TTSSettings'
|
||||
import { showToast } from '@/lib/toast'
|
||||
|
||||
export function GeneralSettings() {
|
||||
const { preferences, isLoading, updateSettings, isUpdating } = useSettings()
|
||||
const { preferences, isLoading, updateSettings, updateSettingsAsync, isUpdating } = useSettings()
|
||||
|
||||
const [gitToken, setGitToken] = useState('')
|
||||
|
||||
@@ -120,7 +121,17 @@ export function GeneralSettings() {
|
||||
placeholder="ghp_..."
|
||||
value={gitToken}
|
||||
onChange={(e) => setGitToken(e.target.value)}
|
||||
onBlur={() => updateSettings({ gitToken })}
|
||||
onBlur={async () => {
|
||||
if (gitToken !== preferences?.gitToken) {
|
||||
showToast.loading('Restarting OpenCode server...', { id: 'restart-server' })
|
||||
try {
|
||||
await updateSettingsAsync({ gitToken })
|
||||
showToast.success('GitHub token updated', { id: 'restart-server' })
|
||||
} catch {
|
||||
showToast.error('Failed to update GitHub token', { id: 'restart-server' })
|
||||
}
|
||||
}
|
||||
}}
|
||||
className="bg-background border-border text-foreground placeholder:text-muted-foreground"
|
||||
/>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
|
||||
@@ -10,6 +10,12 @@ interface ToastOptions {
|
||||
id?: string | number
|
||||
}
|
||||
|
||||
interface PromiseToastMessages {
|
||||
loading: string
|
||||
success: string
|
||||
error: string
|
||||
}
|
||||
|
||||
export const showToast = {
|
||||
success: (message: string, options?: ToastOptions) => {
|
||||
return toast.success(message, options)
|
||||
@@ -31,6 +37,10 @@ export const showToast = {
|
||||
return toast.loading(message, options)
|
||||
},
|
||||
|
||||
promise: <T>(promise: Promise<T>, messages: PromiseToastMessages) => {
|
||||
return toast.promise(promise, messages)
|
||||
},
|
||||
|
||||
dismiss: (id?: string | number) => {
|
||||
toast.dismiss(id)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user