Skip to content

Commit 12bdb89

Browse files
committed
feat(undoStash) functionalityadded
1 parent 838e9c5 commit 12bdb89

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

actions/undoStash.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { execSync } =require('child_process')
2+
const React = require('react')
3+
4+
const popStash = () => {
5+
let undoStash = execSync(
6+
'git stash pop'
7+
)
8+
}
9+
10+
module.exports = popStash

components/DropDownOther.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ const TreeTab = importJsx('./TreeTab')
88
const Stash = importJsx('./Stash')
99
const MergeRevert = importJsx('./MergeRevert')
1010

11+
const popStash = require('../actions/undoStash')
12+
1113
//Creates the switch case for the 'Other' Tab.
1214

1315
const dropDown = ({ refreshTab, accentColor, defaultColor }) => {
1416
const [currentDrop, setCurrentDrop] = useState('')
1517

1618
const handleSelect = (item) => {
1719
setCurrentDrop(item.value)
20+
if(item.value === 'undoStash') {
21+
popStash()
22+
}
1823
}
1924
const items = [
2025
{
@@ -49,6 +54,13 @@ const dropDown = ({ refreshTab, accentColor, defaultColor }) => {
4954
<Stash refreshTab={refreshTab} />
5055
</Box>
5156
)
57+
case 'undoStash':
58+
return (
59+
<Box flexDirection='column'>
60+
<SelectInput items={items} isFocused={false} displayDirection='column' defaultColor={defaultColor} accentColor={accentColor}/>
61+
<popStash refreshTab={refreshTab} />
62+
</Box>
63+
)
5264
case 'undoMerge':
5365
return (
5466
<Box flexDirection='column'>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
const React = require("react");
2+
const { useEffect, useState, useRef } = require("react");
3+
const { Text, Box, Newline } = require("ink");
4+
const SelectInput = require("ink-select-input-horizontal").default;
5+
const { execSync, exec } = require("child_process");
6+
const importJsx = require("import-jsx");
7+
const TreeTab = importJsx('./TreeTab')
8+
const Stash = importJsx('./Stash')
9+
const MergeRevert = importJsx('./MergeRevert')
10+
11+
//Creates the switch case for the 'Other' Tab.
12+
13+
const dropDown = ({ refreshTab, accentColor, defaultColor }) => {
14+
const [currentDrop, setCurrentDrop] = useState('')
15+
16+
const handleSelect = (item) => {
17+
setCurrentDrop(item.value)
18+
}
19+
const items = [
20+
{
21+
label: 'Access Full Log Tree',
22+
value: 'fullLogTree'
23+
},
24+
{
25+
label: 'Stash Changes',
26+
value: 'stashChanges'
27+
},
28+
{
29+
label: 'Undo Stash',
30+
value: 'undoStash'
31+
},
32+
{
33+
label: 'Undo Merge',
34+
value: 'undoMerge'
35+
}
36+
]
37+
switch (currentDrop) {
38+
case 'fullLogTree':
39+
return (
40+
<Box flexDirection='column'>
41+
<SelectInput items={items} isFocused={false} displayDirection='column' defaultColor={defaultColor} accentColor={accentColor}/>
42+
<TreeTab refreshTab={refreshTab} />
43+
</Box>
44+
)
45+
case 'stashChanges':
46+
return (
47+
<Box flexDirection='column'>
48+
<SelectInput items={items} isFocused={false} displayDirection='column' defaultColor={defaultColor} accentColor={accentColor}/>
49+
<Stash refreshTab={refreshTab} />
50+
</Box>
51+
)
52+
case 'undoMerge':
53+
return (
54+
<Box flexDirection='column'>
55+
<SelectInput items={items} isFocused={false} displayDirection='column' defaultColor={defaultColor} accentColor={accentColor}/>
56+
<MergeRevert refreshTab={refreshTab} />
57+
</Box>
58+
)
59+
default:
60+
return (
61+
// Replace "marginLeft='109'" for optimized solution later down the line.
62+
<Box flexDirection="column" marginLeft='109' >
63+
<SelectInput items={items} onSelect={handleSelect} displayDirection='column' defaultColor={defaultColor} accentColor={accentColor}/>
64+
<Newline />
65+
<Text color='gray'>Press ESC to go back</Text>
66+
</Box>
67+
)//teste
68+
}
69+
};
70+
71+
module.exports = dropDown

0 commit comments

Comments
 (0)