Skip to content

Commit

Permalink
Merge pull request #5450 from pKallert/feature/workspaceui-rebase-wor…
Browse files Browse the repository at this point in the history
…kspace-button

FEATURE: Add Rebase Workspace button to Workspace UI
  • Loading branch information
mhsdesign authored Jan 28, 2025
2 parents 82b5a18 + 6f284de commit 35127cd
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Exception\WorkspaceAlreadyExists;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Dto\RebaseErrorHandlingStrategy;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Exception\WorkspaceRebaseFailed;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
Expand Down Expand Up @@ -706,6 +707,33 @@ public function discardWorkspaceAction(WorkspaceName $workspace): void
$this->forward('review', null, null, ['workspace' => $workspace->value]);
}

/**
* Rebase a workspace
*/
public function rebaseAction(WorkspaceName $workspaceName, bool $force): void
{
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;

try {
$this->workspacePublishingService->rebaseWorkspace(
$contentRepositoryId,
$workspaceName,
$force ? RebaseErrorHandlingStrategy::STRATEGY_FORCE : RebaseErrorHandlingStrategy::STRATEGY_FAIL
);
$this->addFlashMessage($this->getModuleLabel('workspaces.workspaceHasBeenRebased'));
$this->forward('index');

} catch (WorkspaceRebaseFailed $e) {
if ($force) {
$this->addFlashMessage($this->getModuleLabel('workspaces.ForceRebaseWorkspaceFailed'));
$this->forward('index');
}
}
$this->response->addHttpHeader('HX-Retarget', '#popover-container');
$this->response->addHttpHeader('HX-ReSwap', 'innerHTML');
$this->view->assign('workspaceName', $workspaceName->value);
}

/**
* Computes the number of added, changed and removed nodes for the given workspace
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Neos.Workspace.Ui.WorkspaceController.rebase = Neos.Fusion:Component {
/// string
workspaceName = ${workspaceName}

renderer = afx`
<Neos.Workspace.Ui:Component.Modal.Rebase
workspaceName={props.workspaceName}
/>
`
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ prototype(Neos.Workspace.Ui:Component.WorkspaceTableRow) < prototype(Neos.Fusion
workspaceName = ${props.workspaceListItem.name}
}
}
rebaseWorkspaceUri = Neos.Fusion:ActionUri {
action = 'rebase'
format = 'htmx'
arguments {
workspaceName = ${props.workspaceListItem.name}
force = false
}
}
rebaseWorkspacePopoverId = 'workspace-rebase-modal'
deleteWorkspacePopoverId = 'workspace-delete-modal'
editWorkspacePopoverId = 'workspace-edit-modal'
}
Expand Down Expand Up @@ -131,6 +140,16 @@ prototype(Neos.Workspace.Ui:Component.WorkspaceTableRow) < prototype(Neos.Fusion
attributes.hx-swap='innerHTML'
attributes.hx-on--after-request={'document.getElementById("' + private.deleteWorkspacePopoverId + '").showPopover()'}
/>
<Neos.Workspace.Ui:Component.Button
isDanger
title={private.i18n.id('workspaces.rebaseWorkspace').arguments([props.workspaceListItem.title])}
icon="sync icon-white"
disabled={props.workspaceListItem.status != 'OUTDATED' || props.workspaceListItem.permissions.edit == false}
attributes.hx-get={private.rebaseWorkspaceUri}
attributes.hx-target="#workspace-module-content"
attributes.hx-swap="outerHTML"
attributes.hx-on--after-request={'document.getElementById("' + private.rebaseWorkspacePopoverId + '")?.showPopover()'}
/>
</td>
</tr>
`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
prototype(Neos.Workspace.Ui:Component.Modal.Rebase) < prototype(Neos.Fusion:Component) {
/// string
workspaceName = null

@private {
i18n = ${I18n.id('').source('Main').package('Neos.Workspace.Ui')}
popoverId = 'workspace-rebase-modal'

forceRebaseWorkspaceUri = Neos.Fusion:ActionUri {
action = 'rebase'
format = 'htmx'
arguments {
workspaceName = ${workspaceName}
force = true
}
}
}

renderer = afx`
<div popover id={private.popoverId}>
<header>
<button
type="button"
class="neos-close neos-button"
popovertarget={private.popoverId}
popovertargetaction="close"
>
<Neos.Workspace.Ui:Component.Icon icon="times"/>
</button>
<div class="neos-header">
{private.i18n.id('workspaces.dialog.forceSyncWorkspace')}
</div>
</header>
<section>
<p>{private.i18n.id('workspaces.dialog.thisCanLeadToLostChanges')}</p>
</section>
<footer>
<button
type="button"
class="neos-button"
popovertarget={private.popoverId}
popovertargetaction="close"
>
{private.i18n.id('cancel')}
</button>
<Neos.Workspace.Ui:Component.Button
isDanger
label={private.i18n.id('workspaces.modal.yesRebaseWorkspace')}
attributes.hx-get={private.forceRebaseWorkspaceUri}
attributes.hx-target="#workspace-module-content"
attributes.hx-swap="outerHTML"
attributes.hx-on--after-request={'document.getElementById("' + private.popoverId + '").hidePopover()'}
/>
</footer>
</div>
`
}
18 changes: 18 additions & 0 deletions Neos.Workspace.Ui/Resources/Private/Translations/en/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<trans-unit id="workspaces.editWorkspace" xml:space="preserve">
<source>Edit workspace "{0}"</source>
</trans-unit>
<trans-unit id="workspaces.rebaseWorkspace" xml:space="preserve">
<source>Sync workspace "{0}" with its base workspace</source>
</trans-unit>
<trans-unit id="workspaces.personalWorkspace" xml:space="preserve">
<source>Personal workspace</source>
</trans-unit>
Expand Down Expand Up @@ -171,6 +174,15 @@
<trans-unit id="workspaces.dialog.thisWillDeleteTheWorkspace" xml:space="preserve">
<source>This will delete the workspace including all unpublished content. This operation cannot be undone.</source>
</trans-unit>
<trans-unit id="workspaces.dialog.forceSyncWorkspace" xml:space="preserve">
<source>Syncing has failed</source>
</trans-unit>
<trans-unit id="workspaces.dialog.thisCanLeadToLostChanges" xml:space="preserve">
<source>A conflict occured while syncing the workspace. Do you want to drop the conflicting changes?</source>
</trans-unit>
<trans-unit id="workspaces.modal.yesRebaseWorkspace" xml:space="preserve">
<source>Yes, drop changes</source>
</trans-unit>
<trans-unit id="workspaces.description" xml:space="preserve">
<source>This module contains the overview of all elements within the current workspace and it enables to continue the review and publishing workflow for them.</source>
</trans-unit>
Expand Down Expand Up @@ -308,6 +320,12 @@
<trans-unit id="table.column.access.personal" xml:space="preserve">
<source>This is the personal workspace of "{0}"</source>
</trans-unit>
<trans-unit id="workspaces.workspaceHasBeenRebased" xml:space="preserve">
<source>The workspace has been successfully synced</source>
</trans-unit>
<trans-unit id="workspaces.ForceRebaseWorkspaceFailed" xml:space="preserve">
<source>Forcing the sync has failed. Please try discarding your changes.</source>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit 35127cd

Please sign in to comment.