Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit 907a2a9

Browse files
authored
Add delete button to git branch plugin (#887)
1 parent 7d8dac9 commit 907a2a9

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/plugins/GitBranch.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ class GitBranchComponent extends React.Component<GitBranchProps, GitBranchState>
5757
<div style={{ padding: "10px" }}>
5858
{this.state.branches.map((branch, index) =>
5959
<div key={index.toString()} style={branch.isCurrent() ? {color: colors.green} : {}}>
60-
<span style={{whiteSpace: "pre"}}>{branch.isCurrent() ? "* " : " "}{branch.toString()}</span>
60+
<span style={{
61+
whiteSpace: "pre",
62+
lineHeight: "18px",
63+
}}>{branch.isCurrent() ? "* " : " "}{branch.toString()}</span>
6164
<Button onClick={async () => {
6265
try {
6366
await executeCommand("git", ["checkout", branch.toString()], this.props.repoRoot);
@@ -66,6 +69,14 @@ class GitBranchComponent extends React.Component<GitBranchProps, GitBranchState>
6669
this.setState({ failReason: e.message } as GitBranchState);
6770
}
6871
}}>Checkout</Button>
72+
<Button color={colors.red} onClick={async () => {
73+
try {
74+
await executeCommand("git", ["branch", "-d", branch.toString()], this.props.repoRoot);
75+
this.reload();
76+
} catch (e) {
77+
this.setState({ failReason: e.message } as GitBranchState);
78+
}
79+
}}>Delete</Button>
6980
</div>
7081
)}
7182
</div>

src/plugins/autocompletion_utils/Button.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import * as React from "react";
22
import {colors} from "../../views/css/colors";
33

4-
const buttonStyles = {
5-
borderColor: colors.blue,
4+
const buttonStyles = (color: string) => ({
5+
borderColor: color,
66
borderStyle: "solid",
77
borderRadius: "4px",
88
borderWidth: "1px",
99
padding: "2px",
10-
color: colors.blue,
10+
color: color,
1111
WebkitUserSelect: "none",
1212
fontSize: "10px",
1313
margin: "4px",
1414
cursor: "pointer",
15-
};
15+
});
1616

1717
type ButtonProps = {
1818
onClick: () => void;
1919
children?: React.ReactElement<any>;
20+
color?: string;
2021
};
2122

22-
const Button = ({ onClick, children}: ButtonProps) => <span
23-
style={buttonStyles}
23+
const Button = ({ onClick, children, color = colors.blue }: ButtonProps) => <span
24+
style={buttonStyles(color)}
2425
onClick={onClick}
2526
>{children}</span>;
2627

src/plugins/autocompletion_utils/Common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ function gitStatusCodeColor(statusCode: StatusCode) {
283283
return colors.blue;
284284

285285
case "UnstagedDeleted":
286+
case "UnstagedModified":
286287
case "UnmergedBothDeleted":
287288
case "UnmergedAddedByUs":
288289
case "UnmergedDeletedByThem":

0 commit comments

Comments
 (0)