-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore draft cancellation confirmation
- Loading branch information
1 parent
c708300
commit ef344e2
Showing
12 changed files
with
151 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
frontend/src/features/SideWindow/useCases/askForSideWindowDraftCancellationConfirmation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { getFullPathFromPath } from '../../../domain/entities/sideWindow/utils' | ||
import { sideWindowActions } from '../../../domain/shared_slices/SideWindow' | ||
import { PendingUseCaseKey, setPendingUseCase } from '../../../libs/PendingUseCase' | ||
|
||
import type { SideWindow } from '../../../domain/entities/sideWindow/types' | ||
import type { MainAppThunk } from '../../../store' | ||
import type { RetryableUseCase } from '../../../types' | ||
|
||
export const askForSideWindowDraftCancellationConfirmation = | ||
(nextPath: SideWindow.Path, useCase?: RetryableUseCase): MainAppThunk => | ||
dispatch => { | ||
if (useCase) { | ||
setPendingUseCase(PendingUseCaseKey.DRAFT_CANCELLATION_CONFIRMATION, useCase) | ||
} | ||
|
||
const nextFullPath = getFullPathFromPath(nextPath) | ||
|
||
dispatch(sideWindowActions.setNextPath(nextFullPath)) | ||
dispatch(sideWindowActions.openDraftCancellationConfirmationDialog()) | ||
} |
17 changes: 17 additions & 0 deletions
17
frontend/src/features/SideWindow/useCases/confirmSideWindowDraftCancellationAndProceed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { sideWindowActions } from '../../../domain/shared_slices/SideWindow' | ||
import { getPendingUseCase, PendingUseCaseKey } from '../../../libs/PendingUseCase' | ||
import { assert } from '../../../utils/assert' | ||
|
||
import type { MainAppThunk } from '../../../store' | ||
|
||
export const confirmSideWindowDraftCancellationAndProceed = (): MainAppThunk => (dispatch, getState) => { | ||
const { sideWindow } = getState() | ||
assert(sideWindow.nextPath, 'sideWindow.nextPath') | ||
const pendingUseCase = getPendingUseCase(PendingUseCaseKey.DRAFT_CANCELLATION_CONFIRMATION) | ||
|
||
if (pendingUseCase) { | ||
dispatch(pendingUseCase()) | ||
} | ||
dispatch(sideWindowActions.cancelDraftCancellationConfirmationDialog()) | ||
dispatch(sideWindowActions.openOrFocusAndGoTo(sideWindow.nextPath)) | ||
} |
17 changes: 9 additions & 8 deletions
17
frontend/src/features/SideWindow/useCases/openSideWindowPath.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
// import { SideWindowStatus } from '../../../domain/entities/sideWindow/constants' | ||
import { askForSideWindowDraftCancellationConfirmation } from './askForSideWindowDraftCancellationConfirmation' | ||
import { SideWindowStatus } from '../../../domain/entities/sideWindow/constants' | ||
import { getFullPathFromPath } from '../../../domain/entities/sideWindow/utils' | ||
import { sideWindowActions } from '../../../domain/shared_slices/SideWindow' | ||
|
||
import type { SideWindow } from '../../../domain/entities/sideWindow/types' | ||
import type { MainAppThunk } from '../../../store' | ||
|
||
export const openSideWindowPath = | ||
(path: SideWindow.Path): MainAppThunk => | ||
async dispatch => { | ||
// const { missionForm, sideWindow } = getState() | ||
(path: SideWindow.Path, withoutConfirmation: boolean = false): MainAppThunk => | ||
async (dispatch, getState) => { | ||
const { missionForm, sideWindow } = getState() | ||
|
||
const fullPath: SideWindow.FullPath = getFullPathFromPath(path) | ||
|
||
// if (sideWindow.status !== SideWindowStatus.CLOSED && missionForm.isDraftDirty) { | ||
// dispatch(sideWindowActions.askForDraftCancellationConfirmationBeforeGoingTo(fullPath)) | ||
if (!withoutConfirmation && sideWindow.status !== SideWindowStatus.CLOSED && missionForm.isDraftDirty) { | ||
dispatch(askForSideWindowDraftCancellationConfirmation(path)) | ||
|
||
// return | ||
// } | ||
return | ||
} | ||
|
||
dispatch(sideWindowActions.openOrFocusAndGoTo(fullPath)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { assert } from '../utils/assert' | ||
|
||
import type { RetryableUseCase } from '../types' | ||
|
||
export enum PendingUseCaseKey { | ||
DRAFT_CANCELLATION_CONFIRMATION = 'DRAFT_CANCELLATION_CONFIRMATION', | ||
RETRYABLE_ERROR = 'RETRYABLE_ERROR' | ||
} | ||
|
||
const PENDING_USE_CASE_STORE: Record<PendingUseCaseKey, RetryableUseCase | undefined> = { | ||
DRAFT_CANCELLATION_CONFIRMATION: undefined, | ||
RETRYABLE_ERROR: undefined | ||
} | ||
|
||
export function getPendingUseCase(key: PendingUseCaseKey): RetryableUseCase { | ||
const pendingUseCase = PENDING_USE_CASE_STORE[key] | ||
assert(pendingUseCase, 'pendingUseCase') | ||
|
||
unsetPendingUseCase(key) | ||
|
||
return pendingUseCase | ||
} | ||
|
||
export function setPendingUseCase(key: PendingUseCaseKey, useCase: RetryableUseCase) { | ||
PENDING_USE_CASE_STORE[key] = useCase | ||
} | ||
|
||
export function unsetPendingUseCase(key: PendingUseCaseKey) { | ||
PENDING_USE_CASE_STORE[key] = undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters