add git initialization

pull/5248/head
Joseph Izang 2 months ago committed by Aniket
parent a2bd252936
commit 57744dc072
  1. 32
      libs/remix-ui/workspace/src/lib/components/file-explorer-menu.tsx
  2. 9
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  3. 2
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  4. 2
      libs/remix-ui/workspace/src/lib/types/index.ts

@ -56,10 +56,17 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => {
},
{
action: 'connectToLocalFileSystem',
title: 'Import files with https',
title: 'Connect to local filesystem with remixd',
icon: 'fa-solid fa-desktop',
placement: 'top',
platforms: [appPlatformTypes.web]
},
{
action: 'initializeWorkspaceAsGitRepo',
title: 'Initialize workspace as a git repository',
icon: 'fa-brands fa-git-alt',
placement: 'top',
platforms: [appPlatformTypes.web]
}
].filter(
(item) =>
@ -143,6 +150,29 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => {
</label>
</CustomTooltip>
)
} else if (action === 'initializeWorkspaceAsGitRepo') {
return (
<CustomTooltip
placement={placement as Placement}
tooltipId="uploadFolderTooltip"
tooltipClasses="text-nowrap"
tooltipText={<FormattedMessage id={`filePanel.${action}`} defaultMessage={title} />}
key={`index-${action}-${placement}-${icon}`}
>
<label
id={action}
style={{ fontSize: '1.1rem', cursor: 'pointer' }}
data-id={'fileExplorerUploadFolder' + action}
className={icon + ' mx-1 remixui_menuItem'}
key={`index-${action}-${placement}-${icon}`}
onClick={() => {
_paq.push(['trackEvent', 'fileExplorer', 'fileAction', action])
props.handleGitInit()
}}
>
</label>
</CustomTooltip>
)
} else {
return (
<CustomTooltip

@ -581,6 +581,12 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
const handleGitInit = async () => {
const isActive = await plugin.call('manager', 'isActive', 'dgit')
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
await plugin.call('dgitApi', 'init')
}
return (
<div className="h-100 remixui_treeview" data-id="filePanelFileExplorerTree">
<div ref={treeRef} tabIndex={0} style={{
@ -609,7 +615,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
uploadFolder={uploadFolder}
importFromIpfs={props.importFromIpfs}
importFromHttps={props.importFromHttps}
connectToLocalFileSystem={() => console.log('connectToLocalFileSystem')}
connectToLocalFileSystem={() => props.connectToLocalFileSystem()}
handleGitInit={handleGitInit}
/>
</div>
</span>

@ -1174,7 +1174,7 @@ export function Workspace() {
<FileExplorer
fileState={global.fs.browser.fileState}
name={currentWorkspace}
menuItems={['createNewFile', 'createNewFolder', selectedWorkspace && selectedWorkspace.isGist ? 'updateGist' : 'publishToGist', canUpload ? 'uploadFile' : '', canUpload ? 'uploadFolder' : '', 'importFromIpfs','importFromHttps', 'connectToLocalFileSystem']}
menuItems={['createNewFile', 'createNewFolder', selectedWorkspace && selectedWorkspace.isGist ? 'updateGist' : 'publishToGist', canUpload ? 'uploadFile' : '', canUpload ? 'uploadFolder' : '', 'importFromIpfs','importFromHttps', 'connectToLocalFileSystem', 'initializeWorkspaceAsGitRepo']}
contextMenuItems={global.fs.browser.contextMenu.registeredMenuItems}
removedContextMenuItems={global.fs.browser.contextMenu.removedMenuItems}
files={global.fs.browser.files}

@ -160,6 +160,7 @@ export interface FileExplorerProps {
importFromIpfs: any
importFromHttps: any
connectToLocalFileSystem?: any
handleGitInit?: () => Promise<void>
handleMultiCopies: any
feTarget: { key: string, type: 'file' | 'folder' }[]
setFeTarget: Dispatch<React.SetStateAction<{
@ -182,6 +183,7 @@ export interface FileExplorerMenuProps {
importFromIpfs: any
importFromHttps: any
connectToLocalFileSystem?: any
handleGitInit?: () => Promise<void>
tooltipPlacement?: Placement
}
export interface FileExplorerContextMenuProps {

Loading…
Cancel
Save