MCPcopy Create free account
hub / github.com/MiniMax-AI/OpenRoom / ModEditor

Function ModEditor

apps/webuiapps/src/components/ChatPanel/ModPanel.tsx:245–376  ·  view source on GitHub ↗
({ entry, onSave, onClose })

Source from the content-addressed store, hash-verified

243 onSave: (entry: ModEntry) => void;
244 onClose: () => void;
245}> = ({ entry, onSave, onClose }) => {
246 const config = entry.config;
247 const state = entry.state;
248
249 const [modName, setModName] = useState(config.mod_name);
250 const [modNameEn, setModNameEn] = useState(config.mod_name_en);
251 const [modDescription, setModDescription] = useState(config.mod_description);
252 const [stages, setStages] = useState<EditableStage[]>(configToEditable(config));
253 const [activeTab, setActiveTab] = useState<'progress' | 'edit'>('progress');
254 const [currentState] = useState<ModState>({ ...state });
255
256 const handleAddStage = () => {
257 setStages([
258 ...stages,
259 {
260 stage_name: `Stage ${stages.length + 1}`,
261 stage_description: '',
262 targets: [{ id: nextTargetId++, description: '' }],
263 },
264 ]);
265 };
266
267 const handleRemoveStage = (index: number) => {
268 setStages(stages.filter((_, i) => i !== index));
269 };
270
271 const updateStage = (index: number, field: keyof EditableStage, value: string) => {
272 const updated = [...stages];
273 (updated[index] as Record<string, unknown>)[field] = value;
274 setStages(updated);
275 };
276
277 const handleAddTarget = (stageIndex: number) => {
278 const updated = [...stages];
279 updated[stageIndex].targets.push({ id: nextTargetId++, description: '' });
280 setStages(updated);
281 };
282
283 const handleRemoveTarget = (stageIndex: number, targetIndex: number) => {
284 const updated = [...stages];
285 updated[stageIndex].targets = updated[stageIndex].targets.filter((_, i) => i !== targetIndex);
286 setStages(updated);
287 };
288
289 const updateTarget = (stageIndex: number, targetIndex: number, value: string) => {
290 const updated = [...stages];
291 updated[stageIndex].targets[targetIndex].description = value;
292 setStages(updated);
293 };
294
295 const handleSave = () => {
296 const newConfig = editableToConfig(stages, config.id, modName, modNameEn, modDescription);
297 onSave({ config: newConfig, state: currentState });
298 };
299
300 const handleSaveAndReset = () => {
301 const newConfig = editableToConfig(stages, config.id, modName, modNameEn, modDescription);
302 onSave({

Callers

nothing calls this directly

Calls 1

configToEditableFunction · 0.85

Tested by

no test coverage detected