desktopmerge
filip mertens 1 year ago
parent a92a3dee4d
commit ce89b149a1
  1. 17
      apps/remix-ide/src/app.js
  2. 48
      apps/remix-ide/src/app/files/dgitProvider.ts
  3. 8
      apps/remix-ide/src/app/files/fileManager.ts
  4. 3
      apps/remix-ide/src/app/panels/terminal.js
  5. 4
      apps/remix-ide/src/app/plugins/parser/services/code-parser-antlr-service.ts
  6. 4
      apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts
  7. 6
      apps/remix-ide/src/app/plugins/remixd-handle.tsx
  8. 2
      apps/remix-ide/src/app/state/registry.ts
  9. 10
      apps/remix-ide/src/remixAppManager.js
  10. 2
      libs/remix-ui/app/src/index.ts
  11. 8
      libs/remix-ui/app/src/lib/remix-app/context/context.tsx
  12. 5
      libs/remix-ui/home-tab/src/lib/components/homeTabGetStarted.tsx
  13. 7
      libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx
  14. 5
      libs/remix-ui/panel/src/lib/main/main-panel.tsx
  15. 4
      libs/remix-ui/search/src/lib/components/results/SearchHelper.ts
  16. 7
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  17. 8
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx
  18. 8
      libs/remix-ui/workspace/src/lib/actions/index.ts
  19. 5
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  20. 7
      libs/remix-ui/workspace/src/lib/components/electron-menu.tsx
  21. 7
      libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx
  22. 7
      libs/remix-ui/workspace/src/lib/components/workspace-hamburger-item.tsx
  23. 27
      libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx
  24. 6
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  25. 3
      libs/remix-ui/workspace/src/lib/types/index.ts
  26. 15
      libs/remix-ui/workspace/src/lib/utils/index.ts

