Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,6 @@ export function DataMapperView(props: DataMapperProps) {
await refreshDMModel();
};

const onDMReset = async () => {
await deleteMapping(
{ output: name, expression: undefined },
name
);
};

const onEdit = () => {
const context: VisualizerLocation = {
view: MACHINE_VIEW.BIDataMapperForm,
Expand Down Expand Up @@ -691,7 +684,6 @@ export function DataMapperView(props: DataMapperProps) {
reusable={reusable}
onClose={onDMClose}
onRefresh={onDMRefresh}
onReset={onDMReset}
onEdit={reusable ? onEdit : undefined}
applyModifications={updateExpression}
addArrayElement={addArrayElement}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export function DataMapperEditor(props: DataMapperEditorProps) {
applyModifications,
onClose,
onRefresh,
onReset,
onEdit,
addArrayElement,
handleView,
Expand Down Expand Up @@ -191,6 +190,19 @@ export function DataMapperEditor(props: DataMapperEditorProps) {
dispatch({ type: ActionType.RESET_VIEW, payload: { view: newData } });
}, [resetSearchStore]);

const handleOnReset = useCallback(async () => {
const targetField = views[views.length - 1].targetField;
const outputIds = targetField.split('.');

let output: string;
while ((output = outputIds.pop()) === '0');

await deleteMapping(
{ output, expression: undefined },
targetField
);
}, [views, deleteMapping]);

useEffect(() => {
const lastView = views[views.length - 1];
handleView(lastView.targetField, !!lastView?.subMappingInfo);
Expand Down Expand Up @@ -335,7 +347,7 @@ export function DataMapperEditor(props: DataMapperEditorProps) {
onClose={handleOnClose}
onBack={handleOnBack}
onRefresh={onRefresh}
onReset={onReset}
onReset={handleOnReset}
onEdit={onEdit}
autoMapWithAI={autoMapWithAI}
undoRedoGroup={undoRedoGroup}
Expand Down
1 change: 0 additions & 1 deletion workspaces/ballerina/data-mapper/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export interface DataMapperEditorProps {
goToFunction: (functionRange: LineRange) => Promise<void>;
enrichChildFields: (parentField: IOType) => Promise<void>;
onRefresh: () => Promise<void>;
onReset: () => Promise<void>;
onClose: () => void;
onEdit?: () => void;
handleView: (viewId: string, isSubMapping?: boolean) => void;
Expand Down
Loading