11import PropTypes from 'prop-types' ;
22import React from 'react' ;
3+ import { useSelector , useDispatch , connect } from 'react-redux' ;
34import classNames from 'classnames' ;
45import { Console as ConsoleFeed } from 'console-feed' ;
56import {
@@ -22,7 +23,10 @@ import infoContrastUrl from '../../../images/console-info-contrast.svg?byUrl';
2223import UpArrowIcon from '../../../images/up-arrow.svg' ;
2324import DownArrowIcon from '../../../images/down-arrow.svg' ;
2425
25- class Console extends React . Component {
26+ import * as IDEActions from '../../IDE/actions/ide' ;
27+ import * as ConsoleActions from '../../IDE/actions/console' ;
28+
29+ class ConsoleComponent extends React . Component {
2630 componentDidUpdate ( prevProps ) {
2731 this . consoleMessages . scrollTop = this . consoleMessages . scrollHeight ;
2832 if ( this . props . theme !== prevProps . theme ) {
@@ -132,7 +136,7 @@ class Console extends React.Component {
132136 }
133137}
134138
135- Console . propTypes = {
139+ ConsoleComponent . propTypes = {
136140 consoleEvents : PropTypes . arrayOf ( PropTypes . shape ( {
137141 method : PropTypes . string . isRequired ,
138142 args : PropTypes . arrayOf ( PropTypes . string )
@@ -146,8 +150,45 @@ Console.propTypes = {
146150 fontSize : PropTypes . number . isRequired
147151} ;
148152
149- Console . defaultProps = {
153+ ConsoleComponent . defaultProps = {
150154 consoleEvents : [ ]
151155} ;
152156
157+ // const Console = () => {
158+ // const consoleEvents = useSelector(state => state.console);
159+ // const { consoleIsExpanded } = useSelector(state => state.ide);
160+ // const { theme, fontSize } = useSelector(state => state.preferences);
161+
162+ // const dispatch = useDispatch();
163+
164+ // return (
165+ // <ConsoleComponent
166+ // consoleEvents={consoleEvents}
167+ // isExpanded={consoleIsExpanded}
168+ // theme={theme}
169+ // fontSize={fontSize}
170+ // collapseConsole={() => dispatch({})}
171+ // expandConsole={() => dispatch({})}
172+ // clearConsole={() => dispatch({})}
173+ // dispatchConsoleEvent={() => dispatch({})}
174+ // />
175+ // );
176+ // };
177+
178+
179+ const Console = connect (
180+ state => ( {
181+ consoleEvents : state . console ,
182+ isExpanded : state . ide . consoleIsExpanded ,
183+ theme : state . preferences . theme ,
184+ fontSize : state . preferences . fontSize
185+ } ) ,
186+ dispatch => ( {
187+ collapseConsole : ( ) => dispatch ( IDEActions . collapseConsole ( ) ) ,
188+ expandConsole : ( ) => dispatch ( IDEActions . expandConsole ( ) ) ,
189+ clearConsole : ( ) => dispatch ( ConsoleActions . clearConsole ( ) ) ,
190+ dispatchConsoleEvent : msgs => dispatch ( ConsoleActions . dispatchConsoleEvent ( msgs ) ) ,
191+ } )
192+ ) ( ConsoleComponent ) ;
193+
153194export default Console ;
0 commit comments