Skip to content

Commit de4e90e

Browse files
authored
Merge pull request #26 from Flowpack/feature-show-publish-triggering-user-in-overview
FEATURE: Show username of user that triggered publish
2 parents aacc7f3 + d4e9644 commit de4e90e

File tree

6 files changed

+36
-16
lines changed

6 files changed

+36
-16
lines changed

Classes/Command/ContentReleasePrepareCommandController.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ class ContentReleasePrepareCommandController extends CommandController
2828
*/
2929
protected $concurrentBuildLock;
3030

31-
public function createContentReleaseCommand(string $contentReleaseIdentifier, string $prunnerJobId, string $workspaceName = 'live'): void
31+
public function createContentReleaseCommand(string $contentReleaseIdentifier, string $prunnerJobId, string $workspaceName = 'live', string $accountId = 'cli'): void
3232
{
3333
$contentReleaseIdentifier = ContentReleaseIdentifier::fromString($contentReleaseIdentifier);
3434
$prunnerJobId = PrunnerJobId::fromString($prunnerJobId);
3535
$logger = ContentReleaseLogger::fromConsoleOutput($this->output, $contentReleaseIdentifier);
36-
37-
$this->redisContentReleaseService->createContentRelease($contentReleaseIdentifier, $prunnerJobId, $logger, $workspaceName);
36+
$this->redisContentReleaseService->createContentRelease($contentReleaseIdentifier, $prunnerJobId, $logger, $workspaceName, $accountId);
3837
}
3938

4039
public function ensureAllOtherInProgressContentReleasesWillBeTerminatedCommand(string $contentReleaseIdentifier): void

Classes/ContentReleaseManager.php

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Neos\Flow\Annotations as Flow;
1313
use Flowpack\Prunner\PrunnerApiService;
1414
use Flowpack\Prunner\ValueObject\PipelineName;
15+
use Neos\Flow\Security\Context;
1516
use Neos\Fusion\Core\Cache\ContentCache;
1617

1718
/**
@@ -43,6 +44,12 @@ class ContentReleaseManager
4344
*/
4445
protected $configEpochSettings;
4546

47+
/**
48+
* @FLow\Inject
49+
* @var Context
50+
*/
51+
protected $securityContext;
52+
4653
const REDIS_CURRENT_RELEASE_KEY = 'contentStore:current';
4754
const NO_PREVIOUS_RELEASE = 'NO_PREVIOUS_RELEASE';
4855

@@ -61,6 +68,7 @@ public function startIncrementalContentRelease(string $currentContentReleaseId =
6168
'currentContentReleaseId' => $currentContentReleaseId ?: self::NO_PREVIOUS_RELEASE,
6269
'validate' => true,
6370
'workspaceName' => $workspace ? $workspace->getName() : 'live',
71+
'accountId' => $this->securityContext->getAccount()->getAccountIdentifier(),
6472
]));
6573
return $contentReleaseId;
6674
}
@@ -80,6 +88,7 @@ public function startFullContentRelease(bool $validate = true, string $currentCo
8088
'currentContentReleaseId' => $currentContentReleaseId ?: self::NO_PREVIOUS_RELEASE,
8189
'validate' => $validate,
8290
'workspaceName' => $workspace ? $workspace->getName() : 'live',
91+
'accountId' => $this->securityContext->getAccount()->getAccountIdentifier(),
8392
]));
8493
return $contentReleaseId;
8594
}

Classes/PrepareContentRelease/Dto/ContentReleaseMetadata.php

+20-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Flowpack\DecoupledContentStore\Core\Domain\ValueObject\ContentReleaseIdentifier;
77
use Flowpack\DecoupledContentStore\Core\Domain\ValueObject\PrunnerJobId;
88
use Flowpack\DecoupledContentStore\NodeRendering\Dto\NodeRenderingCompletionStatus;
9-
use Neos\ContentRepository\Domain\Model\Workspace;
109
use Neos\Flow\Annotations as Flow;
1110

