-
-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathSettingsPanel.tsx
More file actions
116 lines (105 loc) · 2.71 KB
/
Copy pathSettingsPanel.tsx
File metadata and controls
116 lines (105 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { useSignal, useSignalEffect } from "@preact/signals";
import { Button } from "./Button";
import { Settings } from "../types";
import { settingsStore } from "../models/SettingsModel";
interface SettingsPanelProps {
isVisible: boolean;
onApply: (settings: Settings) => void;
onCancel: () => void;
}
export function SettingsPanel({
isVisible,
onApply,
onCancel,
}: SettingsPanelProps) {
const settings = settingsStore.settings;
const localSettings = useSignal<Settings>(settings);
useSignalEffect(() => {
localSettings.value = settingsStore.settings;
});
const handleApply = () => {
onApply(localSettings.value);
};
if (!isVisible) {
return null;
}
return (
<div className="settings-panel">
<div className="settings-content">
<h3>Debug Configuration</h3>
<div className="setting-group">
<label>
<input
type="checkbox"
checked={localSettings.value.enabled}
onChange={e =>
(localSettings.value = {
...localSettings.value,
enabled: (e.target as HTMLInputElement).checked,
})
}
/>
Enable debug updates
</label>
</div>
<div className="setting-group">
<label>
<input
type="checkbox"
checked={localSettings.value.grouped}
onChange={e =>
(localSettings.value = {
...localSettings.value,
grouped: (e.target as HTMLInputElement).checked,
})
}
/>
Group related updates
</label>
</div>
<div className="setting-group">
<label htmlFor="maxUpdatesInput">Max updates per second:</label>
<input
type="number"
id="maxUpdatesInput"
value={localSettings.value.maxUpdatesPerSecond}
min="1"
max="1000"
onChange={e =>
(localSettings.value = {
...localSettings.value,
maxUpdatesPerSecond:
parseInt((e.target as HTMLInputElement).value) || 60,
})
}
/>
</div>
<div className="setting-group">
<label htmlFor="filterPatternsInput">
Filter patterns (one per line):
</label>
<textarea
id="filterPatternsInput"
placeholder="user.* .*State$ global"
value={localSettings.value.filterPatterns.join("\n")}
onChange={e =>
(localSettings.value = {
...localSettings.value,
filterPatterns: (e.target as HTMLTextAreaElement).value
.split("\n")
.map(pattern => pattern.trim())
.filter(pattern => pattern.length > 0),
})
}
/>
</div>
<div className="settings-actions">
<Button onClick={handleApply} variant="primary">
Apply
</Button>
<Button onClick={onCancel}>Cancel</Button>
</div>
</div>
</div>
);
}