@ -71,6 +71,7 @@ const Config = require('./config')
const FileManager = require('./app/files/fileManager')
import FileProvider from "./app/files/fileProvider"
import { appPlatformTypes } from '@remix-ui/app'
const DGitProvider = require('./app/files/dgitProvider')
const WorkspaceFileProvider = require('./app/files/workspaceFileProvider')
@ -87,10 +88,22 @@ const Terminal = require('./app/panels/terminal')
const {TabProxy} = require('./app/panels/tab-proxy.js')
export class platformApi {
get name () {
return isElectron() ? appPlatformTypes.desktop : appPlatformTypes.web
}
isDesktop () {
return isElectron()
}
}
class AppComponent {
constructor() {
const PlatFormAPi = new platformApi()
Registry.getInstance().put({
api: PlatFormAPi,
name: 'platform'
})
this.appManager = new RemixAppManager({})
this.queryParams = new QueryParams()
this._components = {}
@ -129,6 +142,8 @@ class AppComponent {
api: this._components.filesProviders,
name: 'fileproviders'
})
}
async run() {

@ -14,7 +14,7 @@ import JSZip from 'jszip'
import path from 'path'
import FormData from 'form-data'
import axios from 'axios'
import isElectron from 'is-electron'
import Registry from '../state/registry'
const profile = {
name: 'dGitProvider',
@ -57,7 +57,7 @@ class DGitProvider extends Plugin {
async getGitConfig() {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return {
fs: window.remixFileSystem,
dir: '/'
@ -89,7 +89,7 @@ class DGitProvider extends Plugin {
}
async init(input?) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'init', {
defaultBranch: (input && input.branch) || 'main'
})
@ -105,7 +105,7 @@ class DGitProvider extends Plugin {
}
async version() {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'version')
}
@ -115,7 +115,7 @@ class DGitProvider extends Plugin {
async status(cmd) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
const status = await this.call('isogit', 'status', cmd)
return status
@ -132,7 +132,7 @@ class DGitProvider extends Plugin {
async add(cmd) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'add', cmd)
} else {
await git.add({
@ -146,7 +146,7 @@ class DGitProvider extends Plugin {
async rm(cmd) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'rm', cmd)
} else {
await git.remove({
@ -160,7 +160,7 @@ class DGitProvider extends Plugin {
async reset(cmd) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'reset', cmd)
} else {
await git.resetIndex({
@ -174,7 +174,7 @@ class DGitProvider extends Plugin {
async checkout(cmd, refresh = true) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'checkout', cmd)
} else {
await git.checkout({
@ -192,7 +192,7 @@ class DGitProvider extends Plugin {
async log(cmd) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
const status = await this.call('isogit', 'log', {
...cmd,
depth: 10
@ -211,7 +211,7 @@ class DGitProvider extends Plugin {
}
async remotes(config) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'remotes', config)
}
@ -227,7 +227,7 @@ class DGitProvider extends Plugin {
async branch(cmd, refresh = true) {
let status
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
status = await this.call('isogit', 'branch', cmd)
} else {
status = await git.branch({
@ -248,7 +248,7 @@ class DGitProvider extends Plugin {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'currentbranch')
}
@ -265,7 +265,7 @@ class DGitProvider extends Plugin {
async branches(config) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'branches')
}
@ -288,7 +288,7 @@ class DGitProvider extends Plugin {
async commit(cmd) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
try {
await this.call('isogit', 'init')
const sha = await this.call('isogit', 'commit', cmd)
@ -315,7 +315,7 @@ class DGitProvider extends Plugin {
async lsfiles(cmd) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'lsfiles', cmd)
}
@ -328,7 +328,7 @@ class DGitProvider extends Plugin {
async resolveref(cmd) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'resolveref', cmd)
}
@ -340,7 +340,7 @@ class DGitProvider extends Plugin {
}
async readblob(cmd) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
const readBlobResult = await this.call('isogit', 'readblob', cmd)
return readBlobResult
}
@ -370,7 +370,7 @@ class DGitProvider extends Plugin {
}
async addremote(input) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'addremote', { url: input.url, remote: input.remote })
return
}
@ -378,7 +378,7 @@ class DGitProvider extends Plugin {
}
async delremote(input) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'delremote', { remote: input.remote })
return
}
@ -391,7 +391,7 @@ class DGitProvider extends Plugin {
async clone(input, workspaceName, workspaceExists = false) {
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
const folder = await this.call('fs', 'selectFolder')
if (!folder) return false
const cmd = {
@ -442,7 +442,7 @@ class DGitProvider extends Plugin {
},
input,
}
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'push', cmd)
} else {
@ -470,7 +470,7 @@ class DGitProvider extends Plugin {
input,
}
let result
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
result = await this.call('isogit', 'pull', cmd)
}
else {
@ -501,7 +501,7 @@ class DGitProvider extends Plugin {
input
}
let result
if (isElectron()) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
result = await this.call('isogit', 'fetch', cmd)
} else {
const cmd2 = {

@ -10,8 +10,6 @@ import { fileChangedToastMsg, recursivePasteToastMsg, storageFullMessage } from
import helper from '../../lib/helper.js'
import { RemixAppManager } from '../../remixAppManager'
import isElectron from 'is-electron'
/*
attach to files event (removed renamed)
trigger: currentFileChanged
@ -157,7 +155,7 @@ class FileManager extends Plugin {
refresh() {
const provider = this.fileProviderOf('/')
// emit rootFolderChanged so that File Explorer reloads the file tree
if(isElectron()){
if(Registry.getInstance().get('platform').api.isDesktop()){
provider.event.emit('refresh')
}else{
provider.event.emit('rootFolderChanged', provider.workspace || '/')
@ -791,7 +789,7 @@ class FileManager extends Plugin {
return this._deps.filesProviders.localhost
}
if(isElectron()){
if(Registry.getInstance().get('platform').api.isDesktop()){
return this._deps.filesProviders.electron
}
return this._deps.filesProviders.workspace
@ -916,7 +914,7 @@ class FileManager extends Plugin {
}
currentWorkspace() {
if(isElectron()){
if(Registry.getInstance().get('platform').api.isDesktop()){
return ''
}

@ -6,7 +6,6 @@ import * as packageJson from '../../../../../package.json'
import Registry from '../state/registry'
import { PluginViewWrapper } from '@remix-ui/helper'
import vm from 'vm'
import isElectron from 'is-electron'
const EventManager = require('../../lib/events')
import { CompilerImports } from '@remix-project/core-plugin' // eslint-disable-line
@ -115,7 +114,7 @@ class Terminal extends Plugin {
}
updateComponent(state) {
return isElectron() ? <RemixUiXterminals onReady={state.onReady} plugin={state.plugin}>
return (Registry.getInstance().get('platform').api.isDesktop()) ? <RemixUiXterminals onReady={state.onReady} plugin={state.plugin}>
</RemixUiXterminals>
: <RemixUiTerminal
plugin={state.plugin}

@ -4,7 +4,7 @@ import { AstNode } from "@remix-project/remix-solidity"
import { CodeParser } from "../code-parser"
import { antlr } from '../types'
import { pathToFileURL } from 'url'
import isElectron from 'is-electron'
import Registry from "../../../state/registry"
const SolidityParser = (window as any).SolidityParser = (window as any).SolidityParser || []
@ -46,7 +46,7 @@ export default class CodeParserAntlrService {
this.worker = new Worker(new URL('./antlr-worker', import.meta.url))
this.worker.postMessage({
cmd: 'load',
url: isElectron() ? 'assets/js/parser/antlr.js' : document.location.protocol + '//' + document.location.host + '/assets/js/parser/antlr.js',
url: Registry.getInstance().get('platform').api.isDesktop() ? 'assets/js/parser/antlr.js' : document.location.protocol + '//' + document.location.host + '/assets/js/parser/antlr.js',
})
const self = this

@ -1,6 +1,6 @@
'use strict'
import Registry from "../../../state/registry";
import { CodeParser } from "../code-parser";
import isElectron from 'is-electron'
export type CodeParserImportsData = {
files?: string[],
@ -40,7 +40,7 @@ export default class CodeParserImports {
}
setFileTree = async () => {
if (isElectron()) {
if (Registry.getInstance().get('platform').api.isDesktop()) {
const files = await this.plugin.call('ripgrep', 'glob', '/', '**/*.sol')
// only get path property of files
this.data.files = files.map((x) => x.path)

@ -1,12 +1,12 @@
/* eslint-disable no-unused-vars */
import React, {useRef, useState, useEffect} from 'react' // eslint-disable-line
import isElectron from 'is-electron'
import {WebsocketPlugin} from '@remixproject/engine-web'
import * as packageJson from '../../../../../package.json'
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import {version as remixdVersion} from '../../../../../libs/remixd/package.json'
import {PluginManager} from '@remixproject/engine'
import {AppModal, AlertModal} from '@remix-ui/app'
import {AppModal, AlertModal, appPlatformTypes} from '@remix-ui/app'
import Registry from '../state/registry'
const LOCALHOST = ' - connect to localhost - '
@ -112,7 +112,7 @@ export class RemixdHandle extends WebsocketPlugin {
}
if (this.localhostProvider.isConnected()) {
this.deactivate()
} else if (!isElectron()) {
} else if (!(Registry.getInstance().get('platform').api.isDektop())) {
// warn the user only if he/she is in the browser context
const mod: AppModal = {
id: 'remixdConnect',

@ -29,7 +29,7 @@ export default class Registry {
return server
}
public get (name: string) {
public get (name: string): registryEntry {
const state = this.state[name]
if (!state) return
const server = state.server

@ -2,7 +2,8 @@ import {PluginManager} from '@remixproject/engine'
import {EventEmitter} from 'events'
import {QueryParams} from '@remix-project/remix-lib'
import {IframePlugin} from '@remixproject/engine-web'
const isElectron = require('is-electron')
import Registry from './app/state/registry'
const _paq = (window._paq = window._paq || [])
// requiredModule removes the plugin from the plugin manager list on UI
@ -78,9 +79,6 @@ let requiredModules = [ // services + layout views + system views
'home'
]
if (isElectron()) {
requiredModules = [...requiredModules, 'fs', 'electronTemplates', 'isogit', 'remix-templates', 'electronconfig']
}
// dependentModules shouldn't be manually activated (e.g hardhat is activated by remixd)
@ -146,6 +144,10 @@ export class RemixAppManager extends PluginManager {
this.event = new EventEmitter()
this.pluginsDirectory = 'https://raw.githubusercontent.com/ethereum/remix-plugins-directory/master/build/metadata.json'
this.pluginLoader = new PluginLoader()
if (Registry.getInstance().get('platform').api.isDesktop()) {
requiredModules = [...requiredModules, 'fs', 'electronTemplates', 'isogit', 'remix-templates', 'electronconfig']
}
}
async canActivatePlugin(from, to) {

@ -1,5 +1,5 @@
export { default as RemixApp } from './lib/remix-app/remix-app'
export { dispatchModalContext, dispatchModalInterface, AppContext } from './lib/remix-app/context/context'
export { dispatchModalContext, dispatchModalInterface, AppContext, appProviderContextType, appPlatformTypes } from './lib/remix-app/context/context'
export { ModalProvider, useDialogDispatchers } from './lib/remix-app/context/provider'
export { AppModal } from './lib/remix-app/interface/index'
export { AlertModal } from './lib/remix-app/interface/index'

@ -1,7 +1,6 @@
import React from 'react'
import {AlertModal, AppModal} from '../interface'
import {ModalInitialState} from '../state/modals'
import { Plugin } from '@remixproject/engine'
export type appProviderContextType = {
settings: any,
@ -9,10 +8,13 @@ export type appProviderContextType = {
appManager: any
modal: any
layout: any
platform: appPlatformType
platform: appPlatformTypes
}
export type appPlatformType = 'web' | 'desktop'
export enum appPlatformTypes {
web = 'web',
desktop = 'desktop'
}
export const AppContext = React.createContext<appProviderContextType>(null)

@ -7,7 +7,7 @@ import Carousel from 'react-multi-carousel'
import WorkspaceTemplate from './workspaceTemplate'
import 'react-multi-carousel/lib/styles.css'
import CustomNavButtons from './customNavButtons'
import isElectron from 'is-electron'
import { AppContext, appPlatformTypes } from '@remix-ui/app'
declare global {
interface Window {
_paq: any
@ -19,6 +19,7 @@ interface HomeTabGetStartedProps {
}
function HomeTabGetStarted({plugin}: HomeTabGetStartedProps) {
const {platform} = useContext(AppContext)
const themeFilter = useContext(ThemeContext)
const carouselRef = useRef<any>({})
const carouselRefDiv = useRef(null)
@ -59,7 +60,7 @@ function HomeTabGetStarted({plugin}: HomeTabGetStartedProps) {
}
const createWorkspace = async (templateName) => {
if(isElectron()){
if(platform === appPlatformTypes.desktop){
await plugin.call('remix-templates', 'loadTemplateInNewWindow', templateName)
return
}

@ -1,4 +1,4 @@
import React, {useState, useEffect} from 'react' // eslint-disable-line
import React, {useState, useEffect, useContext} from 'react' // eslint-disable-line
import './remix-ui-home-tab.css'
import {ThemeContext, themes} from './themeContext'
@ -9,7 +9,7 @@ import HomeTabScamAlert from './components/homeTabScamAlert'
import HomeTabGetStarted from './components/homeTabGetStarted'
import HomeTabFeatured from './components/homeTabFeatured'
import HomeTabFeaturedPlugins from './components/homeTabFeaturedPlugins'
import isElectron from 'is-electron'
import { AppContext, appPlatformTypes } from '@remix-ui/app'
import { HomeTabFileElectron } from './components/homeTabFileElectron'
import { LanguageOptions } from './components/homeTablangOptions'
@ -24,6 +24,7 @@ export interface RemixUiHomeTabProps {
}
export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
const {platform} = useContext(AppContext)
const {plugin} = props
const [state, setState] = useState<{
@ -59,7 +60,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
<div className="d-flex flex-row w-100 custom_home_bg">
<div className="px-2 pl-3 justify-content-start d-flex border-right flex-column" id="remixUIHTLeft" style={{width: 'inherit'}}>
<HomeTabTitle />
{!isElectron()?
{!(platform === appPlatformTypes.desktop) ?
<HomeTabFile plugin={plugin} />:
<HomeTabFileElectron plugin={plugin}></HomeTabFileElectron>}
<HomeTabLearn plugin={plugin} />

@ -1,9 +1,9 @@
/* eslint-disable no-unused-expressions */
import isElectron from 'is-electron'
import React, {useContext, useEffect, useRef, useState} from 'react' // eslint-disable-line
import DragBar from '../dragbar/dragbar'
import RemixUIPanelPlugin from '../plugins/panel-plugin'
import {PluginRecord} from '../types'
import { AppContext, appPlatformTypes } from '@remix-ui/app'
import './main-panel.css'
@ -12,6 +12,7 @@ export type RemixUIMainPanelProps = {
}
const RemixUIMainPanel = (props: RemixUIMainPanelProps) => {
const {platform} = useContext(AppContext)
const appContext = useContext(props.Context)
const [plugins, setPlugins] = useState<PluginRecord[]>([])
const editorRef = useRef<HTMLDivElement>(null)
@ -29,7 +30,7 @@ const RemixUIMainPanel = (props: RemixUIMainPanelProps) => {
profile: panel.plugin.profile,
active: panel.active,
view: panel.plugin.profile.name === 'tabs' ? panel.plugin.renderTabsbar() : panel.plugin.render(),
class: panel.plugin.profile.name + '-wrap ' + (panel.minimized ? 'minimized ' : ' ') + (isElectron()? 'desktop' : ''),
class: panel.plugin.profile.name + '-wrap ' + (panel.minimized ? 'minimized ' : ' ') + ((platform === appPlatformTypes.desktop)? 'desktop' : ''),
minimized: panel.minimized
})
})

@ -1,12 +1,12 @@
import { EOL } from 'os'
import { SearchResultLineLine } from '../../types'
import isElectron from 'is-electron'
import Registry from 'apps/remix-ide/src/app/state/registry'
export const getDirectory = async (dir: string, plugin: any) => {
let result = []
if (isElectron()) {
if (Registry.getInstance().get('platform').api.isDesktop()) {
const files = await plugin.call('ripgrep', 'glob', dir, '**/*')
// only get path property of files

@ -1,4 +1,4 @@
import React, {useEffect, useState, useRef, useReducer} from 'react' // eslint-disable-line
import React, {useEffect, useState, useRef, useReducer, useContext} from 'react' // eslint-disable-line
import {FormattedMessage, useIntl} from 'react-intl'
import semver from 'semver'
import {CompilerContainerProps} from './types'
@ -11,9 +11,9 @@ import {getValidLanguage} from '@remix-project/remix-solidity'
import {CopyToClipboard} from '@remix-ui/clipboard'
import {configFileContent} from './compilerConfiguration'
import axios, {AxiosResponse} from 'axios'
import { AppContext, appPlatformTypes } from '@remix-ui/app'
import './css/style.css'
import isElectron from 'is-electron'
const defaultPath = 'compiler_config.json'
declare global {
@ -25,6 +25,7 @@ declare global {
const _paq = (window._paq = window._paq || []) //eslint-disable-line
export const CompilerContainer = (props: CompilerContainerProps) => {
const {platform} = useContext(AppContext)
const {
api,
compileTabLogic,
@ -576,7 +577,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
// "Uncaught RangeError: Maximum call stack size exceeded" error on Chromium,
// resort to non-worker version in that case.
if (selectedVersion === 'builtin') selectedVersion = state.defaultVersion
if (selectedVersion !== 'builtin' && (canUseWorker(selectedVersion) || isElectron())) {
if (selectedVersion !== 'builtin' && (canUseWorker(selectedVersion) || platform === appPlatformTypes.desktop)) {
compileTabLogic.compiler.loadVersion(true, url)
} else {
compileTabLogic.compiler.loadVersion(false, url)

@ -1,4 +1,4 @@
import React, { useState, useRef, useEffect, ReactElement } from 'react' // eslint-disable-line
import React, { useState, useRef, useEffect, ReactElement, useContext } from 'react' // eslint-disable-line
import { FormattedMessage, useIntl } from 'react-intl'
import * as semver from 'semver'
import { eachOfSeries } from 'async' // eslint-disable-line
@ -9,7 +9,7 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
import { format } from 'util'
import './css/style.css'
import { CustomTooltip } from '@remix-ui/helper'
import isElectron from 'is-electron'
import { AppContext, appPlatformTypes } from '@remix-ui/app'
const _paq = ((window as any)._paq = (window as any)._paq || []) // eslint-disable-line @typescript-eslint/no-explicit-any
@ -44,7 +44,7 @@ interface FinalResult {
export const SolidityUnitTesting = (props: Record<string, any>) => {
// eslint-disable-line @typescript-eslint/no-explicit-any
const {platform} = useContext(AppContext)
const { helper, testTab, initialPath } = props
const { testTabLogic } = testTab
@ -608,7 +608,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => {
currentCompilerUrl,
evmVersion,
optimize,
usingWorker: canUseWorker(currentVersion) || isElectron(),
usingWorker: canUseWorker(currentVersion) || platform === appPlatformTypes.desktop,
runs,
}
const deployCb = async (file: string, contractAddress: string) => {

@ -8,8 +8,8 @@ import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin,
import { QueryParams } from '@remix-project/remix-lib'
import { fetchContractFromEtherscan } from '@remix-project/core-plugin' // eslint-disable-line
import JSZip from 'jszip'
import isElectron from 'is-electron'
import { Actions, FileTree } from '../types'
import Registry from 'apps/remix-ide/src/app/state/registry'
export * from './events'
export * from './workspace'
@ -55,7 +55,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
const electrOnProvider = filePanelPlugin.fileProviders.electron
const params = queryParams.get() as UrlParametersType
let workspaces = []
if (!isElectron()) {
if (!(Registry.getInstance().get('platform').api.isDesktop())) {
workspaces = await getWorkspaces() || []
dispatch(setWorkspaces(workspaces))
}
@ -118,7 +118,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
await basicWorkspaceInit(workspaces, workspaceProvider)
}
} else await basicWorkspaceInit(workspaces, workspaceProvider)
} else if (isElectron()) {
} else if (Registry.getInstance().get('platform').api.isDesktop()) {
if (params.opendir) {
params.opendir = decodeURIComponent(params.opendir)
plugin.call('notification', 'toast', `opening ${params.opendir}...`)
@ -154,7 +154,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
listenOnProviderEvents(workspaceProvider)(dispatch)
listenOnProviderEvents(localhostProvider)(dispatch)
listenOnProviderEvents(electrOnProvider)(dispatch)
if (isElectron()) {
if (Registry.getInstance().get('platform').api.isDesktop()) {
dispatch(setMode('browser'))
} else {
dispatch(setMode('browser'))

@ -38,7 +38,6 @@ import { IndexedDBStorage } from '../../../../../../apps/remix-ide/src/app/files
import { getUncommittedFiles } from '../utils/gitStatusFilter'
import { AppModal, ModalTypes } from '@remix-ui/app'
import { contractDeployerScripts, etherscanScripts } from '@remix-project/remix-ws-templates'
import isElectron from 'is-electron'
declare global {
interface Window {
@ -120,7 +119,7 @@ export const createWorkspace = async (
isGitRepo: boolean = false,
createCommit: boolean = true
) => {
if (isElectron()) {
if (plugin.registry.get('platform').api.isDesktop()) {
if (workspaceTemplateName) {
await plugin.call('remix-templates', 'loadTemplateInNewWindow', workspaceTemplateName, opts)
}
@ -577,7 +576,7 @@ export const cloneRepository = async (url: string) => {
const token = config.get('settings/gist-access-token')
const repoConfig = { url, token }
if (isElectron()) {
if (plugin.registry.get('platform').api.isDesktop()) {
try {
await plugin.call('dGitProvider', 'clone', repoConfig)
} catch (e) {

@ -1,15 +1,16 @@
import React, { MouseEventHandler, useContext, useEffect, useState } from "react"
import { FileSystemContext } from "../contexts"
import isElectron from 'is-electron'
import { AppContext, appPlatformTypes } from '@remix-ui/app'
import { FormattedMessage } from "react-intl"
import '../css/electron-menu.css'
import { CustomTooltip } from '@remix-ui/helper'
export const ElectronMenu = () => {
const {platform} = useContext(AppContext)
const global = useContext(FileSystemContext)
useEffect(() => {
if (isElectron()) {
if (platform === appPlatformTypes.desktop) {
global.dispatchGetElectronRecentFolders()
}
}, [])
@ -24,7 +25,7 @@ export const ElectronMenu = () => {
}
return (
!isElectron() ? null :
(platform !== appPlatformTypes.desktop) ? null :
(global.fs.browser.isSuccessfulWorkspace ? null :
<>
<div onClick={async () => { await openFolderElectron(null) }} className='btn btn-primary'><FormattedMessage id="electron.openFolder" /></div>

@ -1,11 +1,11 @@
import React, {useRef, useEffect, useState} from 'react' // eslint-disable-line
import React, {useRef, useEffect, useState, useContext} from 'react' // eslint-disable-line
import {useIntl} from 'react-intl'
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'
import { AppContext, appPlatformTypes } from '@remix-ui/app'
declare global {
interface Window {
@ -15,6 +15,7 @@ declare global {
const _paq = (window._paq = window._paq || []) //eslint-disable-line
export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) => {
const {platform} = useContext(AppContext)
const {
actions,
createNewFile,
@ -83,7 +84,7 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
}
const itemMatchesCondition = (item: action, itemType: string, itemPath: string) => {
if( isElectron() && item.platform && item.platform === 'browser') return false
if( platform === appPlatformTypes.desktop && item.platform && item.platform === appPlatformTypes.web) 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

@ -2,8 +2,7 @@ import React, { useContext } from 'react'
import {CustomTooltip, CustomMenu, CustomIconsToggle} from '@remix-ui/helper'
import {Dropdown, NavDropdown} from 'react-bootstrap'
import {FormattedMessage} from 'react-intl'
import { AppContext, appPlatformType } from 'libs/remix-ui/app/src/lib/remix-app/context/context'
import { AppContext, appPlatformTypes } from '@remix-ui/app'
const _paq = (window._paq = window._paq || [])
export interface HamburgerMenuItemProps {
@ -11,7 +10,7 @@ export interface HamburgerMenuItemProps {
kind: string
actionOnClick: () => void
fa: string
platforms: appPlatformType[]
platforms: appPlatformTypes[]
}
export function HamburgerMenuItem(props: HamburgerMenuItemProps) {
@ -73,7 +72,7 @@ export interface HamburgerSubMenuItemProps {
id: string
title: string
subMenus: Array<HamburgerMenuItemProps>
platforms: appPlatformType[]
platforms: appPlatformTypes[]
}
export function HamburgerSubMenuItem(props: HamburgerSubMenuItemProps) {

@ -1,3 +1,4 @@
import { appPlatformTypes } from 'libs/remix-ui/app/src/lib/remix-app/context/context'
import React from 'react'
import {Dropdown} from 'react-bootstrap'
import {HamburgerMenuItem, HamburgerSubMenuItem} from './workspace-hamburger-item'
@ -33,7 +34,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.createWorkspace()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web', 'desktop']}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="clone"
@ -43,7 +44,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.cloneGitRepository()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web', 'desktop']}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="rename"
@ -53,7 +54,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.renameCurrentWorkspace()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web']}
platforms={[appPlatformTypes.web]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="download"
@ -63,7 +64,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.downloadCurrentWorkspace()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web']}
platforms={[appPlatformTypes.web]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="delete"
@ -73,7 +74,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.deleteCurrentWorkspace()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web']}
platforms={[appPlatformTypes.web]}
></HamburgerMenuItem>
<Dropdown.Divider className="border mb-0 mt-0 remixui_menuhr" style={{pointerEvents: 'none'}} />
<HamburgerMenuItem
@ -84,7 +85,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.deleteAllWorkspaces()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web']}
platforms={[appPlatformTypes.web]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="backup"
@ -94,7 +95,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.downloadWorkspaces()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web']}
platforms={[appPlatformTypes.web]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="restore"
@ -104,7 +105,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.restoreBackup()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web']}
platforms={[appPlatformTypes.web]}
></HamburgerMenuItem>
<Dropdown.Divider className="border mt-0 mb-0 remixui_menuhr" style={{pointerEvents: 'none'}} />
<HamburgerMenuItem
@ -115,7 +116,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.addGithubAction()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web', 'desktop']}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="tssoltestghaction"
@ -125,7 +126,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.addTsSolTestGithubAction()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web', 'desktop']}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="slitherghaction"
@ -135,7 +136,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.addSlitherGithubAction()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web', 'desktop']}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
></HamburgerMenuItem>
<Dropdown.Divider className="border mb-0 mt-0 remixui_menuhr" style={{pointerEvents: 'none'}} />
<HamburgerMenuItem
@ -146,7 +147,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.addHelperScripts('etherscan')
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web', 'desktop']}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
></HamburgerMenuItem>
<HamburgerMenuItem
kind="addscriptdeployer"
@ -156,7 +157,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
props.addHelperScripts('deployer')
props.hideIconsMenu(!showIconsMenu)
}}
platforms={['web', 'desktop']}
platforms={[appPlatformTypes.web, appPlatformTypes.desktop]}
></HamburgerMenuItem>
</>
)

@ -12,7 +12,7 @@ import {MenuItems, WorkSpaceState} from './types'
import {contextMenuActions} from './utils'
import FileExplorerContextMenu from './components/file-explorer-context-menu'
import { customAction } from '@remixproject/plugin-api'
import isElectron from 'is-electron'
import { AppContext, appPlatformTypes } from '@remix-ui/app'
import { ElectronMenu } from './components/electron-menu'
const _paq = (window._paq = window._paq || [])
@ -20,6 +20,7 @@ const _paq = (window._paq = window._paq || [])
const canUpload = window.File || window.FileReader || window.FileList || window.Blob
export function Workspace() {
const {platform} = useContext(AppContext)
const LOCALHOST = ' - connect to localhost - '
const NO_WORKSPACE = ' - none - '
const ELECTRON = 'electron'
@ -229,7 +230,6 @@ export function Workspace() {
}
const cloneGitRepository = () => {
console.log('clone from workspace modal')
global.modal(
intl.formatMessage({id: 'filePanel.workspace.clone'}),
cloneModalMessage(),
@ -935,7 +935,7 @@ export function Workspace() {
</span>
</div>
<div className='mx-2'>
{!isElectron() ? (
{(platform !== appPlatformTypes.desktop) ? (
<Dropdown id="workspacesSelect" data-id="workspacesSelect" onToggle={toggleDropdown} show={showDropdown}>
<Dropdown.Toggle
as={CustomToggle}

@ -4,8 +4,9 @@ import { customAction } from '@remixproject/plugin-api'
import { fileDecoration } from '@remix-ui/file-decorators'
import { RemixAppManager } from 'libs/remix-ui/plugin-manager/src/types'
import { ViewPlugin } from '@remixproject/engine-web'
import { appPlatformTypes } from '@remix-ui/app'
export type action = { name: string, type?: Array<WorkspaceElement>, path?: string[], extension?: string[], pattern?: string[], id: string, multiselect: boolean, label: string, sticky?: boolean, group: number, platform?: 'electron' | 'browser' }
export type action = { name: string, type?: Array<WorkspaceElement>, path?: string[], extension?: string[], pattern?: string[], id: string, multiselect: boolean, label: string, sticky?: boolean, group: number, platform?: appPlatformTypes }
export interface JSONStandardInput {
language: 'Solidity'
settings?: any

@ -1,3 +1,4 @@
import { appPlatformTypes } from '@remix-ui/app'
import { FileType } from '@remix-ui/file-decorators'
import { WorkspaceProps, MenuItems } from '../types'
@ -64,7 +65,7 @@ export const contextMenuActions: MenuItems = [{
multiselect: false,
label: '',
group: 2,
platform: 'browser'
platform: appPlatformTypes.web
}, {
id: 'run',
name: 'Run',
@ -79,7 +80,7 @@ export const contextMenuActions: MenuItems = [{
multiselect: false,
label: '',
group: 4,
platform: 'browser'
platform: appPlatformTypes.web
}, {
id: 'publishFolderToGist',
name: 'Publish folder to gist',
@ -87,7 +88,7 @@ export const contextMenuActions: MenuItems = [{
multiselect: false,
label: '',
group: 4,
platform: 'browser'
platform: appPlatformTypes.web
}, {
id: 'publishFileToGist',
name: 'Publish file to gist',
@ -95,7 +96,7 @@ export const contextMenuActions: MenuItems = [{
multiselect: false,
label: '',
group: 4,
platform: 'browser'
platform: appPlatformTypes.web
}, {
id: 'uploadFile',
name: 'Load a Local File',
@ -103,7 +104,7 @@ export const contextMenuActions: MenuItems = [{
multiselect: false,
label: 'Load a Local File',
group: 4,
platform: 'browser'
platform: appPlatformTypes.web
}, {
id: 'publishToGist',
name: 'Push changes to gist',
@ -111,7 +112,7 @@ export const contextMenuActions: MenuItems = [{
multiselect: false,
label: 'Publish all to Gist',
group: 4,
platform: 'browser'
platform: appPlatformTypes.web
},
{
id: 'publishWorkspace',
@ -120,7 +121,7 @@ export const contextMenuActions: MenuItems = [{
multiselect: false,
label: '',
group: 4,
platform: 'browser'
platform: appPlatformTypes.web
}]
export const fileKeySort = (children: FileType[]): string[] => {

Loading…
Cancel
Save