Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make docs link to be consistent with Workspace level #550

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading