Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion components/SubgraphEditor/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useRef } from 'react'
import { ViewPort, Top, Fill, Bottom, BottomResizable, Right } from 'react-spaces'
import { ViewPort, Top, Fill, Bottom, BottomResizable, Right, RightResizable } from 'react-spaces'
import { useRouter } from 'next/router'
import styled from 'styled-components'
import CodeEditor from 'components/CodeEditor'
Expand All @@ -19,6 +19,7 @@ import ImageLibrary from './ImageLibrary/ImageLibrary'
import { useEditorState } from 'hooks/editor-state'
import { WalletButton, Header, HeaderRight } from 'components/layouts'
import { useGeneratedFiles } from 'hooks/useGeneratedFiles'
import SubgraphTester from './SubgraphTester'

const CloseButton = styled.button`
background: none;
Expand Down Expand Up @@ -97,6 +98,7 @@ const Editor: React.FC = () => {
const plausible = usePlausible()
const [subgraphId, setSubgraphId] = useEditorState<string | null>('subgraph-file')
const [tab, setTab] = useState(SCHEMA_FILE_NAME)
const [showTest, setShowTest] = useState(false)

const { saveSchema, saveMapping, subgraph } = useLocalSubgraph(subgraphId)

Expand Down Expand Up @@ -181,6 +183,7 @@ const Editor: React.FC = () => {
/>
</Fill>
<Right size={100}>
<button disabled={showTest} onClick={() => setShowTest(true)}>Test</button>
<EditorControls editorRef={editorRef} />
</Right>
</TabContainer>
Expand Down Expand Up @@ -214,6 +217,12 @@ const Editor: React.FC = () => {
)}
</Fill>

{subgraph && showTest && (
<RightResizable size={300}>
<SubgraphTester subgraph={subgraph} />
</RightResizable>
)}

{bottomView !== BottomView.NONE && (
<BottomResizable size={160} minimumSize={60} maximumSize={300}>
<Top size={42}>
Expand Down
105 changes: 0 additions & 105 deletions components/SubgraphEditor/SubAdapterPreview.tsx

This file was deleted.

92 changes: 0 additions & 92 deletions components/SubgraphEditor/SubAdapterTest.tsx

This file was deleted.

46 changes: 46 additions & 0 deletions components/SubgraphEditor/SubgraphTester.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react'
import styled from 'styled-components'
import { SubgraphData } from 'hooks/local-subgraphs'
import { useSubgraphRunner } from 'hooks/useSubgraphRunner'

const Container = styled.div``

const Header = styled.div`
border-top: solid 1px #4a4a4d;
border-bottom: solid 1px #4a4a4d;
padding: 16px;
background: #2f2f2f;
margin: 0 -16px;
cursor: pointer;
font-size: 14px;
display: flex;
align-items: center;

&:hover {
background: #262626;
}
`

const Body = styled.div`
padding: var(--spaces-4) var(--spaces-2);
`

interface SubgraphTesterProps {
subgraph: SubgraphData
}

const SubgraphTester: React.FC<SubgraphTesterProps> = ({ subgraph }) => {
const { compile } = useSubgraphRunner(subgraph)

return (
<Container>
<Header>Test</Header>

<Body>
<button onClick={compile}>Compile</button>
</Body>
</Container>
)
}

export default SubgraphTester
Loading