Skip to content

Commit

Permalink
FEATURE: Prototype Whitelist
Browse files Browse the repository at this point in the history
Adds a new configuration option `alwaysShowPrototypes` that allows
for including prototypes selectively even though they match a
configured `hiddenPrototypeNamePatterns`:

```yaml
Sitegeist:
  Monocle:
    hiddenPrototypeNamePatterns:
      - 'Vendor.Components:*'
    alwaysShowPrototypes:
      - 'Vendor.Components:Components.Atom.SomeAtom'
      - 'Vendor.Components:Components.Molecule.SomeMolecule'
```

Resolves: #89
  • Loading branch information
bwaidelich committed Jan 10, 2020
1 parent b72f01d commit 5bb770c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Classes/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,14 @@ protected function getStyleguideObjects($sitePackageKey): array

$hiddenPrototypeNamePatterns = $this->configurationService->getSiteConfiguration($sitePackageKey, 'hiddenPrototypeNamePatterns');
if (is_array($hiddenPrototypeNamePatterns)) {
$alwaysShowPrototypes = $this->configurationService->getSiteConfiguration($sitePackageKey, 'alwaysShowPrototypes');
foreach ($hiddenPrototypeNamePatterns as $pattern) {
$styleguideObjects = array_filter(
$styleguideObjects,
function ($prototypeName) use ($pattern) {
function ($prototypeName) use ($pattern, $alwaysShowPrototypes) {
if (in_array($prototypeName, $alwaysShowPrototypes, true)) {
return true;
}
return fnmatch($pattern, $prototypeName) === false;
},
ARRAY_FILTER_USE_KEY
Expand Down
1 change: 1 addition & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Sitegeist:
color: '#FFF'

hiddenPrototypeNamePatterns: { }
alwaysShowPrototypes: { }

preview:
fusionRootPath: '/<Sitegeist.Monocle:Preview.Page>'
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,18 @@ Sitegeist:
- 'Another.Vendor.Site:Prototype'
```

Specific components can be "unhidden" even if they match one of the `hiddenPrototypeNamePatterns` patterns:

```YAML
Sitegeist:
Monocle:
alwaysShowPrototypes:
- 'Vendor.Site:Some.Component.ThatShouldBeShown'
- 'Another.Vendor.Site:Prototype.ThatShouldBeShown'
```

This allows for including prototypes of packages selectively.

### Site-specific configuration

All configurations can be overwritten for each selected site package.
Expand Down

0 comments on commit 5bb770c

Please sign in to comment.