Skip to content

Commit

Permalink
fix: context menu now has all options when it's a directory (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelramalho19 authored Sep 18, 2020
1 parent 190b57d commit 0bb8bea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/files/FilesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ class FilesPage extends React.Component {
translateX={contextMenu.translateX}
translateY={contextMenu.translateY}
handleClick={this.handleContextMenu}
isDirectory={contextMenu.file && contextMenu.file.type === 'directory'}
isMfs={filesPathInfo ? filesPathInfo.isMfs : false}
isUnknown={!!(contextMenu.file && contextMenu.file.type === 'unknown')}
pinned={contextMenu.file && contextMenu.file.pinned}
Expand Down
13 changes: 5 additions & 8 deletions src/files/context-menu/ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class ContextMenu extends React.Component {
render () {
const {
t, onRename, onDelete, onDownload, onInspect, onShare,
translateX, translateY, className,
isDirectory, isMfs, isUnknown, pinned, isCliTutorModeEnabled
translateX, translateY, className, isMfs, isUnknown, pinned, isCliTutorModeEnabled
} = this.props
return (
<Dropdown className={className}>
Expand All @@ -58,7 +57,7 @@ class ContextMenu extends React.Component {
translateY={-translateY}
open={this.props.isOpen}
onDismiss={this.props.handleClick}>
{ !isDirectory && onShare &&
{ onShare &&
<Option onClick={this.wrap('onShare')}>
<StrokeShare className='w2 mr2 fill-aqua' />
{t('actions.share')}
Expand All @@ -81,21 +80,21 @@ class ContextMenu extends React.Component {
<StrokePin className='w2 mr2 fill-aqua' />
{ pinned ? t('app:actions.unpin') : t('app:actions.pinVerb') }
</Option>
{ !isDirectory && !isUnknown && onDownload &&
{ !isUnknown && onDownload &&
<Option onClick={this.wrap('onDownload')} isCliTutorModeEnabled={isCliTutorModeEnabled}
onCliTutorMode={this.wrap('onCliTutorMode', cliCmdKeys.DOWNLOAD_OBJECT_COMMAND)}>
<StrokeDownload className='w2 mr2 fill-aqua' />
{t('app:actions.download')}
</Option>
}
{ !isDirectory && !isUnknown && isMfs && onRename &&
{ !isUnknown && isMfs && onRename &&
<Option onClick={this.wrap('onRename')} isCliTutorModeEnabled={isCliTutorModeEnabled}
onCliTutorMode={this.wrap('onCliTutorMode', cliCmdKeys.RENAME_IPFS_OBJECT)}>
<StrokePencil className='w2 mr2 fill-aqua' />
{t('app:actions.rename')}
</Option>
}
{ !isDirectory && !isUnknown && isMfs && onDelete &&
{ !isUnknown && isMfs && onDelete &&
<Option onClick={this.wrap('onDelete')} isCliTutorModeEnabled={isCliTutorModeEnabled}
onCliTutorMode={this.wrap('onCliTutorMode', cliCmdKeys.DELETE_FILE_FROM_IPFS)}
>
Expand All @@ -114,7 +113,6 @@ ContextMenu.propTypes = {
isOpen: PropTypes.bool.isRequired,
isUnknown: PropTypes.bool.isRequired,
hash: PropTypes.string,
isDirectory: PropTypes.bool,
pinned: PropTypes.bool,
handleClick: PropTypes.func,
translateX: PropTypes.number.isRequired,
Expand All @@ -134,7 +132,6 @@ ContextMenu.propTypes = {
ContextMenu.defaultProps = {
isMfs: false,
isOpen: false,
isDirectory: false,
isUnknown: false,
top: 0,
left: 0,
Expand Down

0 comments on commit 0bb8bea

Please sign in to comment.