Skip to content

Commit

Permalink
Merge pull request #150 from jp7677/internal-props
Browse files Browse the repository at this point in the history
Hide internal properties
  • Loading branch information
dirkgroot authored Feb 28, 2023
2 parents 5c2f5e8 + 2953367 commit 0047da3
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 0047da3

Please sign in to comment.