no inheriting label
This commit is contained in:
parent
e7bbda6416
commit
3563b15933
4 changed files with 276 additions and 0 deletions
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#### Improvements 🧹
|
||||
|
||||
- Boards no longer inherit `label` fields from parents. [#1838](https://github.com/terrastruct/d2/pull/1838)
|
||||
|
||||
#### Bugfixes ⛑️
|
||||
|
||||
- Fixes `null` being set on a nested shape not working in certain cases when connections also pointed to that shape [#1830](https://github.com/terrastruct/d2/pull/1830)
|
||||
|
|
|
|||
|
|
@ -2991,6 +2991,22 @@ steps: {
|
|||
assert.True(t, g.IsFolderOnly)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no-inherit-label",
|
||||
run: func(t *testing.T) {
|
||||
g, _ := assertCompile(t, `
|
||||
label: hi
|
||||
|
||||
steps: {
|
||||
1: {
|
||||
RJ
|
||||
}
|
||||
}
|
||||
`, "")
|
||||
assert.True(t, g.Root.Label.MapKey != nil)
|
||||
assert.True(t, g.Steps[0].Root.Label.MapKey == nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "scenarios_edge_index",
|
||||
run: func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -361,6 +361,9 @@ func (c *compiler) overlay(base *Map, f *Field) {
|
|||
return
|
||||
}
|
||||
base = base.CopyBase(f)
|
||||
// Certain fields should never carry forward.
|
||||
// If you give your scenario a label, you don't want all steps in a scenario to be labeled the same.
|
||||
base.DeleteField("label")
|
||||
OverlayMap(base, f.Map())
|
||||
f.Composite = base
|
||||
}
|
||||
|
|
|
|||
255
testdata/d2compiler/TestCompile2/boards/no-inherit-label.exp.json
generated
vendored
Normal file
255
testdata/d2compiler/TestCompile2/boards/no-inherit-label.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
{
|
||||
"graph": {
|
||||
"name": "",
|
||||
"isFolderOnly": true,
|
||||
"ast": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,0:0:0-8:0:41",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,1:0:1-1:9:10",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,1:0:1-1:5:6",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,1:0:1-1:5:6",
|
||||
"value": [
|
||||
{
|
||||
"string": "label",
|
||||
"raw_string": "label"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,1:7:8-1:9:10",
|
||||
"value": [
|
||||
{
|
||||
"string": "hi",
|
||||
"raw_string": "hi"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,3:0:12-7:1:40",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,3:0:12-3:5:17",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,3:0:12-3:5:17",
|
||||
"value": [
|
||||
{
|
||||
"string": "steps",
|
||||
"raw_string": "steps"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,3:7:19-7:1:40",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,4:2:23-6:3:38",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,4:2:23-4:3:24",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,4:2:23-4:3:24",
|
||||
"value": [
|
||||
{
|
||||
"string": "1",
|
||||
"raw_string": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,4:5:26-6:3:38",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,5:4:32-5:6:34",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,5:4:32-5:6:34",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,5:4:32-5:6:34",
|
||||
"value": [
|
||||
{
|
||||
"string": "RJ",
|
||||
"raw_string": "RJ"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"root": {
|
||||
"id": "",
|
||||
"id_val": "",
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "hi"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": ""
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
"edges": null,
|
||||
"objects": null,
|
||||
"steps": [
|
||||
{
|
||||
"name": "1",
|
||||
"isFolderOnly": false,
|
||||
"ast": {
|
||||
"range": ",1:0:0-2:0:0",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"key": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": ",0:0:0-0:0:0",
|
||||
"value": [
|
||||
{
|
||||
"string": "RJ"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"root": {
|
||||
"id": "",
|
||||
"id_val": "",
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": ""
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": ""
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
"edges": null,
|
||||
"objects": [
|
||||
{
|
||||
"id": "RJ",
|
||||
"id_val": "RJ",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,5:4:32-5:6:34",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/boards/no-inherit-label.d2,5:4:32-5:6:34",
|
||||
"value": [
|
||||
{
|
||||
"string": "RJ",
|
||||
"raw_string": "RJ"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "RJ"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"err": null
|
||||
}
|
||||
Loading…
Reference in a new issue