Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions app/src/ui/discard-changes/discard-changes-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ interface IDiscardChangesState {
readonly isDiscardingChanges: boolean

readonly confirmDiscardChanges: boolean

/**
* Whether to permanently discard changes instead of moving them to the trash.
*/
readonly permanentDiscard: boolean
}

/**
Expand All @@ -52,6 +57,7 @@ export class DiscardChanges extends React.Component<
this.state = {
isDiscardingChanges: false,
confirmDiscardChanges: this.props.confirmDiscardChanges,
permanentDiscard: false,
}
}

Expand Down Expand Up @@ -87,10 +93,16 @@ export class DiscardChanges extends React.Component<
>
<DialogContent>
{this.renderFileList()}
<p>
Changes can be restored by retrieving them from the {TrashNameLabel}
.
</p>
<Checkbox
label={
'Permanently discard all changes instead of moving them to ' +
TrashNameLabel
}
value={
this.state.permanentDiscard ? CheckboxValue.On : CheckboxValue.Off
}
onChange={this.onConfirmPermanentDiscardChanged}
/>
{this.renderConfirmDiscardChanges()}
</DialogContent>

Expand Down Expand Up @@ -156,7 +168,8 @@ export class DiscardChanges extends React.Component<

await this.props.dispatcher.discardChanges(
this.props.repository,
this.props.files
this.props.files,
this.state.permanentDiscard
)

this.props.onConfirmDiscardChangesChanged(this.state.confirmDiscardChanges)
Expand All @@ -170,4 +183,12 @@ export class DiscardChanges extends React.Component<

this.setState({ confirmDiscardChanges: value })
}

private onConfirmPermanentDiscardChanged = (
event: React.FormEvent<HTMLInputElement>
) => {
const value = event.currentTarget.checked

this.setState({ permanentDiscard: value })
}
}