Skip to content

Commit

Permalink
Hide internal properties
Browse files Browse the repository at this point in the history
The Structurizr DSL library introduced element/relationship identifiers
as properties recently. Hide those for the site generation since we are
not really interested in presenting them to users.

Note that at the time of committing they still appear on the generated
diagrams, though that has already been addressed upstream in
com.structurizr:structurizr-export and will be fixed with a library
update once a new version has been released.
  • Loading branch information
jp7677 committed Feb 27, 2023
1 parent c5ab7e7 commit 2953367
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ val Model.includedSoftwareSystems: List<SoftwareSystem>
val SoftwareSystem.includedSoftwareSystem
get() = this.location != Location.External

val SoftwareSystem.includedProperties
get() = this.properties.filterNot { (name, _) -> name == "structurizr.dsl.identifier" }

fun SoftwareSystem.hasDecisions() = documentation.decisions.isNotEmpty()

fun SoftwareSystem.hasDocumentationSections() = documentation.sections.size >= 2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package nl.avisi.structurizr.site.generatr.site.model

import com.structurizr.model.SoftwareSystem
import nl.avisi.structurizr.site.generatr.includedProperties
import nl.avisi.structurizr.site.generatr.site.GeneratorContext

class SoftwareSystemHomePageViewModel(generatorContext: GeneratorContext, softwareSystem: SoftwareSystem) :
SoftwareSystemPageViewModel(generatorContext, softwareSystem, Tab.HOME) {
val hasProperties = softwareSystem.properties.any()
val propertiesTable = createPropertiesTableViewModel(softwareSystem.properties)
val hasProperties = softwareSystem.includedProperties.any()
val propertiesTable = createPropertiesTableViewModel(softwareSystem.includedProperties)
val content = markdownToHtml(this, softwareSystem.info(), generatorContext.svgFactory)

private fun SoftwareSystem.info() = documentation.sections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,22 @@ class SoftwareSystemHomePageViewModelTest : ViewModelTest() {
.isEqualTo(createPropertiesTableViewModel(softwareSystem.properties))
}
}

@Test
fun `internal properties present`() {
val generatorContext = generatorContext()
val softwareSystem: SoftwareSystem = generatorContext.workspace.model.addSoftwareSystem("Software system")
.apply {
description = "It's a system."
addProperty("structurizr.dsl.identifier", "id")
}
val viewModel = SoftwareSystemHomePageViewModel(generatorContext, softwareSystem)

assertThat(viewModel)
.all {
prop(SoftwareSystemHomePageViewModel::hasProperties).isEqualTo(false)
prop(SoftwareSystemHomePageViewModel::propertiesTable)
.isEqualTo(createPropertiesTableViewModel(mapOf()))
}
}
}

0 comments on commit 2953367

Please sign in to comment.