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 (
(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>
{global.fs.browser.recentFolders.length > 0 ?

@ -5,6 +5,7 @@ import { action, FileExplorerContextMenuProps } from '../types'
import '../css/file-explorer-context-menu.css'
import { customAction } from '@remixproject/plugin-api'
import UploadFile from './upload-file'
import isElectron from 'is-electron'
declare global {
interface Window {
@ -56,7 +57,8 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
}
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.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

@ -696,7 +696,7 @@ export function Workspace() {
<FormattedMessage id='filePanel.workspace' />
</label>
</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
placement="top"
tooltipId="createWorkspaceTooltip"
@ -806,7 +806,7 @@ export function Workspace() {
<FileExplorer
fileState={global.fs.browser.fileState}
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}
removedContextMenuItems={global.fs.browser.contextMenu.removedMenuItems}
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 { 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 {
language: "Solidity";
settings?: any,

@ -29,7 +29,8 @@ export const contextMenuActions: MenuItems = [{
name: 'Download',
type: ['file', 'folder', 'workspace'],
multiselect: false,
label: ''
label: '',
platform: 'browser'
}, {
id: 'run',
name: 'Run',
@ -41,19 +42,22 @@ export const contextMenuActions: MenuItems = [{
name: 'Push changes to gist',
type: ['gist'],
multiselect: false,
label: ''
label: '',
platform: 'browser'
}, {
id: 'publishFolderToGist',
name: 'Publish folder to gist',
type: ['folder'],
multiselect: false,
label: ''
label: '',
platform: 'browser'
}, {
id: 'publishFileToGist',
name: 'Publish file to gist',
type: ['file'],
multiselect: false,
label: ''
label: '',
platform: 'browser'
}, {
id: 'copy',
name: 'Copy',
@ -83,18 +87,21 @@ export const contextMenuActions: MenuItems = [{
name: 'Load a Local File',
type: ['folder', 'gist', 'workspace'],
multiselect: false,
label: 'Load a Local File'
label: 'Load a Local File',
platform: 'browser'
}, {
id: 'publishToGist',
name: 'Push changes to gist',
type: ['folder', 'gist'],
multiselect: false,
label: 'Publish all to Gist'
label: 'Publish all to Gist',
platform: 'browser'
},
{
id: 'publishWorkspace',
name: 'Publish Workspace to Gist',
type: ['workspace'],
multiselect: false,
label: ''
label: '',
platform: 'browser'
}]
Loading…
Cancel
Save