context menu

rdesktop
filip mertens 1 year ago
parent 570658f54c
commit 3ce2e5b200
  1. 3
      libs/remix-ui/workspace/src/lib/components/electron-menu.tsx
  2. 4
      libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx
  3. 4
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  4. 2
      libs/remix-ui/workspace/src/lib/types/index.ts
  5. 21
      libs/remix-ui/workspace/src/lib/utils/index.ts

@ -30,7 +30,8 @@ export const ElectronMenu = () => {
} }
return ( return (
(isElectron() && global.fs.browser.isSuccessfulWorkspace ? null : !isElectron() ? null :
(global.fs.browser.isSuccessfulWorkspace ? null :
<> <>
<div onClick={async()=>{await openFolderElectron(null)}} className='btn btn-primary'><FormattedMessage id="electron.openFolder" /></div> <div onClick={async()=>{await openFolderElectron(null)}} className='btn btn-primary'><FormattedMessage id="electron.openFolder" /></div>
{global.fs.browser.recentFolders.length > 0 ? {global.fs.browser.recentFolders.length > 0 ?

@ -5,6 +5,7 @@ import { action, FileExplorerContextMenuProps } from '../types'
import '../css/file-explorer-context-menu.css' import '../css/file-explorer-context-menu.css'
import { customAction } from '@remixproject/plugin-api' import { customAction } from '@remixproject/plugin-api'
import UploadFile from './upload-file' import UploadFile from './upload-file'
import isElectron from 'is-electron'
declare global { declare global {
interface Window { interface Window {
@ -56,7 +57,8 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
} }
const itemMatchesCondition = (item: action, itemType: string, itemPath: string) => { const itemMatchesCondition = (item: action, itemType: string, itemPath: string) => {
if (item.type && Array.isArray(item.type) && (item.type.findIndex(name => name === itemType) !== -1)) return true if( isElectron() && item.platform && item.platform === 'browser') return false
else if (item.type && Array.isArray(item.type) && (item.type.findIndex(name => name === itemType) !== -1)) return true
else if (item.path && Array.isArray(item.path) && (item.path.findIndex(key => key === itemPath) !== -1)) return true else if (item.path && Array.isArray(item.path) && (item.path.findIndex(key => key === itemPath) !== -1)) return true
else if (item.extension && Array.isArray(item.extension) && (item.extension.findIndex(ext => itemPath.endsWith(ext)) !== -1)) return true else if (item.extension && Array.isArray(item.extension) && (item.extension.findIndex(ext => itemPath.endsWith(ext)) !== -1)) return true
else if (item.pattern && Array.isArray(item.pattern) && (item.pattern.filter(value => itemPath.match(new RegExp(value))).length > 0)) return true else if (item.pattern && Array.isArray(item.pattern) && (item.pattern.filter(value => itemPath.match(new RegExp(value))).length > 0)) return true

@ -702,7 +702,7 @@ export function Workspace() {
<FormattedMessage id='filePanel.workspace' /> <FormattedMessage id='filePanel.workspace' />
</label> </label>
</span> : null} </span> : null}
{currentWorkspace !== LOCALHOST ? (<span className="remixui_menu remixui_topmenu d-flex justify-content-between align-items-end w-75"> {currentWorkspace !== LOCALHOST && !isElectron() ? (<span className="remixui_menu remixui_topmenu d-flex justify-content-between align-items-end w-75">
<CustomTooltip <CustomTooltip
placement="top" placement="top"
tooltipId="createWorkspaceTooltip" tooltipId="createWorkspaceTooltip"
@ -812,7 +812,7 @@ export function Workspace() {
<FileExplorer <FileExplorer
fileState={global.fs.browser.fileState} fileState={global.fs.browser.fileState}
name={currentWorkspace} name={currentWorkspace}
menuItems={['createNewFile', 'createNewFolder', 'publishToGist', canUpload ? 'uploadFile' : '', canUpload ? 'uploadFolder' : '']} menuItems={['createNewFile', 'createNewFolder', !isElectron() ? 'publishToGist':'', canUpload && !isElectron() ? 'uploadFile' : '', canUpload && !isElectron() ? 'uploadFolder' : '']}
contextMenuItems={global.fs.browser.contextMenu.registeredMenuItems} contextMenuItems={global.fs.browser.contextMenu.registeredMenuItems}
removedContextMenuItems={global.fs.browser.contextMenu.removedMenuItems} removedContextMenuItems={global.fs.browser.contextMenu.removedMenuItems}
files={global.fs.browser.files} files={global.fs.browser.files}

@ -5,7 +5,7 @@ import { fileDecoration } from '@remix-ui/file-decorators'
import { RemixAppManager } from 'libs/remix-ui/plugin-manager/src/types' import { RemixAppManager } from 'libs/remix-ui/plugin-manager/src/types'
import { ViewPlugin } from '@remixproject/engine-web' import { ViewPlugin } from '@remixproject/engine-web'
export type action = { name: string, type?: Array<'folder' | 'gist' | 'file' | 'workspace'>, path?: string[], extension?: string[], pattern?: string[], id: string, multiselect: boolean, label: string, sticky?: boolean, group: number } export type action = { name: string, type?: Array<'folder' | 'gist' | 'file' | 'workspace'>, path?: string[], extension?: string[], pattern?: string[], id: string, multiselect: boolean, label: string, sticky?: boolean, group: number, platform?: 'electron' | 'browser' }
export interface JSONStandardInput { export interface JSONStandardInput {
language: "Solidity"; language: "Solidity";
settings?: any, settings?: any,

@ -62,7 +62,8 @@ export const contextMenuActions: MenuItems = [{
type: ['file', 'folder', 'workspace'], type: ['file', 'folder', 'workspace'],
multiselect: false, multiselect: false,
label: '', label: '',
group: 2 group: 2,
platform: 'browser'
}, { }, {
id: 'run', id: 'run',
name: 'Run', name: 'Run',
@ -76,35 +77,40 @@ export const contextMenuActions: MenuItems = [{
type: ['gist'], type: ['gist'],
multiselect: false, multiselect: false,
label: '', label: '',
group: 4 group: 4,
platform: 'browser'
}, { }, {
id: 'publishFolderToGist', id: 'publishFolderToGist',
name: 'Publish folder to gist', name: 'Publish folder to gist',
type: ['folder'], type: ['folder'],
multiselect: false, multiselect: false,
label: '', label: '',
group: 4 group: 4,
platform: 'browser'
}, { }, {
id: 'publishFileToGist', id: 'publishFileToGist',
name: 'Publish file to gist', name: 'Publish file to gist',
type: ['file'], type: ['file'],
multiselect: false, multiselect: false,
label: '', label: '',
group: 4 group: 4,
platform: 'browser'
}, { }, {
id: 'uploadFile', id: 'uploadFile',
name: 'Load a Local File', name: 'Load a Local File',
type: ['folder', 'gist', 'workspace'], type: ['folder', 'gist', 'workspace'],
multiselect: false, multiselect: false,
label: 'Load a Local File', label: 'Load a Local File',
group: 4 group: 4,
platform: 'browser'
}, { }, {
id: 'publishToGist', id: 'publishToGist',
name: 'Push changes to gist', name: 'Push changes to gist',
type: ['folder', 'gist'], type: ['folder', 'gist'],
multiselect: false, multiselect: false,
label: 'Publish all to Gist', label: 'Publish all to Gist',
group: 4 group: 4,
platform: 'browser'
}, },
{ {
id: 'publishWorkspace', id: 'publishWorkspace',
@ -112,5 +118,6 @@ export const contextMenuActions: MenuItems = [{
type: ['workspace'], type: ['workspace'],
multiselect: false, multiselect: false,
label: '', label: '',
group: 4 group: 4,
platform: 'browser'
}] }]
Loading…
Cancel
Save