Skip to content

Commit

Permalink
Merge pull request #550 from FlyrInc/feature/unify-link-strategy
Browse files Browse the repository at this point in the history
feat: make docs link to be consistent with Workspace level
  • Loading branch information
jp7677 authored Jul 2, 2024
2 parents 22895d1 + 8a5cdd4 commit b056e8b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ class SoftwareSystemContainerSectionPageViewModel(

companion object {
fun url(container: Container, section: Section) =
"${url(container.softwareSystem, Tab.SECTIONS)}/${container.name.normalize()}/${section.order}"
"${url(container.softwareSystem, Tab.SECTIONS)}/${container.name.normalize()}/${section.contentTitle().normalize()}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SoftwareSystemContainerSectionsPageViewModel(generatorContext: GeneratorCo
SoftwareSystemPageViewModel(generatorContext, container.softwareSystem, Tab.SECTIONS) {
override val url = url(container)
val sectionsTable = createSectionsTableViewModel(container.documentation.sections, dropFirst = false) {
"$url/${it.order}"
"$url/${it.contentTitle().normalize()}"
}

val visible = container.hasSections()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package nl.avisi.structurizr.site.generatr.site.model

import com.structurizr.documentation.Section
import com.structurizr.model.SoftwareSystem
import nl.avisi.structurizr.site.generatr.normalize
import nl.avisi.structurizr.site.generatr.site.GeneratorContext

class SoftwareSystemSectionPageViewModel(
Expand All @@ -15,6 +16,6 @@ class SoftwareSystemSectionPageViewModel(

companion object {
fun url(softwareSystem: SoftwareSystem, section: Section) =
"${url(softwareSystem, Tab.SECTIONS)}/${section.order}"
"${url(softwareSystem, Tab.SECTIONS)}/${section.contentTitle().normalize()}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package nl.avisi.structurizr.site.generatr.site.model
import com.structurizr.model.SoftwareSystem
import nl.avisi.structurizr.site.generatr.hasContainerDocumentationSections
import nl.avisi.structurizr.site.generatr.hasDocumentationSections
import nl.avisi.structurizr.site.generatr.normalize
import nl.avisi.structurizr.site.generatr.site.GeneratorContext

class SoftwareSystemSectionsPageViewModel(generatorContext: GeneratorContext, softwareSystem: SoftwareSystem) :
SoftwareSystemPageViewModel(generatorContext, softwareSystem, Tab.SECTIONS) {
val sectionsTable = createSectionsTableViewModel(softwareSystem.documentation.sections) {
"$url/${it.order}"
"$url/${it.contentTitle().normalize()}"
}

private val containerSectionsVisible = softwareSystem.hasContainerDocumentationSections()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SoftwareSystemContainerSectionPageViewModelTest : ViewModelTest() {
val viewModel = SoftwareSystemContainerSectionPageViewModel(generatorContext, container, section)

assertThat(SoftwareSystemContainerSectionPageViewModel.url(container, section))
.isEqualTo("/${softwareSystem.name.normalize()}/sections/${container.name.normalize()}/${section.order}")
.isEqualTo("/${softwareSystem.name.normalize()}/sections/${container.name.normalize()}/${section.contentTitle().normalize()}")
assertThat(viewModel.url)
.isEqualTo(SoftwareSystemContainerSectionPageViewModel.url(container, section))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SoftwareSystemContainerSectionsPageViewModelTest : ViewModelTest() {
LinkViewModel(
viewModel,
"Content",
"/software-system/sections/api-application/1"
"/software-system/sections/api-application/content"
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SoftwareSystemSectionPageViewModelTest : ViewModelTest() {
val viewModel = SoftwareSystemSectionPageViewModel(generatorContext, softwareSystem, section)

assertThat(SoftwareSystemSectionPageViewModel.url(softwareSystem, section))
.isEqualTo("/${softwareSystem.name.normalize()}/sections/${section.order}")
.isEqualTo("/${softwareSystem.name.normalize()}/sections/${section.contentTitle().normalize()}")
assertThat(viewModel.url)
.isEqualTo(SoftwareSystemSectionPageViewModel.url(softwareSystem, section))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package nl.avisi.structurizr.site.generatr.site.model

import assertk.all
import assertk.assertThat
import assertk.assertions.hasSize
import assertk.assertions.index
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import nl.avisi.structurizr.site.generatr.normalize
Expand All @@ -20,17 +23,22 @@ class SoftwareSystemSectionsPageViewModelTest : ViewModelTest() {

@Test
fun `sections table`() {
listOf("Section 0000", "Section 0001")
listOf("# Section 0000", "# Section 0001")
.forEach { softwareSystem.documentation.addSection(createSection(it)) }

val viewModel = SoftwareSystemSectionsPageViewModel(generatorContext, softwareSystem)

assertThat(viewModel.sectionsTable)
.isEqualTo(
viewModel.createSectionsTableViewModel(softwareSystem.documentation.sections) {
"/${softwareSystem.name.normalize()}/sections/2"
}
)
assertThat(viewModel.sectionsTable.bodyRows).all {
hasSize(1)
index(0).transform { (it.columns[1] as TableViewModel.LinkCellViewModel).link }
.isEqualTo(
LinkViewModel(
viewModel,
"Section 0001",
"/software-system/sections/section-0001"
)
)
}
}

@Test
Expand Down

0 comments on commit b056e8b

Please sign in to comment.