-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from galuszkak/feature/add-container-adrs
Introduce Container ADRs in Decision Tab
- Loading branch information
Showing
21 changed files
with
449 additions
and
14 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
docs/example/internet-banking-system/adr/0001-record-architecture-decisions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 1. Record architecture decisions | ||
# 1. Record Internet Banking System architecture decisions | ||
|
||
Date: 2022-06-21 | ||
|
||
|
19 changes: 19 additions & 0 deletions
19
...ternet-banking-system/api-application/adr/0001-record-architecture-decisions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# 1. Record API Application architecture decision records | ||
|
||
Date: 2022-06-21 | ||
|
||
## Status | ||
|
||
Accepted | ||
|
||
## Context | ||
|
||
We need to record the architectural decisions made on this project. | ||
|
||
## Decision | ||
|
||
We will use Architecture Decision Records, as [described by Michael Nygard](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions). | ||
|
||
## Consequences | ||
|
||
See Michael Nygard's article, linked above. For a lightweight ADR toolset, see Nat Pryce's [adr-tools](https://github.com/npryce/adr-tools). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
.../kotlin/nl/avisi/structurizr/site/generatr/site/model/ContainerDecisionsTableViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.model.Container | ||
import nl.avisi.structurizr.site.generatr.hasDecisions | ||
|
||
fun PageViewModel.createContainerDecisionsTableViewModel(containers: Collection<Container>, hrefFactory: (Container) -> String) = | ||
TableViewModel.create { | ||
headerRow(headerCell("#"), headerCell("Container Decisions")) | ||
containers | ||
.sortedBy { it.name } | ||
.filter { it.hasDecisions() } | ||
.forEachIndexed { index, container -> | ||
bodyRow( | ||
cellWithIndex((index+1).toString()), | ||
cellWithLink(this@createContainerDecisionsTableViewModel, container.name, hrefFactory(container)) | ||
) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/DecisionTabViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.model.SoftwareSystem | ||
import nl.avisi.structurizr.site.generatr.hasDecisions | ||
|
||
data class DecisionTabViewModel(val pageViewModel: SoftwareSystemPageViewModel, val title: String, val url: String) { | ||
val link = LinkViewModel(pageViewModel, title, url, true) | ||
} | ||
|
||
fun SoftwareSystemPageViewModel.createDecisionsTabViewModel(softwareSystem: SoftwareSystem, tab: SoftwareSystemPageViewModel.Tab): List<DecisionTabViewModel> { | ||
val tabs = buildList<DecisionTabViewModel> { | ||
if (softwareSystem.hasDecisions()) { | ||
add(DecisionTabViewModel( | ||
this@createDecisionsTabViewModel, | ||
"System", | ||
SoftwareSystemPageViewModel.url(softwareSystem, tab) | ||
)) | ||
} | ||
softwareSystem | ||
.containers | ||
.filter { it.hasDecisions() } | ||
.map { | ||
DecisionTabViewModel( | ||
this@createDecisionsTabViewModel, | ||
it.name, | ||
SoftwareSystemContainerDecisionsPageViewModel.url(it) | ||
) | ||
} | ||
.forEach { add(it) } | ||
} | ||
return tabs | ||
} |
19 changes: 19 additions & 0 deletions
19
...visi/structurizr/site/generatr/site/model/SoftwareSystemContainerDecisionPageViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.documentation.Decision | ||
import com.structurizr.model.Container | ||
import nl.avisi.structurizr.site.generatr.normalize | ||
import nl.avisi.structurizr.site.generatr.site.GeneratorContext | ||
|
||
class SoftwareSystemContainerDecisionPageViewModel( | ||
generatorContext: GeneratorContext, container: Container, decision: Decision | ||
) : SoftwareSystemPageViewModel(generatorContext, container.softwareSystem, Tab.DECISIONS) { | ||
override val url = url(container, decision) | ||
|
||
val content = markdownToHtml(this, decision.content, generatorContext.svgFactory) | ||
|
||
companion object { | ||
fun url(container: Container, decision: Decision) = | ||
"${url(container.softwareSystem, Tab.DECISIONS)}/${container.name.normalize()}/${decision.id}" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...isi/structurizr/site/generatr/site/model/SoftwareSystemContainerDecisionsPageViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.model.Container | ||
import nl.avisi.structurizr.site.generatr.hasDecisions | ||
import nl.avisi.structurizr.site.generatr.normalize | ||
import nl.avisi.structurizr.site.generatr.site.GeneratorContext | ||
|
||
class SoftwareSystemContainerDecisionsPageViewModel(generatorContext: GeneratorContext, container: Container) : | ||
SoftwareSystemPageViewModel(generatorContext, container.softwareSystem, Tab.DECISIONS) { | ||
override val url = url(container) | ||
val decisionsTable = createDecisionsTableViewModel(container.documentation.decisions) { | ||
"$url/${it.id}" | ||
} | ||
|
||
val visible = container.hasDecisions() | ||
val decisionTabs = createDecisionsTabViewModel(container.softwareSystem, Tab.DECISIONS) | ||
|
||
companion object { | ||
fun url(container: Container) = | ||
"${url(container.softwareSystem, Tab.DECISIONS)}/${container.name.normalize()}" | ||
} | ||
} |
12 changes: 11 additions & 1 deletion
12
...lin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemDecisionsPageViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.model.SoftwareSystem | ||
import nl.avisi.structurizr.site.generatr.hasContainerDecisions | ||
import nl.avisi.structurizr.site.generatr.hasDecisions | ||
import nl.avisi.structurizr.site.generatr.site.GeneratorContext | ||
|
||
class SoftwareSystemDecisionsPageViewModel(generatorContext: GeneratorContext, softwareSystem: SoftwareSystem) : | ||
SoftwareSystemPageViewModel(generatorContext, softwareSystem, Tab.DECISIONS) { | ||
|
||
val decisionsTable = createDecisionsTableViewModel(softwareSystem.documentation.decisions) { | ||
"$url/${it.id}" | ||
} | ||
val visible = softwareSystem.hasDecisions() | ||
|
||
private val containerDecisionsVisible = softwareSystem.hasContainerDecisions() | ||
val softwareSystemDecisionsVisible = softwareSystem.hasDecisions() | ||
|
||
val visible = softwareSystemDecisionsVisible or containerDecisionsVisible | ||
val onlyContainersDecisionsVisible = !softwareSystemDecisionsVisible and containerDecisionsVisible | ||
|
||
val decisionTabs = createDecisionsTabViewModel(softwareSystem, Tab.DECISIONS) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/views/RedirectRelative.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package nl.avisi.structurizr.site.generatr.site.views | ||
|
||
import kotlinx.html.HTML | ||
import kotlinx.html.body | ||
import kotlinx.html.head | ||
import kotlinx.html.meta | ||
import kotlinx.html.title | ||
|
||
fun HTML.redirectRelative(appendUrl: String) { | ||
attributes["lang"] = "en" | ||
head { | ||
meta { | ||
httpEquiv = "refresh" | ||
content = "0; url=./$appendUrl" | ||
} | ||
title { +"Structurizr site generatr" } | ||
} | ||
body() | ||
} |
10 changes: 10 additions & 0 deletions
10
...tlin/nl/avisi/structurizr/site/generatr/site/views/SoftwareSystemContainerDecisionPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package nl.avisi.structurizr.site.generatr.site.views | ||
|
||
import kotlinx.html.HTML | ||
import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemContainerDecisionPageViewModel | ||
|
||
fun HTML.softwareSystemContainerDecisionPage(viewModel: SoftwareSystemContainerDecisionPageViewModel) { | ||
softwareSystemPage(viewModel) { | ||
rawHtml(viewModel.content) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...lin/nl/avisi/structurizr/site/generatr/site/views/SoftwareSystemContainerDecisionsPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package nl.avisi.structurizr.site.generatr.site.views | ||
|
||
import kotlinx.html.HTML | ||
import kotlinx.html.div | ||
import kotlinx.html.li | ||
import kotlinx.html.ul | ||
import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemContainerDecisionsPageViewModel | ||
|
||
fun HTML.softwareSystemContainerDecisionsPage(viewModel: SoftwareSystemContainerDecisionsPageViewModel) { | ||
if (viewModel.visible) | ||
softwareSystemPage(viewModel) { | ||
div(classes = "tabs") { | ||
ul(classes = "m-0") { | ||
viewModel.decisionTabs | ||
.forEach { | ||
li(classes = if (it.link.active) "is-active" else null) { | ||
link(it.link) | ||
} | ||
} | ||
} | ||
} | ||
table(viewModel.decisionsTable) | ||
} | ||
else | ||
redirectUpPage() | ||
} |
25 changes: 23 additions & 2 deletions
25
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/views/SoftwareSystemDecisionsPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,34 @@ | ||
package nl.avisi.structurizr.site.generatr.site.views | ||
|
||
import kotlinx.html.HTML | ||
import kotlinx.html.div | ||
import kotlinx.html.li | ||
import kotlinx.html.ul | ||
import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemDecisionsPageViewModel | ||
|
||
fun HTML.softwareSystemDecisionsPage(viewModel: SoftwareSystemDecisionsPageViewModel) { | ||
if (viewModel.visible) | ||
if (viewModel.onlyContainersDecisionsVisible) { | ||
redirectRelative( | ||
viewModel.decisionTabs.first().link.relativeHref | ||
) | ||
} | ||
else if (viewModel.visible) { | ||
softwareSystemPage(viewModel) { | ||
table(viewModel.decisionsTable) | ||
div(classes = "tabs") { | ||
ul(classes = "m-0") { | ||
viewModel.decisionTabs | ||
.forEach { | ||
li(classes = if (it.link.active) "is-active" else null) { | ||
link(it.link) | ||
} | ||
} | ||
} | ||
} | ||
if (viewModel.softwareSystemDecisionsVisible) { | ||
table(viewModel.decisionsTable) | ||
} | ||
} | ||
} | ||
else | ||
redirectUpPage() | ||
} |
47 changes: 47 additions & 0 deletions
47
...lin/nl/avisi/structurizr/site/generatr/site/model/ContainerDecisionsTableViewModelTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import assertk.assertThat | ||
import assertk.assertions.isEqualTo | ||
import kotlin.test.Test | ||
|
||
class ContainerDecisionsTableViewModelTest : ViewModelTest() { | ||
|
||
@Test | ||
fun `no container with decisions available`() { | ||
assertThat(pageViewModel().createContainerDecisionsTableViewModel(emptySet()) { "href" }) | ||
.isEqualTo( | ||
TableViewModel.create { | ||
containersTableHeaderRow() | ||
} | ||
) | ||
} | ||
|
||
@Test | ||
fun `many containers shown if they have decisions`() { | ||
val containers = generatorContext().workspace.model.addSoftwareSystem("Mock").also { | ||
it.addContainer("Web Application") | ||
it.addContainer("API Application") | ||
.documentation.addDecision(createDecision("1","API Decision")) | ||
it.addContainer("Mobile Application") | ||
.documentation.addDecision(createDecision("1", "Mobile Decision")) | ||
}.containers | ||
val pageViewModel = pageViewModel() | ||
assertThat(pageViewModel.createContainerDecisionsTableViewModel(containers) { it.name }).isEqualTo( | ||
TableViewModel.create { | ||
containersTableHeaderRow() | ||
bodyRow( | ||
cellWithIndex("1"), | ||
cellWithLink(pageViewModel, "API Application", "API Application"), | ||
) | ||
bodyRow( | ||
cellWithIndex("2"), | ||
cellWithLink(pageViewModel, "Mobile Application", "Mobile Application") | ||
) | ||
} | ||
) | ||
} | ||
|
||
private fun TableViewModel.TableViewInitializerContext.containersTableHeaderRow() { | ||
headerRow(headerCell("#"), headerCell("Container Decisions")) | ||
} | ||
} |
Oops, something went wrong.