데이터 저장 설정 개선: INSERT가 아닌 액션에 대한 실행조건 필수 검증 추가 및 DELETE 액션에 대한 필드 매핑 및 데이터 분할 설정 생략 로직 구현. 조건 미비 시 사용자 안내 메시지 추가.
This commit is contained in:
parent
8bfb269446
commit
cbd54316cf
|
|
@ -343,6 +343,37 @@ export const ConnectionSetupModal: React.FC<ConnectionSetupModalProps> = ({
|
|||
break;
|
||||
case "data-save":
|
||||
settings = dataSaveSettings;
|
||||
|
||||
// INSERT가 아닌 액션 타입에 대한 실행조건 필수 검증
|
||||
for (const action of dataSaveSettings.actions) {
|
||||
if (action.actionType !== "insert") {
|
||||
if (!action.conditions || action.conditions.length === 0) {
|
||||
toast.error(
|
||||
`${action.actionType.toUpperCase()} 액션은 실행조건이 필수입니다. '${action.name}' 액션에 실행조건을 추가해주세요.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 실제 조건이 있는지 확인 (group-start, group-end만 있는 경우 제외)
|
||||
const hasValidConditions = action.conditions.some((condition) => {
|
||||
if (condition.type !== "condition") return false;
|
||||
if (!condition.field || !condition.operator) return false;
|
||||
|
||||
// value가 null, undefined, 빈 문자열이면 유효하지 않음
|
||||
const value = condition.value;
|
||||
if (value === null || value === undefined || value === "") return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if (!hasValidConditions) {
|
||||
toast.error(
|
||||
`${action.actionType.toUpperCase()} 액션은 완전한 실행조건이 필요합니다. '${action.name}' 액션에 필드, 연산자, 값을 모두 설정해주세요.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "external-call":
|
||||
// 외부 호출은 plan에 저장
|
||||
|
|
@ -508,9 +539,21 @@ export const ConnectionSetupModal: React.FC<ConnectionSetupModalProps> = ({
|
|||
case "data-save":
|
||||
// 데이터 저장: 액션과 필드 매핑이 완성되어야 함
|
||||
const hasActions = dataSaveSettings.actions.length > 0;
|
||||
const allActionsHaveMappings = dataSaveSettings.actions.every((action) => action.fieldMappings.length > 0);
|
||||
const allMappingsComplete = dataSaveSettings.actions.every((action) =>
|
||||
action.fieldMappings.every((mapping) => {
|
||||
|
||||
// DELETE 액션은 필드 매핑이 필요 없음
|
||||
const allActionsHaveMappings = dataSaveSettings.actions.every((action) => {
|
||||
if (action.actionType === "delete") {
|
||||
return true; // DELETE는 필드 매핑 불필요
|
||||
}
|
||||
return action.fieldMappings.length > 0;
|
||||
});
|
||||
|
||||
const allMappingsComplete = dataSaveSettings.actions.every((action) => {
|
||||
if (action.actionType === "delete") {
|
||||
return true; // DELETE는 필드 매핑 검증 생략
|
||||
}
|
||||
|
||||
return action.fieldMappings.every((mapping) => {
|
||||
// 타겟은 항상 필요
|
||||
if (!mapping.targetTable || !mapping.targetField) return false;
|
||||
|
||||
|
|
@ -525,9 +568,36 @@ export const ConnectionSetupModal: React.FC<ConnectionSetupModalProps> = ({
|
|||
|
||||
// FROM 테이블이 있으면 소스 매핑 완성 또는 기본값 필요
|
||||
return hasSource || hasDefault;
|
||||
}),
|
||||
);
|
||||
return !hasActions || !allActionsHaveMappings || !allMappingsComplete;
|
||||
});
|
||||
});
|
||||
|
||||
// INSERT가 아닌 액션 타입에 대한 실행조건 필수 검증
|
||||
const allRequiredConditionsMet = dataSaveSettings.actions.every((action) => {
|
||||
if (action.actionType === "insert") {
|
||||
return true; // INSERT는 조건 불필요
|
||||
}
|
||||
|
||||
// INSERT가 아닌 액션은 유효한 조건이 있어야 함
|
||||
if (!action.conditions || action.conditions.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 실제 조건이 있는지 확인 (group-start, group-end만 있는 경우 제외)
|
||||
const hasValidConditions = action.conditions.some((condition) => {
|
||||
if (condition.type !== "condition") return false;
|
||||
if (!condition.field || !condition.operator) return false;
|
||||
|
||||
// value가 null, undefined, 빈 문자열이면 유효하지 않음
|
||||
const value = condition.value;
|
||||
if (value === null || value === undefined || value === "") return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return hasValidConditions;
|
||||
});
|
||||
|
||||
return !hasActions || !allActionsHaveMappings || !allMappingsComplete || !allRequiredConditionsMet;
|
||||
|
||||
case "external-call":
|
||||
// 외부 호출: 설정 ID와 메시지가 있어야 함
|
||||
|
|
|
|||
|
|
@ -32,6 +32,22 @@ export const ActionConditionsSection: React.FC<ActionConditionsSectionProps> = (
|
|||
}) => {
|
||||
const { addActionGroupStart, addActionGroupEnd, getActionCurrentGroupLevel } = useActionConditionHelpers();
|
||||
|
||||
// INSERT가 아닌 액션 타입인지 확인
|
||||
const isConditionRequired = action.actionType !== "insert";
|
||||
|
||||
// 유효한 조건이 있는지 확인 (group-start, group-end만 있는 경우 제외)
|
||||
const hasValidConditions =
|
||||
action.conditions?.some((condition) => {
|
||||
if (condition.type !== "condition") return false;
|
||||
if (!condition.field || !condition.operator) return false;
|
||||
|
||||
// value가 null, undefined, 빈 문자열이면 유효하지 않음
|
||||
const value = condition.value;
|
||||
if (value === null || value === undefined || value === "") return false;
|
||||
|
||||
return true;
|
||||
}) || false;
|
||||
|
||||
const addActionCondition = () => {
|
||||
const newActions = [...settings.actions];
|
||||
if (!newActions[actionIndex].conditions) {
|
||||
|
|
@ -65,14 +81,28 @@ export const ActionConditionsSection: React.FC<ActionConditionsSectionProps> = (
|
|||
return (
|
||||
<div className="mt-3">
|
||||
<details className="group">
|
||||
<summary className="flex cursor-pointer items-center justify-between rounded border p-2 text-xs font-medium text-gray-700 hover:bg-gray-50 hover:text-gray-900">
|
||||
<summary
|
||||
className={`flex cursor-pointer items-center justify-between rounded border p-2 text-xs font-medium hover:bg-gray-50 hover:text-gray-900 ${
|
||||
isConditionRequired && !hasValidConditions
|
||||
? "border-red-300 bg-red-50 text-red-700"
|
||||
: "border-gray-200 text-gray-700"
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
🔍 이 액션의 실행 조건 (선택사항)
|
||||
🔍 이 액션의 실행 조건
|
||||
{isConditionRequired ? (
|
||||
<span className="rounded bg-red-100 px-1 py-0.5 text-xs font-semibold text-red-700">필수</span>
|
||||
) : (
|
||||
<span className="text-gray-500">(선택사항)</span>
|
||||
)}
|
||||
{action.conditions && action.conditions.length > 0 && (
|
||||
<span className="rounded-full bg-blue-100 px-2 py-0.5 text-xs text-blue-700">
|
||||
{action.conditions.length}개
|
||||
</span>
|
||||
)}
|
||||
{isConditionRequired && !hasValidConditions && (
|
||||
<span className="rounded bg-red-100 px-1 py-0.5 text-xs text-red-600">⚠️ 조건 필요</span>
|
||||
)}
|
||||
</div>
|
||||
{action.conditions && action.conditions.length > 0 && (
|
||||
<Button
|
||||
|
|
@ -115,6 +145,36 @@ export const ActionConditionsSection: React.FC<ActionConditionsSectionProps> = (
|
|||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 조건이 없을 때 안내 메시지 */}
|
||||
{(!action.conditions || action.conditions.length === 0) && (
|
||||
<div
|
||||
className={`rounded border p-3 text-xs ${
|
||||
isConditionRequired
|
||||
? "border-red-200 bg-red-50 text-red-700"
|
||||
: "border-gray-200 bg-gray-50 text-gray-600"
|
||||
}`}
|
||||
>
|
||||
{isConditionRequired ? (
|
||||
<div className="flex items-start gap-2">
|
||||
<span className="text-red-500">⚠️</span>
|
||||
<div>
|
||||
<div className="font-medium">실행조건이 필요합니다</div>
|
||||
<div className="mt-1">
|
||||
{action.actionType.toUpperCase()} 액션은 언제 실행될지 결정하는 조건이 반드시 필요합니다.
|
||||
<br />
|
||||
<strong>필드, 연산자, 값</strong>을 모두 입력해야 합니다.
|
||||
<br />
|
||||
예: user_name = '관리자우저' AND status = 'active'
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div>조건이 설정되지 않았습니다. INSERT 액션은 조건 없이도 실행 가능합니다.</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{action.conditions && action.conditions.length > 0 && (
|
||||
<div className="space-y-2">
|
||||
{action.conditions.map((condition, condIndex) => (
|
||||
|
|
|
|||
|
|
@ -54,7 +54,10 @@ export const ActionFieldMappings: React.FC<ActionFieldMappingsProps> = ({
|
|||
return (
|
||||
<div className="mt-3">
|
||||
<div className="mb-2 flex items-center justify-between">
|
||||
<Label className="text-xs font-medium">필드 매핑</Label>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="text-xs font-medium">필드 매핑</Label>
|
||||
<span className="text-xs text-red-600">(필수)</span>
|
||||
</div>
|
||||
<Button size="sm" variant="outline" onClick={addFieldMapping} className="h-6 text-xs">
|
||||
<Plus className="mr-1 h-2 w-2" />
|
||||
매핑 추가
|
||||
|
|
@ -208,6 +211,22 @@ export const ActionFieldMappings: React.FC<ActionFieldMappingsProps> = ({
|
|||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* 필드 매핑이 없을 때 안내 메시지 */}
|
||||
{action.fieldMappings.length === 0 && (
|
||||
<div className="rounded border border-red-200 bg-red-50 p-3 text-xs text-red-700">
|
||||
<div className="flex items-start gap-2">
|
||||
<span className="text-red-500">⚠️</span>
|
||||
<div>
|
||||
<div className="font-medium">필드 매핑이 필요합니다</div>
|
||||
<div className="mt-1">
|
||||
{action.actionType.toUpperCase()} 액션은 어떤 데이터를 어떻게 처리할지 결정하는 필드 매핑이
|
||||
필요합니다.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -135,25 +135,52 @@ export const DataSaveSettings: React.FC<DataSaveSettingsProps> = ({
|
|||
toTableName={toTableName}
|
||||
/>
|
||||
|
||||
{/* 데이터 분할 설정 */}
|
||||
<ActionSplitConfig
|
||||
action={action}
|
||||
actionIndex={actionIndex}
|
||||
settings={settings}
|
||||
onSettingsChange={onSettingsChange}
|
||||
fromTableColumns={fromTableColumns}
|
||||
toTableColumns={toTableColumns}
|
||||
/>
|
||||
{/* 데이터 분할 설정 - DELETE 액션은 제외 */}
|
||||
{action.actionType !== "delete" && (
|
||||
<ActionSplitConfig
|
||||
action={action}
|
||||
actionIndex={actionIndex}
|
||||
settings={settings}
|
||||
onSettingsChange={onSettingsChange}
|
||||
fromTableColumns={fromTableColumns}
|
||||
toTableColumns={toTableColumns}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 필드 매핑 */}
|
||||
<ActionFieldMappings
|
||||
action={action}
|
||||
actionIndex={actionIndex}
|
||||
settings={settings}
|
||||
onSettingsChange={onSettingsChange}
|
||||
availableTables={availableTables}
|
||||
tableColumnsCache={tableColumnsCache}
|
||||
/>
|
||||
{/* 필드 매핑 - DELETE 액션은 제외 */}
|
||||
{action.actionType !== "delete" && (
|
||||
<ActionFieldMappings
|
||||
action={action}
|
||||
actionIndex={actionIndex}
|
||||
settings={settings}
|
||||
onSettingsChange={onSettingsChange}
|
||||
availableTables={availableTables}
|
||||
tableColumnsCache={tableColumnsCache}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* DELETE 액션일 때 안내 메시지 */}
|
||||
{action.actionType === "delete" && (
|
||||
<div className="mt-3">
|
||||
<div className="rounded border border-blue-200 bg-blue-50 p-3 text-xs text-blue-700">
|
||||
<div className="flex items-start gap-2">
|
||||
<span>ℹ️</span>
|
||||
<div>
|
||||
<div className="font-medium">DELETE 액션 정보</div>
|
||||
<div className="mt-1">
|
||||
DELETE 액션은 <strong>실행조건만</strong> 필요합니다.
|
||||
<br />
|
||||
• 데이터 분할 설정: 불필요 (삭제 작업에는 분할이 의미 없음)
|
||||
<br />
|
||||
• 필드 매핑: 불필요 (조건에 맞는 데이터를 통째로 삭제)
|
||||
<br />
|
||||
위에서 설정한 실행조건에 맞는 모든 데이터가 삭제됩니다.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue