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 (
(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

@ -702,7 +702,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"
@ -812,7 +812,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, 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 {
language: "Solidity";
settings?: any,

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