diff --git a/apps/learneth/src/pages/StepDetail/index.tsx b/apps/learneth/src/pages/StepDetail/index.tsx index 8ce821cf67..f235b885eb 100644 --- a/apps/learneth/src/pages/StepDetail/index.tsx +++ b/apps/learneth/src/pages/StepDetail/index.tsx @@ -1,37 +1,57 @@ -import React, {useEffect} from 'react' -import {useLocation, useNavigate} from 'react-router-dom' +import React, { useEffect } from 'react' +import { useLocation, useNavigate } from 'react-router-dom' import Markdown from 'react-markdown' import rehypeRaw from 'rehype-raw' import BackButton from '../../components/BackButton' -import {useAppSelector, useAppDispatch} from '../../redux/hooks' +import { useAppSelector, useAppDispatch } from '../../redux/hooks' import './index.scss' +import remixClient from '../../remix-client' function StepDetailPage() { const navigate = useNavigate() const location = useLocation() const dispatch = useAppDispatch() + const [clonedStep, setClonedStep] = React.useState(null) + const queryParams = new URLSearchParams(location.search) const id = queryParams.get('id') as string const stepId = Number(queryParams.get('stepId')) const { - workshop: {detail, selectedId}, - remixide: {errorLoadingFile, errors, success}, + workshop: { detail, selectedId }, + remixide: { errorLoadingFile, errors, success }, } = useAppSelector((state: any) => state) const entity = detail[selectedId].entities[id] const steps = entity.steps const step = steps[stepId] - console.log(step) useEffect(() => { - dispatch({ - type: 'remixide/displayFile', - payload: step, - }) - dispatch({ - type: 'remixide/save', - payload: {errors: [], success: false}, + setClonedStep(null) + const clonedStep = JSON.parse(JSON.stringify(step)) + const loadFiles = async () => { + async function loadFile(step, fileType) { + if (step[fileType] && step[fileType].file && !step[fileType].content) { + clonedStep[fileType].content = (await remixClient.call('contentImport', 'resolve', step[fileType].file)).content; + } + } + + const fileTypes = ['markdown', 'solidity', 'test', 'answer', 'js', 'vy']; + for (const fileType of fileTypes) { + await loadFile(step, fileType); + } + } + loadFiles().then(() => { + + setClonedStep(clonedStep) + dispatch({ + type: 'remixide/displayFile', + payload: clonedStep, + }) + dispatch({ + type: 'remixide/save', + payload: { errors: [], success: false }, + }) + window.scrollTo(0, 0) }) - window.scrollTo(0, 0) }, [step]) useEffect(() => { @@ -40,6 +60,18 @@ function StepDetailPage() { } }, [errors, success]) + if (!clonedStep) { + return (
+
+
+ +
+
+ loading... +
+ ) + } + return (
@@ -51,13 +83,13 @@ function StepDetailPage() { {errorLoadingFile ? ( <>
-

{step.name}

+

{clonedStep.name}

- {step.answer?.content && ( + {clonedStep.answer?.content && ( - {step.answer?.content && ( + {clonedStep.answer?.content && ( } { props.tagList &&
diff --git a/libs/remix-ui/grid-view/src/lib/remix-ui-grid-section.tsx b/libs/remix-ui/grid-view/src/lib/remix-ui-grid-section.tsx index ca391c7685..93d98950e2 100644 --- a/libs/remix-ui/grid-view/src/lib/remix-ui-grid-section.tsx +++ b/libs/remix-ui/grid-view/src/lib/remix-ui-grid-section.tsx @@ -1,6 +1,7 @@ import React, {useState, useEffect, useContext, useRef, ReactNode} from 'react' // eslint-disable-line import './remix-ui-grid-section.css' +import FiltersContext from "./filtersContext" declare global { interface Window { @@ -19,7 +20,43 @@ interface RemixUIGridSectionProps { expandedCell?: any } +const hasChildCell = (children: ReactNode): boolean => { + let found = false + + const isElement = (child: ReactNode): child is React.ReactElement => { + return React.isValidElement(child) + } + + const traverse = (child: ReactNode) => { + console.log('found ', children) + + if (found) return + + if (isElement(child)) { + if (child.props.classList === 'EECellStyle') { + found = true + console.log('found ', child.props.className) + return + } + + if (child.props.children) { + React.Children.forEach(child.props.children, traverse) + } + } + } + + React.Children.forEach(children, traverse) + return found +} + export const RemixUIGridSection = (props: RemixUIGridSectionProps) => { + const [children, setChildren] = useState(props.children) + const filterCon = useContext(FiltersContext) + + useEffect(() => { + setChildren(props.children) + }, [props.children]) + return (
{
{ props.title &&
{ props.title }
}
+ { !hasChildCell(children) && No items found } { props.children }
{ props.expandedCell &&
diff --git a/libs/remix-ui/grid-view/src/lib/remix-ui-grid-view.tsx b/libs/remix-ui/grid-view/src/lib/remix-ui-grid-view.tsx index 6c6cc27bbd..b8c8373869 100644 --- a/libs/remix-ui/grid-view/src/lib/remix-ui-grid-view.tsx +++ b/libs/remix-ui/grid-view/src/lib/remix-ui-grid-view.tsx @@ -51,7 +51,6 @@ export const RemixUIGridView = (props: RemixUIGridViewProps) => { searchInputRef.current.value = '' } else { setState((prevState) => { - console.log("update filter", searchInputRef.current.value) return { ...prevState, searchDisable: searchInputRef.current.value === '', @@ -120,7 +119,7 @@ export const RemixUIGridView = (props: RemixUIGridViewProps) => { ref={searchInputRef} type="text" style={{ minWidth: '100px' }} - className="border form-control border-right-0 mr-4" + className="border form-control mr-4" id="GVFilterInput" placeholder={"Filter the list"} data-id="RemixGVFilterInput" diff --git a/libs/remix-ui/run-tab/src/lib/actions/events.ts b/libs/remix-ui/run-tab/src/lib/actions/events.ts index b5b4037eb2..41deac6c6f 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/events.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/events.ts @@ -69,9 +69,9 @@ export const setupEvents = (plugin: RunTab) => { } }) - plugin.blockchain.event.register('addProvider', provider => addExternalProvider(dispatch, provider)) + plugin.on('blockchain', 'shouldAddProvidertoUdapp', (name, provider) => addExternalProvider(dispatch, provider)) - plugin.blockchain.event.register('removeProvider', name => removeExternalProvider(dispatch, name)) + plugin.on('blockchain', 'shouldRemoveProviderFromUdapp', (name, provider) => removeExternalProvider(dispatch, name)) plugin.blockchain.events.on('newProxyDeployment', (address, date, contractName) => addNewProxyDeployment(dispatch, address, date, contractName)) diff --git a/libs/remix-ui/run-tab/src/lib/components/environment.tsx b/libs/remix-ui/run-tab/src/lib/components/environment.tsx index 9f07f26186..17509eaf03 100644 --- a/libs/remix-ui/run-tab/src/lib/components/environment.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/environment.tsx @@ -6,6 +6,11 @@ import { Dropdown } from 'react-bootstrap' import { CustomMenu, CustomToggle, CustomTooltip } from '@remix-ui/helper' export function EnvironmentUI(props: EnvironmentProps) { + + Object.entries(props.providers.providerList.filter((provider) => { return provider.isVM })) + Object.entries(props.providers.providerList.filter((provider) => { return provider.isInjected })) + Object.entries(props.providers.providerList.filter((provider) => { return !(provider.isVM || provider.isInjected) })) + const handleChangeExEnv = (env: string) => { const provider = props.providers.providerList.find((exEnv) => exEnv.name === env) const context = provider.name @@ -23,7 +28,6 @@ export function EnvironmentUI(props: EnvironmentProps) {