Skip to content

Commit

Permalink
Add "Clear" options for file and directory inputs (#2760)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Apr 8, 2024
1 parent bf3f90a commit 6c2804b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
"inputs": {
"copyInputOverrideId": "Copy Input Override Id",
"directory": {
"clear": "Clear",
"copyFullDirectoryPath": "Copy Full Directory Path",
"openInFileExplorer": "Open in File Explorer",
"selectDirectory": "Select a directory..."
},
"extractValueIntoNode": "Extract value into node",
"file": {
"clear": "Clear",
"copyFileName": "Copy File Name",
"copyFullFilePath": "Copy Full File Path",
"openInFileExplorer": "Open in File Explorer",
Expand Down
10 changes: 10 additions & 0 deletions src/renderer/components/inputs/DirectoryInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Type, isStringLiteral } from '@chainner/navi';
import { CloseIcon } from '@chakra-ui/icons';
import {
Icon,
Input,
Expand Down Expand Up @@ -37,6 +38,7 @@ export const DirectoryInput = memo(
({
value,
setValue,
resetValue,
isLocked,
input,
inputKey,
Expand Down Expand Up @@ -99,6 +101,14 @@ export const DirectoryInput = memo(
>
{t('inputs.directory.copyFullDirectoryPath', 'Copy Full Directory Path')}
</MenuItem>
<MenuDivider />
<MenuItem
icon={<CloseIcon />}
isDisabled={!value}
onClick={resetValue}
>
{t('inputs.directory.clear', 'Clear')}
</MenuItem>
{refactor}
</MenuList>
));
Expand Down
10 changes: 10 additions & 0 deletions src/renderer/components/inputs/FileInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CloseIcon } from '@chakra-ui/icons';
import {
Icon,
Input,
Expand Down Expand Up @@ -30,6 +31,7 @@ export const FileInput = memo(
({
value: filePath,
setValue: setFilePath,
resetValue: resetFilePath,
input,
inputKey,
isConnected,
Expand Down Expand Up @@ -149,6 +151,14 @@ export const FileInput = memo(
>
{t('inputs.file.copyFullFilePath', 'Copy Full File Path')}
</MenuItem>
<MenuDivider />
<MenuItem
icon={<CloseIcon />}
isDisabled={!filePath}
onClick={resetFilePath}
>
{t('inputs.file.clear', 'Clear')}
</MenuItem>
{refactor}
</MenuList>
));
Expand Down

0 comments on commit 6c2804b

Please sign in to comment.