+
+ shouldComponentUpdate(nextProps) {
+ if (nextProps.searchResult && Object.keys(nextProps.searchResult).length &&
+ nextProps.searchResult !== this.props.searchResult) {
+ this.setState({loading: false});
+
+ if (nextProps.searchResult.error) {
+ return true;
+ }
+
+ if (nextProps.searchResult.address) {
+ this.props.history.push(`/embark/explorer/accounts/${nextProps.searchResult.address}`);
+ return false;
+ }
+ if (nextProps.searchResult.hasOwnProperty('transactionIndex')) {
+ this.props.history.push(`/embark/explorer/transactions/${nextProps.searchResult.hash}`);
+ return false;
+ }
+ if (nextProps.searchResult.hasOwnProperty('number')) {
+ this.props.history.push(`/embark/explorer/blocks/${nextProps.searchResult.number}`);
+ return false;
+ }
+ // Returned something we didn't know existed
+ }
+ return true;
+ }
+
+ searchTheExplorer(value) {
+ this.props.explorerSearch(value);
+ this.setState({loading: true});
+ }
+
+ render() {
+ const {children, logout, location, toggleTheme, currentTheme, searchResult} = this.props;
+
+ return (
-
+
+
{sidebar &&
-
-
-
-
-
-
-
+
+
+
+
+
+
+
}
@@ -128,8 +173,8 @@ const Layout = ({children, logout, location, toggleTheme, currentTheme}) => {
Github
-
- );
+
);
+ }
}
Layout.propTypes = {
@@ -138,7 +183,20 @@ Layout.propTypes = {
location: PropTypes.object,
logout: PropTypes.func,
toggleTheme: PropTypes.func,
- currentTheme: PropTypes.string
+ currentTheme: PropTypes.string,
+ explorerSearch: PropTypes.func,
+ searchResult: PropTypes.object,
+ history: PropTypes.object
};
-export default Layout;
+
+function mapStateToProps(state) {
+ return {searchResult: searchResult(state)};
+}
+
+export default withRouter(connect(
+ mapStateToProps,
+ {
+ explorerSearch: explorerSearch.request
+ },
+)(Layout));