structurizr / dsl

Structurizr DSL
https://docs.structurizr.com/dsl
Apache License 2.0
1.41k stars 265 forks source link

Setting default tag for elements in scope of views #65

Closed juanrferia closed 3 years ago

juanrferia commented 3 years ago

Hello,

I would like to automatically apply a blue color for the elements in scope of a view, while the elements our of scope keep being grey. Currently, I can achieve that by assigning tags to elements and defining a stiles for those tags, but then the elements are displayed always with the same stile for all views, regardless they are in or out of scope.

Let me explain with an example.

Given this workspace:

workspace {

    model {

        enterprise "My Enterprise" {

            softwareSystem1 = softwareSystem "Software System 1" {
                api1 = container "API"
            }

            softwareSystem2 = softwareSystem "Software System 2" {
                api2 = container "API"
            }

        }

        thirdPartySystem = softwareSystem "Third Party System"

        api1 -> api2
        api2 -> thirdPartySystem

    }

    views {

        systemlandscape "SystemLandscape" {
            include *
            autoLayout
        }

        systemcontext softwareSystem1 "softwareSystem1_SystemContext" {
            include *
            autoLayout
        }

        systemcontext softwareSystem2 "softwareSystem2_SystemContext" {
            include *
            autoLayout
        }

        container softwareSystem1 "softwareSystem1_Containers" {
            include *
            autoLayout
        }

        container softwareSystem2 "softwareSystem2_Containers" {
            include *
            autoLayout
        }
    }
}

I would like to get these views:

SystemLandscape: image

softwareSystem1_SystemContext: image

softwareSystem2_SystemContext: image

softwareSystem1_Containers: image

softwareSystem2_Containers: image

Is it maybe possible to automatically apply some default tag to the elements in scope? That would be a way to make it happen. If there is any existing way to achieve my goals, please let me know.

Thanks.

simonbrowndotje commented 3 years ago

For consistency reasons, view specific styles are not supported I'm afraid. You can achieve this via the workspace extension mechanism though (see https://github.com/structurizr/dsl/blob/master/docs/language-reference.md#workspace), as follows:

  1. Create a base workspace that contains all of your model elements, and any common styles.
  2. Extend this base workspace, creating a view and view specific styles.
juanrferia commented 3 years ago

Thanks for the clarification