Skip to content

Commit

Permalink
Merge pull request #1504 from alixander/robust-folder
Browse files Browse the repository at this point in the history
g.isFolderOnly=true when no objects
  • Loading branch information
alixander authored Jul 29, 2023
2 parents 3b0939f + fb54208 commit 0f7dc63
Show file tree
Hide file tree
Showing 24 changed files with 393 additions and 121 deletions.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- All font styles in sketch mode use a consistent font-family [#1463](https://github.com/terrastruct/d2/pull/1463)
- Tooltip and link icons are now positioned on shape border [#1466](https://github.com/terrastruct/d2/pull/1466)
- Tooltip and link icons are always rendered over shapes [#1467](https://github.com/terrastruct/d2/pull/1467)
- Boards with no objects are considered folders [#1504](https://github.com/terrastruct/d2/pull/1504)

#### Bugfixes ⛑️

Expand Down
3 changes: 3 additions & 0 deletions d2compiler/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func (c *compiler) compileBoard(g *d2graph.Graph, ir *d2ir.Map) *d2graph.Graph {
g.IsFolderOnly = true
}
}
if len(g.Objects) == 0 {
g.IsFolderOnly = true
}
return g
}

Expand Down
15 changes: 15 additions & 0 deletions d2compiler/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2832,6 +2832,21 @@ layers: {
assert.False(t, g.Layers[1].Scenarios[1].IsFolderOnly)
},
},
{
name: "isFolderOnly-shapes",
run: func(t *testing.T) {
g, _ := assertCompile(t, `
direction: right
steps: {
1: {
RJ
}
}
`, "")
assert.True(t, g.IsFolderOnly)
},
},
{
name: "scenarios_edge_index",
run: func(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions e2etests-cli/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ func TestCLI_E2E(t *testing.T) {
writeFile(t, dir, "empty-layer.d2", `layers: { x: {} }`)
err := runTestMain(t, ctx, dir, env, "empty-layer.d2")
assert.Success(t, err)

assert.TestdataDir(t, filepath.Join(dir, "empty-layer"))
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion e2etests/testdata/sanity/empty/dagre/board.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions e2etests/testdata/sanity/empty/dagre/sketch.exp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion e2etests/testdata/sanity/empty/elk/board.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions e2etests/testdata/sanity/empty/elk/sketch.exp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0f7dc63

Please sign in to comment.