Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions Neos.Neos/Classes/Domain/Model/WorkspaceRoleAssignments.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,6 @@ public static function createForSharedWorkspace(UserId $userId): self
);
}

/**
* Default role assignment to be specified at creation via {@see WorkspaceService::createSharedWorkspace()}
*
* The specified user is manager
*/
public static function createForPrivateWorkspace(UserId $userId): self
{
return new self(
WorkspaceRoleAssignment::createForUser(
$userId,
WorkspaceRole::MANAGER,
)
);
}

public function isEmpty(): bool
{
return $this->assignments === [];
Expand Down
258 changes: 214 additions & 44 deletions Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the Neos.Workspace.Ui package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

declare(strict_types=1);

namespace Neos\Workspace\Ui\ViewModel;

use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Model\WorkspaceTitle;

#[Flow\Proxy(false)]
final readonly class ConfirmDeleteWorkspaceRoleAssignmentFormData
{
public function __construct(
public WorkspaceName $workspaceName,
public WorkspaceTitle $workspaceTitle,
public string $subjectValue,
public string $subjectType,
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
* This file is part of the Neos.Workspace.Ui package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

declare(strict_types=1);

namespace Neos\Workspace\Ui\ViewModel;

use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Model\WorkspaceTitle;

/**
* Derived from Neos\Neos\Domain\Model\WorkspaceRoleAssignment
*
* WHY: We need a custom DTO here, because
* - subject.value is either userId or group identifier (the latter would be fine, but for user we want the label)
* - role should be internationalized, maybe
*/
#[Flow\Proxy(false)]
final readonly class CreateWorkspaceRoleAssignmentFormData
{
public function __construct(

Check failure on line 31 in Neos.Workspace.Ui/Classes/ViewModel/CreateWorkspaceRoleAssignmentFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 Test linting-unit-functionaltests-mysql (deps: highest)

Method Neos\Workspace\Ui\ViewModel\CreateWorkspaceRoleAssignmentFormData::__construct() has parameter $options with no value type specified in iterable type array.

Check failure on line 31 in Neos.Workspace.Ui/Classes/ViewModel/CreateWorkspaceRoleAssignmentFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

Method Neos\Workspace\Ui\ViewModel\CreateWorkspaceRoleAssignmentFormData::__construct() has parameter $options with no value type specified in iterable type array.

Check failure on line 31 in Neos.Workspace.Ui/Classes/ViewModel/CreateWorkspaceRoleAssignmentFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

Method Neos\Workspace\Ui\ViewModel\CreateWorkspaceRoleAssignmentFormData::__construct() has parameter $options with no value type specified in iterable type array.
public WorkspaceName $workspaceName,
public WorkspaceTitle $workspaceTitle,
public array $options,
/**
* TODO: translate role labels?
* Options for the workspaceManager selector where the key is the role identifier and the value is the role label.
* @var array<string, string>
*/
public array $roleOptions
)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public function __construct(
public bool $workspaceHasChanges,
public WorkspaceName $baseWorkspaceName,
public array $baseWorkspaceOptions,
public bool $isShared,
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
* This file is part of the Neos.Workspace.Ui package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

declare(strict_types=1);

namespace Neos\Workspace\Ui\ViewModel;

use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Model\WorkspaceTitle;

/**
* Derived from Neos\Neos\Domain\Model\WorkspaceRoleAssignment
*
* WHY: We need a custom DTO here, because
* - subject.value is either userId or group identifier (the latter would be fine, but for user we want the label)
* - role should be internationalized, maybe
*/
#[Flow\Proxy(false)]
final readonly class EditWorkspaceRoleAssignmentsFormData
{
/**
* @param array<RoleAssignmentListItem> $roleAssignments
*/
public function __construct(

Check failure on line 34 in Neos.Workspace.Ui/Classes/ViewModel/EditWorkspaceRoleAssignmentsFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 Test linting-unit-functionaltests-mysql (deps: highest)

PHPDoc tag @param references unknown parameter: $roleAssignments

Check failure on line 34 in Neos.Workspace.Ui/Classes/ViewModel/EditWorkspaceRoleAssignmentsFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 Test linting-unit-functionaltests-mysql (deps: highest)

Method Neos\Workspace\Ui\ViewModel\EditWorkspaceRoleAssignmentsFormData::__construct() has parameter $userRoleAssignments with no value type specified in iterable type array.

Check failure on line 34 in Neos.Workspace.Ui/Classes/ViewModel/EditWorkspaceRoleAssignmentsFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 Test linting-unit-functionaltests-mysql (deps: highest)

Method Neos\Workspace\Ui\ViewModel\EditWorkspaceRoleAssignmentsFormData::__construct() has parameter $groupRoleAssignments with no value type specified in iterable type array.

Check failure on line 34 in Neos.Workspace.Ui/Classes/ViewModel/EditWorkspaceRoleAssignmentsFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

PHPDoc tag @param references unknown parameter: $roleAssignments

Check failure on line 34 in Neos.Workspace.Ui/Classes/ViewModel/EditWorkspaceRoleAssignmentsFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

Method Neos\Workspace\Ui\ViewModel\EditWorkspaceRoleAssignmentsFormData::__construct() has parameter $userRoleAssignments with no value type specified in iterable type array.

Check failure on line 34 in Neos.Workspace.Ui/Classes/ViewModel/EditWorkspaceRoleAssignmentsFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

Method Neos\Workspace\Ui\ViewModel\EditWorkspaceRoleAssignmentsFormData::__construct() has parameter $groupRoleAssignments with no value type specified in iterable type array.

Check failure on line 34 in Neos.Workspace.Ui/Classes/ViewModel/EditWorkspaceRoleAssignmentsFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

PHPDoc tag @param references unknown parameter: $roleAssignments

Check failure on line 34 in Neos.Workspace.Ui/Classes/ViewModel/EditWorkspaceRoleAssignmentsFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

Method Neos\Workspace\Ui\ViewModel\EditWorkspaceRoleAssignmentsFormData::__construct() has parameter $userRoleAssignments with no value type specified in iterable type array.

Check failure on line 34 in Neos.Workspace.Ui/Classes/ViewModel/EditWorkspaceRoleAssignmentsFormData.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

Method Neos\Workspace\Ui\ViewModel\EditWorkspaceRoleAssignmentsFormData::__construct() has parameter $groupRoleAssignments with no value type specified in iterable type array.
public WorkspaceName $workspaceName,
public WorkspaceTitle $workspaceTitle,
public bool $roleAssignmentsEditable,
public array $userRoleAssignments,
public array $groupRoleAssignments,
) {
}
}
39 changes: 39 additions & 0 deletions Neos.Workspace.Ui/Classes/ViewModel/RoleAssignmentListItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* This file is part of the Neos.Workspace.Ui package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

declare(strict_types=1);

namespace Neos\Workspace\Ui\ViewModel;

use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Model\WorkspaceRoleSubjectType;

/**
* Derived from Neos\Neos\Domain\Model\WorkspaceRoleAssignment
*
* WHY: We need a custom DTO here, because
* - subject.value is either userId or group identifier (the latter would be fine, but for user we want the label)
* - role should be internationalized, maybe
*/
#[Flow\Proxy(false)]
final readonly class RoleAssignmentListItem
{
// todo $subjectType and $subjectTypeValue are exact the same???
public function __construct(
public string $subjectValue,
public string $subjectLabel,
public string $subjectTypeValue,
public string $roleLabel,
public string $subjectType,
) {
}
}
5 changes: 2 additions & 3 deletions Neos.Workspace.Ui/Classes/ViewModel/WorkspaceListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ public function isPersonal(): bool
return $this->classification === WorkspaceClassification::PERSONAL->value;
}

// todo remove this old shared vs private mapping!
public function isPrivate(): bool
{
if ($this->classification !== WorkspaceClassification::SHARED->value) {
return false;
}
foreach ($this->roleAssignments as $roleAssignment) {
if ($roleAssignment->role === WorkspaceRole::COLLABORATOR) {
return false;
Expand All @@ -59,6 +57,7 @@ public function isPrivate(): bool
return true;
}

// todo remove this old shared vs private mapping!
public function isShared(): bool
{
foreach ($this->roleAssignments as $roleAssignment) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Neos.Workspace.Ui.WorkspaceController.confirmDeleteWorkspaceRoleAssignment = Neos.Fusion:Component {
/// \Neos\Workspace\Ui\ViewModel\ConfirmDeleteWorkspaceRoleAssignmentFormData
confirmDeleteWorkspaceRoleAssignmentFormData = ${confirmDeleteWorkspaceRoleAssignmentFormData}

renderer = afx`
<Neos.Workspace.Ui:Component.Modal.ConfirmDeleteWorkspaceRoleAssignment
workspaceName={props.confirmDeleteWorkspaceRoleAssignmentFormData.workspaceName.value}
workspaceTitle={props.confirmDeleteWorkspaceRoleAssignmentFormData.workspaceTitle.value}
subjectValue={props.confirmDeleteWorkspaceRoleAssignmentFormData.subjectValue}
subjectType={props.confirmDeleteWorkspaceRoleAssignmentFormData.subjectType}
/>
`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Neos.Workspace.Ui.WorkspaceController.createGroupWorkspaceRoleAssignment = Neos.Fusion:Component {
createWorkspaceRoleAssignmentFormData = ${createWorkspaceRoleAssignmentFormData}

renderer = afx`
<Neos.Workspace.Ui:Component.Modal.CreateGroupWorkspaceRoleAssignment
workspaceName={props.createWorkspaceRoleAssignmentFormData.workspaceName.value}
workspaceTitle={props.createWorkspaceRoleAssignmentFormData.workspaceTitle.value}
options={props.createWorkspaceRoleAssignmentFormData.options}
roleOptions={props.createWorkspaceRoleAssignmentFormData.roleOptions}
/>
`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Neos.Workspace.Ui.WorkspaceController.createUserWorkspaceRoleAssignment = Neos.Fusion:Component {
createWorkspaceRoleAssignmentFormData = ${createWorkspaceRoleAssignmentFormData}

renderer = afx`
<Neos.Workspace.Ui:Component.Modal.CreateUserWorkspaceRoleAssignment
workspaceName={props.createWorkspaceRoleAssignmentFormData.workspaceName.value}
workspaceTitle={props.createWorkspaceRoleAssignmentFormData.workspaceTitle.value}

options={props.createWorkspaceRoleAssignmentFormData.options}
roleOptions={props.createWorkspaceRoleAssignmentFormData.roleOptions}
/>
`
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ Neos.Workspace.Ui.WorkspaceController.edit = Neos.Fusion:Component {
baseWorkspaceName={props.editWorkspaceFormData.baseWorkspaceName.value}
workspaceHasChanges={props.editWorkspaceFormData.workspaceHasChanges}
baseWorkspaceOptions={props.editWorkspaceFormData.baseWorkspaceOptions}
isShared={props.editWorkspaceFormData.isShared}

roleAssignmentsVisible={props.editWorkspaceFormData.roleAssignmentsVisible}
roleAssignmentsEditable={props.editWorkspaceFormData.roleAssignmentsEditable}
roleAssignments={props.editWorkspaceFormData.roleAssignments}
roleAssignmentUserOptions={props.editWorkspaceFormData.roleAssignmentUserOptions}
roleAssignmentGroupOptions={props.editWorkspaceFormData.roleAssignmentGroupOptions}
/>
`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Neos.Workspace.Ui.WorkspaceController.editWorkspaceRoleAssignments = Neos.Fusion:Component {
/// \Neos\Workspace\Ui\ViewModel\EditWorkspaceRoleAssignmentsFormData
editWorkspaceRoleAssignmentsFormData = ${editWorkspaceRoleAssignmentsFormData}

renderer = afx`
<Neos.Workspace.Ui:Component.Modal.EditWorkspaceRoleAssignments
workspaceName={props.editWorkspaceRoleAssignmentsFormData.workspaceName.value}
workspaceTitle={props.editWorkspaceRoleAssignmentsFormData.workspaceTitle.value}
roleAssignmentsEditable={props.editWorkspaceRoleAssignmentsFormData.roleAssignmentsEditable}

userRoleAssignments={props.editWorkspaceRoleAssignmentsFormData.userRoleAssignments}

groupRoleAssignments={props.editWorkspaceRoleAssignmentsFormData.groupRoleAssignments}

userOptions={props.editWorkspaceRoleAssignmentsFormData.roleAssignmentUserOptions}
groupOptions={props.editWorkspaceRoleAssignmentsFormData.roleAssignmentGroupOptions}
subjectTypeOptions={props.editWorkspaceRoleAssignmentsFormData.roleAssignmentSubjectTypeOptions}
roleOptions={props.editWorkspaceRoleAssignmentsFormData.roleAssignmentRoleOptions}
/>
`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
##
# Renders a Workspace Role Assignment list
#
prototype(Neos.Workspace.Ui:Component.WorkspaceRoleAssignmentTable) < prototype(Neos.Fusion:Component) {
/// string
workspaceName = null
/// array<Neos\Workspace\Ui\ViewModel\RoleAssignmentListItem>
roleAssignments=${[]}

@private {
i18n = ${I18n.id('').source('Main').package('Neos.Workspace.Ui')}
confirmDeleteWorkspaceRoleAssignmentPopoverId = 'confirm-delete-workspace-role-assignment-popover'

}

renderer = afx`
<table class="role-assignments-table workspace-table">
<thead>
<tr>
<th>{private.i18n.id('workspaces.workspace.workspaceRoleAssignment.subject')}</th>
<th>{private.i18n.id('workspaces.workspace.workspaceRoleAssignment.role')}</th>
<th>
{private.i18n.id('workspaces.workspace.workspaceRoleAssignment.actions')}
</th>
</tr>
</thead>
<tbody>
<Neos.Fusion:Loop items={props.roleAssignments} itemName="roleAssignment">
<Neos.Workspace.Ui:Component.WorkspaceRoleAssignmentTableRow
workspaceName={props.workspaceName}
roleAssignmentsEditable={props.roleAssignmentsEditable}
roleAssignmentFormData={roleAssignment}
/>
</Neos.Fusion:Loop>
</tbody>
</table>
`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
##
# Renders a single WorkspaceRoleAssignment list item
#
prototype(Neos.Workspace.Ui:Component.WorkspaceRoleAssignmentTableRow) < prototype(Neos.Fusion:Component) {
/// string
workspaceName = null
/// bool
roleAssignmentsEditable = false
/// Neos\Workspace\Ui\ViewModel\RoleAssignmentListItem
roleAssignmentFormData = null

@private {
i18n = ${I18n.id('').source('Main').package('Neos.Workspace.Ui')}
confirmDeleteWorkspaceRoleAssignmentPopoverId = 'confirm-delete-workspace-role-assignment-popover'
confirmDeleteWorkspaceRoleAssignmentUri = Neos.Fusion:ActionUri {
action = 'confirmDeleteWorkspaceRoleAssignment'
format = 'htmx'
arguments {
workspaceName = ${props.workspaceName}
subjectValue = ${props.roleAssignmentFormData.subjectValue}
subjectType = ${props.roleAssignmentFormData.subjectType}
}
}
}

renderer = afx`
<tr>
<td>{props.roleAssignmentFormData.subjectLabel}</td>
<td>{private.i18n.id('workspaces.workspace.workspaceRoleAssignment.role.label.' + props.roleAssignmentFormData.roleLabel)}</td>
<td>
<Neos.Workspace.Ui:Component.Button
isDanger
title="TODO title"
icon="trash-alt icon-white"
attributes.disabled={!props.roleAssignmentsEditable}
attributes.hx-get={private.confirmDeleteWorkspaceRoleAssignmentUri}
attributes.hx-target={'#' + private.confirmDeleteWorkspaceRoleAssignmentPopoverId}
attributes.hx-swap='outerHTML'
attributes.hx-on--after-request={'document.getElementById("' + private.confirmDeleteWorkspaceRoleAssignmentPopoverId + '").showPopover()'}
/>
</td>
</tr>
`
}
Loading
Loading