forked from ethereum/remix-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b625db3
commit c9dd9fb
Showing
26 changed files
with
546 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ViewPlugin } from '@remixproject/engine-web' | ||
import * as packageJson from '../../../../../package.json' | ||
import React from 'react' // eslint-disable-line | ||
import { PluginViewWrapper } from '@remix-ui/helper' | ||
import { SearchTab } from '@remix-ui/search' | ||
const profile = { | ||
name: 'search', | ||
displayName: 'Search', | ||
methods: [''], | ||
events: [], | ||
icon: 'assets/img/Search_Icon.svg', | ||
description: '', | ||
kind: '', | ||
location: 'sidePanel', | ||
documentation: '', | ||
version: packageJson.version | ||
} | ||
|
||
export class SearchPlugin extends ViewPlugin { | ||
dispatch: React.Dispatch<any> = () => {} | ||
constructor () { | ||
super(profile) | ||
} | ||
|
||
|
||
render() { | ||
return ( | ||
<div id='searchTab'> | ||
<SearchTab plugin={this}></SearchTab> | ||
</div> | ||
); | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"presets": ["@nrwl/react/babel"], | ||
"plugins": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true | ||
}, | ||
"ignorePatterns": ["!**/*"], | ||
"extends": "../../../.eslintrc.json", | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly" | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 11, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"standard/no-callback-literal": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"semi": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# remix-ui-vertical-icons-panel | ||
|
||
React library for RemixIde vertical icons Panel | ||
|
||
## Running unit tests | ||
|
||
Run `nx test remix-ui-vertical-icons-panel` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { SearchTab } from './lib/components/Search'; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, { useContext, useReducer } from "react" | ||
import { SearchContext } from "../context/context" | ||
import { SearchingInitialState, SearchReducer } from "../reducers/Reducer" | ||
|
||
|
||
|
||
export const Find = props => { | ||
|
||
const { setFind } = useContext(SearchContext) | ||
const change = (e) => { | ||
setFind(e.target.value) | ||
} | ||
|
||
return(<> | ||
<input placeholder="Search" className="form-control" onChange={change}></input> | ||
</>) | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React, { useContext, useEffect } from 'react' | ||
import { SearchContext } from '../context/context' | ||
|
||
export const Replace = props => { | ||
const { state, setReplace } = useContext(SearchContext) | ||
|
||
const change = e => { | ||
setReplace(e.target.value) | ||
} | ||
|
||
return ( | ||
<> | ||
<input placeholder='Replace' className="form-control" onChange={change}></input> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { useContext, useEffect, useReducer } from 'react' | ||
import { SearchContext, SearchProvider } from '../context/context' | ||
import { SearchingInitialState, SearchReducer } from '../reducers/Reducer' | ||
import { Find } from './Find' | ||
import { Replace } from './Replace' | ||
import { Results } from './results/Results' | ||
|
||
export const SearchTab = props => { | ||
|
||
const plugin = props.plugin | ||
|
||
useEffect(() => { | ||
console.log (plugin) | ||
},[]) | ||
|
||
return ( | ||
<> | ||
<SearchProvider> | ||
<Find></Find> | ||
<Replace></Replace> | ||
<Results plugin={plugin}></Results> | ||
</SearchProvider> | ||
</> | ||
) | ||
} |
Empty file.
Empty file.
Empty file.
81 changes: 81 additions & 0 deletions
81
libs/remix-ui/search/src/lib/components/results/Results.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { ViewPlugin } from "@remixproject/engine-web" | ||
import React, { useContext, useEffect } from "react" | ||
import { SearchContext } from "../../context/context" | ||
import { SearchResult } from "../../reducers/Reducer" | ||
|
||
interface ResultsProps { | ||
plugin: ViewPlugin | ||
} | ||
|
||
export const Results = (props: ResultsProps) => { | ||
|
||
const { state, setSearchResults } = useContext(SearchContext) | ||
|
||
const { plugin } = props | ||
|
||
const getDirectory = async (dir) => { | ||
let result = [] | ||
const files = await plugin.call('fileManager', 'readdir', dir) | ||
const fileArray = normalize(files) | ||
for (const fi of fileArray) { | ||
if (fi) { | ||
const type = fi.data.isDirectory | ||
if (type === true) { | ||
result = [ | ||
...result, | ||
...(await getDirectory( | ||
`${fi.filename}` | ||
)) | ||
] | ||
} else { | ||
result = [...result, fi.filename] | ||
} | ||
} | ||
} | ||
return result | ||
} | ||
|
||
const normalize = (filesList) => { | ||
const folders = [] | ||
const files = [] | ||
Object.keys(filesList || {}).forEach(key => { | ||
if (filesList[key].isDirectory) { | ||
folders.push({ | ||
filename: key, | ||
data: filesList[key] | ||
}) | ||
} else { | ||
files.push({ | ||
filename: key, | ||
data: filesList[key] | ||
}) | ||
} | ||
}) | ||
return [...folders, ...files] | ||
} | ||
|
||
useEffect(() => { | ||
if (state.find) { | ||
getDirectory('/').then(res => { | ||
const ob = res.map(file => { | ||
const r:SearchResult = { | ||
filename: file, | ||
lines: [], | ||
path: file, | ||
searchComplete: false | ||
} | ||
return r | ||
}) | ||
console.log(ob) | ||
setSearchResults(ob) | ||
}) | ||
} | ||
},[state.find]) | ||
|
||
|
||
useEffect(() => { | ||
console.log(state.searchResults) | ||
},[state.searchResults]) | ||
|
||
return(<></>) | ||
} |
Oops, something went wrong.