context menu

rdesktop^2
filip mertens 1 year ago
parent 443dcde260
commit 68515019a9
  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

@ -696,7 +696,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"
@ -806,7 +806,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 } 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, platform?: 'electron' | 'browser' }
export interface JSONStandardInput { export interface JSONStandardInput {
language: "Solidity"; language: "Solidity";
settings?: any, settings?: any,

@ -29,7 +29,8 @@ export const contextMenuActions: MenuItems = [{
name: 'Download', name: 'Download',
type: ['file', 'folder', 'workspace'], type: ['file', 'folder', 'workspace'],
multiselect: false, multiselect: false,
label: '' label: '',
platform: 'browser'
}, { }, {
id: 'run', id: 'run',
name: 'Run', name: 'Run',
@ -41,19 +42,22 @@ export const contextMenuActions: MenuItems = [{
name: 'Push changes to gist', name: 'Push changes to gist',
type: ['gist'], type: ['gist'],
multiselect: false, multiselect: false,
label: '' label: '',
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: '',
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: '',
platform: 'browser'
}, { }, {
id: 'copy', id: 'copy',
name: 'Copy', name: 'Copy',
@ -83,18 +87,21 @@ export const contextMenuActions: MenuItems = [{
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',
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',
platform: 'browser'
}, },
{ {
id: 'publishWorkspace', id: 'publishWorkspace',
name: 'Publish Workspace to Gist', name: 'Publish Workspace to Gist',
type: ['workspace'], type: ['workspace'],
multiselect: false, multiselect: false,
label: '' label: '',
platform: 'browser'
}] }]
Loading…
Cancel
Save