fix steps panic

This commit is contained in:
Alexander Wang 2023-02-22 13:43:24 -08:00
parent d64e1ddbb1
commit a0f8dbee22
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
6 changed files with 142 additions and 2 deletions

View file

@ -66,6 +66,9 @@ func (c *compiler) compileSteps(m *Map) {
if i == 0 { if i == 0 {
base = m.CopyBase(sf) base = m.CopyBase(sf)
} else { } else {
if steps.Fields[i-1].Map() == nil {
continue
}
base = steps.Fields[i-1].Map().CopyBase(sf) base = steps.Fields[i-1].Map().CopyBase(sf)
} }
OverlayMap(base, sf.Map()) OverlayMap(base, sf.Map())

View file

@ -0,0 +1,22 @@
{
"name": "",
"fontFamily": "SourceSansPro",
"shapes": [],
"connections": [],
"scenarios": [
{
"name": "hey",
"fontFamily": "SourceSansPro",
"shapes": [],
"connections": []
}
],
"steps": [
{
"name": "id",
"fontFamily": "SourceSansPro",
"shapes": [],
"connections": []
}
]
}

View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<svg
id="d2-svg"
style="background: white;"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="200" height="200" viewBox="-100 -100 200 200"><style type="text/css">
<![CDATA[
.shape {
shape-rendering: geometricPrecision;
stroke-linejoin: round;
}
.connection {
stroke-linecap: round;
stroke-linejoin: round;
}
.blend {
mix-blend-mode: multiply;
opacity: 0.5;
}
]]>
</style><script type="application/javascript"><![CDATA[window.addEventListener("DOMContentLoaded", () => {
if (document.documentElement.getAttribute("id") !== "d2-svg") {
return;
}
const svgEl = document.documentElement;
let width = parseInt(svgEl.getAttribute("width"), 10);
let height = parseInt(svgEl.getAttribute("height"), 10);
let ratio;
if (width > height) {
if (width > window.innerWidth) {
ratio = window.innerWidth / width;
}
} else if (height > window.innerHeight) {
ratio = window.innerHeight / height;
}
if (ratio) {
svgEl.setAttribute("width", width * ratio - 16);
svgEl.setAttribute("height", height * ratio - 16);
}
});
]]></script><mask id="121760133" maskUnits="userSpaceOnUse" x="-100" y="-100" width="200" height="200">
<rect x="-100" y="-100" width="200" height="200" fill="white"></rect>
</mask><style type="text/css"><![CDATA[]]></style></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

22
e2etests/testdata/todo/steps_panic/elk/board.exp.json generated vendored Normal file
View file

@ -0,0 +1,22 @@
{
"name": "",
"fontFamily": "SourceSansPro",
"shapes": [],
"connections": [],
"scenarios": [
{
"name": "hey",
"fontFamily": "SourceSansPro",
"shapes": [],
"connections": []
}
],
"steps": [
{
"name": "id",
"fontFamily": "SourceSansPro",
"shapes": [],
"connections": []
}
]
}

View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<svg
id="d2-svg"
style="background: white;"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="200" height="200" viewBox="-100 -100 200 200"><style type="text/css">
<![CDATA[
.shape {
shape-rendering: geometricPrecision;
stroke-linejoin: round;
}
.connection {
stroke-linecap: round;
stroke-linejoin: round;
}
.blend {
mix-blend-mode: multiply;
opacity: 0.5;
}
]]>
</style><script type="application/javascript"><![CDATA[window.addEventListener("DOMContentLoaded", () => {
if (document.documentElement.getAttribute("id") !== "d2-svg") {
return;
}
const svgEl = document.documentElement;
let width = parseInt(svgEl.getAttribute("width"), 10);
let height = parseInt(svgEl.getAttribute("height"), 10);
let ratio;
if (width > height) {
if (width > window.innerWidth) {
ratio = window.innerWidth / width;
}
} else if (height > window.innerHeight) {
ratio = window.innerHeight / height;
}
if (ratio) {
svgEl.setAttribute("width", width * ratio - 16);
svgEl.setAttribute("height", height * ratio - 16);
}
});
]]></script><mask id="121760133" maskUnits="userSpaceOnUse" x="-100" y="-100" width="200" height="200">
<rect x="-100" y="-100" width="200" height="200" fill="white"></rect>
</mask><style type="text/css"><![CDATA[]]></style></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -162,11 +162,14 @@ small code: |go
`, `,
}, },
{ {
skip: true,
name: "steps_panic", name: "steps_panic",
script: `steps: { script: `steps: {
shape: sql_table shape: sql_table
id: {type: int, constraint: primary_key} id: int {constraint: primary_key}
}
scenarios: {
shape: sql_table
hey: int {constraint: primary_key}
} }
`, `,
}, },