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