added and integrated redux search action creator
parent
292df97183
commit
ffb209edb6
|
|
@ -1,6 +1,6 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as ReactDOM from 'react-dom';
|
import * as ReactDOM from 'react-dom';
|
||||||
import { App } from './App';
|
import App from './App';
|
||||||
|
|
||||||
it('renders without crashing', () => {
|
it('renders without crashing', () => {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
|
|
|
||||||
52
src/App.tsx
52
src/App.tsx
|
|
@ -1,25 +1,47 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Provider } from 'react-redux';
|
import { bindActionCreators } from 'redux';
|
||||||
|
import { Provider, connect } from 'react-redux';
|
||||||
import { LexEditor } from './LexComponents';
|
import { LexEditor } from './LexComponents';
|
||||||
import { Header, Icon, Segment } from 'semantic-ui-react';
|
import * as actionCreators from './actions/actionCreators';
|
||||||
import { walleStore } from './WallEStore';
|
import { walleStore } from './WallEStore';
|
||||||
|
import { Header, Icon, Segment } from 'semantic-ui-react';
|
||||||
|
|
||||||
export class App extends React.Component<{}, null> {
|
function mapStateToProps(state: any) {
|
||||||
|
return {
|
||||||
|
lexicon: state.lexicon
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapDispachToProps(dispatch: any) {
|
||||||
|
return bindActionCreators<any>(actionCreators, dispatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Main extends React.Component<any, any> {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Provider store={walleStore}>
|
<div>
|
||||||
<div>
|
<Segment inverted={true} size="tiny" attached={true}>
|
||||||
<Segment inverted={true} size="tiny" attached={true}>
|
<Header inverted={true} color="teal" size="mini">
|
||||||
<Header inverted={true} color="teal" size="mini">
|
<Icon name="edit" size="small" />
|
||||||
<Icon name="edit" size="small" />
|
<Header.Content>
|
||||||
<Header.Content>
|
Freespeech Lexicon Editor
|
||||||
Freespeech Lexicon Editor
|
|
||||||
</Header.Content>
|
</Header.Content>
|
||||||
</Header>
|
</Header>
|
||||||
</Segment>
|
</Segment>
|
||||||
<LexEditor fileName="/new_es.xml" />
|
<LexEditor {...this.props} fileName="/new_es.xml" />
|
||||||
</div>
|
</div>
|
||||||
</Provider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ReduxMain = connect(mapStateToProps, mapDispachToProps)(Main);
|
||||||
|
|
||||||
|
const App = (props: any) => {
|
||||||
|
return (
|
||||||
|
<Provider store={walleStore}>
|
||||||
|
<ReduxMain />
|
||||||
|
</Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default App;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ const { Flex } = require('reflexbox');
|
||||||
interface LexEditorProps {
|
interface LexEditorProps {
|
||||||
fileName: RequestInfo;
|
fileName: RequestInfo;
|
||||||
}
|
}
|
||||||
// const imageRoot = 'https://s3-us-west-2.amazonaws.com/aac-buddy/static/img/png/';
|
|
||||||
|
|
||||||
// container component
|
// container component
|
||||||
export class LexEditor extends React.Component<any, any> {
|
export class LexEditor extends React.Component<any, any> {
|
||||||
|
|
@ -78,7 +77,7 @@ export class LexEditor extends React.Component<any, any> {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<LexSearch
|
<LexSearch
|
||||||
{...{ fieldMetaMap: this.fieldMetaMap }}
|
{...{fieldMetaMap: this.fieldMetaMap}}
|
||||||
handleOnSearch={(e: any) => this.handleOnSearch(e)}
|
handleOnSearch={(e: any) => this.handleOnSearch(e)}
|
||||||
/>
|
/>
|
||||||
<LexMatches
|
<LexMatches
|
||||||
|
|
@ -99,6 +98,7 @@ export class LexEditor extends React.Component<any, any> {
|
||||||
.filter((q: any) => _.get<any>(q, searchLens, '') === searchText)
|
.filter((q: any) => _.get<any>(q, searchLens, '') === searchText)
|
||||||
.take(10)
|
.take(10)
|
||||||
.value();
|
.value();
|
||||||
|
this.props.search(searchText);
|
||||||
this.setState({ ...this.state, matchedEntries, searchText, searchLens });
|
this.setState({ ...this.state, matchedEntries, searchText, searchLens });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
export function search(searchKey: any) {
|
||||||
|
return {
|
||||||
|
type: 'ACTION_SEARCH_TEXT',
|
||||||
|
searchKey
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as ReactDOM from 'react-dom';
|
import * as ReactDOM from 'react-dom';
|
||||||
import { App } from './App';
|
import App from './App';
|
||||||
import registerServiceWorker from './registerServiceWorker';
|
import registerServiceWorker from './registerServiceWorker';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(<App />, document.getElementById('root') as HTMLElement);
|
||||||
<App />,
|
|
||||||
document.getElementById('root') as HTMLElement
|
|
||||||
);
|
|
||||||
registerServiceWorker();
|
registerServiceWorker();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
from flask import Flask,send_from_directory
|
from flask import Flask,send_from_directory
|
||||||
app = Flask(__name__,static_url_path='',static_folder='build')
|
app = Flask(__name__,static_url_path='',static_folder='build')
|
||||||
import os
|
|
||||||
|
|
||||||
@app.route('/static/<path:path>')
|
|
||||||
def send_js(path):
|
|
||||||
return send_from_directory('build/static', path)
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def hello_world():
|
def walle_index():
|
||||||
return app.send_static_file('index.html')
|
return app.send_static_file('index.html')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/test')
|
||||||
|
def walle_test():
|
||||||
|
return "test"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue