-
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.
Add container and component tabs on code view
- Loading branch information
Showing
22 changed files
with
306 additions
and
93 deletions.
There are no files selected for viewing
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
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/ComponentTabViewModel.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,5 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
data class ComponentTabViewModel(val pageViewModel: PageViewModel, val title: String, val url: String) { | ||
val link = LinkViewModel(pageViewModel, title, url) | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/ComponentsTabViewModel.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,24 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.model.Container | ||
import nl.avisi.structurizr.site.generatr.hasImageViews | ||
import nl.avisi.structurizr.site.generatr.site.GeneratorContext | ||
|
||
fun SoftwareSystemPageViewModel.createComponentsTabViewModel( | ||
generatorContext: GeneratorContext, | ||
container: Container | ||
) = buildList { | ||
container | ||
.components | ||
.sortedBy { it.name } | ||
.filter { component -> | ||
generatorContext.workspace.hasImageViews(component.id) } | ||
.map { | ||
ComponentTabViewModel( | ||
this@createComponentsTabViewModel, | ||
it.name, | ||
SoftwareSystemContainerComponentCodePageViewModel.url(it.container, it) | ||
) | ||
} | ||
.forEach { add(it) } | ||
} |
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/ContainerTabViewModel.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,5 +1,5 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
data class ContainerTabViewModel(val pageViewModel: SoftwareSystemPageViewModel, val title: String, val url: String) { | ||
val link = LinkViewModel(pageViewModel, title, url) | ||
data class ContainerTabViewModel(val pageViewModel: SoftwareSystemPageViewModel, val title: String, val url: String, val match: Match = Match.EXACT) { | ||
val link = LinkViewModel(pageViewModel, title, url, match) | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/ContainersCodeTabViewModel.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,29 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.model.SoftwareSystem | ||
import nl.avisi.structurizr.site.generatr.hasComponentDiagrams | ||
import nl.avisi.structurizr.site.generatr.hasImageViews | ||
import nl.avisi.structurizr.site.generatr.site.GeneratorContext | ||
|
||
fun SoftwareSystemPageViewModel.createContainersCodeTabViewModel( | ||
generatorContext: GeneratorContext, | ||
softwareSystem: SoftwareSystem, | ||
) = buildList { | ||
softwareSystem | ||
.containers | ||
.sortedBy { it.name } | ||
.filter { container -> | ||
(generatorContext.workspace.hasComponentDiagrams(container) or | ||
generatorContext.workspace.hasImageViews(container.id)) and | ||
container.components.any { component -> generatorContext.workspace.hasImageViews(component.id) } | ||
} | ||
.map { container -> | ||
ContainerTabViewModel( | ||
this@createContainersCodeTabViewModel, | ||
container.name, | ||
SoftwareSystemContainerComponentCodePageViewModel.url(container, container.components.sortedBy { it.name }.firstOrNull { component -> generatorContext.workspace.hasImageViews(component.id) }), | ||
Match.SIBLING | ||
) | ||
} | ||
.forEach { add(it) } | ||
} |
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
13 changes: 0 additions & 13 deletions
13
...n/kotlin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemCodePageViewModel.kt
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
...structurizr/site/generatr/site/model/SoftwareSystemContainerComponentCodePageViewModel.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.model | ||
|
||
import com.structurizr.model.Container | ||
import com.structurizr.model.Component | ||
import nl.avisi.structurizr.site.generatr.normalize | ||
import nl.avisi.structurizr.site.generatr.site.GeneratorContext | ||
|
||
class SoftwareSystemContainerComponentCodePageViewModel(generatorContext: GeneratorContext, container: Container, component: Component) : | ||
SoftwareSystemPageViewModel(generatorContext, container.softwareSystem, Tab.CODE) { | ||
override val url = url(container, component) | ||
val images = generatorContext.workspace.views.imageViews | ||
.filter { it.elementId in component.id } | ||
.sortedBy { it.key } | ||
.map { ImageViewViewModel(it) } | ||
|
||
val visible = images.isNotEmpty() | ||
val containerTabs = createContainersCodeTabViewModel(generatorContext, container.softwareSystem) | ||
val componentTabs = createComponentsTabViewModel(generatorContext, container) | ||
|
||
companion object { | ||
fun url(container: Container, component: Component?) = | ||
url(container.softwareSystem, Tab.CODE) + | ||
"/${container.name.normalize()}" + | ||
"/${component?.name?.normalize()}" | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
...nl/avisi/structurizr/site/generatr/site/views/SoftwareSystemContainerComponentCodePage.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,36 @@ | ||
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.SoftwareSystemContainerComponentCodePageViewModel | ||
|
||
fun HTML.softwareSystemContainerComponentCodePage(viewModel: SoftwareSystemContainerComponentCodePageViewModel) { | ||
if (viewModel.visible) { | ||
softwareSystemPage(viewModel) { | ||
div(classes = "tabs") { | ||
ul(classes = "m-0 is-flex-wrap-wrap is-flex-shrink-1 is-flex-grow-0") { | ||
viewModel.containerTabs | ||
.forEach { | ||
li(classes = if (it.link.active) "is-active" else null) { | ||
link(it.link) | ||
} | ||
} | ||
} | ||
} | ||
div(classes = "tabs tabs-code") { | ||
ul(classes = "m-0 is-flex-wrap-wrap is-flex-shrink-1 is-flex-grow-0") { | ||
viewModel.componentTabs | ||
.forEach { | ||
li(classes = if (it.link.active) "is-active" else null) { | ||
link(it.link) | ||
} | ||
} | ||
} | ||
} | ||
viewModel.images.forEach { image(it) } | ||
} | ||
} else | ||
redirectUpPage() | ||
} |
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
14 changes: 0 additions & 14 deletions
14
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/views/softwareSystemCodePage.kt
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -44,3 +44,7 @@ svg a:hover { | |
.modal-image { | ||
object-fit: contain; | ||
} | ||
|
||
.tabs-code { | ||
font-size: 0.75rem; | ||
} |
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
Oops, something went wrong.