mirror of
https://github.com/desktop/desktop
synced 2024-10-02 14:23:59 +00:00
Merge pull request #18147 from desktop/feature-flag-diff-checkmarks
Feature flag and setup for adding setting of diff checkmarks
This commit is contained in:
commit
2b17667b38
|
@ -332,6 +332,9 @@ export interface IAppState {
|
|||
| PullRequestSuggestedNextAction
|
||||
| undefined
|
||||
|
||||
/** Whether or not the user will see check marks indicating a line is included in the check in the diff */
|
||||
readonly showDiffCheckMarks: boolean
|
||||
|
||||
/**
|
||||
* Cached repo rulesets. Used to prevent repeatedly querying the same
|
||||
* rulesets to check their bypass status.
|
||||
|
|
|
@ -101,3 +101,7 @@ export function enableSectionList(): boolean {
|
|||
export const enableRepoRulesBeta = () => true
|
||||
|
||||
export const enableCommitDetailsHeaderExpansion = () => true
|
||||
|
||||
export const enableDiffCheckMarksAndLinkUnderlines = enableBetaFeatures
|
||||
|
||||
export const enableDiffCheckMarks = enableDiffCheckMarksAndLinkUnderlines
|
||||
|
|
|
@ -407,6 +407,9 @@ const lastThankYouKey = 'version-and-users-of-last-thank-you'
|
|||
const pullRequestSuggestedNextActionKey =
|
||||
'pull-request-suggested-next-action-key'
|
||||
|
||||
const showDiffCheckMarksDefault = true
|
||||
const showDiffCheckMarksKey = 'diff-check-marks-visible'
|
||||
|
||||
export class AppStore extends TypedBaseStore<IAppState> {
|
||||
private readonly gitStoreCache: GitStoreCache
|
||||
|
||||
|
@ -537,6 +540,8 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
| PullRequestSuggestedNextAction
|
||||
| undefined = undefined
|
||||
|
||||
private showDiffCheckMarks: boolean = showDiffCheckMarksDefault
|
||||
|
||||
private cachedRepoRulesets = new Map<number, IAPIRepoRuleset>()
|
||||
|
||||
public constructor(
|
||||
|
@ -1018,6 +1023,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
pullRequestSuggestedNextAction: this.pullRequestSuggestedNextAction,
|
||||
resizablePaneActive: this.resizablePaneActive,
|
||||
cachedRepoRulesets: this.cachedRepoRulesets,
|
||||
showDiffCheckMarks: this.showDiffCheckMarks,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2206,6 +2212,11 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
PullRequestSuggestedNextAction
|
||||
) ?? defaultPullRequestSuggestedNextAction
|
||||
|
||||
this.showDiffCheckMarks = getBoolean(
|
||||
showDiffCheckMarksKey,
|
||||
showDiffCheckMarksDefault
|
||||
)
|
||||
|
||||
this.emitUpdateNow()
|
||||
|
||||
this.accountsStore.refresh()
|
||||
|
|
|
@ -3288,6 +3288,7 @@ export class App extends React.Component<IAppProps, IAppState> {
|
|||
imageDiffType={state.imageDiffType}
|
||||
hideWhitespaceInChangesDiff={state.hideWhitespaceInChangesDiff}
|
||||
hideWhitespaceInHistoryDiff={state.hideWhitespaceInHistoryDiff}
|
||||
showDiffCheckMarks={state.showDiffCheckMarks}
|
||||
showSideBySideDiff={state.showSideBySideDiff}
|
||||
focusCommitMessage={state.focusCommitMessage}
|
||||
askForConfirmationOnDiscardChanges={
|
||||
|
|
|
@ -49,6 +49,9 @@ interface IChangesProps {
|
|||
*/
|
||||
readonly showSideBySideDiff: boolean
|
||||
|
||||
/** Whether or not to show the diff check marks indicating inclusion in a commit */
|
||||
readonly showDiffCheckMarks: boolean
|
||||
|
||||
/** Called when the user opens the diff options popover */
|
||||
readonly onDiffOptionsOpened: () => void
|
||||
}
|
||||
|
@ -120,6 +123,7 @@ export class Changes extends React.Component<IChangesProps, {}> {
|
|||
diff={this.props.diff}
|
||||
hideWhitespaceInDiff={this.props.hideWhitespaceInDiff}
|
||||
showSideBySideDiff={this.props.showSideBySideDiff}
|
||||
showDiffCheckMarks={this.props.showDiffCheckMarks}
|
||||
askForConfirmationOnDiscardChanges={
|
||||
this.props.askForConfirmationOnDiscardChanges
|
||||
}
|
||||
|
|
|
@ -76,6 +76,9 @@ interface IDiffProps {
|
|||
/** Whether we should show a confirmation dialog when the user discards changes */
|
||||
readonly askForConfirmationOnDiscardChanges?: boolean
|
||||
|
||||
/** Whether or not to show the diff check marks indicating inclusion in a commit */
|
||||
readonly showDiffCheckMarks: boolean
|
||||
|
||||
/**
|
||||
* Called when the user requests to open a binary file in an the
|
||||
* system-assigned application for said file type.
|
||||
|
@ -287,6 +290,7 @@ export class Diff extends React.Component<IDiffProps, IDiffState> {
|
|||
onHideWhitespaceInDiffChanged={
|
||||
this.props.onHideWhitespaceInDiffChanged
|
||||
}
|
||||
showDiffCheckMarks={this.props.showDiffCheckMarks}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -68,6 +68,11 @@ interface ISeamlessDiffSwitcherProps {
|
|||
// eslint-disable-next-line react/no-unused-prop-types
|
||||
readonly showSideBySideDiff: boolean
|
||||
|
||||
/** Whether or not to show the diff check marks indicating inclusion in a commit */
|
||||
// Used in getDerivedStateFromProps, no-unused-prop-types doesn't know that
|
||||
// eslint-disable-next-line react/no-unused-prop-types
|
||||
readonly showDiffCheckMarks: boolean
|
||||
|
||||
/** Whether we should show a confirmation dialog when the user discards changes */
|
||||
readonly askForConfirmationOnDiscardChanges?: boolean
|
||||
|
||||
|
@ -327,6 +332,7 @@ export class SeamlessDiffSwitcher extends React.Component<
|
|||
readOnly,
|
||||
hideWhitespaceInDiff,
|
||||
showSideBySideDiff,
|
||||
showDiffCheckMarks,
|
||||
onIncludeChanged,
|
||||
onDiscardChanges,
|
||||
file,
|
||||
|
@ -363,6 +369,7 @@ export class SeamlessDiffSwitcher extends React.Component<
|
|||
askForConfirmationOnDiscardChanges={
|
||||
this.props.askForConfirmationOnDiscardChanges
|
||||
}
|
||||
showDiffCheckMarks={showDiffCheckMarks}
|
||||
onIncludeChanged={isLoadingDiff ? noop : onIncludeChanged}
|
||||
onDiscardChanges={isLoadingDiff ? noop : onDiscardChanges}
|
||||
onOpenBinaryFile={isLoadingDiff ? noop : onOpenBinaryFile}
|
||||
|
|
|
@ -19,6 +19,7 @@ import { WhitespaceHintPopover } from './whitespace-hint-popover'
|
|||
import { TooltipDirection } from '../lib/tooltip'
|
||||
import { Button } from '../lib/button'
|
||||
import { diffCheck } from '../octicons/diff-check'
|
||||
import { enableDiffCheckMarks } from '../../lib/feature-flag'
|
||||
|
||||
enum DiffRowPrefix {
|
||||
Added = '+',
|
||||
|
@ -150,6 +151,9 @@ interface ISideBySideDiffRowProps {
|
|||
expansionType: DiffHunkExpansionType,
|
||||
element: HTMLButtonElement | null
|
||||
) => void
|
||||
|
||||
/** Whether or not to show the diff check marks indicating inclusion in a commit */
|
||||
readonly showDiffCheckMarks: boolean
|
||||
}
|
||||
|
||||
interface ISideBySideDiffRowState {
|
||||
|
@ -399,10 +403,17 @@ export class SideBySideDiffRow extends React.Component<
|
|||
* for side-by-side diffs the gutter contains the line number of only one side.
|
||||
*/
|
||||
private get lineGutterWidth() {
|
||||
const { showSideBySideDiff, lineNumberWidth, isDiffSelectable } = this.props
|
||||
const {
|
||||
showSideBySideDiff,
|
||||
lineNumberWidth,
|
||||
isDiffSelectable,
|
||||
showDiffCheckMarks,
|
||||
} = this.props
|
||||
return (
|
||||
(showSideBySideDiff ? lineNumberWidth : lineNumberWidth * 2) +
|
||||
(isDiffSelectable ? 14 : 0)
|
||||
(isDiffSelectable && showDiffCheckMarks && enableDiffCheckMarks()
|
||||
? 14
|
||||
: 0)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -545,7 +556,11 @@ export class SideBySideDiffRow extends React.Component<
|
|||
}
|
||||
|
||||
private renderLineNumberCheck(isSelected?: boolean) {
|
||||
if (!this.props.isDiffSelectable) {
|
||||
if (
|
||||
!this.props.isDiffSelectable ||
|
||||
!enableDiffCheckMarks() ||
|
||||
!this.props.showDiffCheckMarks
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
@ -135,6 +135,9 @@ interface ISideBySideDiffProps {
|
|||
*/
|
||||
readonly showSideBySideDiff: boolean
|
||||
|
||||
/** Whether or not to show the diff check marks indicating inclusion in a commit */
|
||||
readonly showDiffCheckMarks: boolean
|
||||
|
||||
/** Called when the user changes the hide whitespace in diffs setting. */
|
||||
readonly onHideWhitespaceInDiffChanged: (checked: boolean) => void
|
||||
}
|
||||
|
@ -661,6 +664,7 @@ export class SideBySideDiff extends React.Component<
|
|||
isHunkHovered={isHunkHovered}
|
||||
showSideBySideDiff={this.props.showSideBySideDiff}
|
||||
hideWhitespaceInDiff={this.props.hideWhitespaceInDiff}
|
||||
showDiffCheckMarks={this.props.showDiffCheckMarks}
|
||||
onStartSelection={this.onStartSelection}
|
||||
onMouseEnterHunk={this.onMouseEnterHunk}
|
||||
onMouseLeaveHunk={this.onMouseLeaveHunk}
|
||||
|
|
|
@ -173,6 +173,7 @@ export class SelectedCommits extends React.Component<
|
|||
diff={diff}
|
||||
readOnly={true}
|
||||
hideWhitespaceInDiff={this.props.hideWhitespaceInDiff}
|
||||
showDiffCheckMarks={false}
|
||||
showSideBySideDiff={this.props.showSideBySideDiff}
|
||||
onOpenBinaryFile={this.props.onOpenBinaryFile}
|
||||
onChangeImageDiffType={this.props.onChangeImageDiffType}
|
||||
|
|
|
@ -301,6 +301,7 @@ export class PullRequestFilesChanged extends React.Component<
|
|||
readOnly={true}
|
||||
hideWhitespaceInDiff={hideWhitespaceInDiff}
|
||||
showSideBySideDiff={showSideBySideDiff}
|
||||
showDiffCheckMarks={false}
|
||||
onOpenBinaryFile={this.onOpenBinaryFile}
|
||||
onChangeImageDiffType={this.onChangeImageDiffType}
|
||||
onHideWhitespaceInDiffChanged={this.onHideWhitespaceInDiffChanged}
|
||||
|
|
|
@ -49,6 +49,7 @@ interface IRepositoryViewProps {
|
|||
readonly hideWhitespaceInChangesDiff: boolean
|
||||
readonly hideWhitespaceInHistoryDiff: boolean
|
||||
readonly showSideBySideDiff: boolean
|
||||
readonly showDiffCheckMarks: boolean
|
||||
readonly askForConfirmationOnDiscardChanges: boolean
|
||||
readonly askForConfirmationOnDiscardStash: boolean
|
||||
readonly askForConfirmationOnCheckoutCommit: boolean
|
||||
|
@ -533,6 +534,7 @@ export class RepositoryView extends React.Component<
|
|||
imageDiffType={this.props.imageDiffType}
|
||||
hideWhitespaceInDiff={this.props.hideWhitespaceInChangesDiff}
|
||||
showSideBySideDiff={this.props.showSideBySideDiff}
|
||||
showDiffCheckMarks={this.props.showDiffCheckMarks}
|
||||
onOpenBinaryFile={this.onOpenBinaryFile}
|
||||
onOpenSubmodule={this.onOpenSubmodule}
|
||||
onChangeImageDiffType={this.onChangeImageDiffType}
|
||||
|
|
|
@ -109,6 +109,7 @@ export class StashDiffViewer extends React.PureComponent<IStashDiffViewerProps>
|
|||
diff={stashedFileDiff}
|
||||
imageDiffType={imageDiffType}
|
||||
hideWhitespaceInDiff={false}
|
||||
showDiffCheckMarks={false}
|
||||
showSideBySideDiff={this.props.showSideBySideDiff}
|
||||
onOpenBinaryFile={onOpenBinaryFile}
|
||||
onChangeImageDiffType={onChangeImageDiffType}
|
||||
|
|
Loading…
Reference in a new issue