Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ignore action to context menu for simple staging #751

Merged
merged 1 commit into from
Aug 30, 2020
Merged
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
19 changes: 17 additions & 2 deletions src/components/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
this._contextMenuUntracked = new Menu({ commands });
this._contextMenuUntrackedMin = new Menu({ commands });
this._contextMenuSimpleUntracked = new Menu({ commands });
this._contextMenuSimpleUntrackedMin = new Menu({ commands });
this._contextMenuSimpleTracked = new Menu({ commands });

this.state = {
Expand Down Expand Up @@ -239,9 +240,17 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
this._contextMenuSimpleTracked.addItem({ command });
});

[CommandIDs.gitFileOpen].forEach(command => {
[
CommandIDs.gitFileOpen,
CommandIDs.gitIgnore,
CommandIDs.gitIgnoreExtension
].forEach(command => {
this._contextMenuSimpleUntracked.addItem({ command });
});

[CommandIDs.gitFileOpen, CommandIDs.gitIgnore].forEach(command => {
this._contextMenuSimpleUntrackedMin.addItem({ command });
});
}

/** Handle right-click on a staged file */
Expand Down Expand Up @@ -270,7 +279,12 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
/** Handle right-click on an untracked file in Simple mode*/
contextMenuSimpleUntracked = (event: React.MouseEvent) => {
event.preventDefault();
this._contextMenuSimpleUntracked.open(event.clientX, event.clientY);
const extension = PathExt.extname(this.state.selectedFile.to);
if (extension.length > 0) {
this._contextMenuSimpleUntracked.open(event.clientX, event.clientY);
} else {
this._contextMenuSimpleUntrackedMin.open(event.clientX, event.clientY);
}
};

/** Handle right-click on an tracked file in Simple mode*/
Expand Down Expand Up @@ -821,4 +835,5 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
private _contextMenuUntrackedMin: Menu;
private _contextMenuSimpleTracked: Menu;
private _contextMenuSimpleUntracked: Menu;
private _contextMenuSimpleUntrackedMin: Menu;
}