1211
/**
@@ -41,14 +40,17 @@ final class ContentReleaseMetadata implements \JsonSerializable
4140

4241
private ?string $workspaceName;
4342

43+
private ?string $accountId;
44+
4445
private function __construct(
4546
PrunnerJobId $prunnerJobId,
4647
?\DateTimeInterface $startTime,
4748
?\DateTimeInterface $endTime,
4849
?\DateTimeInterface $switchTime,
4950
?NodeRenderingCompletionStatus $status,
5051
?array $manualTransferJobIds = [],
51-
string $workspaceName = 'live'
52+
string $workspaceName = 'live',
53+
?string $accountId = 'cli'
5254
)
5355
{
5456
$this->prunnerJobId = $prunnerJobId;
@@ -58,12 +60,13 @@ private function __construct(
5860
$this->status = $status ?: NodeRenderingCompletionStatus::scheduled();
5961
$this->manualTransferJobIds = $manualTransferJobIds;
6062
$this->workspaceName = $workspaceName;
63+
$this->accountId = $accountId;
6164
}
6265

6366

64-
public static function create(PrunnerJobId $prunnerJobId, \DateTimeInterface $startTime, string $workspace = 'live'): self
67+
public static function create(PrunnerJobId $prunnerJobId, \DateTimeInterface $startTime, string $workspace = 'live', string $accountId = 'cli'): self
6568
{
66-
return new self($prunnerJobId, $startTime, null, null, NodeRenderingCompletionStatus::scheduled(), [], $workspace);
69+
return new self($prunnerJobId, $startTime, null, null, NodeRenderingCompletionStatus::scheduled(), [], $workspace, $accountId);
6770
}
6871

6972
public static function fromJsonString($metadataEncoded, ContentReleaseIdentifier $contentReleaseIdentifier): self
@@ -85,7 +88,8 @@ public static function fromJsonString($metadataEncoded, ContentReleaseIdentifier
8588
isset($tmp['manualTransferJobIds']) ? array_map(function (string $item) {
8689
return PrunnerJobId::fromString($item);
8790
}, json_decode($tmp['manualTransferJobIds'])) : [],
88-
$tmp['workspace'] ?? 'live'
91+
$tmp['workspace'] ?? 'live',
92+
key_exists('accountId', $tmp) ? $tmp['accountId'] : 'cli',
8993
);
9094
}
9195

@@ -99,30 +103,31 @@ public function jsonSerialize(): array
99103
'switchTime' => $this->switchTime ? $this->switchTime->format(\DateTime::RFC3339_EXTENDED) : null,
100104
'status' => $this->status,
101105
'manualTransferJobIds' => json_encode($this->manualTransferJobIds),
102-
'workspaceName' => $this->workspaceName
106+
'workspaceName' => $this->workspaceName,
107+
'accountId' => $this->accountId,
103108
];
104109
}
105110

106111
public function withEndTime(\DateTimeInterface $endTime): self
107112
{
108-
return new self($this->prunnerJobId, $this->startTime, $endTime, $this->switchTime, $this->status, $this->manualTransferJobIds);
113+
return new self($this->prunnerJobId, $this->startTime, $endTime, $this->switchTime, $this->status, $this->manualTransferJobIds, $this->workspaceName, $this->accountId);
109114
}
110115

111116
public function withSwitchTime(\DateTimeInterface $switchTime): self
112117
{
113-
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $switchTime, $this->status, $this->manualTransferJobIds);
118+
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $switchTime, $this->status, $this->manualTransferJobIds, $this->workspaceName, $this->accountId);
114119
}
115120

116121
public function withStatus(NodeRenderingCompletionStatus $status): self
117122
{
118-
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $this->switchTime, $status, $this->manualTransferJobIds);
123+
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $this->switchTime, $status, $this->manualTransferJobIds, $this->workspaceName, $this->accountId);
119124
}
120125

121126
public function withAdditionalManualTransferJobId(PrunnerJobId $prunnerJobId): self
122127
{
123128
$manualTransferIdArray = self::getManualTransferJobIds();
124129
$manualTransferIdArray[] = $prunnerJobId;
125-
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $this->switchTime, $this->status, $manualTransferIdArray);
130+
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $this->switchTime, $this->status, $manualTransferIdArray, $this->workspaceName, $this->accountId);
126131
}
127132

128133
public function getPrunnerJobId(): PrunnerJobId
@@ -163,4 +168,9 @@ public function getWorkspaceName(): ?string
163168
return $this->workspaceName;
164169
}
165170

171+
public function getAccountId(): ?string
172+
{
173+
return $this->accountId;
174+
}
175+
166176
}

Classes/PrepareContentRelease/Infrastructure/RedisContentReleaseService.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ class RedisContentReleaseService
3838
*/
3939
protected $redisContentReleaseService;
4040

41-
public function createContentRelease(ContentReleaseIdentifier $contentReleaseIdentifier, PrunnerJobId $prunnerJobId, ContentReleaseLogger $contentReleaseLogger, string $workspaceName = 'live'): void
41+
public function createContentRelease(ContentReleaseIdentifier $contentReleaseIdentifier, PrunnerJobId $prunnerJobId, ContentReleaseLogger $contentReleaseLogger, string $workspaceName = 'live', string $accountId = 'cli'): void
4242
{
4343
$redis = $this->redisClientManager->getPrimaryRedis();
44-
$metadata = ContentReleaseMetadata::create($prunnerJobId, new \DateTimeImmutable(), $workspaceName);
44+
$metadata = ContentReleaseMetadata::create($prunnerJobId, new \DateTimeImmutable(), $workspaceName, $accountId);
4545
$redis->multi();
4646
try {
4747
$redis->zAdd('contentStore:registeredReleases', 0, $contentReleaseIdentifier->getIdentifier());

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

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Flowpack.DecoupledContentStore.BackendController.index = Neos.Fusion:Component {
5757
<span @if.isActive={item.active} class="neos-badge neos-badge-info">active</span>
5858
<span @if.errors={item.errorCount} class="neos-badge neos-badge-important" title="errors" data-neos-toggle="tooltip">{item.errorCount}</span>
5959
</td>
60+
<td>{item.metadata.accountId}</td>
6061
<td>
6162
{props.enumeratedDocumentNodesCount}
6263
</td>
@@ -93,6 +94,7 @@ Flowpack.DecoupledContentStore.BackendController.index = Neos.Fusion:Component {
9394
<thead>
9495
<tr>
9596
<th style="width: 240px">Identifier</th>
97+
<th>Author</th>
9698
<th style="width: 200px">Page Count</th>
9799
<th style="width: 200px">Render Progress</th>
98100
<th style="width: 200px">Iterations</th>

pipelines_template.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pipelines:
3434
################################################################################
3535
prepare_finished:
3636
script:
37-
- ./flow contentReleasePrepare:createContentRelease {{ .contentReleaseId }} {{ .__jobID }} {{ .workspaceName }}
37+
- ./flow contentReleasePrepare:createContentRelease {{ .contentReleaseId }} {{ .__jobID }} --workspaceName {{ .workspaceName }} --accountId {{ .accountId }}
3838
- ./flow contentReleasePrepare:ensureAllOtherInProgressContentReleasesWillBeTerminated {{ .contentReleaseId }}
3939

4040
################################################################################

0 commit comments

Comments
 (0)