From efc5fea7cc7c981501ce40e50571cdced2380e38 Mon Sep 17 00:00:00 2001 From: tidy-dev <75402236+tidy-dev@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:15:22 -0500 Subject: [PATCH 01/16] Add check for if all files to be committed are visible --- app/src/ui/changes/commit-message.tsx | 12 +++++++++++- app/src/ui/changes/filter-changes-list.tsx | 13 +++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/src/ui/changes/commit-message.tsx b/app/src/ui/changes/commit-message.tsx index bbe9bfc1716..96a05c182c8 100644 --- a/app/src/ui/changes/commit-message.tsx +++ b/app/src/ui/changes/commit-message.tsx @@ -74,6 +74,9 @@ interface ICommitMessageProps { readonly branch: string | null readonly commitAuthor: CommitIdentity | null readonly anyFilesSelected: boolean + /** Whether the user can see all the files to commit in the changes list. They + * may not be able to if the list is filtered */ + readonly allFilesToCommitNotVisible?: boolean readonly isShowingModal: boolean readonly isShowingFoldout: boolean @@ -161,7 +164,7 @@ interface ICommitMessageProps { readonly onCommitSpellcheckEnabledChanged: (enabled: boolean) => void readonly onStopAmending: () => void readonly onShowCreateForkDialog: () => void - + readonly onFilesToCommitNotVisible?: () => void readonly accounts: ReadonlyArray } @@ -479,6 +482,13 @@ export class CommitMessage extends React.Component< } private onSubmit = () => { + if ( + this.props.allFilesToCommitNotVisible === true && + this.props.onFilesToCommitNotVisible + ) { + this.props.onFilesToCommitNotVisible() + return + } this.createCommit() } diff --git a/app/src/ui/changes/filter-changes-list.tsx b/app/src/ui/changes/filter-changes-list.tsx index 47c94cb9a60..ef8804b9263 100644 --- a/app/src/ui/changes/filter-changes-list.tsx +++ b/app/src/ui/changes/filter-changes-list.tsx @@ -842,6 +842,7 @@ export class FilterChangesList extends React.Component< const anyFilesSelected = fileCount > 0 && includeAllValue !== CheckboxValue.Off + // Files selected to commit (to be committed) (not selected to see in diff) const filesSelected = workingDirectory.files.filter( f => f.selection.getSelectionType() !== DiffSelectionType.None ) @@ -859,6 +860,10 @@ export class FilterChangesList extends React.Component< this.props.repository.gitHubRepository === null || hasWritePermission(this.props.repository.gitHubRepository) + const allFilesToCommitNotVisible = filesSelected.some( + file => !this.state.filteredItems.find(fi => fi.id === file.id) + ) + return ( 0} repository={repository} repositoryAccount={repositoryAccount} @@ -904,6 +910,7 @@ export class FilterChangesList extends React.Component< onCommitSpellcheckEnabledChanged={this.onCommitSpellcheckEnabledChanged} onStopAmending={this.onStopAmending} onShowCreateForkDialog={this.onShowCreateForkDialog} + onFilesToCommitNotVisible={this.onFilesToCommitNotVisible} accounts={this.props.accounts} /> ) @@ -1032,8 +1039,6 @@ export class FilterChangesList extends React.Component< filteredItems: ReadonlyArray ) => { this.setState({ filteredItems }) - // TBD: Remove when used. - console.log(this.state.filteredItems, filteredItems) } private onFileSelectionChanged = (items: ReadonlyArray) => { @@ -1043,6 +1048,10 @@ export class FilterChangesList extends React.Component< this.props.onFileSelectionChanged(rows) } + private onFilesToCommitNotVisible = () => { + console.log('Really?"') + } + public render() { const { workingDirectory, rebaseConflictState, isCommitting } = this.props const { files } = workingDirectory From 14223ba1cabf70e047f69838655190ac5ffc2318 Mon Sep 17 00:00:00 2001 From: tidy-dev <75402236+tidy-dev@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:57:09 -0500 Subject: [PATCH 02/16] Create confirm-commit-filtered-changes-dialog.tsx Update confirm-commit-filtered-changes-dialog.tsx --- ...confirm-commit-filtered-changes-dialog.tsx | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 app/src/ui/changes/confirm-commit-filtered-changes-dialog.tsx diff --git a/app/src/ui/changes/confirm-commit-filtered-changes-dialog.tsx b/app/src/ui/changes/confirm-commit-filtered-changes-dialog.tsx new file mode 100644 index 00000000000..f32da9a6304 --- /dev/null +++ b/app/src/ui/changes/confirm-commit-filtered-changes-dialog.tsx @@ -0,0 +1,74 @@ +import * as React from 'react' +import { Dialog, DialogContent, DialogFooter } from '../dialog' +import { Row } from '../lib/row' +import { OkCancelButtonGroup } from '../dialog/ok-cancel-button-group' +import { Checkbox, CheckboxValue } from '../lib/checkbox' +import { LinkButton } from '../lib/link-button' + +interface IConfirmCommitFilteredChangesProps { + readonly onCommitAnyway: () => void + readonly onDismissed: () => void + readonly onClearFilter: () => void + readonly setConfirmCommitFilteredChanges: (value: boolean) => void +} + +interface IConfirmCommitFilteredChangesState { + readonly showAgain: boolean +} + +export class ConfirmCommitFilteredChanges extends React.Component< + IConfirmCommitFilteredChangesProps, + IConfirmCommitFilteredChangesState +> { + public render() { + return ( + + ) + } + + private onShowMessageChange = (event: React.FormEvent) => { + const value = !event.currentTarget.checked + + this.setState({ showAgain: value }) + } + + private onSubmit = async () => { + this.props.setConfirmCommitFilteredChanges(this.state.showAgain) + this.props.onCommitAnyway() + this.props.onDismissed() + } +} From c1f643351492a7fb272b3f996de4267f43c27419 Mon Sep 17 00:00:00 2001 From: tidy-dev <75402236+tidy-dev@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:00:33 -0500 Subject: [PATCH 03/16] Create prompt setting for committing filtered changes Update app.tsx --- app/src/lib/app-state.ts | 3 +++ app/src/lib/stores/app-store.ts | 16 ++++++++++++++++ app/src/ui/app.tsx | 16 ++++++++++++++++ app/src/ui/dispatcher/dispatcher.ts | 4 ++++ app/src/ui/preferences/preferences.tsx | 15 +++++++++++++++ app/src/ui/preferences/prompts.tsx | 23 +++++++++++++++++++++++ 6 files changed, 77 insertions(+) diff --git a/app/src/lib/app-state.ts b/app/src/lib/app-state.ts index 3ec85adc2f8..e97835cb970 100644 --- a/app/src/lib/app-state.ts +++ b/app/src/lib/app-state.ts @@ -232,6 +232,9 @@ export interface IAppState { /** Should the app prompt the user to confirm an undo commit? */ readonly askForConfirmationOnUndoCommit: boolean + /** Should the app prompt the user to confirm they want to commit with changes are hidden by filter? */ + readonly askForConfirmationOnCommitFilteredChanges: boolean + /** How the app should handle uncommitted changes when switching branches */ readonly uncommittedChangesStrategy: UncommittedChangesStrategy diff --git a/app/src/lib/stores/app-store.ts b/app/src/lib/stores/app-store.ts index 0f3da9ffda8..f224e265992 100644 --- a/app/src/lib/stores/app-store.ts +++ b/app/src/lib/stores/app-store.ts @@ -379,6 +379,7 @@ const confirmDiscardStashDefault: boolean = true const confirmCheckoutCommitDefault: boolean = true const askForConfirmationOnForcePushDefault = true const confirmUndoCommitDefault: boolean = true +const confirmCommitFilteredChangesDefault: boolean = true const askToMoveToApplicationsFolderKey: string = 'askToMoveToApplicationsFolder' const confirmRepoRemovalKey: string = 'confirmRepoRemoval' const showCommitLengthWarningKey: string = 'showCommitLengthWarning' @@ -389,6 +390,8 @@ const confirmDiscardChangesPermanentlyKey: string = 'confirmDiscardChangesPermanentlyKey' const confirmForcePushKey: string = 'confirmForcePush' const confirmUndoCommitKey: string = 'confirmUndoCommit' +const confirmCommitFilteredChangesKey: string = + 'confirmCommitFilteredChangesKey' const uncommittedChangesStrategyKey = 'uncommittedChangesStrategyKind' @@ -518,6 +521,8 @@ export class AppStore extends TypedBaseStore { private confirmCheckoutCommit: boolean = confirmCheckoutCommitDefault private askForConfirmationOnForcePush = askForConfirmationOnForcePushDefault private confirmUndoCommit: boolean = confirmUndoCommitDefault + private confirmCommitFilteredChanges: boolean = + confirmCommitFilteredChangesDefault private imageDiffType: ImageDiffType = imageDiffTypeDefault private hideWhitespaceInChangesDiff: boolean = hideWhitespaceInChangesDiffDefault @@ -1041,6 +1046,8 @@ export class AppStore extends TypedBaseStore { askForConfirmationOnCheckoutCommit: this.confirmCheckoutCommit, askForConfirmationOnForcePush: this.askForConfirmationOnForcePush, askForConfirmationOnUndoCommit: this.confirmUndoCommit, + askForConfirmationOnCommitFilteredChanges: + this.confirmCommitFilteredChanges, uncommittedChangesStrategy: this.uncommittedChangesStrategy, selectedExternalEditor: this.selectedExternalEditor, imageDiffType: this.imageDiffType, @@ -5771,6 +5778,15 @@ export class AppStore extends TypedBaseStore { return Promise.resolve() } + public _setConfirmCommitFilteredChanges(value: boolean): Promise { + this.confirmCommitFilteredChanges = value + setBoolean(confirmCommitFilteredChangesKey, value) + + this.emitUpdate() + + return Promise.resolve() + } + public _setUncommittedChangesStrategySetting( value: UncommittedChangesStrategy ): Promise { diff --git a/app/src/ui/app.tsx b/app/src/ui/app.tsx index db2cc8fe977..ec5b6431a92 100644 --- a/app/src/ui/app.tsx +++ b/app/src/ui/app.tsx @@ -181,6 +181,7 @@ import { accessibilityBannerDismissed } from './banners/accessibilty-settings-ba import { isCertificateErrorSuppressedFor } from '../lib/suppress-certificate-error' import { webUtils } from 'electron' import { showTestUI } from './lib/test-ui-components/test-ui-components' +import { ConfirmCommitFilteredChanges } from './changes/confirm-commit-filtered-changes-dialog' const MinuteInMilliseconds = 1000 * 60 const HourInMilliseconds = MinuteInMilliseconds * 60 @@ -1557,6 +1558,9 @@ export class App extends React.Component { } confirmForcePush={this.state.askForConfirmationOnForcePush} confirmUndoCommit={this.state.askForConfirmationOnUndoCommit} + askForConfirmationOnCommitFilteredChanges={ + this.state.askForConfirmationOnCommitFilteredChanges + } uncommittedChangesStrategy={this.state.uncommittedChangesStrategy} selectedExternalEditor={this.state.selectedExternalEditor} useWindowsOpenSSH={this.state.useWindowsOpenSSH} @@ -2482,6 +2486,18 @@ export class App extends React.Component { /> ) } + case PopupType.ConfirmCommitFilteredChanges: { + return ( + + ) + } default: return assertNever(popup, `Unknown popup type: ${popup}`) } diff --git a/app/src/ui/dispatcher/dispatcher.ts b/app/src/ui/dispatcher/dispatcher.ts index 57804ea3306..bfa642963a7 100644 --- a/app/src/ui/dispatcher/dispatcher.ts +++ b/app/src/ui/dispatcher/dispatcher.ts @@ -2421,6 +2421,10 @@ export class Dispatcher { return this.appStore._setConfirmUndoCommitSetting(value) } + public setConfirmCommitFilteredChanges(value: boolean) { + return this.appStore._setConfirmCommitFilteredChanges(value) + } + /** * Converts a local repository to use the given fork * as its default remote and associated `GitHubRepository`. diff --git a/app/src/ui/preferences/preferences.tsx b/app/src/ui/preferences/preferences.tsx index 0cd7cf4649f..416fb331f35 100644 --- a/app/src/ui/preferences/preferences.tsx +++ b/app/src/ui/preferences/preferences.tsx @@ -67,6 +67,7 @@ interface IPreferencesProps { readonly confirmCheckoutCommit: boolean readonly confirmForcePush: boolean readonly confirmUndoCommit: boolean + readonly askForConfirmationOnCommitFilteredChanges: boolean readonly uncommittedChangesStrategy: UncommittedChangesStrategy readonly selectedExternalEditor: string | null readonly selectedShell: Shell @@ -103,6 +104,7 @@ interface IPreferencesState { readonly confirmCheckoutCommit: boolean readonly confirmForcePush: boolean readonly confirmUndoCommit: boolean + readonly askForConfirmationOnCommitFilteredChanges: boolean readonly uncommittedChangesStrategy: UncommittedChangesStrategy readonly availableEditors: ReadonlyArray readonly useCustomEditor: boolean @@ -177,6 +179,7 @@ export class Preferences extends React.Component< confirmCheckoutCommit: false, confirmForcePush: false, confirmUndoCommit: false, + askForConfirmationOnCommitFilteredChanges: false, uncommittedChangesStrategy: defaultUncommittedChangesStrategy, selectedExternalEditor: this.props.selectedExternalEditor, availableShells: [], @@ -243,6 +246,8 @@ export class Preferences extends React.Component< confirmCheckoutCommit: this.props.confirmCheckoutCommit, confirmForcePush: this.props.confirmForcePush, confirmUndoCommit: this.props.confirmUndoCommit, + askForConfirmationOnCommitFilteredChanges: + this.props.askForConfirmationOnCommitFilteredChanges, uncommittedChangesStrategy: this.props.uncommittedChangesStrategy, availableShells, availableEditors, @@ -476,6 +481,9 @@ export class Preferences extends React.Component< confirmCheckoutCommit={this.state.confirmCheckoutCommit} confirmForcePush={this.state.confirmForcePush} confirmUndoCommit={this.state.confirmUndoCommit} + askForConfirmationOnCommitFilteredChanges={ + this.state.askForConfirmationOnCommitFilteredChanges + } onConfirmRepositoryRemovalChanged={ this.onConfirmRepositoryRemovalChanged } @@ -487,6 +495,9 @@ export class Preferences extends React.Component< this.onConfirmDiscardChangesPermanentlyChanged } onConfirmUndoCommitChanged={this.onConfirmUndoCommitChanged} + onAskForConfirmationOnCommitFilteredChanges={ + this.onAskForConfirmationOnCommitFilteredChanges + } uncommittedChangesStrategy={this.state.uncommittedChangesStrategy} onUncommittedChangesStrategyChanged={ this.onUncommittedChangesStrategyChanged @@ -607,6 +618,10 @@ export class Preferences extends React.Component< this.setState({ confirmUndoCommit: value }) } + private onAskForConfirmationOnCommitFilteredChanges = (value: boolean) => { + this.setState({ askForConfirmationOnCommitFilteredChanges: value }) + } + private onUncommittedChangesStrategyChanged = ( uncommittedChangesStrategy: UncommittedChangesStrategy ) => { diff --git a/app/src/ui/preferences/prompts.tsx b/app/src/ui/preferences/prompts.tsx index 599162ca612..dd1c103fd9f 100644 --- a/app/src/ui/preferences/prompts.tsx +++ b/app/src/ui/preferences/prompts.tsx @@ -13,6 +13,7 @@ interface IPromptsPreferencesProps { readonly confirmCheckoutCommit: boolean readonly confirmForcePush: boolean readonly confirmUndoCommit: boolean + readonly askForConfirmationOnCommitFilteredChanges: boolean readonly showCommitLengthWarning: boolean readonly uncommittedChangesStrategy: UncommittedChangesStrategy readonly onConfirmDiscardChangesChanged: (checked: boolean) => void @@ -26,6 +27,7 @@ interface IPromptsPreferencesProps { readonly onUncommittedChangesStrategyChanged: ( value: UncommittedChangesStrategy ) => void + readonly onAskForConfirmationOnCommitFilteredChanges: (value: boolean) => void } interface IPromptsPreferencesState { @@ -36,6 +38,7 @@ interface IPromptsPreferencesState { readonly confirmCheckoutCommit: boolean readonly confirmForcePush: boolean readonly confirmUndoCommit: boolean + readonly askForConfirmationOnCommitFilteredChanges: boolean readonly uncommittedChangesStrategy: UncommittedChangesStrategy } @@ -56,6 +59,8 @@ export class Prompts extends React.Component< confirmForcePush: this.props.confirmForcePush, confirmUndoCommit: this.props.confirmUndoCommit, uncommittedChangesStrategy: this.props.uncommittedChangesStrategy, + askForConfirmationOnCommitFilteredChanges: + this.props.askForConfirmationOnCommitFilteredChanges, } } @@ -113,6 +118,15 @@ export class Prompts extends React.Component< this.props.onConfirmUndoCommitChanged(value) } + private onAskForConfirmationOnCommitFilteredChanges = ( + event: React.FormEvent + ) => { + const value = event.currentTarget.checked + + this.setState({ askForConfirmationOnCommitFilteredChanges: value }) + this.props.onAskForConfirmationOnCommitFilteredChanges(value) + } + private onConfirmRepositoryRemovalChanged = ( event: React.FormEvent ) => { @@ -247,6 +261,15 @@ export class Prompts extends React.Component< } onChange={this.onConfirmUndoCommitChanged} /> + {this.renderSwitchBranchOptions()} From 0893f63273f826b5a06188da07ac4e94411803ac Mon Sep 17 00:00:00 2001 From: tidy-dev <75402236+tidy-dev@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:07:02 -0500 Subject: [PATCH 04/16] Add confirm filter changes popup model --- app/src/models/popup.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/models/popup.ts b/app/src/models/popup.ts index 9191b3a94e8..ea89afafc5e 100644 --- a/app/src/models/popup.ts +++ b/app/src/models/popup.ts @@ -95,6 +95,7 @@ export enum PopupType { PullRequestComment = 'PullRequestComment', UnknownAuthors = 'UnknownAuthors', TestIcons = 'TestIcons', + ConfirmCommitFilteredChanges = 'ConfirmCommitFilteredChanges', } interface IBasePopup { @@ -423,5 +424,10 @@ export type PopupDetail = | { type: PopupType.TestIcons } + | { + type: PopupType.ConfirmCommitFilteredChanges + onCommitAnyway: () => void + onClearFilter: () => void + } export type Popup = IBasePopup & PopupDetail From 0db1c85a187f8f305c2cbf27e33765368e53cc8b Mon Sep 17 00:00:00 2001 From: tidy-dev <75402236+tidy-dev@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:07:29 -0500 Subject: [PATCH 05/16] Bubble create commit action on confirm --- app/src/ui/changes/commit-message.tsx | 43 ++++++++++++++++----------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/app/src/ui/changes/commit-message.tsx b/app/src/ui/changes/commit-message.tsx index 96a05c182c8..7a08a9bfca1 100644 --- a/app/src/ui/changes/commit-message.tsx +++ b/app/src/ui/changes/commit-message.tsx @@ -69,6 +69,11 @@ const addAuthorIcon: OcticonSymbolVariant = { ], } +interface ICreateCommitOptions { + warnUnknownAuthors: boolean + warnFilesNotVisible: boolean +} + interface ICommitMessageProps { readonly onCreateCommit: (context: ICommitContext) => Promise readonly branch: string | null @@ -164,7 +169,7 @@ interface ICommitMessageProps { readonly onCommitSpellcheckEnabledChanged: (enabled: boolean) => void readonly onStopAmending: () => void readonly onShowCreateForkDialog: () => void - readonly onFilesToCommitNotVisible?: () => void + readonly onFilesToCommitNotVisible?: (onCommitAnyway: () => {}) => void readonly accounts: ReadonlyArray } @@ -482,13 +487,6 @@ export class CommitMessage extends React.Component< } private onSubmit = () => { - if ( - this.props.allFilesToCommitNotVisible === true && - this.props.onFilesToCommitNotVisible - ) { - this.props.onFilesToCommitNotVisible() - return - } this.createCommit() } @@ -508,26 +506,24 @@ export class CommitMessage extends React.Component< : this.state.summary } - private forceCreateCommit = async () => { - return this.createCommit(false) - } - - private async createCommit(warnUnknownAuthors: boolean = true) { + private async createCommit(options?: ICreateCommitOptions) { const { description } = this.state if (!this.canCommit() && !this.canAmend()) { return } - if (warnUnknownAuthors) { + if (options?.warnUnknownAuthors === true) { const unknownAuthors = this.props.coAuthors.filter( (author): author is UnknownAuthor => !isKnownAuthor(author) ) if (unknownAuthors.length > 0) { - this.props.onConfirmCommitWithUnknownCoAuthors( - unknownAuthors, - this.forceCreateCommit + this.props.onConfirmCommitWithUnknownCoAuthors(unknownAuthors, () => + this.createCommit({ + warnUnknownAuthors: false, + warnFilesNotVisible: options?.warnFilesNotVisible === true, + }) ) return } @@ -542,6 +538,19 @@ export class CommitMessage extends React.Component< amend: this.props.commitToAmend !== null, } + if ( + this.props.allFilesToCommitNotVisible === true && + this.props.onFilesToCommitNotVisible + ) { + this.props.onFilesToCommitNotVisible(() => + this.createCommit({ + warnUnknownAuthors: options?.warnUnknownAuthors === true, + warnFilesNotVisible: false, + }) + ) + return + } + const timer = startTimer('create commit', this.props.repository) const commitCreated = await this.props.onCreateCommit(commitContext) timer.done() From 730c0b9aed4537bbc8562e3601bd0ad21d8984c6 Mon Sep 17 00:00:00 2001 From: tidy-dev <75402236+tidy-dev@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:07:43 -0500 Subject: [PATCH 06/16] Dispatch popup --- app/src/ui/changes/filter-changes-list.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/ui/changes/filter-changes-list.tsx b/app/src/ui/changes/filter-changes-list.tsx index ef8804b9263..a8a577e771f 100644 --- a/app/src/ui/changes/filter-changes-list.tsx +++ b/app/src/ui/changes/filter-changes-list.tsx @@ -51,7 +51,7 @@ import { hasWritePermission } from '../../models/github-repository' import { hasConflictedFiles } from '../../lib/status' import { createObservableRef } from '../lib/observable-ref' import { TooltipDirection } from '../lib/tooltip' -import { Popup } from '../../models/popup' +import { Popup, PopupType } from '../../models/popup' import { EOL } from 'os' import { TooltippedContent } from '../lib/tooltipped-content' import { RepoRulesInfo } from '../../models/repo-rules' @@ -1048,8 +1048,12 @@ export class FilterChangesList extends React.Component< this.props.onFileSelectionChanged(rows) } - private onFilesToCommitNotVisible = () => { - console.log('Really?"') + private onFilesToCommitNotVisible = (onCommitAnyway: () => void) => { + this.props.dispatcher.showPopup({ + type: PopupType.ConfirmCommitFilteredChanges, + onCommitAnyway, + onClearFilter: () => this.setState({ filterText: '' }), + }) } public render() { From 3abfaea87bab3cc925dd0ddfa5099aaa07e12dff Mon Sep 17 00:00:00 2001 From: tidy-dev <75402236+tidy-dev@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:30:20 -0500 Subject: [PATCH 07/16] Finish wiring up askForConfirmationOnCommitFilteredChanges --- app/src/lib/stores/app-store.ts | 5 +++++ app/src/ui/app.tsx | 9 ++++++++- app/src/ui/changes/filter-changes-list.tsx | 9 ++++++--- app/src/ui/changes/sidebar.tsx | 4 ++++ app/src/ui/preferences/preferences.tsx | 3 +++ app/src/ui/repository.tsx | 4 ++++ 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/src/lib/stores/app-store.ts b/app/src/lib/stores/app-store.ts index f224e265992..c099e54516b 100644 --- a/app/src/lib/stores/app-store.ts +++ b/app/src/lib/stores/app-store.ts @@ -2218,6 +2218,11 @@ export class AppStore extends TypedBaseStore { confirmUndoCommitDefault ) + this.confirmCommitFilteredChanges = getBoolean( + confirmCommitFilteredChangesKey, + confirmCommitFilteredChangesDefault + ) + this.uncommittedChangesStrategy = getEnum(uncommittedChangesStrategyKey, UncommittedChangesStrategy) ?? defaultUncommittedChangesStrategy diff --git a/app/src/ui/app.tsx b/app/src/ui/app.tsx index ec5b6431a92..65ba4e12a4c 100644 --- a/app/src/ui/app.tsx +++ b/app/src/ui/app.tsx @@ -2493,7 +2493,7 @@ export class App extends React.Component { onDismissed={onPopupDismissedFn} onClearFilter={popup.onClearFilter} setConfirmCommitFilteredChanges={ - this.props.dispatcher.setConfirmCommitFilteredChanges + this.setConfirmCommitFilteredChanges } /> ) @@ -2503,6 +2503,10 @@ export class App extends React.Component { } } + private setConfirmCommitFilteredChanges = (value: boolean) => { + this.props.dispatcher.setConfirmCommitFilteredChanges(value) + } + private getPullRequestState() { const { selectedState } = this.state if ( @@ -3241,6 +3245,9 @@ export class App extends React.Component { askForConfirmationOnCheckoutCommit={ state.askForConfirmationOnCheckoutCommit } + askForConfirmationOnCommitFilteredChanges={ + state.askForConfirmationOnCommitFilteredChanges + } accounts={state.accounts} isExternalEditorAvailable={ state.useCustomEditor || state.selectedExternalEditor !== null diff --git a/app/src/ui/changes/filter-changes-list.tsx b/app/src/ui/changes/filter-changes-list.tsx index a8a577e771f..b069f586139 100644 --- a/app/src/ui/changes/filter-changes-list.tsx +++ b/app/src/ui/changes/filter-changes-list.tsx @@ -142,6 +142,7 @@ interface IFilterChangesListProps { readonly onCreateCommit: (context: ICommitContext) => Promise readonly onDiscardChanges: (file: WorkingDirectoryFileChange) => void readonly askForConfirmationOnDiscardChanges: boolean + readonly askForConfirmationOnCommitFilteredChanges: boolean readonly focusCommitMessage: boolean readonly isShowingModal: boolean readonly isShowingFoldout: boolean @@ -860,9 +861,11 @@ export class FilterChangesList extends React.Component< this.props.repository.gitHubRepository === null || hasWritePermission(this.props.repository.gitHubRepository) - const allFilesToCommitNotVisible = filesSelected.some( - file => !this.state.filteredItems.find(fi => fi.id === file.id) - ) + const allFilesToCommitNotVisible = + this.props.askForConfirmationOnCommitFilteredChanges && + filesSelected.some( + file => !this.state.filteredItems.find(fi => fi.id === file.id) + ) return ( readonly isShowingModal: boolean readonly isShowingFoldout: boolean @@ -421,6 +422,9 @@ export class ChangesSidebar extends React.Component { askForConfirmationOnDiscardChanges={ this.props.askForConfirmationOnDiscardChanges } + askForConfirmationOnCommitFilteredChanges={ + this.props.askForConfirmationOnCommitFilteredChanges + } onDiscardChangesFromFiles={this.onDiscardChangesFromFiles} onOpenItem={this.onOpenItem} onRowClick={this.onChangedItemClick} diff --git a/app/src/ui/preferences/preferences.tsx b/app/src/ui/preferences/preferences.tsx index 416fb331f35..485da893886 100644 --- a/app/src/ui/preferences/preferences.tsx +++ b/app/src/ui/preferences/preferences.tsx @@ -805,6 +805,9 @@ export class Preferences extends React.Component< ) await dispatcher.setConfirmUndoCommitSetting(this.state.confirmUndoCommit) + await dispatcher.setConfirmCommitFilteredChanges( + this.state.askForConfirmationOnCommitFilteredChanges + ) if (this.state.selectedExternalEditor) { await dispatcher.setExternalEditor(this.state.selectedExternalEditor) diff --git a/app/src/ui/repository.tsx b/app/src/ui/repository.tsx index 5738811ccf4..2ee6862d77f 100644 --- a/app/src/ui/repository.tsx +++ b/app/src/ui/repository.tsx @@ -52,6 +52,7 @@ interface IRepositoryViewProps { readonly showSideBySideDiff: boolean readonly showDiffCheckMarks: boolean readonly askForConfirmationOnDiscardChanges: boolean + readonly askForConfirmationOnCommitFilteredChanges: boolean readonly askForConfirmationOnDiscardStash: boolean readonly askForConfirmationOnCheckoutCommit: boolean readonly focusCommitMessage: boolean @@ -250,6 +251,9 @@ export class RepositoryView extends React.Component< askForConfirmationOnDiscardChanges={ this.props.askForConfirmationOnDiscardChanges } + askForConfirmationOnCommitFilteredChanges={ + this.props.askForConfirmationOnCommitFilteredChanges + } accounts={this.props.accounts} isShowingModal={this.props.isShowingModal} isShowingFoldout={this.props.isShowingFoldout} From 62dd1bf27695decc6b83aebb1f7c7134b81baa6c Mon Sep 17 00:00:00 2001 From: tidy-dev <75402236+tidy-dev@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:30:48 -0500 Subject: [PATCH 08/16] Clearer title --- app/src/ui/changes/confirm-commit-filtered-changes-dialog.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/ui/changes/confirm-commit-filtered-changes-dialog.tsx b/app/src/ui/changes/confirm-commit-filtered-changes-dialog.tsx index f32da9a6304..6a91bb76c1d 100644 --- a/app/src/ui/changes/confirm-commit-filtered-changes-dialog.tsx +++ b/app/src/ui/changes/confirm-commit-filtered-changes-dialog.tsx @@ -25,7 +25,9 @@ export class ConfirmCommitFilteredChanges extends React.Component<