Align git options to base of file-explorer

pull/2879/head
David Disu 2 years ago
parent 976cf090df
commit 6dbb0e9db2
  1. 446
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -534,246 +534,246 @@ export function Workspace () {
] ]
return ( return (
<> <div className='d-flex flex-column justify-content-between h-100'>
<div className='remixui_container' style={{ height: selectedWorkspace && selectedWorkspace.isGitRepo ? '95%' : '100%' }}> <div className='remixui_container'>
<div className='d-flex flex-column w-100 remixui_fileexplorer' data-id="remixUIWorkspaceExplorer" onClick={resetFocus}> <div className='d-flex flex-column w-100 remixui_fileexplorer' data-id="remixUIWorkspaceExplorer" onClick={resetFocus}>
<div> <div>
<header> <header>
<div className="mx-2 mb-2 d-flex flex-column"> <div className="mx-2 mb-2 d-flex flex-column">
<div className="d-flex justify-content-between"> <div className="d-flex justify-content-between">
<span className="d-flex align-items-end"> <span className="d-flex align-items-end">
<label className="pl-1 form-check-label" htmlFor="workspacesSelect"> <label className="pl-1 form-check-label" htmlFor="workspacesSelect">
WORKSPACES WORKSPACES
</label> </label>
</span> </span>
<span className="remixui_menu remixui_topmenu d-flex justify-content-between align-items-end w-75"> <span className="remixui_menu remixui_topmenu d-flex justify-content-between align-items-end w-75">
<OverlayTrigger <OverlayTrigger
placement="top-end" placement="top-end"
overlay={ overlay={
<Tooltip id="createWorkspaceTooltip" className="text-nowrap"> <Tooltip id="createWorkspaceTooltip" className="text-nowrap">
<span>Create</span> <span>Create</span>
</Tooltip> </Tooltip>
} }
> >
<span <span
hidden={currentWorkspace === LOCALHOST} hidden={currentWorkspace === LOCALHOST}
id='workspaceCreate' id='workspaceCreate'
data-id='workspaceCreate' data-id='workspaceCreate'
onClick={(e) => { onClick={(e) => {
e.stopPropagation() e.stopPropagation()
createWorkspace() createWorkspace()
_paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspaceCreate']) _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspaceCreate'])
}}
style={{ fontSize: 'large' }}
className='far fa-plus remixui_menuicon d-flex align-self-end'
>
</span>
</OverlayTrigger>
<Dropdown id="workspacesMenuDropdown" data-id="workspacesMenuDropdown" onToggle={() => hideIconsMenu(!showIconsMenu)} show={showIconsMenu}>
<Dropdown.Toggle
as={CustomIconsToggle}
onClick={() => {
hideIconsMenu(!showIconsMenu)
}} }}
style={{ fontSize: 'large' }} icon={'fas fa-bars'}
className='far fa-plus remixui_menuicon d-flex align-self-end' ></Dropdown.Toggle>
> <Dropdown.Menu as={CustomMenu} data-id="wsdropdownMenu" className='custom-dropdown-items remixui_menuwidth' rootCloseEvent="click">
</span> {
</OverlayTrigger> workspaceMenuIcons.map(m => {
<Dropdown id="workspacesMenuDropdown" data-id="workspacesMenuDropdown" onToggle={() => hideIconsMenu(!showIconsMenu)} show={showIconsMenu}> return (
<Dropdown.Toggle <Dropdown.Item>
as={CustomIconsToggle} {m}
</Dropdown.Item>
)
})
}
</Dropdown.Menu>
</Dropdown>
</span>
</div>
<Dropdown id="workspacesSelect" data-id="workspacesSelect" onToggle={toggleDropdown} show={showDropdown}>
<Dropdown.Toggle as={CustomToggle} id="dropdown-custom-components" className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control mt-1" icon={selectedWorkspace && selectedWorkspace.isGitRepo && !(currentWorkspace === LOCALHOST) ? 'far fa-code-branch' : null}>
{ selectedWorkspace ? selectedWorkspace.name : currentWorkspace === LOCALHOST ? 'localhost' : NO_WORKSPACE }
</Dropdown.Toggle>
<Dropdown.Menu as={CustomMenu} className='w-100 custom-dropdown-items' data-id="custom-dropdown-items">
<Dropdown.Item
onClick={() => { onClick={() => {
hideIconsMenu(!showIconsMenu) createWorkspace()
}} }}
icon={'fas fa-bars'} >
></Dropdown.Toggle>
<Dropdown.Menu as={CustomMenu} data-id="wsdropdownMenu" className='custom-dropdown-items remixui_menuwidth' rootCloseEvent="click">
{ {
workspaceMenuIcons.map(m => { <span className="pl-3"> - create a new workspace - </span>
return ( }
<Dropdown.Item> </Dropdown.Item>
{m} <Dropdown.Item onClick={() => { switchWorkspace(LOCALHOST) }}>{currentWorkspace === LOCALHOST ? <span>&#10003; localhost </span> : <span className="pl-3"> { LOCALHOST } </span>}</Dropdown.Item>
{
global.fs.browser.workspaces.map(({ name, isGitRepo }, index) => (
<Dropdown.Item
key={index}
onClick={() => {
switchWorkspace(name)
}}
data-id={`dropdown-item-${name}`}
>
{ isGitRepo ?
<div className='d-flex justify-content-between'>
<span>{ currentWorkspace === name ? <span>&#10003; { name } </span> : <span className="pl-3">{ name }</span> }</span>
<i className='fas fa-code-branch pt-1'></i>
</div> :
<span>{ currentWorkspace === name ? <span>&#10003; { name } </span> : <span className="pl-3">{ name }</span> }</span>
}
</Dropdown.Item> </Dropdown.Item>
) ))
}) }
} <Dropdown.Item onClick={() => { switchWorkspace(LOCALHOST) }}>{currentWorkspace === LOCALHOST ? <span>&#10003; localhost </span> : <span className="pl-3"> { LOCALHOST } </span>}</Dropdown.Item>
{ ((global.fs.browser.workspaces.length <= 0) || currentWorkspace === NO_WORKSPACE) && <Dropdown.Item onClick={() => { switchWorkspace(NO_WORKSPACE) }}>{ <span className="pl-3">NO_WORKSPACE</span> }</Dropdown.Item> }
</Dropdown.Menu> </Dropdown.Menu>
</Dropdown> </Dropdown>
</span> </div>
</div> </header>
</div>
<Dropdown id="workspacesSelect" data-id="workspacesSelect" onToggle={toggleDropdown} show={showDropdown}> <div className='h-100 remixui_fileExplorerTree' onFocus={() => { toggleDropdown(false) }}>
<Dropdown.Toggle as={CustomToggle} id="dropdown-custom-components" className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control mt-1" icon={selectedWorkspace && selectedWorkspace.isGitRepo && !(currentWorkspace === LOCALHOST) ? 'far fa-code-branch' : null}> <div className='h-100'>
{ selectedWorkspace ? selectedWorkspace.name : currentWorkspace === LOCALHOST ? 'localhost' : NO_WORKSPACE } { (global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning) && <div className="text-center py-5"><i className="fas fa-spinner fa-pulse fa-2x"></i></div>}
</Dropdown.Toggle> { !(global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning) &&
(global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) &&
<Dropdown.Menu as={CustomMenu} className='w-100 custom-dropdown-items' data-id="custom-dropdown-items"> <div className='h-100 remixui_treeview' data-id='filePanelFileExplorerTree'>
<Dropdown.Item <FileExplorer
onClick={() => { name={currentWorkspace}
createWorkspace() menuItems={['createNewFile', 'createNewFolder', 'publishToGist', canUpload ? 'uploadFile' : '']}
}} contextMenuItems={global.fs.browser.contextMenu.registeredMenuItems}
> removedContextMenuItems={global.fs.browser.contextMenu.removedMenuItems}
{ files={global.fs.browser.files}
<span className="pl-3"> - create a new workspace - </span> fileState={global.fs.browser.fileState}
} expandPath={global.fs.browser.expandPath}
</Dropdown.Item> focusEdit={global.fs.focusEdit}
<Dropdown.Item onClick={() => { switchWorkspace(LOCALHOST) }}>{currentWorkspace === LOCALHOST ? <span>&#10003; localhost </span> : <span className="pl-3"> { LOCALHOST } </span>}</Dropdown.Item> focusElement={global.fs.focusElement}
{ hideIconsMenu={hideIconsMenu}
global.fs.browser.workspaces.map(({ name, isGitRepo }, index) => ( showIconsMenu={showIconsMenu}
<Dropdown.Item dispatchCreateNewFile={global.dispatchCreateNewFile}
key={index} modal={global.modal}
onClick={() => { dispatchCreateNewFolder={global.dispatchCreateNewFolder}
switchWorkspace(name) readonly={global.fs.readonly}
}} toast={global.toast}
data-id={`dropdown-item-${name}`} dispatchDeletePath={global.dispatchDeletePath}
> dispatchRenamePath={global.dispatchRenamePath}
{ isGitRepo ? dispatchUploadFile={global.dispatchUploadFile}
<div className='d-flex justify-content-between'> dispatchCopyFile={global.dispatchCopyFile}
<span>{ currentWorkspace === name ? <span>&#10003; { name } </span> : <span className="pl-3">{ name }</span> }</span> dispatchCopyFolder={global.dispatchCopyFolder}
<i className='fas fa-code-branch pt-1'></i> dispatchPublishToGist={global.dispatchPublishToGist}
</div> : dispatchRunScript={global.dispatchRunScript}
<span>{ currentWorkspace === name ? <span>&#10003; { name } </span> : <span className="pl-3">{ name }</span> }</span> dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent}
} dispatchHandleClickFile={global.dispatchHandleClickFile}
</Dropdown.Item> dispatchSetFocusElement={global.dispatchSetFocusElement}
)) dispatchFetchDirectory={global.dispatchFetchDirectory}
} dispatchRemoveInputField={global.dispatchRemoveInputField}
<Dropdown.Item onClick={() => { switchWorkspace(LOCALHOST) }}>{currentWorkspace === LOCALHOST ? <span>&#10003; localhost </span> : <span className="pl-3"> { LOCALHOST } </span>}</Dropdown.Item> dispatchAddInputField={global.dispatchAddInputField}
{ ((global.fs.browser.workspaces.length <= 0) || currentWorkspace === NO_WORKSPACE) && <Dropdown.Item onClick={() => { switchWorkspace(NO_WORKSPACE) }}>{ <span className="pl-3">NO_WORKSPACE</span> }</Dropdown.Item> } dispatchHandleExpandPath={global.dispatchHandleExpandPath}
</Dropdown.Menu> dispatchMoveFile={global.dispatchMoveFile}
</Dropdown> dispatchMoveFolder={global.dispatchMoveFolder}
/>
</div> </div>
</header> }
</div> { global.fs.localhost.isRequestingLocalhost && <div className="text-center py-5"><i className="fas fa-spinner fa-pulse fa-2x"></i></div> }
<div className='h-100 remixui_fileExplorerTree' onFocus={() => { toggleDropdown(false) }}> { (global.fs.mode === 'localhost' && global.fs.localhost.isSuccessfulLocalhost) &&
<div className='h-100'> <div className='h-100 filesystemexplorer remixui_treeview'>
{ (global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning) && <div className="text-center py-5"><i className="fas fa-spinner fa-pulse fa-2x"></i></div>} <FileExplorer
{ !(global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning) && name='localhost'
(global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && menuItems={['createNewFile', 'createNewFolder']}
<div className='h-100 remixui_treeview' data-id='filePanelFileExplorerTree'> contextMenuItems={global.fs.localhost.contextMenu.registeredMenuItems}
<FileExplorer removedContextMenuItems={global.fs.localhost.contextMenu.removedMenuItems}
name={currentWorkspace} files={global.fs.localhost.files}
menuItems={['createNewFile', 'createNewFolder', 'publishToGist', canUpload ? 'uploadFile' : '']} fileState={[]}
contextMenuItems={global.fs.browser.contextMenu.registeredMenuItems} expandPath={global.fs.localhost.expandPath}
removedContextMenuItems={global.fs.browser.contextMenu.removedMenuItems} focusEdit={global.fs.focusEdit}
files={global.fs.browser.files} focusElement={global.fs.focusElement}
fileState={global.fs.browser.fileState} hideIconsMenu={hideIconsMenu}
expandPath={global.fs.browser.expandPath} showIconsMenu={showIconsMenu}
focusEdit={global.fs.focusEdit} dispatchCreateNewFile={global.dispatchCreateNewFile}
focusElement={global.fs.focusElement} modal={global.modal}
hideIconsMenu={hideIconsMenu} dispatchCreateNewFolder={global.dispatchCreateNewFolder}
showIconsMenu={showIconsMenu} readonly={global.fs.readonly}
dispatchCreateNewFile={global.dispatchCreateNewFile} toast={global.toast}
modal={global.modal} dispatchDeletePath={global.dispatchDeletePath}
dispatchCreateNewFolder={global.dispatchCreateNewFolder} dispatchRenamePath={global.dispatchRenamePath}
readonly={global.fs.readonly} dispatchUploadFile={global.dispatchUploadFile}
toast={global.toast} dispatchCopyFile={global.dispatchCopyFile}
dispatchDeletePath={global.dispatchDeletePath} dispatchCopyFolder={global.dispatchCopyFolder}
dispatchRenamePath={global.dispatchRenamePath} dispatchPublishToGist={global.dispatchPublishToGist}
dispatchUploadFile={global.dispatchUploadFile} dispatchRunScript={global.dispatchRunScript}
dispatchCopyFile={global.dispatchCopyFile} dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent}
dispatchCopyFolder={global.dispatchCopyFolder} dispatchHandleClickFile={global.dispatchHandleClickFile}
dispatchPublishToGist={global.dispatchPublishToGist} dispatchSetFocusElement={global.dispatchSetFocusElement}
dispatchRunScript={global.dispatchRunScript} dispatchFetchDirectory={global.dispatchFetchDirectory}
dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent} dispatchRemoveInputField={global.dispatchRemoveInputField}
dispatchHandleClickFile={global.dispatchHandleClickFile} dispatchAddInputField={global.dispatchAddInputField}
dispatchSetFocusElement={global.dispatchSetFocusElement} dispatchHandleExpandPath={global.dispatchHandleExpandPath}
dispatchFetchDirectory={global.dispatchFetchDirectory} dispatchMoveFile={global.dispatchMoveFile}
dispatchRemoveInputField={global.dispatchRemoveInputField} dispatchMoveFolder={global.dispatchMoveFolder}
dispatchAddInputField={global.dispatchAddInputField}
dispatchHandleExpandPath={global.dispatchHandleExpandPath}
dispatchMoveFile={global.dispatchMoveFile}
dispatchMoveFolder={global.dispatchMoveFolder}
/> />
</div>
}
</div> </div>
}
{ global.fs.localhost.isRequestingLocalhost && <div className="text-center py-5"><i className="fas fa-spinner fa-pulse fa-2x"></i></div> }
{ (global.fs.mode === 'localhost' && global.fs.localhost.isSuccessfulLocalhost) &&
<div className='h-100 filesystemexplorer remixui_treeview'>
<FileExplorer
name='localhost'
menuItems={['createNewFile', 'createNewFolder']}
contextMenuItems={global.fs.localhost.contextMenu.registeredMenuItems}
removedContextMenuItems={global.fs.localhost.contextMenu.removedMenuItems}
files={global.fs.localhost.files}
fileState={[]}
expandPath={global.fs.localhost.expandPath}
focusEdit={global.fs.focusEdit}
focusElement={global.fs.focusElement}
hideIconsMenu={hideIconsMenu}
showIconsMenu={showIconsMenu}
dispatchCreateNewFile={global.dispatchCreateNewFile}
modal={global.modal}
dispatchCreateNewFolder={global.dispatchCreateNewFolder}
readonly={global.fs.readonly}
toast={global.toast}
dispatchDeletePath={global.dispatchDeletePath}
dispatchRenamePath={global.dispatchRenamePath}
dispatchUploadFile={global.dispatchUploadFile}
dispatchCopyFile={global.dispatchCopyFile}
dispatchCopyFolder={global.dispatchCopyFolder}
dispatchPublishToGist={global.dispatchPublishToGist}
dispatchRunScript={global.dispatchRunScript}
dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent}
dispatchHandleClickFile={global.dispatchHandleClickFile}
dispatchSetFocusElement={global.dispatchSetFocusElement}
dispatchFetchDirectory={global.dispatchFetchDirectory}
dispatchRemoveInputField={global.dispatchRemoveInputField}
dispatchAddInputField={global.dispatchAddInputField}
dispatchHandleExpandPath={global.dispatchHandleExpandPath}
dispatchMoveFile={global.dispatchMoveFile}
dispatchMoveFolder={global.dispatchMoveFolder}
/>
</div>
}
</div> </div>
</div> </div>
</div> </div>
</div> {
{ selectedWorkspace &&
selectedWorkspace && <div className={`bg-light border-top ${selectedWorkspace.isGitRepo ? 'd-block' : 'd-none'}`}>
<div className={`bg-light border-top ${selectedWorkspace.isGitRepo ? 'd-block' : 'd-none'}`} style={{ height: '5%' }}> <div className='d-flex justify-space-between p-1'>
<div className='d-flex justify-space-between p-1'> <div className="mr-auto text-uppercase text-dark pt-2 pl-2">GIT</div>
<div className="mr-auto text-uppercase text-dark pt-2 pl-2">DGIT</div> <div className="pt-1 mr-1">
<div className="pt-1 mr-1"> <Dropdown style={{ height: 30, minWidth: 80 }} onToggle={toggleBranches} show={showBranches} drop={'up'}>
<Dropdown style={{ height: 30, minWidth: 80 }} onToggle={toggleBranches} show={showBranches} drop={'up'}> <Dropdown.Toggle as={CustomToggle} id="dropdown-custom-components" className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control h-100 p-0 pl-2 pr-2 text-dark" icon={null}>
<Dropdown.Toggle as={CustomToggle} id="dropdown-custom-components" className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control h-100 p-0 pl-2 pr-2 text-dark" icon={null}> { global.fs.browser.isRequestingCloning ? <i className="fad fa-spinner fa-spin"></i> : currentBranch || '-none-' }
{ global.fs.browser.isRequestingCloning ? <i className="fad fa-spinner fa-spin"></i> : currentBranch || '-none-' } </Dropdown.Toggle>
</Dropdown.Toggle>
<Dropdown.Menu as={CustomMenu} className='custom-dropdown-items branches-dropdown' data-id="custom-dropdown-items">
<Dropdown.Menu as={CustomMenu} className='custom-dropdown-items branches-dropdown' data-id="custom-dropdown-items"> <div className='d-flex text-dark' style={{ fontSize: 14, fontWeight: 'bold' }}>
<div className='d-flex text-dark' style={{ fontSize: 14, fontWeight: 'bold' }}> <span className='mt-2 ml-2 mr-auto'>Switch branches</span>
<span className='mt-2 ml-2 mr-auto'>Switch branches</span> <div className='pt-2 pr-2' onClick={() => { toggleBranches(false) }}><i className='fa fa-close'></i>
<div className='pt-2 pr-2' onClick={() => { toggleBranches(false) }}><i className='fa fa-close'></i> </div>
</div>
<div className='border-top py-2'>
<input
className='form-control border checkout-input bg-light'
placeholder='Find or create a branch.'
style={{ minWidth: 225 }}
onChange={handleBranchFilterChange}
/>
</div>
<div className='border-top' style={{ maxHeight: 120, overflowY: 'scroll' }}>
{
filteredBranches.length > 0 ? filteredBranches.map((branch, index) => {
return (
<Dropdown.Item key={index} onClick={() => { switchToBranch(branch) }} title={branch.remote ? 'Checkout new branch from remote branch' : 'Checkout to local branch'}>
{
(currentBranch === branch.name) && !branch.remote ?
<span>&#10003; <i className='far fa-code-branch'></i><span className='pl-1'>{ branch.name }</span></span> :
<span className='pl-3'><i className={`far ${ branch.remote ? 'fa-cloud' : 'fa-code-branch'}`}></i><span className='pl-1'>{ branch.remote ? `${branch.remote}/${branch.name}` : branch.name }</span></span>
}
</Dropdown.Item>
)
}) :
<Dropdown.Item onClick={switchToNewBranch}>
<div className="pl-1 pr-1">
<i className="fas fa-code-branch pr-2"></i><span>Create branch: { branchFilter } from '{currentBranch}'</span>
</div>
</Dropdown.Item>
}
</div> </div>
</div>
<div className='border-top py-2'>
<input
className='form-control border checkout-input bg-light'
placeholder='Find or create a branch.'
style={{ minWidth: 225 }}
onChange={handleBranchFilterChange}
/>
</div>
<div className='border-top' style={{ maxHeight: 120, overflowY: 'scroll' }}>
{ {
filteredBranches.length > 0 ? filteredBranches.map((branch, index) => { (selectedWorkspace.branches || []).length > 4 && <div className='text-center border-top pt-2'><a href='#' style={{ fontSize: 12 }} onClick={showAllBranches}>view all branches</a></div>
return (
<Dropdown.Item key={index} onClick={() => { switchToBranch(branch) }} title={branch.remote ? 'Checkout new branch from remote branch' : 'Checkout to local branch'}>
{
(currentBranch === branch.name) && !branch.remote ?
<span>&#10003; <i className='far fa-code-branch'></i><span className='pl-1'>{ branch.name }</span></span> :
<span className='pl-3'><i className={`far ${ branch.remote ? 'fa-cloud' : 'fa-code-branch'}`}></i><span className='pl-1'>{ branch.remote ? `${branch.remote}/${branch.name}` : branch.name }</span></span>
}
</Dropdown.Item>
)
}) :
<Dropdown.Item onClick={switchToNewBranch}>
<div className="pl-1 pr-1">
<i className="fas fa-code-branch pr-2"></i><span>Create branch: { branchFilter } from '{currentBranch}'</span>
</div>
</Dropdown.Item>
} }
</div> </Dropdown.Menu>
{ </Dropdown>
(selectedWorkspace.branches || []).length > 4 && <div className='text-center border-top pt-2'><a href='#' style={{ fontSize: 12 }} onClick={showAllBranches}>view all branches</a></div> </div>
}
</Dropdown.Menu>
</Dropdown>
</div> </div>
</div> </div>
</div> }
} </div>
</>
) )
} }

Loading…
Cancel
Save