-
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 tabs on component view
- Loading branch information
Showing
14 changed files
with
254 additions
and
120 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
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: SoftwareSystemPageViewModel, val title: String, val url: String) { | ||
val link = LinkViewModel(pageViewModel, title, url) | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/ComponentsTableViewModel.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,23 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.model.SoftwareSystem | ||
import nl.avisi.structurizr.site.generatr.site.GeneratorContext | ||
|
||
fun SoftwareSystemPageViewModel.createComponentsTabViewModel( | ||
generatorContext: GeneratorContext, | ||
softwareSystem: SoftwareSystem, | ||
) = buildList { | ||
softwareSystem | ||
.containers | ||
.filter { container -> | ||
container.hasComponents() or | ||
generatorContext.workspace.views.imageViews.any { it.elementId in container.id } } | ||
.map { | ||
ComponentTabViewModel( | ||
this@createComponentsTabViewModel, | ||
it.name, | ||
SoftwareSystemContainerComponentsPageViewModel.url(it) | ||
) | ||
} | ||
.forEach { add(it) } | ||
} |
18 changes: 0 additions & 18 deletions
18
...lin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemComponentPageViewModel.kt
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...si/structurizr/site/generatr/site/model/SoftwareSystemContainerComponentsPageViewModel.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.normalize | ||
import nl.avisi.structurizr.site.generatr.site.GeneratorContext | ||
|
||
class SoftwareSystemContainerComponentsPageViewModel(generatorContext: GeneratorContext, container: Container) : | ||
SoftwareSystemPageViewModel(generatorContext, container.softwareSystem, Tab.COMPONENT) { | ||
override val url = url(container) | ||
val diagrams = generatorContext.workspace.views.componentViews | ||
.filter { it.container == container } | ||
.sortedBy { it.key } | ||
.map { DiagramViewModel.forView(this, it, generatorContext.svgFactory) } | ||
val images = generatorContext.workspace.views.imageViews | ||
.filter { it.elementId in container.id } | ||
.sortedBy { it.key } | ||
.map { ImageViewViewModel(it) } | ||
|
||
val visible = container.hasComponents() or images.isNotEmpty() | ||
val containerTabs = createComponentsTabViewModel(generatorContext, container.softwareSystem) | ||
companion object { | ||
fun url(container: Container) = "${url(container.softwareSystem, Tab.COMPONENT)}/${container.name.normalize()}" | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/views/SoftwareSystemComponentPage.kt
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
...in/nl/avisi/structurizr/site/generatr/site/views/SoftwareSystemContainerComponentsPage.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,27 @@ | ||
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.SoftwareSystemContainerComponentsPageViewModel | ||
|
||
fun HTML.softwareSystemContainerComponentsPage(viewModel: SoftwareSystemContainerComponentsPageViewModel) { | ||
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) | ||
} | ||
} | ||
} | ||
} | ||
viewModel.diagrams.forEach { diagram(it) } | ||
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
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
77 changes: 0 additions & 77 deletions
77
...nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemComponentPageViewModelTest.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.