Show toast when enabling auto-approve on non-settings UI
This commit is contained in:
@@ -1,17 +1,25 @@
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user