Skip to content

Commit

Permalink
add git initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
joeizang committed Sep 26, 2024
1 parent a89b139 commit 065237b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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={{
Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 2 additions & 0 deletions libs/remix-ui/workspace/src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand All @@ -182,6 +183,7 @@ export interface FileExplorerMenuProps {
importFromIpfs: any
importFromHttps: any
connectToLocalFileSystem?: any
handleGitInit?: () => Promise<void>
tooltipPlacement?: Placement
}
export interface FileExplorerContextMenuProps {
Expand Down

0 comments on commit 065237b

Please sign in to comment.