Replies: 1 comment
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Six issues found integrating drawDB via the extension hooks
Ref:
8f4fe78(main) · All line numbers verified against that commit.Context: we deploy drawDB under a sub-path (
https://example.com/schema/) with a custompersistence layer built on
ExtensionsContext(cloudSave/cloudLoad). Everything belowwas hit in that setup, but items 1–3 and 6 affect the stock app too.
Each item is independent; happy to send PRs for any subset — just say which shape you'd prefer.
1. Three different JSON shapes for the same diagram
Three keys differ depending on which code path produced the object:
diagrams/cloudSavetemplatesreferencesrelationshipsrelationshipsareassubjectAreassubjectAreasnametitlenameIt isn't an "internal vs external" split: both A and B are persisted to IndexedDB —
db.diagramsstores A,db.templatesstores B — and both are produced by user-facing saveactions.
Produces A
src/components/Workspace.jsx#L113-L117—buildCloudPayload()src/components/Workspace.jsx#L177-L181,#L201-L204—save()→db.diagramssrc/components/EditorHeader/ControlPanel.jsx#L842,#L901— cloud save payloadsProduces B
src/components/EditorHeader/ControlPanel.jsx#L1326-L1347— File → Export → JSONsrc/components/EditorHeader/ControlPanel.jsx#L1014-L1030— Save as template →db.templatessrc/components/EditorHeader/Modal/Share.jsx#L74-L76— gist payloadsrc/templates/template1.js#L288,#L346,#L348— bundled templatesConsumes A
src/components/Workspace.jsx#L302—applyDiagramState()readsdiagram.referencesConsumes B
src/components/Workspace.jsx#L373-L374—loadTemplate()readstemplate.relationships/subjectAreassrc/components/Workspace.jsx#L395-L397—loadFromGist()readsparsed.relationships/subjectAreassrc/components/EditorHeader/Modal/Modal.jsx#L104-L109—overwriteDiagram()readsimportData.relationships/subjectAreas/titleloadDiagramandloadTemplatesit ~70 lines apart in the same file and read different keysfor the same concept.
Consequence for integrators:
cloudSavehands over shape A, but the importer requiresshape B (
src/data/schemas.js#L212:required: ["tables", "relationships", "notes", "subjectAreas"],checked by
src/utils/validateSchema.js#L4-L10). Persisting exactly whatcloudSaveprovidesproduces a file drawDB itself cannot import. Round-tripping
cloudSave→ file → import isimpossible without an undocumented rename.
2.
exportSavedDatadoes half the conversion and leaks storage bookkeepingsrc/utils/exportSavedData.js#L7-L16:Two problems:
referencesandareasbut leavesname, while the file format usestitle— that's shape C above. Files from this path are missing their title onre-import:
Modal.jsx#L108only callssetTitleif (importData.title).id,diagramId,lastModifiedand
loadedFromGistId— storage bookkeeping in a file meant to be re-imported. Theidinparticular is a stale auto-increment key from another database.
This is also the only place in the codebase where the two shapes are explicitly reconciled,
and it exists solely for the backup ZIP.
3. Import reports a shape problem as a database mismatch
src/components/EditorHeader/Modal/ImportDiagram.jsx:#L53-L69— shape validation runs first, but on failure only callssetErrorandreturns#L71-L83— the database check compares against the currently open diagram and reports"The imported diagram and the open diagram don't use matching databases."
#L85—jsonObject.relationships.forEach(...), which throws on shape ABecause the database check is what surfaces in the UI, a file that is simply in the wrong
shape is reported as a database mismatch. Two unrelated causes, one message. We lost real
time to this: the file was valid MySQL, and the actual problem was the open diagram sitting
on
GENERIC(see issue 5).Suggested fix: report the schema-validation failure with its own message, and say which
properties are missing.
4. Four
window.opencalls use absolute paths, breaking sub-path deploymentssrc/components/EditorHeader/Modal/Modal.jsx#L266window.open("/editor/templates/" + selectedTemplateId, "_blank")src/components/EditorHeader/ControlPanel.jsx#L969window.open("/editor", "_blank")src/components/EditorHeader/ControlPanel.jsx#L1742window.open("/bug-report", "_blank")src/pages/Templates.jsx#L25window.open("/editor/templates/" + id, "_blank")These bypass both Vite's
baseand React Router'sbasename. Served under/schema/, File →New navigates to
/editor/templates/blankat the site root, which is not the app.Note the contrast: the
navigate(...)calls with absolute paths (e.g.ControlPanel.jsx#L1065,Workspace.jsx#L155) work fine, because they go through the router.Only the
window.opencalls escape it.Fix would be prefixing
import.meta.env.BASE_URL, or routing these through the router where anew tab isn't required.
5. A missing diagram leaves the editor with no way to choose a database
With
<WorkSpace forcedDiagramId="…" />,load()goes straight toloadDiagram():src/components/Workspace.jsx#L344-L346—const { diagram } = await fetchDiagram(id); if (!diagram) return;The "choose a database" modal only exists in the branch without a forced id:
src/components/Workspace.jsx#L420-L424—if (!loadedDiagramId) { … if (selectedDb === "") setShowSelectDbModal(true); … }So when the backing store has no diagram yet — a first run, or any
cloudLoadreturningnull— the editor silently keeps the defaultGENERIC(
src/context/DiagramContext.jsx#L13) with no UI affordance to change it. Importing a MySQLfile then fails with the message from issue 3, and File → New doesn't help: it re-enters the
same path and hits the same
return.Suggested fix: show the database selector when a forced-id load finds nothing, or let the
integrator supply a default database.
6.
load()is called without error handlingsrc/components/Workspace.jsx#L503-L507:load()callsextensions.cloudLoad(id)(src/components/Workspace.jsx#L290). A rejected promise there — an auth error,a network failure — becomes an unhandled rejection. The editor stays blank on
GENERIC, withnothing in the UI indicating that loading failed, and the next symptom is the misleading
import error from issue 3.
extensions.cloudSaveis handled carefully by comparison(
src/components/Workspace.jsx#L151-L167, including the 402 case). A.catchonload()that surfaces the failure would match.Questions
internal? If so,
db.templatesstoring B whiledb.diagramsstores A seems to cut acrossthat line, and
exportSavedDataproducing C cuts across it again.existing files and IndexedDB records keep working?
the conversion as a shared exported helper (1, 2), the import error ordering (3), the
BASE_URLprefix (4), the database selector on empty forced-id load (5), and the.catchon
load()(6)?All reactions