fix hamburger menu

flattentree
filip mertens 10 months ago
parent e68b410bd9
commit 9127c87f64
  1. 2
      apps/remix-ide/src/app/tabs/locales/en/filePanel.json
  2. 6
      apps/remixdesktop/src/plugins/fsPlugin.ts
  3. 10
      libs/remix-ui/workspace/src/lib/actions/index.ts
  4. 9
      libs/remix-ui/workspace/src/lib/actions/payload.ts
  5. 45
      libs/remix-ui/workspace/src/lib/components/electron-workspace-name.tsx
  6. 2
      libs/remix-ui/workspace/src/lib/components/workspace-hamburger-item.tsx
  7. 25
      libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx
  8. 15
      libs/remix-ui/workspace/src/lib/reducers/workspace.ts
  9. 9
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  10. 1
      libs/remix-ui/workspace/src/lib/types/index.ts

@ -2,11 +2,13 @@
"filePanel.displayName": "File explorer",
"filePanel.workspace": "WORKSPACES",
"filePanel.create": "Create",
"filePanel.create.desktop": "Create Project",
"filePanel.clone": "Clone",
"filePanel.download": "Download",
"filePanel.backup": "Backup",
"filePanel.restore": "Restore",
"filePanel.workspace.create": "Create Workspace",
"filePanel.workspace.create.desktop": "Create Project in new Folder",
"filePanel.workspace.rename": "Rename Workspace",
"filePanel.workspace.delete": "Delete Workspace",
"filePanel.workspace.deleteConfirm": "Are you sure to delete the current workspace?",

@ -84,7 +84,7 @@ const clientProfile: Profile = {
name: 'fs',
displayName: 'fs',
description: 'fs',
methods: ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'currentPath', 'watch', 'closeWatch', 'setWorkingDir', 'openFolder', 'openFolderInSameWindow', 'getRecentFolders', 'removeRecentFolder', 'openWindow', 'selectFolder', 'revealInExplorer', 'openInVSCode', 'openInVSCode'],
methods: ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'currentPath', 'getWorkingDir', 'watch', 'closeWatch', 'setWorkingDir', 'openFolder', 'openFolderInSameWindow', 'getRecentFolders', 'removeRecentFolder', 'openWindow', 'selectFolder', 'revealInExplorer', 'openInVSCode', 'openInVSCode', 'currentPath'],
}
class FSPluginClient extends ElectronBasePluginClient {
@ -204,6 +204,10 @@ class FSPluginClient extends ElectronBasePluginClient {
return process.cwd()
}
async getWorkingDir(): Promise<string> {
return this.workingDir
}
async watch(): Promise<void> {
try {
this.off('filePanel' as any, 'expandPathChanged')

@ -2,7 +2,7 @@ import React from 'react'
import { extractNameFromKey, createNonClashingNameAsync } from '@remix-ui/helper'
import Gists from 'gists'
import { customAction } from '@remixproject/plugin-api'
import { displayNotification, displayPopUp, fetchDirectoryError, fetchDirectoryRequest, fetchDirectorySuccess, focusElement, fsInitializationCompleted, hidePopUp, removeInputFieldSuccess, setCurrentWorkspace, setExpandPath, setMode, setWorkspaces } from './payload'
import { displayNotification, displayPopUp, fetchDirectoryError, fetchDirectoryRequest, fetchDirectorySuccess, focusElement, fsInitializationCompleted, hidePopUp, removeInputFieldSuccess, setCurrentLocalFilePath, setCurrentWorkspace, setExpandPath, setMode, setWorkspaces } from './payload'
import { listenOnPluginEvents, listenOnProviderEvents } from './events'
import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin, workspaceExists } from './workspace'
import { QueryParams } from '@remix-project/remix-lib'
@ -124,8 +124,14 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
plugin.call('notification', 'toast', `opening ${params.opendir}...`)
await plugin.call('fs', 'setWorkingDir', params.opendir)
}
plugin.setWorkspace({ name: 'electron', isLocalhost: false })
plugin.on('fs', 'workingDirChanged', async (dir) => {
dispatch(setCurrentLocalFilePath(dir))
})
const currentPath = await plugin.call('fs', 'getWorkingDir')
dispatch(setCurrentLocalFilePath(currentPath))
plugin.setWorkspace({ name: 'electron', isLocalhost: false })
dispatch(setCurrentWorkspace({ name: 'electron', isGitRepo: false }))
electrOnProvider.init()
listenOnProviderEvents(electrOnProvider)(dispatch)

@ -308,9 +308,16 @@ export const setGitConfig = (config: {username: string, token: string, email: st
}
}
export const setElectronRecentFolders = (folders: string[]) => {
export const setElectronRecentFolders = (folders: string[]): Action<'SET_ELECTRON_RECENT_FOLDERS'> => {
return {
type: 'SET_ELECTRON_RECENT_FOLDERS',
payload: folders
}
}
export const setCurrentLocalFilePath = (path: string): Action<'SET_CURRENT_LOCAL_FILE_PATH'> => {
return {
type: 'SET_CURRENT_LOCAL_FILE_PATH',
payload: path
}
}

@ -0,0 +1,45 @@
import { CustomTooltip } from "@remix-ui/helper"
import React, { MouseEventHandler, useContext, useEffect, useState } from "react"
interface ElectronWorkspaceNameProps {
path: string
plugin: any
}
export const ElectronWorkspaceName = (props: ElectronWorkspaceNameProps) => {
const { path } = props
const parsePath = (path: string) => {
const pathArray = path.split('/')
return pathArray[pathArray.length - 1]
}
const openInExplorer = () => {
props.plugin.call('fs', 'revealInExplorer', {
path
})
}
return (
(path === undefined || path === '') ? <></> :
<div className="d-flex align-items-baseline">
<CustomTooltip
placement="top"
tooltipId="workspace-name"
tooltipClasses="text-nowrap"
tooltipText={path}
>
<div>{parsePath(path)}</div>
</CustomTooltip>
<CustomTooltip
placement="top"
tooltipId="workspace-open-in-explorer"
tooltipClasses="text-nowrap"
tooltipText='Open in file explorer'
>
<i onClick={openInExplorer} style={{ cursor: 'pointer' }} className="fa fas fa-arrow-up-right-from-square ml-2"></i>
</CustomTooltip>
</div>
)
}

@ -19,7 +19,7 @@ export function HamburgerMenuItem(props: HamburgerMenuItemProps) {
const uid = 'workspace' + props.kind
return (
<>
{props.platforms.includes(platform)?(
{props.platforms.includes(platform) && !hideOption?(
<Dropdown.Item>
<CustomTooltip placement="right" tooltipId={uid + 'Tooltip'} tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id={'filePanel.workspace.' + props.kind} />}>
<div

@ -20,10 +20,11 @@ export interface HamburgerMenuProps {
showIconsMenu: boolean
hideWorkspaceOptions: boolean
hideLocalhostOptions: boolean
hideFileOperations: boolean
}
export function HamburgerMenu(props: HamburgerMenuProps) {
const {showIconsMenu, hideWorkspaceOptions, hideLocalhostOptions} = props
const {showIconsMenu, hideWorkspaceOptions, hideLocalhostOptions, hideFileOperations} = props
return (
<>
<HamburgerMenuItem
@ -34,7 +35,17 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.createWorkspace()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
platforms={[appPlatformTypes.web]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="create.desktop"
fa="far fa-plus"
hideOption={hideWorkspaceOptions}
actionOnClick={() => {
props.createWorkspace()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={[appPlatformTypes.desktop]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="clone"
@ -111,7 +122,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
<HamburgerMenuItem
kind="solghaction"
fa="fa-kit fa-solidity-mono"
hideOption={hideWorkspaceOptions}
hideOption={hideWorkspaceOptions || hideFileOperations}
actionOnClick={() => {
props.addGithubAction()
props.hideIconsMenu(!showIconsMenu)
@ -121,7 +132,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
<HamburgerMenuItem
kind="tssoltestghaction"
fa="fab fa-js"
hideOption={hideWorkspaceOptions}
hideOption={hideWorkspaceOptions || hideFileOperations}
actionOnClick={() => {
props.addTsSolTestGithubAction()
props.hideIconsMenu(!showIconsMenu)
@ -131,7 +142,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
<HamburgerMenuItem
kind="slitherghaction"
fa="far fa-shield"
hideOption={hideWorkspaceOptions}
hideOption={hideWorkspaceOptions || hideFileOperations}
actionOnClick={() => {
props.addSlitherGithubAction()
props.hideIconsMenu(!showIconsMenu)
@ -142,7 +153,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
<HamburgerMenuItem
kind="addscriptetherscan"
fa="fa-kit fa-ts-logo"
hideOption={hideWorkspaceOptions}
hideOption={hideWorkspaceOptions || hideFileOperations}
actionOnClick={() => {
props.addHelperScripts('etherscan')
props.hideIconsMenu(!showIconsMenu)
@ -152,7 +163,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
<HamburgerMenuItem
kind="addscriptdeployer"
fa="fa-kit fa-ts-logo"
hideOption={hideWorkspaceOptions}
hideOption={hideWorkspaceOptions || hideFileOperations}
actionOnClick={() => {
props.addHelperScripts('deployer')
props.hideIconsMenu(!showIconsMenu)

@ -35,6 +35,7 @@ export interface BrowserState {
}
fileState: fileDecoration[]
recentFolders: string[]
currentLocalFilePath?: string
}
localhost: {
sharedFolder: string
@ -90,7 +91,8 @@ export const browserInitialState: BrowserState = {
error: null
},
fileState: [],
recentFolders: []
recentFolders: [],
currentLocalFilePath: ''
},
localhost: {
sharedFolder: '',
@ -872,6 +874,17 @@ export const browserReducer = (state = browserInitialState, action: Actions) =>
}
}
case 'SET_CURRENT_LOCAL_FILE_PATH': {
const payload: string = action.payload
return {
...state,
browser: {
...state.browser,
currentLocalFilePath: payload
}
}
}
default:
throw new Error()
}

@ -14,6 +14,7 @@ import FileExplorerContextMenu from './components/file-explorer-context-menu'
import { customAction } from '@remixproject/plugin-api'
import { appPlatformTypes, platformContext } from '@remix-ui/app'
import { ElectronMenu } from './components/electron-menu'
import { ElectronWorkspaceName } from './components/electron-workspace-name'
const _paq = (window._paq = window._paq || [])
@ -24,7 +25,6 @@ export function Workspace() {
const platform = useContext(platformContext)
const LOCALHOST = ' - connect to localhost - '
const NO_WORKSPACE = ' - none - '
const ELECTRON = 'electron'
const [currentWorkspace, setCurrentWorkspace] = useState<string>(NO_WORKSPACE)
const [selectedWorkspace, setSelectedWorkspace] = useState<{
name: string
@ -945,14 +945,17 @@ export function Workspace() {
showIconsMenu={showIconsMenu}
hideWorkspaceOptions={currentWorkspace === LOCALHOST}
hideLocalhostOptions={currentWorkspace === NO_WORKSPACE}
hideFileOperations={(platform == appPlatformTypes.desktop)? (global.fs.browser.currentLocalFilePath && global.fs.browser.currentLocalFilePath !== ''? false:true):false}
/>
</Dropdown.Menu>
</Dropdown>
</span>
) : null}
<span className="d-flex">
<label className="pl-2 form-check-label" style={{wordBreak: 'keep-all'}}>
<FormattedMessage id='filePanel.workspace' />
<label className="pl-2 form-check-label" style={{ wordBreak: 'keep-all' }}>
{(platform == appPlatformTypes.desktop) ? (
<ElectronWorkspaceName plugin={global.plugin} path={global.fs.browser.currentLocalFilePath} />
) : <FormattedMessage id='filePanel.workspace' />}
</label>
</span>
</div>

@ -303,6 +303,7 @@ export interface ActionPayloadTypes {
email: string
},
SET_ELECTRON_RECENT_FOLDERS: string[]
SET_CURRENT_LOCAL_FILE_PATH: string
}
export interface Action<T extends keyof ActionPayloadTypes> {

Loading…
Cancel
Save