Skip to content

Commit

Permalink
Redirect to software system home on hidden tabs
Browse files Browse the repository at this point in the history
The tabs for context, components etc. are conditionally visible.
Redirect to the software systems home (one level up in the url path)
when visiting a page that is not visible.
  • Loading branch information
jp7677 committed Nov 28, 2022
1 parent 23608f6 commit c84ca79
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package nl.avisi.structurizr.site.generatr.site.views

import kotlinx.html.FlowContent
import kotlinx.html.ScriptType
import kotlinx.html.script

fun FlowContent.redirectUp() {
script(type = ScriptType.textJavaScript) {
+"window.location.href = '../'"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemComponentPage

fun HTML.softwareSystemComponentPage(viewModel: SoftwareSystemComponentPageViewModel) {
softwareSystemPage(viewModel) {
if (viewModel.diagrams.none())
redirectUp()

viewModel.diagrams.forEach {
diagram(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemContainerPage

fun HTML.softwareSystemContainerPage(viewModel: SoftwareSystemContainerPageViewModel) {
softwareSystemPage(viewModel) {
if (viewModel.diagrams.none())
redirectUp()

viewModel.diagrams.forEach {
diagram(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemContextPageVi

fun HTML.softwareSystemContextPage(viewModel: SoftwareSystemContextPageViewModel) {
softwareSystemPage(viewModel) {
if (viewModel.diagrams.none())
redirectUp()

viewModel.diagrams.forEach {
diagram(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemDecisionsPage

fun HTML.softwareSystemDecisionsPage(viewModel: SoftwareSystemDecisionsPageViewModel) {
softwareSystemPage(viewModel) {
if (viewModel.decisionsTable.bodyRows.none())
redirectUp()

table(viewModel.decisionsTable)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemDeploymentPag

fun HTML.softwareSystemDeploymentPage(viewModel: SoftwareSystemDeploymentPageViewModel) {
softwareSystemPage(viewModel) {
if (viewModel.diagrams.none())
redirectUp()

viewModel.diagrams.forEach {
diagram(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemSectionsPageV

fun HTML.softwareSystemSectionsPage(viewModel: SoftwareSystemSectionsPageViewModel) {
softwareSystemPage(viewModel) {
if (viewModel.sectionsTable.bodyRows.none())
redirectUp()

table(viewModel.sectionsTable)
}
}

0 comments on commit c84ca79

Please sign in to comment.