提交 a4629e76 authored 作者: Will Chen's avatar Will Chen

Show toast when enabling auto-approve on non-settings UI

上级 5e95ae36
import { useSettings } from "@/hooks/useSettings";
import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
import { showInfo } from "@/lib/toast";
export function AutoApproveSwitch() {
export function AutoApproveSwitch({
showToast = true,
}: {
showToast?: boolean;
}) {
const { settings, updateSettings } = useSettings();
return (
<div className="flex items-center space-x-2">
<Switch
id="auto-approve"
checked={settings?.autoApproveChanges}
onCheckedChange={() =>
updateSettings({ autoApproveChanges: !settings?.autoApproveChanges })
}
onCheckedChange={() => {
updateSettings({ autoApproveChanges: !settings?.autoApproveChanges });
if (!settings?.autoApproveChanges && showToast) {
showInfo("You can disable auto-approve in the Settings.");
}
}}
/>
<Label htmlFor="auto-approve">Auto-approve</Label>
</div>
......
......@@ -323,7 +323,9 @@ function ChatInputActions({
}: ChatInputActionsProps) {
const [autoApprove, setAutoApprove] = useState(false);
const [isDetailsVisible, setIsDetailsVisible] = useState(false);
if (proposal.type === "tip-proposal") {
return <div>Tip proposal</div>;
}
if (proposal.type === "action-proposal") {
return <ActionProposalActions proposal={proposal}></ActionProposalActions>;
}
......
......@@ -69,7 +69,7 @@ export default function SettingsPage() {
<div className="space-y-4">
<div className="space-y-2">
<AutoApproveSwitch />
<AutoApproveSwitch showToast={false} />
<div className="text-sm text-gray-500 dark:text-gray-400">
This will automatically approve code changes and run them.
</div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论