Skip to content

Commit

Permalink
Backport PR jupyterlab#751: Add ignore action to context menu for sim…
Browse files Browse the repository at this point in the history
…ple staging
  • Loading branch information
fcollonval authored and meeseeksmachine committed Aug 30, 2020
1 parent d3d9b56 commit f7ea3a3
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/components/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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 @@ -231,9 +232,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 @@ -262,7 +271,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 @@ -813,4 +827,5 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
private _contextMenuUntrackedMin: Menu;
private _contextMenuSimpleTracked: Menu;
private _contextMenuSimpleUntracked: Menu;
private _contextMenuSimpleUntrackedMin: Menu;
}

0 comments on commit f7ea3a3

Please sign in to comment.