From 6645c4dc701161a1f3c074bfcf6a73951e946f12 Mon Sep 17 00:00:00 2001 From: Wilhelm Behncke Date: Wed, 10 Apr 2024 14:01:20 +0200 Subject: [PATCH] TASK: Update WorkspaceInfo after publish/discard --- .../src/CR/Publishing/index.ts | 5 +--- .../src/CR/Workspaces/index.ts | 12 +-------- .../neos-ui-sagas/src/CR/Workspaces/index.ts | 20 +++++++++++++++ packages/neos-ui-sagas/src/Publish/index.ts | 25 ++++++++++--------- 4 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 packages/neos-ui-sagas/src/CR/Workspaces/index.ts diff --git a/packages/neos-ui-redux-store/src/CR/Publishing/index.ts b/packages/neos-ui-redux-store/src/CR/Publishing/index.ts index dfa628be0f..a3ad443d79 100644 --- a/packages/neos-ui-redux-store/src/CR/Publishing/index.ts +++ b/packages/neos-ui-redux-store/src/CR/Publishing/index.ts @@ -11,8 +11,6 @@ import {action as createAction, ActionType} from 'typesafe-actions'; import type {AnyError} from '@neos-project/neos-ui-error'; -import {PublishableNode} from '../Workspaces'; - export enum PublishingMode { PUBLISH, DISCARD @@ -96,7 +94,7 @@ const acknowledge = () => createAction(actionTypes.ACKNOWLEDGED); /** * Finish the ongoing publish/discard workflow */ -const finish = (affectedNodes: PublishableNode[]) => createAction(actionTypes.FINISHED, {affectedNodes}); +const finish = () => createAction(actionTypes.FINISHED); // // Export the actions @@ -113,7 +111,6 @@ export const actions = { }; export type Action = ActionType; -export type FinishAction = ActionType; // // Export the reducer diff --git a/packages/neos-ui-redux-store/src/CR/Workspaces/index.ts b/packages/neos-ui-redux-store/src/CR/Workspaces/index.ts index 3635e15777..6f78fd8619 100644 --- a/packages/neos-ui-redux-store/src/CR/Workspaces/index.ts +++ b/packages/neos-ui-redux-store/src/CR/Workspaces/index.ts @@ -6,7 +6,6 @@ import {NodeContextPath} from '@neos-project/neos-ts-interfaces'; import {WorkspaceName} from '@neos-project/neos-ts-interfaces'; import {actionTypes as system, InitAction} from '../../System'; -import {actionTypes as publishing, FinishAction} from '../Publishing'; import * as selectors from './selectors'; @@ -79,7 +78,7 @@ export const actions = { // // Export the reducer // -export const reducer = (state: State = defaultState, action: InitAction | FinishAction | Action) => produce(state, draft => { +export const reducer = (state: State = defaultState, action: InitAction | Action) => produce(state, draft => { switch (action.type) { case system.INIT: { draft.personalWorkspace = action.payload.cr.workspaces.personalWorkspace; @@ -89,15 +88,6 @@ export const reducer = (state: State = defaultState, action: InitAction | Finish draft.personalWorkspace = assignIn(draft.personalWorkspace, action.payload); break; } - case publishing.FINISHED: { - draft.personalWorkspace.publishableNodes = - state.personalWorkspace.publishableNodes.filter( - (publishableNode) => !action.payload.affectedNodes.some( - (affectedNode) => affectedNode.contextPath === publishableNode.contextPath - ) - ); - break; - } } }); diff --git a/packages/neos-ui-sagas/src/CR/Workspaces/index.ts b/packages/neos-ui-sagas/src/CR/Workspaces/index.ts new file mode 100644 index 0000000000..4daf9aa73e --- /dev/null +++ b/packages/neos-ui-sagas/src/CR/Workspaces/index.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ +import {put, call} from 'redux-saga/effects'; + +import {actions} from '@neos-project/neos-ui-redux-store'; +import {WorkspaceInformation} from '@neos-project/neos-ui-redux-store/src/CR/Workspaces'; +import backend from '@neos-project/neos-ui-backend-connector'; + +export function * updateWorkspaceInfo() { + const {getWorkspaceInfo} = backend.get().endpoints; + const workspaceInfo: WorkspaceInformation = yield call(getWorkspaceInfo); + yield put(actions.CR.Workspaces.update(workspaceInfo)); +} diff --git a/packages/neos-ui-sagas/src/Publish/index.ts b/packages/neos-ui-sagas/src/Publish/index.ts index 1fbbee3e92..0bad73ae21 100644 --- a/packages/neos-ui-sagas/src/Publish/index.ts +++ b/packages/neos-ui-sagas/src/Publish/index.ts @@ -7,7 +7,7 @@ * information, please view the LICENSE file which was distributed with this * source code. */ -import {put, call, select, takeEvery, take, race} from 'redux-saga/effects'; +import {put, call, select, takeEvery, take, race, all} from 'redux-saga/effects'; import {AnyError} from '@neos-project/neos-ui-error'; import {NodeContextPath, WorkspaceName} from '@neos-project/neos-ts-interfaces'; @@ -15,10 +15,11 @@ import {actionTypes, actions, selectors} from '@neos-project/neos-ui-redux-store import {GlobalState} from '@neos-project/neos-ui-redux-store/src/System'; import {FeedbackEnvelope} from '@neos-project/neos-ui-redux-store/src/ServerFeedback'; import {PublishingMode, PublishingScope} from '@neos-project/neos-ui-redux-store/src/CR/Publishing'; -import {PublishableNode, WorkspaceInformation} from '@neos-project/neos-ui-redux-store/src/CR/Workspaces'; +import {WorkspaceInformation} from '@neos-project/neos-ui-redux-store/src/CR/Workspaces'; import backend, {Routes} from '@neos-project/neos-ui-backend-connector'; import {makeReloadNodes} from '../CR/NodeOperations/reloadNodes'; +import {updateWorkspaceInfo} from '../CR/Workspaces'; const handleWindowBeforeUnload = (event: BeforeUnloadEvent) => { event.preventDefault(); @@ -48,12 +49,10 @@ export function * watchPublishing({routes}: {routes: Routes}) { }; const SELECTORS_BY_SCOPE = { [PublishingScope.SITE]: { - ancestorIdSelector: selectors.CR.Nodes.siteNodeContextPathSelector, - publishableNodesSelector: selectors.CR.Workspaces.publishableNodesSelector + ancestorIdSelector: selectors.CR.Nodes.siteNodeContextPathSelector }, [PublishingScope.DOCUMENT]: { - ancestorIdSelector: selectors.CR.Nodes.documentNodeContextPathSelector, - publishableNodesSelector: selectors.CR.Workspaces.publishableNodesInDocumentSelector + ancestorIdSelector: selectors.CR.Nodes.documentNodeContextPathSelector } }; @@ -67,24 +66,23 @@ export function * watchPublishing({routes}: {routes: Routes}) { const {scope, mode} = action.payload; const endpoint = ENDPOINT_BY_MODE_AND_SCOPE[mode][scope]; - const {ancestorIdSelector, publishableNodesSelector} = SELECTORS_BY_SCOPE[scope]; + const {ancestorIdSelector} = SELECTORS_BY_SCOPE[scope]; const workspaceName: WorkspaceName = yield select(selectors.CR.Workspaces.personalWorkspaceNameSelector); const ancestorId: NodeContextPath = yield select(ancestorIdSelector); - const publishableNodes: PublishableNode[] = yield select(publishableNodesSelector); - let affectedNodes: PublishableNode[] = []; do { try { window.addEventListener('beforeunload', handleWindowBeforeUnload); const result: PublishingResponse = yield call(endpoint, ancestorId, workspaceName); if ('success' in result) { - affectedNodes = publishableNodes; yield put(actions.CR.Publishing.succeed()); if (mode === PublishingMode.DISCARD) { yield * reloadAfterDiscard(); + } else { + yield * updateWorkspaceInfo(); } } else if ('error' in result) { yield put(actions.CR.Publishing.fail(result.error)); @@ -98,7 +96,7 @@ export function * watchPublishing({routes}: {routes: Routes}) { } } while (yield * waitForRetry()); - yield put(actions.CR.Publishing.finish(affectedNodes)); + yield put(actions.CR.Publishing.finish()); }); } @@ -132,7 +130,10 @@ const makeReloadAfterDiscard = (deps: { const reloadNodes = makeReloadNodes(deps); function * reloadAfterDiscard() { - yield * reloadNodes(); + yield all([ + call(updateWorkspaceInfo), + call(reloadNodes) + ]); } return reloadAfterDiscard;