|
|
@ -1,4 +1,6 @@ |
|
|
|
import React, { useState, useEffect } from 'react' //eslint-disable-line
|
|
|
|
import React, { useState, useEffect } from 'react' //eslint-disable-line
|
|
|
|
|
|
|
|
import { OverlayTrigger, Tooltip } from 'react-bootstrap' |
|
|
|
|
|
|
|
import { Placement } from 'react-bootstrap/esm/Overlay' |
|
|
|
import { FileExplorerMenuProps } from '../types' |
|
|
|
import { FileExplorerMenuProps } from '../types' |
|
|
|
const _paq = window._paq = window._paq || [] |
|
|
|
const _paq = window._paq = window._paq || [] |
|
|
|
|
|
|
|
|
|
|
@ -8,27 +10,32 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => { |
|
|
|
{ |
|
|
|
{ |
|
|
|
action: 'createNewFile', |
|
|
|
action: 'createNewFile', |
|
|
|
title: 'Create New File', |
|
|
|
title: 'Create New File', |
|
|
|
icon: 'far fa-file' |
|
|
|
icon: 'far fa-file', |
|
|
|
|
|
|
|
placement: 'top-end' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
action: 'createNewFolder', |
|
|
|
action: 'createNewFolder', |
|
|
|
title: 'Create New Folder', |
|
|
|
title: 'Create New Folder', |
|
|
|
icon: 'far fa-folder' |
|
|
|
icon: 'far fa-folder', |
|
|
|
|
|
|
|
placement: 'top-end' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
action: 'publishToGist', |
|
|
|
action: 'publishToGist', |
|
|
|
title: 'Publish all the current workspace files (only root) to a github gist', |
|
|
|
title: 'Publish all the current workspace files (only root) to a github gist', |
|
|
|
icon: 'fab fa-github' |
|
|
|
icon: 'fab fa-github', |
|
|
|
|
|
|
|
placement: 'top-start' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
action: 'uploadFile', |
|
|
|
action: 'uploadFile', |
|
|
|
title: 'Load a local file into current workspace', |
|
|
|
title: 'Load a local file into current workspace', |
|
|
|
icon: 'fa fa-upload' |
|
|
|
icon: 'fa fa-upload', |
|
|
|
|
|
|
|
placement: 'bottom-start' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
action: 'updateGist', |
|
|
|
action: 'updateGist', |
|
|
|
title: 'Update the current [gist] explorer', |
|
|
|
title: 'Update the current [gist] explorer', |
|
|
|
icon: 'fab fa-github' |
|
|
|
icon: 'fab fa-github', |
|
|
|
|
|
|
|
placement: 'right-start' |
|
|
|
} |
|
|
|
} |
|
|
|
].filter(item => props.menuItems && props.menuItems.find((name) => { return name === item.action })), |
|
|
|
].filter(item => props.menuItems && props.menuItems.find((name) => { return name === item.action })), |
|
|
|
actions: {} |
|
|
|
actions: {} |
|
|
@ -48,14 +55,13 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => { |
|
|
|
<> |
|
|
|
<> |
|
|
|
<span className='remixui_label' title={props.title} data-path={props.title} style={{ fontWeight: 'bold' }}>{ props.title }</span> |
|
|
|
<span className='remixui_label' title={props.title} data-path={props.title} style={{ fontWeight: 'bold' }}>{ props.title }</span> |
|
|
|
<span className="pl-2">{ |
|
|
|
<span className="pl-2">{ |
|
|
|
state.menuItems.map(({ action, title, icon }, index) => { |
|
|
|
state.menuItems.map(({ action, title, icon, placement }, index) => { |
|
|
|
if (action === 'uploadFile') { |
|
|
|
if (action === 'uploadFile') { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<label |
|
|
|
<label |
|
|
|
id={action} |
|
|
|
id={action} |
|
|
|
data-id={'fileExplorerUploadFile' + action } |
|
|
|
data-id={'fileExplorerUploadFile' + action } |
|
|
|
className={icon + ' mb-0 remixui_newFile'} |
|
|
|
className={icon + ' mb-0 remixui_newFile'} |
|
|
|
title={title} |
|
|
|
|
|
|
|
key={index} |
|
|
|
key={index} |
|
|
|
> |
|
|
|
> |
|
|
|
<input id="fileUpload" data-id="fileExplorerFileUpload" type="file" onChange={(e) => { |
|
|
|
<input id="fileUpload" data-id="fileExplorerFileUpload" type="file" onChange={(e) => { |
|
|
@ -68,6 +74,15 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => { |
|
|
|
) |
|
|
|
) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
|
|
|
|
<OverlayTrigger |
|
|
|
|
|
|
|
placement={placement as Placement} |
|
|
|
|
|
|
|
overlay={ |
|
|
|
|
|
|
|
<Tooltip id={`${action}-${title}-${icon}-${index}`} className="text-nowrap"> |
|
|
|
|
|
|
|
<span>{title}</span> |
|
|
|
|
|
|
|
</Tooltip> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
key={`${action}-${title}-${index}`} |
|
|
|
|
|
|
|
> |
|
|
|
<span |
|
|
|
<span |
|
|
|
id={action} |
|
|
|
id={action} |
|
|
|
data-id={'fileExplorerNewFile' + action} |
|
|
|
data-id={'fileExplorerNewFile' + action} |
|
|
@ -85,10 +100,10 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
}} |
|
|
|
}} |
|
|
|
className={'newFile ' + icon + ' remixui_newFile'} |
|
|
|
className={'newFile ' + icon + ' remixui_newFile'} |
|
|
|
title={title} |
|
|
|
|
|
|
|
key={index} |
|
|
|
key={index} |
|
|
|
> |
|
|
|
> |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
|
|
|
|
</OverlayTrigger> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
})} |
|
|
|
})} |
|
|
|