Skip to content

Commit 461815c

Browse files
committed
TASK: Adjustments after workspace service fixes
see #5334
1 parent 2d3e48b commit 461815c

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ public function reviewAction(WorkspaceName $workspace): void
213213
$workspaceMetadata = $this->workspaceService->getWorkspaceMetadata($contentRepositoryId, $workspace);
214214
$baseWorkspaceMetadata = null;
215215
$baseWorkspacePermissions = null;
216-
if ($workspaceObj->baseWorkspaceName !== null) {
217-
$baseWorkspace = $contentRepository->findWorkspaceByName($workspaceObj->baseWorkspaceName);
218-
assert($baseWorkspace !== null);
216+
$baseWorkspace = $workspaceObj->baseWorkspaceName !== null
217+
? $contentRepository->findWorkspaceByName($workspaceObj->baseWorkspaceName)
218+
: null;
219+
if ($baseWorkspace !== null) {
219220
$baseWorkspaceMetadata = $this->workspaceService->getWorkspaceMetadata($contentRepositoryId, $baseWorkspace->workspaceName);
220221
$baseWorkspacePermissions = $this->authorizationService->getWorkspacePermissions($contentRepositoryId, $baseWorkspace->workspaceName, $this->securityContext->getRoles(), $currentUser->getId());
221222
}
@@ -225,7 +226,7 @@ public function reviewAction(WorkspaceName $workspace): void
225226
'baseWorkspaceName' => $workspaceObj->baseWorkspaceName,
226227
'baseWorkspaceLabel' => $baseWorkspaceMetadata?->title->value,
227228
'canPublishToBaseWorkspace' => $baseWorkspacePermissions?->write ?? false,
228-
'canPublishToWorkspace' => $workspacePermissions?->write ?? false,
229+
'canPublishToWorkspace' => $workspacePermissions->write,
229230
'siteChanges' => $this->computeSiteChanges($workspaceObj, $contentRepository),
230231
'contentDimensions' => $contentRepository->getContentDimensionSource()->getContentDimensionsOrderedByPriority()
231232
]);
@@ -369,10 +370,10 @@ public function updateAction(
369370
);
370371

371372
// Update Base Workspace
372-
$this->workspaceService->setBaseWorkspace(
373+
$this->workspacePublishingService->changeBaseWorkspace(
373374
$contentRepositoryId,
374375
$workspaceName,
375-
$baseWorkspace,
376+
$baseWorkspace
376377
);
377378

378379
$this->addFlashMessage(
@@ -495,19 +496,19 @@ public function editWorkspaceRoleAssignmentsAction(WorkspaceName $workspaceName)
495496
$workspaceRoleAssignments = [];
496497

497498
foreach ($this->workspaceService->getWorkspaceRoleAssignments($contentRepositoryId, $workspaceName) as $workspaceRoleAssignment) {
498-
$subjectLabel = match ($workspaceRoleAssignment->subjectType) {
499+
$subjectLabel = match ($workspaceRoleAssignment->subject->type) {
499500
WorkspaceRoleSubjectType::USER => $this->userService->findUserById(UserId::fromString($workspaceRoleAssignment->subject->value))?->getLabel(),
500-
default => $workspaceRoleAssignment->subject->value,
501+
WorkspaceRoleSubjectType::GROUP => $workspaceRoleAssignment->subject->value,
501502
};
502503

503504
$roleLabel = $workspaceRoleAssignment->role->value;
504505

505506
$workspaceRoleAssignments[] = new RoleAssignmentListItem(
506507
subjectValue: $workspaceRoleAssignment->subject->value,
507508
subjectLabel: $subjectLabel,
508-
subjectTypeValue: $workspaceRoleAssignment->subjectType->value,
509+
subjectTypeValue: $workspaceRoleAssignment->subject->type->value,
509510
roleLabel: $roleLabel,
510-
subjectType: $workspaceRoleAssignment->subjectType->value,
511+
subjectType: $workspaceRoleAssignment->subject->type->value,
511512
);
512513
}
513514

@@ -572,8 +573,8 @@ public function addWorkspaceRoleAssignmentAction(
572573
{
573574
// TODO: Validate if user can add role assignment to workspace
574575

575-
$subject = WorkspaceRoleSubject::fromString($subjectValue);
576576
$subjectType = WorkspaceRoleSubjectType::from($subjectTypeValue);
577+
$subject = WorkspaceRoleSubject::create($subjectType, $subjectValue);
577578
$role = WorkspaceRole::from($roleValue);
578579

579580
if ($subjectType === WorkspaceRoleSubjectType::USER) {
@@ -612,8 +613,10 @@ public function deleteWorkspaceRoleAssignmentAction(WorkspaceName $workspaceName
612613
$this->workspaceService->unassignWorkspaceRole(
613614
$contentRepositoryId,
614615
$workspaceName,
615-
WorkspaceRoleSubjectType::from($subjectType),
616-
WorkspaceRoleSubject::fromString($subjectValue),
616+
WorkspaceRoleSubject::create(
617+
WorkspaceRoleSubjectType::from($subjectType),
618+
$subjectValue
619+
)
617620
);
618621
} catch (\Exception $e) {
619622
// TODO: error handling
@@ -1535,7 +1538,7 @@ private function addUserRoleAssignment(WorkspaceName $workspaceName, WorkspaceRo
15351538
);
15361539
}
15371540

1538-
private function addGroupRoleAssignment(WorkspaceName $workspaceName, WorkspaceRoleSubject $subject, WorkspaceRole $role)
1541+
private function addGroupRoleAssignment(WorkspaceName $workspaceName, WorkspaceRoleSubject $subject, WorkspaceRole $role): void
15391542
{
15401543
// TODO check if group exists?
15411544
$this->workspaceService->assignWorkspaceRole(

Neos.Workspace.Ui/Classes/ViewModel/RoleAssignmentListItem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
#[Flow\Proxy(false)]
2828
final readonly class RoleAssignmentListItem
2929
{
30+
// todo $subjectType and $subjectTypeValue are exact the same???
3031
public function __construct(
3132
public string $subjectValue,
3233
public string $subjectLabel,
3334
public string $subjectTypeValue,
3435
public string $roleLabel,
3536
public string $subjectType,
36-
)
37-
{
37+
) {
3838
}
3939
}

0 commit comments

Comments
 (0)