mirror of
https://github.com/desktop/desktop
synced 2024-09-19 08:02:22 +00:00
Setup tracking the cherry pick flow state
This commit is contained in:
parent
624018c158
commit
659a28424f
|
@ -20,6 +20,7 @@ import {
|
|||
Progress,
|
||||
ICheckoutProgress,
|
||||
ICloneProgress,
|
||||
ICherryPickProgress,
|
||||
} from '../models/progress'
|
||||
import { Popup } from '../models/popup'
|
||||
|
||||
|
@ -37,6 +38,7 @@ import { RebaseFlowStep } from '../models/rebase-flow-step'
|
|||
import { IStashEntry } from '../models/stash-entry'
|
||||
import { TutorialStep } from '../models/tutorial-step'
|
||||
import { UncommittedChangesStrategy } from '../models/uncommitted-changes-strategy'
|
||||
import { CherryPickFlowStep } from '../models/cherry-pick'
|
||||
|
||||
export enum SelectionType {
|
||||
Repository,
|
||||
|
@ -430,6 +432,9 @@ export interface IRepositoryState {
|
|||
readonly revertProgress: IRevertProgress | null
|
||||
|
||||
readonly localTags: Map<string, string> | null
|
||||
|
||||
/** State associated with a cherry pick being performed */
|
||||
readonly cherryPickState: ICherryPickState
|
||||
}
|
||||
|
||||
export interface IBranchesState {
|
||||
|
@ -724,3 +729,21 @@ export interface ICompareToBranch {
|
|||
* An action to send to the application store to update the compare state
|
||||
*/
|
||||
export type CompareAction = IViewHistory | ICompareToBranch
|
||||
|
||||
/** State associated with a cherry pick being performed on a repository */
|
||||
export interface ICherryPickState {
|
||||
/**
|
||||
* The current step of the flow the user should see.
|
||||
*
|
||||
* `null` indicates that there is no cherry pick underway.
|
||||
*/
|
||||
readonly step: CherryPickFlowStep | null
|
||||
|
||||
/**
|
||||
* The underlying Git information associated with the current cherry pick
|
||||
*
|
||||
* This will be set to `null` when no target branch has been selected to
|
||||
* initiate the rebase.
|
||||
*/
|
||||
readonly progress: ICherryPickProgress | null
|
||||
}
|
||||
|
|
|
@ -266,6 +266,7 @@ import {
|
|||
getShowSideBySideDiff,
|
||||
setShowSideBySideDiff,
|
||||
} from '../../ui/lib/diff-mode'
|
||||
import { CherryPickFlowStep } from '../../models/cherry-pick'
|
||||
|
||||
const LastSelectedRepositoryIDKey = 'last-selected-repository-id'
|
||||
|
||||
|
@ -5681,6 +5682,18 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
this._closePopup(PopupType.CreateTutorialRepository)
|
||||
}
|
||||
}
|
||||
|
||||
/** This shouldn't be called directly. See `Dispatcher`. */
|
||||
public async _setCherryPickFlowStep(
|
||||
repository: Repository,
|
||||
step: CherryPickFlowStep
|
||||
): Promise<void> {
|
||||
this.repositoryStateCache.updateCherryPickState(repository, () => ({
|
||||
step,
|
||||
}))
|
||||
|
||||
this.emitUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
ICommitSelection,
|
||||
IRebaseState,
|
||||
ChangesSelectionKind,
|
||||
ICherryPickState,
|
||||
} from '../app-state'
|
||||
import { merge } from '../merge'
|
||||
import { DefaultCommitMessage } from '../../models/commit-message'
|
||||
|
@ -101,6 +102,17 @@ export class RepositoryStateCache {
|
|||
return { rebaseState: newState }
|
||||
})
|
||||
}
|
||||
|
||||
public updateCherryPickState<K extends keyof ICherryPickState>(
|
||||
repository: Repository,
|
||||
fn: (state: ICherryPickState) => Pick<ICherryPickState, K>
|
||||
) {
|
||||
this.update(repository, state => {
|
||||
const { cherryPickState } = state
|
||||
const newState = merge(cherryPickState, fn(cherryPickState))
|
||||
return { cherryPickState: newState }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function getInitialRepositoryState(): IRepositoryState {
|
||||
|
@ -170,5 +182,9 @@ function getInitialRepositoryState(): IRepositoryState {
|
|||
checkoutProgress: null,
|
||||
pushPullFetchProgress: null,
|
||||
revertProgress: null,
|
||||
cherryPickState: {
|
||||
step: null,
|
||||
progress: null,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,6 +97,7 @@ import { IStashEntry } from '../../models/stash-entry'
|
|||
import { WorkflowPreferences } from '../../models/workflow-preferences'
|
||||
import { enableForkSettings } from '../../lib/feature-flag'
|
||||
import { resolveWithin } from '../../lib/path'
|
||||
import { CherryPickFlowStep } from '../../models/cherry-pick'
|
||||
|
||||
/**
|
||||
* An error handler function.
|
||||
|
@ -2517,4 +2518,14 @@ export class Dispatcher {
|
|||
commitSha,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cherry pick flow to a new state.
|
||||
*/
|
||||
public setCherryPickFlowStep(
|
||||
repository: Repository,
|
||||
step: CherryPickFlowStep
|
||||
): Promise<void> {
|
||||
return this.appStore._setCherryPickFlowStep(repository, step)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue