1
1
import PropTypes from 'prop-types' ;
2
2
import React from 'react' ;
3
+ import { useSelector , useDispatch , connect } from 'react-redux' ;
3
4
import classNames from 'classnames' ;
4
5
import { Console as ConsoleFeed } from 'console-feed' ;
5
6
import {
@@ -22,7 +23,10 @@ import infoContrastUrl from '../../../images/console-info-contrast.svg?byUrl';
22
23
import UpArrowIcon from '../../../images/up-arrow.svg' ;
23
24
import DownArrowIcon from '../../../images/down-arrow.svg' ;
24
25
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 {
26
30
componentDidUpdate ( prevProps ) {
27
31
this . consoleMessages . scrollTop = this . consoleMessages . scrollHeight ;
28
32
if ( this . props . theme !== prevProps . theme ) {
@@ -132,7 +136,7 @@ class Console extends React.Component {
132
136
}
133
137
}
134
138
135
- Console . propTypes = {
139
+ ConsoleComponent . propTypes = {
136
140
consoleEvents : PropTypes . arrayOf ( PropTypes . shape ( {
137
141
method : PropTypes . string . isRequired ,
138
142
args : PropTypes . arrayOf ( PropTypes . string )
@@ -146,8 +150,45 @@ Console.propTypes = {
146
150
fontSize : PropTypes . number . isRequired
147
151
} ;
148
152
149
- Console . defaultProps = {
153
+ ConsoleComponent . defaultProps = {
150
154
consoleEvents : [ ]
151
155
} ;
152
156
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
+
153
194
export default Console ;
0 commit comments