diff --git a/Classes/Controller/PreferencesController.php b/Classes/Controller/PreferencesController.php index c3beb2e..9e3797b 100644 --- a/Classes/Controller/PreferencesController.php +++ b/Classes/Controller/PreferencesController.php @@ -13,20 +13,20 @@ */ use Doctrine\ORM\EntityManagerInterface; -use Neos\ContentRepository\Domain\Model\NodeInterface; +use Neos\ContentRepository\Core\Feature\Security\Exception\AccessDenied; +use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\Controller\ActionController; use Neos\Flow\Mvc\View\JsonView; -use Neos\Neos\Controller\CreateContentContextTrait; use Neos\Neos\Domain\Model\UserPreferences; +use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface; use Neos\Neos\Service\LinkingService; use Neos\Neos\Service\UserService; -use Neos\Neos\Ui\ContentRepository\Service\NodeService; class PreferencesController extends ActionController { - use CreateContentContextTrait; - protected const FAVOURITES_PREFERENCE = 'commandBar.favourites'; protected const RECENT_COMMANDS_PREFERENCE = 'commandBar.recentCommands'; protected const RECENT_DOCUMENTS_PREFERENCE = 'commandBar.recentDocuments'; @@ -36,8 +36,9 @@ class PreferencesController extends ActionController public function __construct( protected UserService $userService, protected EntityManagerInterface $entityManager, - protected NodeService $nodeService, protected LinkingService $linkingService, + protected ContentRepositoryRegistry $contentRepositoryRegistry, + protected NodeLabelGeneratorInterface $nodeLabelGenerator, ) { } @@ -47,7 +48,9 @@ public function getPreferencesAction(): void $this->view->assign('value', [ 'favouriteCommands' => $preferences->get(self::FAVOURITES_PREFERENCE) ?? [], 'recentCommands' => $preferences->get(self::RECENT_COMMANDS_PREFERENCE) ?? [], - 'recentDocuments' => $this->mapContextPathsToNodes($preferences->get(self::RECENT_DOCUMENTS_PREFERENCE) ?? []), + 'recentDocuments' => $this->mapContextPathsToNodes( + $preferences->get(self::RECENT_DOCUMENTS_PREFERENCE) ?? [] + ), 'showBranding' => $this->settings['features']['showBranding'], ]); } @@ -94,23 +97,28 @@ public function addRecentCommandAction(string $commandId): void /** * Updates the list of recently used documents in the user preferences * - * @Flow\SkipCsrfProtection - * @param string $nodeContextPath a context path to add to the recently visited documents + * @param string $nodeContextPath a node to add to the recently visited documents */ + #[Flow\SkipCsrfProtection] public function addRecentDocumentAction(string $nodeContextPath): void { $preferences = $this->getUserPreferences(); + /** @var string[]|null $recentDocuments */ $recentDocuments = $preferences->get(self::RECENT_DOCUMENTS_PREFERENCE); if ($recentDocuments === null) { $recentDocuments = []; } // Remove the command from the list if it is already in there (to move it to the top) - $recentDocuments = array_filter($recentDocuments, - static fn($existingContextPath) => $existingContextPath !== $nodeContextPath); + $recentDocuments = array_filter( + $recentDocuments, + static fn($existingContextPath) => $existingContextPath !== $nodeContextPath + ); + // Add the path to the top of the list array_unshift($recentDocuments, $nodeContextPath); + // Limit the list to 5 items $recentDocuments = array_slice($recentDocuments, 0, 5); @@ -130,32 +138,52 @@ protected function getUserPreferences(): UserPreferences } /** - * @var string[] $contextPaths + * @param string[] $nodeContextPaths */ - protected function mapContextPathsToNodes(array $contextPaths): array - { - return array_reduce($contextPaths, function (array $carry, string $contextPath) { - $node = $this->nodeService->getNodeFromContextPath($contextPath); - if ($node instanceof NodeInterface) { + protected function mapContextPathsToNodes( + array $nodeContextPaths, + ): array { + return array_filter( + array_map(function (string $nodeContextPath) { + $nodeAddress = NodeAddress::fromJsonString($nodeContextPath); + + $contentRepository = $this->contentRepositoryRegistry->get($nodeAddress->contentRepositoryId); + try { + $subgraph = $contentRepository->getContentSubgraph( + $nodeAddress->workspaceName, + $nodeAddress->dimensionSpacePoint + ); + } catch (AccessDenied) { + // If the user does not have access to the subgraph, we skip this node + return null; + } + + $node = $subgraph->findNodeById($nodeAddress->aggregateId); + if (!$node) { + return null; + } + $uri = $this->getNodeUri($node); - if ($uri) { - $carry[]= [ - 'name' => $node->getLabel(), - 'icon' => $node->getNodeType()->getConfiguration('ui.icon') ?? 'question', - 'uri' => $this->getNodeUri($node), - 'contextPath' => $contextPath, - ]; + if (!$uri) { + return null; } - } - return $carry; - }, []); + + $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($node->nodeTypeName); + return [ + 'name' => $this->nodeLabelGenerator->getLabel($node), + 'icon' => $nodeType?->getConfiguration('ui.icon') ?? 'question', + 'uri' => $this->getNodeUri($node), + 'contextPath' => $nodeContextPath, + ]; + }, $nodeContextPaths) + ); } - protected function getNodeUri(NodeInterface $node): string + protected function getNodeUri(Node $node): string { try { return $this->linkingService->createNodeUri($this->controllerContext, $node, null, 'html', true); - } catch (\Exception $e) { + } catch (\Exception) { return ''; } } diff --git a/Classes/Domain/Dto/CommandDto.php b/Classes/Domain/Dto/CommandDto.php index 2cbad36..96c228a 100644 --- a/Classes/Domain/Dto/CommandDto.php +++ b/Classes/Domain/Dto/CommandDto.php @@ -15,16 +15,16 @@ use Neos\Flow\Annotations as Flow; #[Flow\Proxy(false)] -class CommandDto implements \JsonSerializable +readonly class CommandDto implements \JsonSerializable { public function __construct( - public readonly string $id, - public readonly string $name, - public readonly string $description, - public readonly string $action, - public readonly string $icon, - public readonly string $category = '', + public string $id, + public string $name, + public string $description, + public string $action, + public string $icon, + public string $category = '', ) { } diff --git a/Classes/Helper/TranslationHelper.php b/Classes/Helper/TranslationHelper.php index 4e04643..c1eece3 100644 --- a/Classes/Helper/TranslationHelper.php +++ b/Classes/Helper/TranslationHelper.php @@ -16,20 +16,22 @@ use Neos\Flow\I18n\EelHelper\TranslationParameterToken; #[Flow\Proxy(false)] -class TranslationHelper +final class TranslationHelper { - public static function translateByShortHandString(string $shortHandString): string { $shortHandStringParts = explode(':', $shortHandString); if (count($shortHandStringParts) === 3) { [$package, $source, $id] = $shortHandStringParts; - return (new TranslationParameterToken($id)) - ->package($package) - ->source(str_replace('.', '/', $source)) - ->translate(); + try { + return (new TranslationParameterToken($id)) + ->package($package) + ->source(str_replace('.', '/', $source)) + ->translate(); + } catch (\Exception) { + return $shortHandString; // Fallback to original string if translation fails + } } - return $shortHandString; } } diff --git a/Classes/Service/DataSource/CommandsDataSource.php b/Classes/Service/DataSource/CommandsDataSource.php index 66f5aa6..aa4d77d 100644 --- a/Classes/Service/DataSource/CommandsDataSource.php +++ b/Classes/Service/DataSource/CommandsDataSource.php @@ -12,10 +12,14 @@ * source code. */ -use Neos\ContentRepository\Domain\Model\NodeInterface; +use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\Flow\Http\Exception; use Neos\Flow\I18n\Translator; +use Neos\Flow\Mvc\Routing\Exception\MissingActionNameException; use Neos\Flow\Mvc\Routing\UriBuilder; +use Neos\Flow\Persistence\Exception\IllegalObjectTypeException; use Neos\Neos\Controller\Backend\MenuHelper; +use Neos\Neos\Domain\Model\SiteNodeName; use Neos\Neos\Service\BackendRedirectionService; use Neos\Neos\Service\DataSource\AbstractDataSource; use Shel\Neos\CommandBar\Domain\Dto\CommandDto; @@ -34,16 +38,25 @@ public function __construct( ) { } - public function getData(NodeInterface $node = null, array $arguments = []): array - { + /** + * @throws Exception + * @throws MissingActionNameException + * @throws IllegalObjectTypeException + */ + public function getData( + Node $node = null, + array $arguments = [] + ): array { $this->uriBuilder->setRequest($this->controllerContext->getRequest()->getMainRequest()); - $sitesForMenu = array_reduce($this->menuHelper->buildSiteList($this->controllerContext), + $sitesForMenu = array_reduce( + $this->menuHelper->buildSiteList($this->controllerContext), + /** @param array{name: string, nodeName: SiteNodeName, uri: string, active: bool} $site */ static function (array $carry, array $site) { if (!$site['uri']) { return $carry; } - $carry[$site['nodeName']] = new CommandDto( + $carry[$site['nodeName']->value] = new CommandDto( $site['name'], $site['name'], '', @@ -51,40 +64,11 @@ static function (array $carry, array $site) { 'globe' ); return $carry; - }, []); + }, + [] + ); - $modulesForMenu = array_reduce($this->menuHelper->buildModuleList($this->controllerContext), - function (array $carry, array $module) { - // Skip modules without submodules - if (!$module['submodules']) { - return $carry; - } - $carry[$module['group']] = [ - 'name' => TranslationHelper::translateByShortHandString($module['label']), - 'description' => TranslationHelper::translateByShortHandString($module['description']), - 'icon' => $module['icon'], - 'subCommands' => array_reduce($module['submodules'], - function (array $carry, array $submodule) { - if ($submodule['hideInMenu']) { - return $carry; - } - $carry[$submodule['module']] = new CommandDto( - $submodule['modulePath'], - TranslationHelper::translateByShortHandString($submodule['label']), - TranslationHelper::translateByShortHandString($submodule['description']), - $this->uriBuilder->uriFor( - 'index', - ['module' => $submodule['modulePath']], - 'Backend\Module', - 'Neos.Neos' - ), - $submodule['icon'], - ); - return $carry; - }, []), - ]; - return $carry; - }, []); + $modulesForMenu = $this->getModuleCommands(); $commands = [ 'preferred-start-module' => new CommandDto( @@ -94,6 +78,7 @@ function (array $carry, array $submodule) { $this->backendRedirectionService->getAfterLoginRedirectionUri($this->controllerContext), 'home' ), + // TODO: Introduce group DTO 'modules' => [ 'name' => $this->translate('CommandDataSource.category.modules'), 'description' => $this->translate('CommandDataSource.category.modules.description'), @@ -104,6 +89,7 @@ function (array $carry, array $submodule) { // Only show site switch command if there is more than one site if (count($sitesForMenu) > 1) { + // TODO: Introduce group DTO $commands['sites'] = [ 'name' => $this->translate('CommandDataSource.category.sites'), 'description' => $this->translate('CommandDataSource.category.sites.description'), @@ -115,8 +101,56 @@ function (array $carry, array $submodule) { return $commands; } - protected function translate($id): string + protected function translate(string $id): string + { + try { + return $this->translator->translateById($id, [], null, null, 'Main', 'Shel.Neos.CommandBar') ?? $id; + } catch (\Exception) { + return $id; + } + } + + protected function getModuleCommands(): mixed { - return $this->translator->translateById($id, [], null, null, 'Main', 'Shel.Neos.CommandBar') ?? $id; + return array_reduce( + $this->menuHelper->buildModuleList($this->controllerContext), + function (array $carry, array $module) { + // Skip modules without submodules + if (!$module['submodules']) { + return $carry; + } + + // TODO: Introduce group DTO + $carry[$module['group']] = [ + 'name' => TranslationHelper::translateByShortHandString($module['label']), + 'description' => TranslationHelper::translateByShortHandString($module['description']), + 'icon' => $module['icon'], + 'subCommands' => array_reduce( + $module['submodules'], + function (array $carry, array $submodule) { + if ($submodule['hideInMenu']) { + return $carry; + } + $carry[$submodule['module']] = new CommandDto( + $submodule['modulePath'], + TranslationHelper::translateByShortHandString($submodule['label']), + TranslationHelper::translateByShortHandString($submodule['description']), + $this->uriBuilder->uriFor( + 'index', + ['module' => $submodule['modulePath']], + 'Backend\Module', + 'Neos.Neos' + ), + $submodule['icon'], + ); + return $carry; + }, + [] + ), + ]; + return $carry; + }, + [] + ); } } diff --git a/Classes/Service/DataSource/SearchNeosDocsDataSource.php b/Classes/Service/DataSource/SearchNeosDocsDataSource.php index b5d5c42..a4c3e42 100644 --- a/Classes/Service/DataSource/SearchNeosDocsDataSource.php +++ b/Classes/Service/DataSource/SearchNeosDocsDataSource.php @@ -13,7 +13,7 @@ */ use GuzzleHttp\Psr7\Uri; -use Neos\ContentRepository\Domain\Model\NodeInterface; +use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\Flow\Annotations as Flow; use Neos\Flow\Http\Client\Browser; use Neos\Flow\Http\Client\CurlEngine; @@ -30,15 +30,15 @@ class SearchNeosDocsDataSource extends AbstractDataSource static protected $identifier = 'shel-neos-commandbar-search-neos-docs'; /** - * @var {enabled: bool, endpoint: string, queryParameter: string} array + * @var array{enabled: bool, endpoint: string, queryParameter: string} $settings */ #[Flow\InjectConfiguration('features.searchNeosDocs', 'Shel.Neos.CommandBar')] - protected $settings; + protected array $settings; /** * @throws Exception */ - public function getData(NodeInterface $node = null, array $arguments = []): array + public function getData(Node $node = null, array $arguments = []): array { $query = $arguments['query'] ?? ''; @@ -52,7 +52,9 @@ public function getData(NodeInterface $node = null, array $arguments = []): arra $endpoint = new Uri($this->settings['endpoint']); try { - $result = $browser->request($endpoint->withQuery($this->settings['queryParameter'] . '=' . urlencode($query))); + $result = $browser->request( + $endpoint->withQuery($this->settings['queryParameter'] . '=' . urlencode($query)) + ); } catch (\Exception $e) { throw new Exception('Could not fetch search results from the Neos documentation', 1676205990, $e); } @@ -61,7 +63,9 @@ public function getData(NodeInterface $node = null, array $arguments = []): arra } // TODO: Implement JSON API in Neos docs to simplify this and provide structured data - $searchResults = $browser->getCrawler()->filterXPath('//div[contains(@class, "search-results")]//div[contains(@class, "search-result")]'); + $searchResults = $browser->getCrawler()->filterXPath( + '//div[contains(@class, "search-results")]//div[contains(@class, "search-result")]' + ); $subCommands = []; $searchResults->slice(0, self::MAX_RESULTS)->each(function (Crawler $searchResult, int $i) use ( diff --git a/Classes/Service/DataSource/SearchNeosPackagesDataSource.php b/Classes/Service/DataSource/SearchNeosPackagesDataSource.php index a8503b7..76bae5c 100644 --- a/Classes/Service/DataSource/SearchNeosPackagesDataSource.php +++ b/Classes/Service/DataSource/SearchNeosPackagesDataSource.php @@ -13,32 +13,28 @@ */ use GuzzleHttp\Psr7\Uri; -use Neos\ContentRepository\Domain\Model\NodeInterface; +use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\Flow\Annotations as Flow; use Neos\Flow\Http\Client\Browser; use Neos\Flow\Http\Client\CurlEngine; use Neos\Neos\Service\DataSource\AbstractDataSource; use Shel\Neos\CommandBar\Domain\Dto\CommandDto; use Shel\Neos\CommandBar\Exception; -use Symfony\Component\DomCrawler\Crawler; class SearchNeosPackagesDataSource extends AbstractDataSource { - - protected const MAX_RESULTS = 10; - static protected $identifier = 'shel-neos-commandbar-search-neos-packages'; /** - * @var {enabled: bool, endpoint: string, queryParameter: string} array + * @var array{enabled: bool, endpoint: string, queryParameter: string} $settings */ #[Flow\InjectConfiguration('features.searchNeosPackages', 'Shel.Neos.CommandBar')] - protected $settings; + protected array $settings = []; /** * @throws Exception */ - public function getData(NodeInterface $node = null, array $arguments = []): array + public function getData(Node $node = null, array $arguments = []): array { $query = $arguments['query'] ?? ''; @@ -62,7 +58,7 @@ public function getData(NodeInterface $node = null, array $arguments = []): arra try { $data = json_decode($result->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR); - } catch (\Exception $e) { + } catch (\Exception) { throw new Exception('Could not decode search results from the Neos package repository', 1682681305); } diff --git a/Classes/Service/DataSource/SearchNodesDataSource.php b/Classes/Service/DataSource/SearchNodesDataSource.php index 98234c1..591b33f 100644 --- a/Classes/Service/DataSource/SearchNodesDataSource.php +++ b/Classes/Service/DataSource/SearchNodesDataSource.php @@ -12,52 +12,88 @@ * source code. */ -use Neos\ContentRepository\Domain\Model\NodeInterface; -use Neos\Neos\Domain\Service\NodeSearchServiceInterface; +use Neos\ContentRepository\Core\NodeType\NodeTypeNames; +use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindDescendantNodesFilter; +use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria; +use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; +use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface; use Neos\Neos\Service\DataSource\AbstractDataSource; use Neos\Neos\Service\LinkingService; use Shel\Neos\CommandBar\Helper\TranslationHelper; class SearchNodesDataSource extends AbstractDataSource { - static protected $identifier = 'shel-neos-commandbar-search-nodes'; public function __construct( - private readonly NodeSearchServiceInterface $nodeSearchService, - private readonly LinkingService $linkingService + private readonly LinkingService $linkingService, + private readonly ContentRepositoryRegistry $contentRepositoryRegistry, + private readonly NodeLabelGeneratorInterface $nodeLabelGenerator, ) { } - public function getData(NodeInterface $node = null, array $arguments = []): array - { + public function getData( + ?Node $node = null, + array $arguments = [] + ): array { $query = $arguments['query'] ?? ''; if (!$node || !$query) { return []; } + $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); + $contentRepository = $this->contentRepositoryRegistry->get($node->contentRepositoryId); - $matchingNodes = $this->nodeSearchService->findByProperties($query, [ - 'Neos.Neos:Document', - 'Neos.Neos:Shortcut', - ], $node->getContext(), $node); + $matchingNodes = $subgraph->findDescendantNodes( + $node->aggregateId, + FindDescendantNodesFilter::create( + NodeTypeCriteria::createWithAllowedNodeTypeNames( + NodeTypeNames::fromStringArray([ + 'Neos.Neos:Document', + 'Neos.Neos:Shortcut', + ]) + ), + searchTerm: $query + ) + ); - return array_values(array_filter(array_map(function (NodeInterface $matchingNode) { - return [ - 'name' => $matchingNode->getLabel(), - 'nodetype' => TranslationHelper::translateByShortHandString($matchingNode->getNodeType()->getLabel()), - 'contextPath' => $matchingNode->getContextPath(), - 'icon' => $matchingNode->getNodeType()->getFullConfiguration()['ui']['icon'] ?? 'file', - 'uri' => $this->getNodeUri($matchingNode), - ]; - }, $matchingNodes), static fn($item) => $item['uri'])); + return array_values( + array_filter( + $matchingNodes->map(function (Node $matchingNode) use ($contentRepository) { + return [ + 'name' => $this->nodeLabelGenerator->getLabel($matchingNode), + 'nodetype' => TranslationHelper::translateByShortHandString( + $contentRepository->getNodeTypeManager()->getNodeType( + $matchingNode->nodeTypeName + )?->getLabel() + ), + 'contextPath' => NodeAddress::fromNode( + $matchingNode + )->toJson(), + 'icon' => $contentRepository->getNodeTypeManager()->getNodeType( + $matchingNode->nodeTypeName + )?->getFullConfiguration()['ui']['icon'] ?? 'file', + 'uri' => $this->getNodeUri($matchingNode), + ]; + }), + static fn($item) => $item['uri'] + ) + ); } - protected function getNodeUri(NodeInterface $node): string + protected function getNodeUri(Node $node): string { try { - return $this->linkingService->createNodeUri($this->controllerContext, $node, null, 'html', true); - } catch (\Exception $e) { + return $this->linkingService->createNodeUri( + $this->controllerContext, + $node, + null, + 'html', + true + ); + } catch (\Exception) { return ''; } } diff --git a/composer.json b/composer.json index 6cf91cf..6944353 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ "cmdk" ], "require": { - "php": ">= 8.1", - "neos/neos": "^7.3 || ^8.0" + "php": ">= 8.2", + "neos/neos": "^9.0" }, "authors": [ { diff --git a/packages/ui-plugin/src/CommandBarUiPlugin.tsx b/packages/ui-plugin/src/CommandBarUiPlugin.tsx index 9f074d8..784e633 100644 --- a/packages/ui-plugin/src/CommandBarUiPlugin.tsx +++ b/packages/ui-plugin/src/CommandBarUiPlugin.tsx @@ -28,7 +28,8 @@ type CommandBarUiPluginProps = { baseWorkspace: string; commandBarOpen: boolean; config: CommandBarConfig; - discardAction: (contextPaths: string[]) => void; + // TODO: Reimplement discardAction + // discardAction: (contextPaths: string[]) => void; documentNode: CRNode; editPreviewMode: string; editPreviewModes: EditPreviewModes; @@ -38,7 +39,8 @@ type CommandBarUiPluginProps = { i18nRegistry: I18nRegistry; isWorkspaceReadOnly: boolean; plugins: Record HierarchicalCommandList>; - publishAction: (contextPaths: string[], baseWorkspace: string) => void; + // TODO: Reimplement publishAction + // publishAction: (contextPaths: string[], baseWorkspace: string) => void; publishableNodes: CRNode[]; publishableNodesInDocument: CRNode[]; previewUrl: string | null; @@ -83,7 +85,8 @@ class CommandBarUiPlugin extends React.PureComponent { - const { publishableNodesInDocument, publishAction, baseWorkspace } = this.props; - publishAction( - publishableNodesInDocument.map((node) => node.contextPath), - baseWorkspace - ); - return { - success: true, - message: this.translate( - 'CommandBarUiPlugin.command.publish.success', - { count: publishableNodesInDocument.length }, - `Published ${publishableNodesInDocument.length} changes` - ), - }; - }; - - handlePublishAll = async (): AsyncCommandResult => { - const { publishableNodes, publishAction, baseWorkspace } = this.props; - publishAction( - publishableNodes.map((node) => node.contextPath), - baseWorkspace - ); - return { - success: true, - message: this.translate( - 'CommandBarUiPlugin.command.publishAll.success', - { count: publishableNodes.length }, - `Published ${publishableNodes.length} changes` - ), - }; - }; - - handleDiscard = async (): AsyncCommandResult => { - const { publishableNodesInDocument, discardAction } = this.props; - discardAction(publishableNodesInDocument.map((node) => node.contextPath)); - return { - success: true, - message: this.translate( - 'CommandBarUiPlugin.command.discard.success', - { count: publishableNodesInDocument.length }, - `Discarded ${publishableNodesInDocument.length} changes` - ), - }; - }; - - handleDiscardAll = async (): AsyncCommandResult => { - const { publishableNodes, discardAction } = this.props; - discardAction(publishableNodes.map((node) => node.contextPath)); - return { - success: true, - message: this.translate( - 'CommandBarUiPlugin.command.discardAll.success', - { count: publishableNodes.length }, - `Discarded ${publishableNodes.length} changes` - ), - }; - }; + // TODO: Reimplement publishAction + // handlePublish = async (): AsyncCommandResult => { + // const { publishableNodesInDocument, publishAction, baseWorkspace } = this.props; + // publishAction( + // publishableNodesInDocument.map((node) => node.contextPath), + // baseWorkspace + // ); + // return { + // success: true, + // message: this.translate( + // 'CommandBarUiPlugin.command.publish.success', + // { count: publishableNodesInDocument.length }, + // `Published ${publishableNodesInDocument.length} changes` + // ), + // }; + // }; + // + // handlePublishAll = async (): AsyncCommandResult => { + // const { publishableNodes, publishAction, baseWorkspace } = this.props; + // publishAction( + // publishableNodes.map((node) => node.contextPath), + // baseWorkspace + // ); + // return { + // success: true, + // message: this.translate( + // 'CommandBarUiPlugin.command.publishAll.success', + // { count: publishableNodes.length }, + // `Published ${publishableNodes.length} changes` + // ), + // }; + // }; + + // TODO: Reimplement discardAction + // handleDiscard = async (): AsyncCommandResult => { + // const { publishableNodesInDocument, discardAction } = this.props; + // discardAction(publishableNodesInDocument.map((node) => node.contextPath)); + // return { + // success: true, + // message: this.translate( + // 'CommandBarUiPlugin.command.discard.success', + // { count: publishableNodesInDocument.length }, + // `Discarded ${publishableNodesInDocument.length} changes` + // ), + // }; + // }; + // + // handleDiscardAll = async (): AsyncCommandResult => { + // const { publishableNodes, discardAction } = this.props; + // discardAction(publishableNodes.map((node) => node.contextPath)); + // return { + // success: true, + // message: this.translate( + // 'CommandBarUiPlugin.command.discardAll.success', + // { count: publishableNodes.length }, + // `Discarded ${publishableNodes.length} changes` + // ), + // }; + // }; setDragging = (dragging: boolean) => { this.setState({ ...this.state, dragging }); @@ -683,8 +690,10 @@ export default connect(() => ({}), { toggleCommandBar: commandBarActions.toggleCommandBar, addNode: actions.CR.Nodes.commenceCreation, setEditPreviewMode: actions.UI.EditPreviewMode.set, - publishAction: actions.CR.Workspaces.publish, - discardAction: actions.CR.Workspaces.commenceDiscard, + // TODO: Reimplement publishAction + // publishAction: actions.CR.Workspaces.publish, + // TODO: Reimplement discardAction + //discardAction: actions.CR.Workspaces.commenceDiscard, setActiveContentCanvasSrc: actions.UI.ContentCanvas.setSrc, setActiveContentCanvasContextPath: actions.CR.Nodes.setDocumentNode, changeBaseWorkspaceAction: actions.CR.Workspaces.changeBaseWorkspace,