Skip to content

Commit

Permalink
BUGFIX: Convert review actions to htmx and make flash messages work
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebobo committed Dec 17, 2024
1 parent d505870 commit e94d23a
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 17 deletions.
26 changes: 12 additions & 14 deletions Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ public function reviewAction(WorkspaceName $workspace): void
'',
Message::SEVERITY_ERROR
);
$this->redirect('index');
$this->indexAction();
return;
}

$workspacePermissions = $this->authorizationService->getWorkspacePermissions($contentRepositoryId, $workspace, $this->securityContext->getRoles(), $currentUser->getId());
Expand All @@ -195,7 +196,8 @@ public function reviewAction(WorkspaceName $workspace): void
'',
Message::SEVERITY_ERROR
);
$this->redirect('index');
$this->indexAction();
return;
}
$workspaceMetadata = $this->workspaceService->getWorkspaceMetadata($contentRepositoryId, $workspace);
$baseWorkspaceMetadata = null;
Expand All @@ -215,7 +217,8 @@ public function reviewAction(WorkspaceName $workspace): void
'canPublishToBaseWorkspace' => $baseWorkspacePermissions?->write ?? false,
'canPublishToWorkspace' => $workspacePermissions->write,
'siteChanges' => $this->computeSiteChanges($workspaceObj, $contentRepository),
'contentDimensions' => $contentRepository->getContentDimensionSource()->getContentDimensionsOrderedByPriority()
'contentDimensions' => $contentRepository->getContentDimensionSource()->getContentDimensionsOrderedByPriority(),
'flashMessages' => $this->controllerContext->getFlashMessageContainer()->getMessagesAndFlush(),
]);
}

Expand Down Expand Up @@ -267,7 +270,7 @@ public function createAction(
$this->throwStatus(500, 'Workspace could not be created');
}
$this->addFlashMessage($this->getModuleLabel('workspaces.workspaceHasBeenCreated', [$title->value]));
$this->redirect('index');
$this->indexAction();
}

/**
Expand Down Expand Up @@ -556,7 +559,7 @@ public function publishDocumentAction(string $nodeAddress, WorkspaceName $select
);

$this->addFlashMessage($this->getModuleLabel('workspaces.selectedChangeHasBeenPublished'));
$this->redirect('review', null, null, ['workspace' => $selectedWorkspace->value]);
$this->reviewAction($selectedWorkspace);
}

/**
Expand All @@ -580,9 +583,7 @@ public function discardDocumentAction(string $nodeAddress, WorkspaceName $select
);

$this->addFlashMessage($this->getModuleLabel('workspaces.selectedChangeHasBeenDiscarded'));

$this->redirect('review', null, null, ['workspace' => $selectedWorkspace->value]);

$this->reviewAction($selectedWorkspace);
}

/**
Expand Down Expand Up @@ -625,8 +626,7 @@ public function publishOrDiscardNodesAction(array $nodes, string $action, Worksp
default:
throw new \RuntimeException('Invalid action "' . htmlspecialchars($action) . '" given.', 1346167441);
}

$this->redirect('review', null, null, ['workspace' => $workspace->value]);
$this->reviewAction($workspace);
}

/**
Expand All @@ -648,8 +648,7 @@ public function publishWorkspaceAction(WorkspaceName $workspace): void
],
)
);
//todo make redirect work
$this->redirect('index');
$this->indexAction();
}

public function confirmPublishAllChangesAction(WorkspaceName $workspaceName): void
Expand Down Expand Up @@ -754,8 +753,7 @@ public function discardWorkspaceAction(WorkspaceName $workspace): void
[htmlspecialchars($workspace->value)],
)
);
//todo make redirect to index work
$this->redirect('review', null, null, ['workspace' => $workspace->value]);
$this->reviewAction($workspace);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Actions that update a workspace and redirect to the review view

# Discard actions
Neos.Workspace.Ui.WorkspaceController.discardWorkspace < Neos.Workspace.Ui.WorkspaceController.review
Neos.Workspace.Ui.WorkspaceController.discardDocument < Neos.Workspace.Ui.WorkspaceController.review

# Publish actions
Neos.Workspace.Ui.WorkspaceController.publishDocument < Neos.Workspace.Ui.WorkspaceController.review
Neos.Workspace.Ui.WorkspaceController.publishOrDiscardNodes < Neos.Workspace.Ui.WorkspaceController.review
Neos.Workspace.Ui.WorkspaceController.publishWorkspace < Neos.Workspace.Ui.WorkspaceController.review
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ prototype(Neos.Workspace.Ui:Component.ReviewDocumentTableRow) < prototype(Neos.F
arguments {
targetWorkspaceName = ${selectedWorkspaceName}
targetNode = ${document.document.documentNodeAddress}

}
}
openNodeInPreviewAction = Neos.Fusion:ActionUri {
Expand All @@ -28,17 +27,18 @@ prototype(Neos.Workspace.Ui:Component.ReviewDocumentTableRow) < prototype(Neos.F
action = 'preview'
// todo fixme
@process.addQuery = ${value + '?node=' + document.document.documentNodeAddress}

}
discardDocumentAction = Neos.Fusion:ActionUri {
action = 'discardDocument'
format = 'htmx'
arguments {
nodeAddress = ${document.document.documentNodeAddress}
selectedWorkspace = ${selectedWorkspaceName}
}
}
publishDocumentAction = Neos.Fusion:ActionUri {
action = 'publishDocument'
format = 'htmx'
arguments {
nodeAddress = ${document.document.documentNodeAddress}
selectedWorkspace = ${selectedWorkspaceName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ prototype(Neos.Workspace.Ui:Component.ReviewTable) < prototype(Neos.Fusion:Compo

@private {
i18n = ${I18n.id('').source('Main').package('Neos.Workspace.Ui')}

}

renderer = afx`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ prototype(Neos.Workspace.Ui:Component.Modal.ConfirmDiscardAllChanges) < prototyp

discardWorkspaceUri = Neos.Fusion:ActionUri {
action = 'discardWorkspace'
format = 'htmx'
arguments {
workspace = ${workspaceName}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ prototype(Neos.Workspace.Ui:Component.Modal.ConfirmDiscardSelectedChanges) < pro

confirmDiscardSelectedChanges = Neos.Fusion:ActionUri {
action = 'publishOrDiscardNodes'
format = 'htmx'
arguments {
workspace = ${workspaceName}
action = 'discard'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ prototype(Neos.Workspace.Ui:Component.Modal.ConfirmPublishSelectedChanges) < pro

publishSelectedChanges = Neos.Fusion:ActionUri {
action = 'publishOrDiscardNodes'
format = 'htmx'
arguments {
workspace = ${workspaceName}
action = 'publish'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Neos.Workspace.Ui.WorkspaceController.index = Neos.Fusion:Component {
userWorkspaceName = ${userWorkspaceName}
/// Neos\Workspace\Ui\ViewModel\WorkspaceListItems
workspaceListItems = ${workspaceListItems}
/// array
flashMessages = ${flashMessages}

newAction = Neos.Fusion:UriBuilder {
action = 'new'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Actions that update a workspace and redirect to the index view

Neos.Workspace.Ui.WorkspaceController.create < Neos.Workspace.Ui.WorkspaceController.index

0 comments on commit e94d23a

Please sign in to comment.