fix context

pull/4360/head
filip mertens 11 months ago
parent 24238f4ee0
commit b038b71c7e
  1. 2
      libs/remix-ui/app/src/index.ts
  2. 6
      libs/remix-ui/app/src/lib/remix-app/context/context.tsx
  3. 13
      libs/remix-ui/app/src/lib/remix-app/remix-app.tsx
  4. 6
      libs/remix-ui/home-tab/src/lib/components/homeTabGetStarted.tsx
  5. 4
      libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx
  6. 24
      libs/remix-ui/panel/src/lib/main/main-panel.tsx
  7. 4
      libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCard.tsx
  8. 6
      libs/remix-ui/search/src/lib/components/Search.tsx
  9. 7
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  10. 7
      libs/remix-ui/solidity-compiler/src/lib/components/compiler-dropdown.tsx
  11. 10
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx
  12. 4
      libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.tsx
  13. 4
      libs/remix-ui/workspace/src/lib/components/electron-menu.tsx
  14. 4
      libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx
  15. 4
      libs/remix-ui/workspace/src/lib/components/workspace-hamburger-item.tsx
  16. 4
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

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

@ -8,9 +8,6 @@ export type appProviderContextType = {
showEnter: boolean, showEnter: boolean,
appManager: any appManager: any
modal: any modal: any
layout: any
platform: appPlatformTypes
online: boolean
} }
export enum appPlatformTypes { export enum appPlatformTypes {
@ -18,8 +15,9 @@ export enum appPlatformTypes {
desktop = 'desktop' desktop = 'desktop'
} }
export const AppContext = React.createContext<appProviderContextType>(null) export const AppContext = React.createContext<appProviderContextType>(null)
export const onLineContext = React.createContext<boolean>(null)
export const platformContext = React.createContext<appPlatformTypes>(null)
export interface dispatchModalInterface { export interface dispatchModalInterface {
modal: (data: AppModal) => void modal: (data: AppModal) => void

@ -8,7 +8,7 @@ import DragBar from './components/dragbar/dragbar'
import {AppProvider} from './context/provider' import {AppProvider} from './context/provider'
import AppDialogs from './components/modals/dialogs' import AppDialogs from './components/modals/dialogs'
import DialogViewPlugin from './components/modals/dialogViewPlugin' import DialogViewPlugin from './components/modals/dialogViewPlugin'
import { AppContext, appProviderContextType } from './context/context' import { appProviderContextType, onLineContext, platformContext } from './context/context'
import { FormattedMessage, IntlProvider } from 'react-intl' import { FormattedMessage, IntlProvider } from 'react-intl'
import {CustomTooltip} from '@remix-ui/helper' import {CustomTooltip} from '@remix-ui/helper'
import {UsageTypes} from './types' import {UsageTypes} from './types'
@ -105,10 +105,7 @@ const RemixApp = (props: IRemixAppUi) => {
showMatamo: props.app.showMatamo, showMatamo: props.app.showMatamo,
appManager: props.app.appManager, appManager: props.app.appManager,
showEnter: props.app.showEnter, showEnter: props.app.showEnter,
modal: props.app.notification, modal: props.app.notification
layout: props.app.layout,
platform: props.app.platform,
online: online
} }
const handleUserChosenType = async (type) => { const handleUserChosenType = async (type) => {
@ -151,6 +148,8 @@ const RemixApp = (props: IRemixAppUi) => {
return ( return (
//@ts-ignore //@ts-ignore
<IntlProvider locale={locale.code} messages={locale.messages}> <IntlProvider locale={locale.code} messages={locale.messages}>
<platformContext.Provider value={props.app.platform}>
<onLineContext.Provider value={online}>
<AppProvider value={value}> <AppProvider value={value}>
<OriginWarning></OriginWarning> <OriginWarning></OriginWarning>
<MatomoDialog hide={!appReady} okFn={() => setShowEnterDialog(true)}></MatomoDialog> <MatomoDialog hide={!appReady} okFn={() => setShowEnterDialog(true)}></MatomoDialog>
@ -176,7 +175,7 @@ const RemixApp = (props: IRemixAppUi) => {
setHideStatus={setHideSidePanel} setHideStatus={setHideSidePanel}
></DragBar> ></DragBar>
<div id="main-panel" data-id="remixIdeMainPanel" className="mainpanel d-flex"> <div id="main-panel" data-id="remixIdeMainPanel" className="mainpanel d-flex">
<RemixUIMainPanel Context={AppContext}></RemixUIMainPanel> <RemixUIMainPanel layout={props.app.layout}></RemixUIMainPanel>
<CustomTooltip placement="bottom" tooltipId="overlay-tooltip-all-tabs" tooltipText={<FormattedMessage id="remixApp.scrollToSeeAllTabs" />}> <CustomTooltip placement="bottom" tooltipId="overlay-tooltip-all-tabs" tooltipText={<FormattedMessage id="remixApp.scrollToSeeAllTabs" />}>
<div className="remix-ui-tabs_end remix-bg-opacity position-absolute position-fixed"></div> <div className="remix-ui-tabs_end remix-bg-opacity position-absolute position-fixed"></div>
</CustomTooltip> </CustomTooltip>
@ -186,6 +185,8 @@ const RemixApp = (props: IRemixAppUi) => {
<AppDialogs></AppDialogs> <AppDialogs></AppDialogs>
<DialogViewPlugin></DialogViewPlugin> <DialogViewPlugin></DialogViewPlugin>
</AppProvider> </AppProvider>
</onLineContext.Provider>
</platformContext.Provider>
</IntlProvider> </IntlProvider>
) )
} }

@ -7,7 +7,9 @@ import Carousel from 'react-multi-carousel'
import WorkspaceTemplate from './workspaceTemplate' import WorkspaceTemplate from './workspaceTemplate'
import 'react-multi-carousel/lib/styles.css' import 'react-multi-carousel/lib/styles.css'
import CustomNavButtons from './customNavButtons' import CustomNavButtons from './customNavButtons'
import { AppContext, appPlatformTypes } from '@remix-ui/app' import { appPlatformTypes, platformContext } from '@remix-ui/app'
declare global { declare global {
interface Window { interface Window {
_paq: any _paq: any
@ -19,7 +21,7 @@ interface HomeTabGetStartedProps {
} }
function HomeTabGetStarted({plugin}: HomeTabGetStartedProps) { function HomeTabGetStarted({plugin}: HomeTabGetStartedProps) {
const {platform} = useContext(AppContext) const platform = useContext(platformContext)
const themeFilter = useContext(ThemeContext) const themeFilter = useContext(ThemeContext)
const carouselRef = useRef<any>({}) const carouselRef = useRef<any>({})
const carouselRefDiv = useRef(null) const carouselRefDiv = useRef(null)

@ -9,7 +9,7 @@ import HomeTabScamAlert from './components/homeTabScamAlert'
import HomeTabGetStarted from './components/homeTabGetStarted' import HomeTabGetStarted from './components/homeTabGetStarted'
import HomeTabFeatured from './components/homeTabFeatured' import HomeTabFeatured from './components/homeTabFeatured'
import HomeTabFeaturedPlugins from './components/homeTabFeaturedPlugins' import HomeTabFeaturedPlugins from './components/homeTabFeaturedPlugins'
import { AppContext, appPlatformTypes } from '@remix-ui/app' import { appPlatformTypes, platformContext } from '@remix-ui/app'
import { HomeTabFileElectron } from './components/homeTabFileElectron' import { HomeTabFileElectron } from './components/homeTabFileElectron'
import { LanguageOptions } from './components/homeTablangOptions' import { LanguageOptions } from './components/homeTablangOptions'
@ -24,7 +24,7 @@ export interface RemixUiHomeTabProps {
} }
export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
const {platform} = useContext(AppContext) const platform = useContext(platformContext)
const {plugin} = props const {plugin} = props
const [state, setState] = useState<{ const [state, setState] = useState<{

@ -3,17 +3,17 @@ import React, {useContext, useEffect, useRef, useState} from 'react' // eslint-d
import DragBar from '../dragbar/dragbar' import DragBar from '../dragbar/dragbar'
import RemixUIPanelPlugin from '../plugins/panel-plugin' import RemixUIPanelPlugin from '../plugins/panel-plugin'
import {PluginRecord} from '../types' import {PluginRecord} from '../types'
import { AppContext, appPlatformTypes } from '@remix-ui/app' import { appPlatformTypes, platformContext } from '@remix-ui/app'
import './main-panel.css' import './main-panel.css'
export type RemixUIMainPanelProps = { export type RemixUIMainPanelProps = {
Context: React.Context<any> layout: any
} }
const RemixUIMainPanel = (props: RemixUIMainPanelProps) => { const RemixUIMainPanel = (props: RemixUIMainPanelProps) => {
const {platform} = useContext(AppContext) const platform = useContext(platformContext)
const appContext = useContext(props.Context) const {layout} = props
const [plugins, setPlugins] = useState<PluginRecord[]>([]) const [plugins, setPlugins] = useState<PluginRecord[]>([])
const editorRef = useRef<HTMLDivElement>(null) const editorRef = useRef<HTMLDivElement>(null)
const mainPanelRef = useRef<HTMLDivElement>(null) const mainPanelRef = useRef<HTMLDivElement>(null)
@ -23,9 +23,9 @@ const RemixUIMainPanel = (props: RemixUIMainPanelProps) => {
const refs = [tabsRef, editorRef, mainPanelRef, terminalRef] const refs = [tabsRef, editorRef, mainPanelRef, terminalRef]
const renderPanels = () => { const renderPanels = () => {
if (appContext) { if (layout.panels) {
const pluginPanels: PluginRecord[] = [] const pluginPanels: PluginRecord[] = []
Object.values(appContext.layout.panels).map((panel: any) => { Object.values(layout.panels).map((panel: any) => {
pluginPanels.push({ pluginPanels.push({
profile: panel.plugin.profile, profile: panel.plugin.profile,
active: panel.active, active: panel.active,
@ -40,23 +40,23 @@ const RemixUIMainPanel = (props: RemixUIMainPanelProps) => {
useEffect(() => { useEffect(() => {
renderPanels() renderPanels()
appContext.layout.event.on('change', () => { layout.event.on('change', () => {
renderPanels() renderPanels()
}) })
return () => { return () => {
appContext.layout.event.off('change') layout.event.off('change')
} }
}, []) }, [])
const showTerminal = (hide: boolean) => { const showTerminal = (hide: boolean) => {
appContext.layout.panels.terminal.minimized = hide layout.panels.terminal.minimized = hide
appContext.layout.event.emit('change', appContext.layout.panels) layout.event.emit('change', layout.panels)
appContext.layout.emit('change', appContext.layout.panels) layout.emit('change', layout.panels)
} }
const resize = (height: number) => { const resize = (height: number) => {
appContext.layout.emit('resize', height) layout.emit('resize', height)
} }
return ( return (

@ -4,7 +4,7 @@ import React, { useContext, useEffect, useState } from 'react'
import {FormattedMessage, useIntl} from 'react-intl' import {FormattedMessage, useIntl} from 'react-intl'
import '../remix-ui-plugin-manager.css' import '../remix-ui-plugin-manager.css'
import {CustomTooltip} from '@remix-ui/helper' import {CustomTooltip} from '@remix-ui/helper'
import { AppContext } from '@remix-ui/app' import { onLineContext } from '@remix-ui/app'
interface PluginCardProps { interface PluginCardProps {
profile: any profile: any
buttonText: string buttonText: string
@ -12,7 +12,7 @@ interface PluginCardProps {
} }
function InactivePluginCard({profile, buttonText, activatePlugin}: PluginCardProps) { function InactivePluginCard({profile, buttonText, activatePlugin}: PluginCardProps) {
const {online} = useContext(AppContext) const online = useContext(onLineContext)
const [canBeActivated, setCanBeActivated] = useState(false) const [canBeActivated, setCanBeActivated] = useState(false)
const intl = useIntl() const intl = useIntl()
useEffect(() => { useEffect(() => {

@ -6,11 +6,13 @@ import {Include} from './Include'
import {Exclude} from './Exclude' import {Exclude} from './Exclude'
import {FindContainer} from './FindContainer' import {FindContainer} from './FindContainer'
import {Undo} from './Undo' import {Undo} from './Undo'
import { AppContext } from '@remix-ui/app' import { platformContext } from '@remix-ui/app'
export const SearchTab = (props) => { export const SearchTab = (props) => {
const plugin = props.plugin const plugin = props.plugin
const {platform} = useContext(AppContext) const platform = useContext(platformContext)
return ( return (
<> <>

@ -10,11 +10,13 @@ import {listenToEvents} from './actions/compiler'
import {getValidLanguage} from '@remix-project/remix-solidity' import {getValidLanguage} from '@remix-project/remix-solidity'
import {CopyToClipboard} from '@remix-ui/clipboard' import {CopyToClipboard} from '@remix-ui/clipboard'
import {configFileContent} from './compilerConfiguration' import {configFileContent} from './compilerConfiguration'
import { AppContext, appPlatformTypes } from '@remix-ui/app' import { appPlatformTypes, platformContext, onLineContext } from '@remix-ui/app'
import './css/style.css' import './css/style.css'
import { CompilerDropdown } from './components/compiler-dropdown' import { CompilerDropdown } from './components/compiler-dropdown'
const defaultPath = 'compiler_config.json' const defaultPath = 'compiler_config.json'
declare global { declare global {
@ -26,7 +28,8 @@ declare global {
const _paq = (window._paq = window._paq || []) //eslint-disable-line const _paq = (window._paq = window._paq || []) //eslint-disable-line
export const CompilerContainer = (props: CompilerContainerProps) => { export const CompilerContainer = (props: CompilerContainerProps) => {
const {platform, online} = useContext(AppContext) const online = useContext(onLineContext)
const platform = useContext(platformContext)
const { const {
api, api,
compileTabLogic, compileTabLogic,

@ -1,4 +1,6 @@
import { AppContext, appPlatformTypes } from '@remix-ui/app'; import { appPlatformTypes, platformContext, onLineContext } from '@remix-ui/app';
;
import React, { useEffect, useState, useRef, useReducer, useContext } from 'react' // eslint-disable-line import React, { useEffect, useState, useRef, useReducer, useContext } from 'react' // eslint-disable-line
import { Dropdown } from 'react-bootstrap'; import { Dropdown } from 'react-bootstrap';
import { CompilerMenu, CompilerMenuToggle } from './compiler-menu'; import { CompilerMenu, CompilerMenuToggle } from './compiler-menu';
@ -20,7 +22,8 @@ interface compilerDropdownProps {
} }
export const CompilerDropdown = (props: compilerDropdownProps) => { export const CompilerDropdown = (props: compilerDropdownProps) => {
const {platform, online} = useContext(AppContext) const online = useContext(onLineContext)
const platform = useContext(platformContext)
const { customVersions, selectedVersion, defaultVersion, allversions, handleLoadVersion, _shouldBeAdded, onlyDownloaded } = props const { customVersions, selectedVersion, defaultVersion, allversions, handleLoadVersion, _shouldBeAdded, onlyDownloaded } = props
return ( return (
<Dropdown id="versionSelector" data-id="versionSelector"> <Dropdown id="versionSelector" data-id="versionSelector">

@ -9,7 +9,9 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
import { format } from 'util' import { format } from 'util'
import './css/style.css' import './css/style.css'
import { CustomTooltip } from '@remix-ui/helper' import { CustomTooltip } from '@remix-ui/helper'
import { AppContext, appPlatformTypes } from '@remix-ui/app' import { appPlatformTypes, platformContext } from '@remix-ui/app'
const _paq = ((window as any)._paq = (window as any)._paq || []) // eslint-disable-line @typescript-eslint/no-explicit-any const _paq = ((window as any)._paq = (window as any)._paq || []) // eslint-disable-line @typescript-eslint/no-explicit-any
@ -44,7 +46,7 @@ interface FinalResult {
export const SolidityUnitTesting = (props: Record<string, any>) => { export const SolidityUnitTesting = (props: Record<string, any>) => {
// eslint-disable-line @typescript-eslint/no-explicit-any // eslint-disable-line @typescript-eslint/no-explicit-any
const {platform} = useContext(AppContext) const platform = useContext(platformContext)
const { helper, testTab, initialPath } = props const { helper, testTab, initialPath } = props
const { testTabLogic } = testTab const { testTabLogic } = testTab
@ -164,10 +166,6 @@ export const SolidityUnitTesting = (props: Record<string, any>) => {
} }
}) })
testTab.on('filePanel', 'workspaceCreated', async () => {
setTimeout(async () => await setCurrentPath(defaultPath), 100)
})
testTab.on('filePanel', 'setWorkspace', async () => { testTab.on('filePanel', 'setWorkspace', async () => {
await setCurrentPath(defaultPath) await setCurrentPath(defaultPath)
}) })

@ -6,7 +6,7 @@ import Home from './components/Home'
import { verticalScrollReducer } from './reducers/verticalScrollReducer' import { verticalScrollReducer } from './reducers/verticalScrollReducer'
import { Chevron } from './components/Chevron' import { Chevron } from './components/Chevron'
import { IconRecord } from './types' import { IconRecord } from './types'
import { AppContext } from '@remix-ui/app' import { onLineContext } from '@remix-ui/app'
import { CustomTooltip } from '@remix-ui/helper' import { CustomTooltip } from '@remix-ui/helper'
export interface RemixUiVerticalIconsPanelProps { export interface RemixUiVerticalIconsPanelProps {
verticalIconsPlugin: Plugin verticalIconsPlugin: Plugin
@ -24,7 +24,7 @@ const RemixUiVerticalIconsPanel = ({ verticalIconsPlugin, icons }: RemixUiVertic
const iconPanelRef = useRef<any>() const iconPanelRef = useRef<any>()
const [activateScroll, dispatchScrollAction] = useReducer(verticalScrollReducer, initialState) const [activateScroll, dispatchScrollAction] = useReducer(verticalScrollReducer, initialState)
const [theme, setTheme] = useState<string>('dark') const [theme, setTheme] = useState<string>('dark')
const { online } = useContext(AppContext) const online = useContext(onLineContext)
const evaluateScrollability = () => { const evaluateScrollability = () => {
dispatchScrollAction({ dispatchScrollAction({

@ -1,12 +1,12 @@
import React, { MouseEventHandler, useContext, useEffect, useState } from "react" import React, { MouseEventHandler, useContext, useEffect, useState } from "react"
import { FileSystemContext } from "../contexts" import { FileSystemContext } from "../contexts"
import { AppContext, appPlatformTypes } from '@remix-ui/app' import { appPlatformTypes, platformContext } from '@remix-ui/app'
import { FormattedMessage } from "react-intl" import { FormattedMessage } from "react-intl"
import '../css/electron-menu.css' import '../css/electron-menu.css'
import { CustomTooltip } from '@remix-ui/helper' import { CustomTooltip } from '@remix-ui/helper'
export const ElectronMenu = () => { export const ElectronMenu = () => {
const {platform} = useContext(AppContext) const platform = useContext(platformContext)
const global = useContext(FileSystemContext) const global = useContext(FileSystemContext)
useEffect(() => { useEffect(() => {

@ -5,7 +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 { AppContext, appPlatformTypes } from '@remix-ui/app' import { appPlatformTypes, platformContext } from '@remix-ui/app'
declare global { declare global {
interface Window { interface Window {
@ -15,7 +15,7 @@ declare global {
const _paq = (window._paq = window._paq || []) //eslint-disable-line const _paq = (window._paq = window._paq || []) //eslint-disable-line
export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) => { export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) => {
const {platform} = useContext(AppContext) const platform = useContext(platformContext)
const { const {
actions, actions,
createNewFile, createNewFile,

@ -2,7 +2,7 @@ import React, { useContext } from 'react'
import {CustomTooltip, CustomMenu, CustomIconsToggle} from '@remix-ui/helper' import {CustomTooltip, CustomMenu, CustomIconsToggle} from '@remix-ui/helper'
import {Dropdown, NavDropdown} from 'react-bootstrap' import {Dropdown, NavDropdown} from 'react-bootstrap'
import {FormattedMessage} from 'react-intl' import {FormattedMessage} from 'react-intl'
import { AppContext, appPlatformTypes } from '@remix-ui/app' import { appPlatformTypes, platformContext } from '@remix-ui/app'
const _paq = (window._paq = window._paq || []) const _paq = (window._paq = window._paq || [])
export interface HamburgerMenuItemProps { export interface HamburgerMenuItemProps {
@ -15,7 +15,7 @@ export interface HamburgerMenuItemProps {
export function HamburgerMenuItem(props: HamburgerMenuItemProps) { export function HamburgerMenuItem(props: HamburgerMenuItemProps) {
const {hideOption} = props const {hideOption} = props
const {platform} = useContext(AppContext) const platform = useContext(platformContext)
const uid = 'workspace' + props.kind const uid = 'workspace' + props.kind
return ( return (
<> <>

@ -12,7 +12,7 @@ import {MenuItems, WorkSpaceState} from './types'
import {contextMenuActions} from './utils' import {contextMenuActions} from './utils'
import FileExplorerContextMenu from './components/file-explorer-context-menu' import FileExplorerContextMenu from './components/file-explorer-context-menu'
import { customAction } from '@remixproject/plugin-api' import { customAction } from '@remixproject/plugin-api'
import { AppContext, appPlatformTypes } from '@remix-ui/app' import { appPlatformTypes, platformContext } from '@remix-ui/app'
import { ElectronMenu } from './components/electron-menu' import { ElectronMenu } from './components/electron-menu'
const _paq = (window._paq = window._paq || []) const _paq = (window._paq = window._paq || [])
@ -20,7 +20,7 @@ const _paq = (window._paq = window._paq || [])
const canUpload = window.File || window.FileReader || window.FileList || window.Blob const canUpload = window.File || window.FileReader || window.FileList || window.Blob
export function Workspace() { export function Workspace() {
const {platform} = useContext(AppContext) const platform = useContext(platformContext)
const LOCALHOST = ' - connect to localhost - ' const LOCALHOST = ' - connect to localhost - '
const NO_WORKSPACE = ' - none - ' const NO_WORKSPACE = ' - none - '
const ELECTRON = 'electron' const ELECTRON = 'electron'

Loading…
Cancel
Save