Skip to content

Commit 73ed149

Browse files
authored
Set overwrite to false by default when importing from source (#394)
1 parent cc7bd69 commit 73ed149

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/components/EditorHeader/Modal/ImportSource.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export default function ImportSource({
5555
<Checkbox
5656
aria-label="overwrite checkbox"
5757
checked={importData.overwrite}
58-
defaultChecked
5958
onChange={(e) =>
6059
setImportData((prev) => ({
6160
...prev,

src/components/EditorHeader/Modal/Modal.jsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function Modal({
5252
importFrom,
5353
}) {
5454
const { t, i18n } = useTranslation();
55-
const { setTables, setRelationships, database, setDatabase } = useDiagram();
55+
const { tables, setTables, setRelationships, database, setDatabase } = useDiagram();
5656
const { setNotes } = useNotes();
5757
const { setAreas } = useAreas();
5858
const { setTypes } = useTypes();
@@ -63,7 +63,7 @@ export default function Modal({
6363
const [uncontrolledTitle, setUncontrolledTitle] = useState(title);
6464
const [importSource, setImportSource] = useState({
6565
src: "",
66-
overwrite: true,
66+
overwrite: false,
6767
});
6868
const [importData, setImportData] = useState(null);
6969
const [error, setError] = useState({
@@ -174,12 +174,15 @@ export default function Modal({
174174
setUndoStack([]);
175175
setRedoStack([]);
176176
} else {
177+
const initialTablesLength = tables.length;
177178
setTables((prev) =>
178179
[...prev, ...diagramData.tables].map((t, i) => ({ ...t, id: i })),
179180
);
180181
setRelationships((prev) =>
181182
[...prev, ...diagramData.relationships].map((r, i) => ({
182183
...r,
184+
startTableId: initialTablesLength + r.startTableId,
185+
endTableId: initialTablesLength + r.endTableId,
183186
id: i,
184187
})),
185188
);
@@ -355,7 +358,7 @@ export default function Modal({
355358
setImportData(null);
356359
setImportSource({
357360
src: "",
358-
overwrite: true,
361+
overwrite: false,
359362
});
360363
}}
361364
onCancel={() => {

0 commit comments

Comments
 (0)