Skip to content

Commit

Permalink
Feature: show confirmation dialogue for all resolution strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
pKallert committed Dec 20, 2024
1 parent 99e5b08 commit fd81b4d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 44 deletions.
9 changes: 1 addition & 8 deletions packages/neos-ui-sagas/src/Publish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ type PublishingResponse =
numberOfAffectedChanges: number;
}
}
| {
partialPublishFail: {
conflicts: Conflict[];
}
}
| { conflicts: Conflict[], isPartialPublish: boolean }
| { error: AnyError };

Expand Down Expand Up @@ -80,6 +75,7 @@ export function * watchPublishing({routes}: {routes: Routes}) {

yield takeEvery(actionTypes.CR.Publishing.STARTED, function * publishingWorkflow(action: ReturnType<typeof actions.CR.Publishing.start>) {
const confirmed = yield * waitForConfirmation();

if (!confirmed) {
return;
}
Expand All @@ -97,7 +93,6 @@ export function * watchPublishing({routes}: {routes: Routes}) {
const ancestorId: NodeContextPath = ancestorIdSelector
? yield select(ancestorIdSelector)
: null;

function * attemptToPublishOrDiscard(): Generator<any, any, any> {
const result: PublishingResponse = scope === PublishingScope.ALL
? yield call(endpoint as any, workspaceName)
Expand Down Expand Up @@ -136,8 +131,6 @@ export function * watchPublishing({routes}: {routes: Routes}) {
}
} else if ('error' in result) {
yield put(actions.CR.Publishing.fail(result.error));
} else if ('partialPublishFail' in result) {
yield put(actions.CR.Publishing.partialFail());
} else {
yield put(actions.CR.Publishing.fail(null));
}
Expand Down
38 changes: 20 additions & 18 deletions packages/neos-ui-sagas/src/Sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const makeResolveConflicts = (deps: {
syncPersonalWorkspace: ReturnType<typeof makeSyncPersonalWorkspace>
}) => {
const discardAll = makeDiscardAll(deps);
const publishAll = makePublishAll(deps);
const publishAll = makePublishAll();

function * resolveConflicts(conflicts: Conflict[], isPartialPublish: boolean): any {
while (true) {
Expand All @@ -107,10 +107,8 @@ export const makeResolveConflicts = (deps: {
cancelled: take(actionTypes.CR.Syncing.CANCELLED),
started: take(actionTypes.CR.Syncing.RESOLUTION_STARTED)
});

if (started) {
const {payload: {strategy}} = started;

if (strategy === ResolutionStrategy.FORCE) {
if (yield * waitForResolutionConfirmation()) {
yield * deps.syncPersonalWorkspace(true);
Expand All @@ -121,13 +119,21 @@ export const makeResolveConflicts = (deps: {
}

if (strategy === ResolutionStrategy.DISCARD_ALL) {
yield * discardAll();
return true;
if (yield * waitForResolutionConfirmation()) {
yield * discardAll();
return true;
}

continue;
}

if (strategy === ResolutionStrategy.PUBLISH_ALL) {
yield * publishAll();
return true;
if (yield * waitForResolutionConfirmation()) {
yield * publishAll();
return true;
}

continue;
}
}

Expand Down Expand Up @@ -170,7 +176,7 @@ const makeDiscardAll = (deps: {
PublishingMode.DISCARD,
PublishingScope.ALL
));

yield put(actions.CR.Publishing.confirm());
const {cancelled, failed}: {
cancelled: null | ReturnType<typeof actions.CR.Publishing.cancel>;
failed: null | ReturnType<typeof actions.CR.Publishing.fail>;
Expand All @@ -186,24 +192,22 @@ const makeDiscardAll = (deps: {
} else if (failed) {
yield put(actions.CR.Syncing.finish());
} else {
yield put(actions.CR.Syncing.confirmResolution());
yield put(actions.CR.Syncing.finish());
yield * deps.syncPersonalWorkspace(false);
}
}

return discardAll;
}

const makePublishAll = (deps: {
syncPersonalWorkspace: ReturnType<typeof makeSyncPersonalWorkspace>;
}) => {
const makePublishAll = () => {
function * publishAll() {
yield put(actions.CR.Publishing.start(
PublishingMode.PUBLISH,
PublishingScope.ALL
PublishingScope.SITE
));

const {cancelled, failed}: {
yield put(actions.CR.Publishing.confirm());
const {cancelled, failed, finished}: {
cancelled: null | ReturnType<typeof actions.CR.Publishing.cancel>;
failed: null | ReturnType<typeof actions.CR.Publishing.fail>;
finished: null | ReturnType<typeof actions.CR.Publishing.finish>;
Expand All @@ -212,14 +216,12 @@ const makePublishAll = (deps: {
failed: take(actionTypes.CR.Publishing.FAILED),
finished: take(actionTypes.CR.Publishing.FINISHED)
});

if (cancelled) {
yield put(actions.CR.Syncing.cancelResolution());
} else if (failed) {
yield put(actions.CR.Syncing.finish());
} else {
yield put(actions.CR.Syncing.confirmResolution());
yield * deps.syncPersonalWorkspace(false);
yield put(actions.CR.Syncing.finish());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ const DiscardAllConfirmationDialog: React.FC<{
}
const PublishAllConfirmationDialog: React.FC<{
workspaceName: WorkspaceName;
baseWorkspaceName: WorkspaceName;
totalNumberOfChangesInWorkspace: number;
onCancelConflictResolution: () => void;
onConfirmResolutionStrategy: () => void;
Expand Down Expand Up @@ -214,7 +215,7 @@ const PublishAllConfirmationDialog: React.FC<{
onClick={props.onConfirmResolutionStrategy}
className={style.button}
>
<Icon icon="trash" className={style.icon} />
<Icon icon="check-double" className={style.icon} />
<I18n
id="Neos.Neos.Ui:SyncWorkspaceDialog:resolutionStrategy.PUBLISH_ALL.confirmation.confirm"
fallback="Yes, publish everything"
Expand Down Expand Up @@ -242,7 +243,7 @@ const PublishAllConfirmationDialog: React.FC<{
<DiscardDiagram
numberOfChanges={props.totalNumberOfChangesInWorkspace}
sourceWorkspaceName={props.workspaceName}
targetWorkspaceName={null}
targetWorkspaceName={props.baseWorkspaceName}
phase={PublishingPhase.START}
/>
<I18n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const SyncWorkspaceDialog: React.FC<SyncWorkspaceDialogProps> = (props) => {
const handleRetry = React.useCallback(() => {
props.retry();
}, []);

switch (props.syncingState?.process.phase) {
case SyncingPhase.START:
return (
Expand Down Expand Up @@ -124,21 +123,18 @@ const SyncWorkspaceDialog: React.FC<SyncWorkspaceDialogProps> = (props) => {
/>
);
case SyncingPhase.RESOLVING:
if (props.syncingState.process.strategy === ResolutionStrategy.FORCE) {
return (
<ResolutionStrategyConfirmationDialog
workspaceName={props.personalWorkspaceName}
baseWorkspaceName={props.baseWorkspaceName}
totalNumberOfChangesInWorkspace={props.totalNumberOfChangesInWorkspace}
strategy={props.syncingState.process.strategy}
conflicts={props.syncingState.process.conflicts}
i18n={props.i18nRegistry}
onCancelConflictResolution={handleCancelConflictResolution}
onConfirmResolutionStrategy={handleConfirmResolutionStrategy}
/>
);
}
return null;
return (
<ResolutionStrategyConfirmationDialog
workspaceName={props.personalWorkspaceName}
baseWorkspaceName={props.baseWorkspaceName}
totalNumberOfChangesInWorkspace={props.totalNumberOfChangesInWorkspace}
strategy={props.syncingState.process.strategy}
conflicts={props.syncingState.process.conflicts}
i18n={props.i18nRegistry}
onCancelConflictResolution={handleCancelConflictResolution}
onConfirmResolutionStrategy={handleConfirmResolutionStrategy}
/>
);
case SyncingPhase.ERROR:
case SyncingPhase.SUCCESS:
return (
Expand Down

0 comments on commit fd81b4d

Please sign in to comment.