Skip to content

Commit

Permalink
Allow right-click on File in Explorer to initiate `DeleteFileDial…
Browse files Browse the repository at this point in the history
…og` modal
  • Loading branch information
nelsonni committed Nov 6, 2023
1 parent 5af0f5d commit ea41640
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/renderer/src/components/Explorer/File.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {extractFilename, isModified, isStaged, isUnmerged, uuid} from '#preload';
import {Description} from '@mui/icons-material';
import {Skeleton} from '@mui/material';
import type {UUID} from '@syn-types/app';
Expand All @@ -8,7 +9,7 @@ import {isFilebasedMetafile, isVersionedMetafile} from '../../store/slices/metaf
import {createCard} from '../../store/thunks/cards';
import {StageButton, UnstageButton} from './GitButtons';
import {StyledTreeItem} from './TreeItem';
import {extractFilename, isModified, isStaged, isUnmerged} from '#preload';
import {modalAdded} from '/@/store/slices/modals';

const File = ({id}: {id: UUID}) => {
const metafile = useAppSelector(state => metafileSelectors.selectById(state, id));
Expand All @@ -27,6 +28,17 @@ const File = ({id}: {id: UUID}) => {
if (isFilebasedMetafile(metafile)) await dispatch(createCard({path: metafile.path}));
};

const handleRightClick = () => {
if (isFilebasedMetafile(metafile))
dispatch(
modalAdded({
id: uuid(),
type: 'DeleteFileDialog',
metafile: metafile.id,
}),
);
};

return (
<>
{isFilebasedMetafile(metafile) ? (
Expand All @@ -53,6 +65,7 @@ const File = ({id}: {id: UUID}) => {
endIcon={<Description />}
color={motif?.color}
onClick={handleClick}
onContextMenu={handleRightClick}
/>
) : (
<Skeleton
Expand Down

0 comments on commit ea41640

Please sign in to comment.