Skip to content

Commit cf3a16f

Browse files
authored
Merge pull request #7 from Flowpack/add-current-release-identifier-to-pipeline
Add current release identifier to pipeline, enable backend module extension
2 parents 45375a4 + 295f5d0 commit cf3a16f

13 files changed

Lines changed: 576 additions & 152484 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Flowpack\DecoupledContentStore\BackendUi\FusionObjects;
4+
5+
use Neos\Flow\Annotations as Flow;
6+
use Neos\Flow\Mvc\FlashMessage\FlashMessageService;
7+
use Neos\Fusion\FusionObjects\AbstractFusionObject;
8+
9+
class RetrieveFlashMessagesImplementation extends AbstractFusionObject
10+
{
11+
/**
12+
* @Flow\Inject
13+
* @var FlashMessageService
14+
*/
15+
protected $flashMessageService;
16+
17+
public function evaluate()
18+
{
19+
return $this->flashMessageService->getFlashMessageContainerForRequest($this->runtime->getControllerContext()->getRequest())->getMessagesAndFlush();
20+
}
21+
}

Classes/ContentReleaseManager.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Flowpack\DecoupledContentStore;
66

7+
use Flowpack\DecoupledContentStore\Core\Infrastructure\RedisClientManager;
78
use Neos\Flow\Annotations as Flow;
89
use Flowpack\Prunner\PrunnerApiService;
910
use Flowpack\Prunner\ValueObject\PipelineName;
@@ -26,16 +27,29 @@ class ContentReleaseManager
2627
*/
2728
protected $prunnerApiService;
2829

30+
/**
31+
* @Flow\Inject
32+
* @var RedisClientManager
33+
*/
34+
protected $redisClientManager;
35+
36+
const REDIS_CURRENT_RELEASE_KEY = 'contentStore:current';
37+
const NO_PREVIOUS_RELEASE = 'NO_PREVIOUS_RELEASE';
2938

3039
public function startIncrementalContentRelease()
3140
{
32-
$this->prunnerApiService->schedulePipeline(PipelineName::create('do_content_release'), ['contentReleaseId' => (string)time()]);
41+
$redis = $this->redisClientManager->getPrimaryRedis();
42+
$currentContentReleaseId = $redis->get(self::REDIS_CURRENT_RELEASE_KEY);
43+
44+
// the currentContentReleaseId is not used in any pipeline step in this package, but is a common need in other
45+
// use cases in extensions, e.g. calculating the differences between current and new release
46+
$this->prunnerApiService->schedulePipeline(PipelineName::create('do_content_release'), ['contentReleaseId' => (string)time(), 'currentContentReleaseId' => $currentContentReleaseId ?: self::NO_PREVIOUS_RELEASE]);
3347
}
3448

3549
public function startFullContentRelease()
3650
{
3751
$this->contentCache->flush();
38-
$this->prunnerApiService->schedulePipeline(PipelineName::create('do_content_release'), ['contentReleaseId' => (string)time()]);
52+
$this->prunnerApiService->schedulePipeline(PipelineName::create('do_content_release'), ['contentReleaseId' => (string)time(), 'currentContentReleaseId' => self::NO_PREVIOUS_RELEASE]);
3953
}
4054

4155
public function cancelAllRunningContentReleases()
@@ -46,4 +60,4 @@ public function cancelAllRunningContentReleases()
4660
$this->prunnerApiService->cancelJob($job);
4761
}
4862
}
49-
}
63+
}

Classes/Controller/BackendController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ public function switchAction(string $contentReleaseIdentifier, string $redisInst
159159

160160
public function switchContentReleaseOnOtherInstanceAction(string $targetRedisInstanceIdentifier, string $contentReleaseIdentifier)
161161
{
162+
$redis = $this->redisClientManager->getPrimaryRedis();
163+
$currentContentReleaseId = $redis->get('contentStore:current');
164+
162165
$this->prunnerApiService->schedulePipeline(PipelineName::create('manually_transfer_content_release'),
163-
['contentReleaseId' => $contentReleaseIdentifier, 'redisInstanceId' => $targetRedisInstanceIdentifier]);
166+
['contentReleaseId' => $contentReleaseIdentifier, 'currentContentReleaseId' => $currentContentReleaseId ?: ContentReleaseManager::NO_PREVIOUS_RELEASE, 'redisInstanceId' => $targetRedisInstanceIdentifier]);
164167

165168
$this->redirect('index', null, null, ['contentStore' => $targetRedisInstanceIdentifier]);
166169
}

Configuration/Views.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-
2-
requestFilter: 'parentRequest.isPackage("Neos.Neos") && isFormat("html") && isPackage("Flowpack.DecoupledContentStore")'
2+
requestFilter: 'isPackage("Flowpack.DecoupledContentStore")'
33
options:
44
fusionPathPatterns:
55
- 'resource://Flowpack.DecoupledContentStore/Private/BackendFusion'

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,34 @@ Flowpack:
338338
This is needed so that the system knows which keys should be synchronized between the different content stores,
339339
and what data to delete if a release is removed.
340340

341+
### Extending the backend module
342+
343+
- You need a Views.yaml in your package, looking like this:
344+
```
345+
-
346+
requestFilter: 'isPackage("Flowpack.DecoupledContentStore")'
347+
viewObjectName: 'Neos\Fusion\View\FusionView'
348+
options:
349+
fusionPathPatterns:
350+
- 'resource://Flowpack.DecoupledContentStore/Private/BackendFusion'
351+
- 'resource://Vendor.Site/Private/DecoupledContentStoreFusion'
352+
```
353+
- Ensure that your package depends on `flowpack/decoupledcontentstore` in composer.json (so that your Views.yaml "wins" because the DecoupledContentStore-Package comes with its own Views.yaml)
354+
- Add a Root.fusion in `Vendor.Site/Resources/Private/DecoupledContentStoreFusion` which can contain your modifications
355+
- We currently support the following adjustments:
356+
- Adding a button to the footer
357+
```
358+
prototype(Flowpack.DecoupledContentStore:ListFooter) {
359+
test = '<span class="align-middle inline-block text-sm pr-4 pl-16">TEST</span>'
360+
test.@position = 'before reload'
361+
}
362+
```
363+
- Adding a flash message
364+
```
365+
// ActionController
366+
$this->addFlashMessage('sth important you have to say');
367+
```
368+
341369
## Development
342370

343371
- You need [pnpm](https://github.com/pnpm/pnpm) as package panager installed: `curl -f https://get.pnpm.io/v6.js | node - add --global pnpm`
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
prototype(Flowpack.DecoupledContentStore:FlashMessages) < prototype(Neos.Fusion:Component) {
2+
flashMessages = Flowpack.DecoupledContentStore:RetrieveFlashMessages
3+
4+
renderer = afx`
5+
<ul id="neos-notifications-inline" @if.hasFlashMessages={props.flashMessages}>
6+
<Neos.Fusion:Loop items={props.flashMessages}>
7+
<li data-type={String.toLowerCase(item.severity)}>
8+
{item.message}
9+
</li>
10+
</Neos.Fusion:Loop>
11+
</ul>
12+
`
13+
}
14+
15+
prototype(Flowpack.DecoupledContentStore:RetrieveFlashMessages) {
16+
@class = 'Flowpack\\DecoupledContentStore\\BackendUi\\FusionObjects\\RetrieveFlashMessagesImplementation'
17+
}

Resources/Private/BackendFusion/Integration/Backend.Details.fusion

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,14 @@ prototype(Flowpack.DecoupledContentStore:DetailsFooter) < prototype(Neos.Fusion:
393393

394394
renderer = afx`
395395
<button form="postHelper" formaction={props._switchUri} type="submit" class="neos-button neos-button-warning neos-pull-right" @if.isNotPrimary={item != "primary"}>
396-
Transfer to {item}
396+
Transfer and switch on {item}
397397
</button>
398398
`
399399
}
400400
}
401401

402402
renderer = afx`
403-
<div class="neos-footer">
403+
<div class="neos-footer !h-full">
404404
<Neos.Fusion:Link.Action href.action="details" href.arguments={{contentReleaseIdentifier: detailsData.contentReleaseIdentifier.identifier}} class="neos-button">
405405
<i class="fa fa-sync"></i> Reload
406406
</Neos.Fusion:Link.Action>

Resources/Private/BackendFusion/Integration/Backend.Index.fusion

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Flowpack.DecoupledContentStore.BackendController.index = Neos.Fusion:Component {
6262
}
6363
}
6464
renderer = afx`
65+
<Flowpack.DecoupledContentStore:FlashMessages id="neos-notifications-inline" class="flashmessages" />
6566
<form id="postHelper" method="post">
6667
<input
6768
type="hidden"
@@ -102,33 +103,37 @@ Flowpack.DecoupledContentStore.BackendController.index = Neos.Fusion:Component {
102103
Cancel running release
103104
</button>
104105

105-
<Flowpack.DecoupledContentStore:ListFooter />
106+
<div class="neos-footer !h-full">
107+
<Flowpack.DecoupledContentStore:ListFooter />
108+
</div>
106109
</div>
107110
</div>
108111
`
109112
}
110113
}
111114

112-
prototype(Flowpack.DecoupledContentStore:ListFooter) < prototype(Neos.Fusion:Component) {
113-
_publishAllUri = Neos.Fusion:UriBuilder {
114-
action = 'publishAll'
115-
}
116-
117-
renderer = afx`
118-
<div class="neos-footer">
119-
<Neos.Fusion:Link.Action href.action="index" class="neos-button">
120-
<i class="fa fa-sync"></i> Reload
115+
prototype(Flowpack.DecoupledContentStore:ListFooter) < prototype(Neos.Fusion:Join) {
116+
reload = afx`
117+
<Neos.Fusion:Link.Action href.action="index" class="neos-button">
118+
<i class="fa fa-sync"></i> Reload
119+
</Neos.Fusion:Link.Action>
120+
`
121+
activeContentStoreLabel = '<span class="align-middle inline-block text-sm pr-4 pl-16">Active Content Store:</span>'
122+
switchContentStore = afx`
123+
<Neos.Fusion:Loop items={redisContentStores}>
124+
<Neos.Fusion:Link.Action href.action="index" href.arguments={{contentStore: item}} class={AtomicFusion.classNames('neos-button', {'neos-button-primary': item == contentStore})}>
125+
{item}
121126
</Neos.Fusion:Link.Action>
122-
<span class="align-middle inline-block text-sm pr-4 pl-16">Active Content Store:</span>
123-
<Neos.Fusion:Loop items={redisContentStores}>
124-
<Neos.Fusion:Link.Action href.action="index" href.arguments={{contentStore: item}} class={AtomicFusion.classNames('neos-button', {'neos-button-primary': item == contentStore})}>
125-
{item}
126-
</Neos.Fusion:Link.Action>
127-
</Neos.Fusion:Loop>
128-
127+
</Neos.Fusion:Loop>
128+
`
129+
publishAll = Neos.Fusion:Component {
130+
_publishAllUri = Neos.Fusion:UriBuilder {
131+
action = 'publishAll'
132+
}
133+
renderer = afx`
129134
<button form="postHelper" formaction={props._publishAllUri} type="submit" class="neos-button neos-button-warning neos-pull-right">
130135
Publish All
131136
</button>
132-
</div>
133-
`
137+
`
138+
}
134139
}

0 commit comments

Comments
 (0)