feat(batch): TO DB 자동 선택 (internal) + Select 컴포넌트 controlled 화
새 배치 (REST API → DB) 진입 시 매번 사용자가 "데이터베이스 커넥션 선택" 셀렉트에서
"내부 DB" 를 직접 골라야 했음. 대부분의 배치가 internal 적재라 디폴트 채움이 자연스러움.
1) TO DB 자동 선택
useEffect 로 batchType === "restapi-to-db" + connections 로드 + toConnection 비어있음
조건 만족 시 handleToConnectionChange("internal") 자동 호출. 사용자가 외부 DB 로 변경하면
toConnection != null 이 되어 더 이상 자동 동작 안 함.
2) Select controlled 화
DB 커넥션/테이블 Select 가 value prop 없는 uncontrolled 상태였음.
setToConnection/setToTable state 가 바뀌어도 Select UI 가 placeholder 그대로 →
programmatic 자동 선택이 시각적으로 반영 안 됨.
→ value prop 추가:
- DB 커넥션: toConnection.type === "internal" ? "internal" : String(toConnection.id)
- 테이블: toTable
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -171,6 +171,16 @@ export default function BatchManagementNewPage() {
|
||||
loadRegisteredRestApis();
|
||||
}, []);
|
||||
|
||||
// TO DB 자동 선택 — REST API → DB 모드에서 connections 로드 완료 후 TO 가 비어있으면 internal 자동.
|
||||
// 사용자가 외부 DB 로 직접 변경하면 toConnection != null 이 되어 더 이상 동작 안 함.
|
||||
// 대부분의 배치가 internal DB 적재라 디폴트로 들어가는 게 UX 상 자연스러움.
|
||||
useEffect(() => {
|
||||
if (batchType === "restapi-to-db" && !toConnection && connections.length > 0) {
|
||||
handleToConnectionChange("internal");
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [batchType, connections, toConnection]);
|
||||
|
||||
// 등록된 REST API 연결 목록 로드
|
||||
const loadRegisteredRestApis = async () => {
|
||||
try {
|
||||
@@ -1286,7 +1296,10 @@ export default function BatchManagementNewPage() {
|
||||
{/* 1. 커넥션 선택 - 항상 활성화 */}
|
||||
<div>
|
||||
<Label>데이터베이스 커넥션 선택 *</Label>
|
||||
<Select onValueChange={handleToConnectionChange}>
|
||||
<Select
|
||||
value={toConnection ? (toConnection.type === "internal" ? "internal" : String(toConnection.id)) : ""}
|
||||
onValueChange={handleToConnectionChange}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="커넥션을 선택하세요" />
|
||||
</SelectTrigger>
|
||||
@@ -1306,7 +1319,7 @@ export default function BatchManagementNewPage() {
|
||||
{/* 2. 테이블 선택 - 커넥션 선택 후 활성화 */}
|
||||
<div className={toTables.length === 0 ? "pointer-events-none opacity-50" : ""}>
|
||||
<Label>테이블 선택 *</Label>
|
||||
<Select onValueChange={handleToTableChange} disabled={toTables.length === 0}>
|
||||
<Select value={toTable} onValueChange={handleToTableChange} disabled={toTables.length === 0}>
|
||||
<SelectTrigger>
|
||||
<SelectValue
|
||||
placeholder={toTables.length === 0 ? "먼저 커넥션을 선택하세요" : "테이블을 선택하세요"}
|
||||
|
||||
Reference in New Issue
Block a user