mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-06 16:53:38 +02:00
Add bot disable flow
This commit is contained in:
@@ -246,6 +246,7 @@ export function SettingsModal(props: SettingsModalProps) {
|
||||
{isSectionVisible('bot') && appSettings && (
|
||||
<SettingsBotSection
|
||||
appSettings={appSettings}
|
||||
health={health}
|
||||
isMobileLayout={isMobileLayout}
|
||||
onSaveAppSettings={onSaveAppSettings}
|
||||
className={sectionContentClass}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Button } from '../ui/button';
|
||||
import { Separator } from '../ui/separator';
|
||||
import { toast } from '../ui/sonner';
|
||||
import { handleKeyboardActivate } from '../../utils/a11y';
|
||||
import type { AppSettings, AppSettingsUpdate, BotConfig } from '../../types';
|
||||
import type { AppSettings, AppSettingsUpdate, BotConfig, HealthStatus } from '../../types';
|
||||
|
||||
const BotCodeEditor = lazy(() =>
|
||||
import('../BotCodeEditor').then((m) => ({ default: m.BotCodeEditor }))
|
||||
@@ -50,11 +50,13 @@ const DEFAULT_BOT_CODE = `def bot(
|
||||
|
||||
export function SettingsBotSection({
|
||||
appSettings,
|
||||
health,
|
||||
isMobileLayout,
|
||||
onSaveAppSettings,
|
||||
className,
|
||||
}: {
|
||||
appSettings: AppSettings;
|
||||
health: HealthStatus | null;
|
||||
isMobileLayout: boolean;
|
||||
onSaveAppSettings: (update: AppSettingsUpdate) => Promise<void>;
|
||||
className?: string;
|
||||
@@ -139,6 +141,14 @@ export function SettingsBotSection({
|
||||
setBots(bots.map((b) => (b.id === botId ? { ...b, code: DEFAULT_BOT_CODE } : b)));
|
||||
};
|
||||
|
||||
if (health?.bots_disabled) {
|
||||
return (
|
||||
<div className={className}>
|
||||
<p className="text-sm text-muted-foreground">Bot system disabled by server startup flag.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<div className="p-3 bg-red-500/10 border border-red-500/30 rounded-md">
|
||||
|
||||
@@ -40,6 +40,7 @@ const baseHealth: HealthStatus = {
|
||||
oldest_undecrypted_timestamp: null,
|
||||
mqtt_status: null,
|
||||
community_mqtt_status: null,
|
||||
bots_disabled: false,
|
||||
};
|
||||
|
||||
const baseSettings: AppSettings = {
|
||||
|
||||
@@ -31,6 +31,7 @@ export interface HealthStatus {
|
||||
oldest_undecrypted_timestamp: number | null;
|
||||
mqtt_status: string | null;
|
||||
community_mqtt_status: string | null;
|
||||
bots_disabled: boolean;
|
||||
}
|
||||
|
||||
export interface MaintenanceResult {
|
||||
|
||||
Reference in New Issue
Block a user