Skip to content

Commit

Permalink
fix: removing Workspace.listIndexViewEnabled helper and move logic to…
Browse files Browse the repository at this point in the history
… DiagramIndexListViewModel
  • Loading branch information
galuszkak committed Nov 5, 2024
1 parent b55d9a6 commit c9c917c
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ fun Workspace.hasImageViews(id: String) = views.imageViews.any { it.elementId ==

fun Workspace.hasComponentDiagrams(container: Container) = views.componentViews.any { it.container == container}

fun Workspace.listIndexViewEnabled(
diagrams: List<DiagramViewModel>?,
images: List<ImageViewViewModel>?
) = ((diagrams?.count() ?: 0) + (images?.count() ?: 0)) > 1

val SoftwareSystem.hasContainers
get() = this.containers.isNotEmpty()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ package nl.avisi.structurizr.site.generatr.site.model
data class DiagramIndexListViewModel(
val diagrams: List<DiagramViewModel>?,
val images: List<ImageViewViewModel>?,
val showList: Boolean
val showList: Boolean = ((diagrams?.count() ?: 0) + (images?.count() ?: 0)) > 1
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package nl.avisi.structurizr.site.generatr.site.model

import com.structurizr.model.Container
import com.structurizr.model.Component
import nl.avisi.structurizr.site.generatr.listIndexViewEnabled
import nl.avisi.structurizr.site.generatr.normalize
import nl.avisi.structurizr.site.generatr.site.GeneratorContext

Expand All @@ -19,8 +18,7 @@ class SoftwareSystemContainerComponentCodePageViewModel(generatorContext: Genera
val componentTabs = createComponentsTabViewModel(generatorContext, container)
val diagramIndexListViewModel = DiagramIndexListViewModel(
null,
images,
generatorContext.workspace.listIndexViewEnabled(null, images)
images
)
companion object {
fun url(container: Container, component: Component?) = "${url(container.softwareSystem, Tab.CODE)}/${container.name.normalize()}/${component?.name?.normalize()}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package nl.avisi.structurizr.site.generatr.site.model

import com.structurizr.model.Container
import nl.avisi.structurizr.site.generatr.includedProperties
import nl.avisi.structurizr.site.generatr.listIndexViewEnabled
import nl.avisi.structurizr.site.generatr.normalize
import nl.avisi.structurizr.site.generatr.site.GeneratorContext

Expand All @@ -24,8 +23,7 @@ class SoftwareSystemContainerComponentsPageViewModel(generatorContext: Generator
val containerTabs = createContainersComponentTabViewModel(generatorContext, container.softwareSystem)
val diagramIndexListViewModel = DiagramIndexListViewModel(
diagrams,
images,
generatorContext.workspace.listIndexViewEnabled(diagrams, images)
images
)
companion object {
fun url(container: Container) = "${url(container.softwareSystem, Tab.COMPONENT)}/${container.name.normalize()}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package nl.avisi.structurizr.site.generatr.site.model

import com.structurizr.model.SoftwareSystem
import nl.avisi.structurizr.site.generatr.hasContainerViews
import nl.avisi.structurizr.site.generatr.listIndexViewEnabled
import nl.avisi.structurizr.site.generatr.site.GeneratorContext

class SoftwareSystemContainerPageViewModel(generatorContext: GeneratorContext, softwareSystem: SoftwareSystem) :
Expand All @@ -18,7 +17,6 @@ class SoftwareSystemContainerPageViewModel(generatorContext: GeneratorContext, s
val visible = generatorContext.workspace.views.hasContainerViews(generatorContext.workspace, softwareSystem) || images.isNotEmpty()
val diagramIndexListViewModel = DiagramIndexListViewModel(
diagrams,
images,
generatorContext.workspace.listIndexViewEnabled(diagrams, images)
images
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package nl.avisi.structurizr.site.generatr.site.model

import com.structurizr.model.SoftwareSystem
import nl.avisi.structurizr.site.generatr.hasSystemContextViews
import nl.avisi.structurizr.site.generatr.listIndexViewEnabled
import nl.avisi.structurizr.site.generatr.site.GeneratorContext

class SoftwareSystemContextPageViewModel(generatorContext: GeneratorContext, softwareSystem: SoftwareSystem) :
Expand All @@ -14,7 +13,6 @@ class SoftwareSystemContextPageViewModel(generatorContext: GeneratorContext, sof
val visible = generatorContext.workspace.views.hasSystemContextViews(softwareSystem)
val diagramIndexListViewModel = DiagramIndexListViewModel(
diagrams,
null,
generatorContext.workspace.listIndexViewEnabled(diagrams, null)
null
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package nl.avisi.structurizr.site.generatr.site.model

import com.structurizr.model.SoftwareSystem
import nl.avisi.structurizr.site.generatr.hasDeploymentViews
import nl.avisi.structurizr.site.generatr.listIndexViewEnabled
import nl.avisi.structurizr.site.generatr.site.GeneratorContext

class SoftwareSystemDeploymentPageViewModel(generatorContext: GeneratorContext, softwareSystem: SoftwareSystem) :
Expand All @@ -14,7 +13,6 @@ class SoftwareSystemDeploymentPageViewModel(generatorContext: GeneratorContext,
val visible = generatorContext.workspace.views.hasDeploymentViews(softwareSystem)
val diagramIndexListViewModel = DiagramIndexListViewModel(
diagrams,
null,
generatorContext.workspace.listIndexViewEnabled(diagrams, null)
null
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package nl.avisi.structurizr.site.generatr.site.model

import com.structurizr.model.SoftwareSystem
import nl.avisi.structurizr.site.generatr.hasDynamicViews
import nl.avisi.structurizr.site.generatr.listIndexViewEnabled
import nl.avisi.structurizr.site.generatr.site.GeneratorContext

class SoftwareSystemDynamicPageViewModel(generatorContext: GeneratorContext, softwareSystem: SoftwareSystem) :
Expand All @@ -14,7 +13,6 @@ class SoftwareSystemDynamicPageViewModel(generatorContext: GeneratorContext, sof
val visible = generatorContext.workspace.views.hasDynamicViews(softwareSystem)
val diagramIndexListViewModel = DiagramIndexListViewModel(
diagrams,
null,
generatorContext.workspace.listIndexViewEnabled(diagrams, null)
null
)
}

0 comments on commit c9c917c

Please sign in to comment.