refactor: extract duplicated utility functions into shared modules
Consolidate 20+ duplicate function definitions across UI components into three shared util files (format-utils, agent-utils, config-draft-utils). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import { useApplicationConfig, useUpdateApplicationConfig } from '../../api/quer
|
||||
import type { ApplicationConfig, TapDefinition, ConfigUpdateResponse } from '../../api/queries/commands';
|
||||
import { useCatalog } from '../../api/queries/catalog';
|
||||
import type { CatalogApp, CatalogRoute } from '../../api/queries/catalog';
|
||||
import { applyTracedProcessorUpdate, applyRouteRecordingUpdate } from '../../utils/config-draft-utils';
|
||||
import styles from './AppConfigDetailPage.module.css';
|
||||
|
||||
type BadgeColor = 'primary' | 'success' | 'warning' | 'error' | 'running' | 'auto';
|
||||
@@ -130,18 +131,11 @@ export default function AppConfigDetailPage() {
|
||||
}
|
||||
|
||||
function updateTracedProcessor(processorId: string, mode: string) {
|
||||
setTracedDraft((prev) => {
|
||||
if (mode === 'REMOVE') {
|
||||
const next = { ...prev };
|
||||
delete next[processorId];
|
||||
return next;
|
||||
}
|
||||
return { ...prev, [processorId]: mode };
|
||||
});
|
||||
setTracedDraft((prev) => applyTracedProcessorUpdate(prev, processorId, mode));
|
||||
}
|
||||
|
||||
function updateRouteRecording(routeId: string, recording: boolean) {
|
||||
setRouteRecordingDraft((prev) => ({ ...prev, [routeId]: recording }));
|
||||
setRouteRecordingDraft((prev) => applyRouteRecordingUpdate(prev, routeId, recording));
|
||||
}
|
||||
|
||||
function handleSave() {
|
||||
|
||||
Reference in New Issue
Block a user