Skip to content

Commit

Permalink
Merge pull request neos#3759 from neos/feature/conflict-resolution-01…
Browse files Browse the repository at this point in the history
…/publishing-modal

!!!FEATURE: Lock the UI and present a modal during publish/discard
  • Loading branch information
grebaldi authored Apr 25, 2024
2 parents ae55434 + 4c80ffa commit 2485e9e
Show file tree
Hide file tree
Showing 56 changed files with 2,868 additions and 689 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{yml,yaml,json}]
[*.{yml,yaml,json,xlf}]
indent_size = 2

[*.md]
Expand Down
65 changes: 65 additions & 0 deletions Classes/Application/ReloadNodes/MinimalNodeForTree.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/*
* This file is part of the Neos.Neos.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\Neos\Ui\Application\ReloadNodes;

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

/**
* A helper DTO containing a minimal node representation as needed for
* the document or content tree
*
* @internal for communication within the Neos UI only
*/
#[Flow\Proxy(false)]
final readonly class MinimalNodeForTree implements \JsonSerializable
{
/**
* @param array{nodeAddress:string}&array<string,mixed> $data
*/
private function __construct(private array $data)
{
}

public static function tryFromNode(
Node $node,
NodeInfoHelper $nodeInfoHelper,
ActionRequest $actionRequest
): ?self {
/** @var null|(array{nodeAddress:string}&array<string,mixed>) $data */
$data = $nodeInfoHelper
->renderNodeWithMinimalPropertiesAndChildrenInformation(
node: $node,
actionRequest: $actionRequest
);

return $data ? new self($data) : null;
}

public function getNodeAddressAsString(): string
{
return $this->data['nodeAddress'];
}

/**
* @return array<string,mixed>
*/
public function jsonSerialize(): array
{
return $this->data;
}
}
22 changes: 22 additions & 0 deletions Classes/Application/ReloadNodes/NoDocumentNodeWasFound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the Neos.Neos.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\Neos\Ui\Application\ReloadNodes;

/**
* @internal for communication within the Neos UI only
*/
final class NoDocumentNodeWasFound extends \Exception
{
}
22 changes: 22 additions & 0 deletions Classes/Application/ReloadNodes/NoSiteNodeWasFound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the Neos.Neos.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\Neos\Ui\Application\ReloadNodes;

/**
* @internal for communication within the Neos UI only
*/
final class NoSiteNodeWasFound extends \Exception
{
}
66 changes: 66 additions & 0 deletions Classes/Application/ReloadNodes/NodeMap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

/*
* This file is part of the Neos.Neos.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\Neos\Ui\Application\ReloadNodes;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

/**
* Helper DTO for collections of nodes
*
* @internal for communication within the Neos UI only
*/
#[Flow\Proxy(false)]
final readonly class NodeMap implements \JsonSerializable
{
/** @var MinimalNodeForTree[] */
private array $items;

public function __construct(MinimalNodeForTree ...$items)
{
$this->items = $items;
}

/**
* @param class-string<MinimalNodeForTree> $nodeRepresentationClass
*/
public static function builder(
string $nodeRepresentationClass,
NodeInfoHelper $nodeInfoHelper,
ActionRequest $actionRequest
): NodeMapBuilder {
return new NodeMapBuilder(
nodeRepresentationClass: $nodeRepresentationClass,
nodeInfoHelper: $nodeInfoHelper,
actionRequest: $actionRequest,
);
}

/**
* @return \stdClass|(array<string,MinimalNodeForTree>)
*/
public function jsonSerialize(): mixed
{
$result = [];
foreach ($this->items as $item) {
$result[$item->getNodeAddressAsString()] = $item;
}

return $result ? $result : new \stdClass;
}
}
60 changes: 60 additions & 0 deletions Classes/Application/ReloadNodes/NodeMapBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/*
* This file is part of the Neos.Neos.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\Neos\Ui\Application\ReloadNodes;

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

/**
* @internal for communication within the Neos UI only
*/
#[Flow\Proxy(false)]
final class NodeMapBuilder
{
/**
* @var MinimalNodeForTree[]
*/
private array $items;

/**
* @param class-string<MinimalNodeForTree> $nodeRepresentationClass
*/
public function __construct(
private readonly string $nodeRepresentationClass,
private readonly NodeInfoHelper $nodeInfoHelper,
private readonly ActionRequest $actionRequest
) {
}

public function addNode(Node $node): void
{
$item = $this->nodeRepresentationClass::tryFromNode(
node: $node,
nodeInfoHelper: $this->nodeInfoHelper,
actionRequest: $this->actionRequest
);

if ($item !== null) {
$this->items[] = $item;
}
}

public function build(): NodeMap
{
return new NodeMap(...$this->items);
}
}
61 changes: 61 additions & 0 deletions Classes/Application/ReloadNodes/ReloadNodesQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

/*
* This file is part of the Neos.Neos.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\Neos\Ui\Application\ReloadNodes;

use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\Flow\Annotations as Flow;

/**
* The application layer level query DTO to find all nodes the UI needs
* to refresh its in-memory node cache
*
* @internal for communication within the Neos UI only
*/
#[Flow\Proxy(false)]
final readonly class ReloadNodesQuery
{
public function __construct(
public ContentRepositoryId $contentRepositoryId,
public WorkspaceName $workspaceName,
public DimensionSpacePoint $dimensionSpacePoint,
public NodeAggregateId $siteId,
public NodeAggregateId $documentId,
public NodeAggregateIds $ancestorsOfDocumentIds,
public NodeAggregateIds $toggledNodesIds,
public NodeAggregateIds $clipboardNodesIds
) {
}

/**
* @param array<mixed> $values
*/
public static function fromArray(array $values): self
{
return new self(
contentRepositoryId: ContentRepositoryId::fromString($values['contentRepositoryId']),
workspaceName: WorkspaceName::fromString($values['workspaceName']),
dimensionSpacePoint: DimensionSpacePoint::fromLegacyDimensionArray($values['dimensionSpacePoint']),
siteId: NodeAggregateId::fromString($values['siteId']),
documentId: NodeAggregateId::fromString($values['documentId']),
ancestorsOfDocumentIds: NodeAggregateIds::fromArray($values['ancestorsOfDocumentIds']),
toggledNodesIds: NodeAggregateIds::fromArray($values['toggledNodesIds']),
clipboardNodesIds: NodeAggregateIds::fromArray($values['clipboardNodesIds'])
);
}
}
Loading

0 comments on commit 2485e9e

Please sign in to comment.