|
| 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