Skip to content

Commit dd1141b

Browse files
committed
🚧 connect <Console />
1 parent 8e137d0 commit dd1141b

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

client/modules/IDE/components/Console.jsx

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3+
import { useSelector, useDispatch, connect } from 'react-redux';
34
import classNames from 'classnames';
45
import { Console as ConsoleFeed } from 'console-feed';
56
import {
@@ -22,7 +23,10 @@ import infoContrastUrl from '../../../images/console-info-contrast.svg?byUrl';
2223
import UpArrowIcon from '../../../images/up-arrow.svg';
2324
import 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+
153194
export default Console;

client/modules/IDE/pages/MobileIDEView.jsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,7 @@ const MobileIDEView = (props) => {
102102
provideController={setTmController}
103103
/>
104104
</IDEWrapper>
105-
<Footer before={<Console
106-
fontSize={preferences.fontSize}
107-
consoleEvents={console}
108-
isExpanded={ide.consoleIsExpanded}
109-
clearConsole={clearConsole}
110-
theme={preferences.theme}
111-
dispatchConsoleEvent={dispatchConsoleEvent}
112-
expandConsole={expandConsole}
113-
collapseConsole={collapseConsole}
114-
/>}
115-
>
105+
<Footer before={<Console />} >
116106
<h2>Bottom Bar</h2>
117107
</Footer>
118108
</Screen>

client/modules/Mobile/MobileSketchView.jsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,7 @@ const MobileSketchView = (props) => {
8787
clearConsole={clearConsole}
8888
/>
8989
</Content>
90-
<Footer before={<Console
91-
fontSize={preferences.fontSize}
92-
consoleEvents={console}
93-
isExpanded={ide.consoleIsExpanded}
94-
clearConsole={clearConsole}
95-
theme={preferences.theme}
96-
dispatchConsoleEvent={dispatchConsoleEvent}
97-
expandConsole={expandConsole}
98-
collapseConsole={collapseConsole}
99-
/>}
100-
/>
90+
<Footer before={<Console />} />
10191
</Screen>);
10292
};
10393

0 commit comments

Comments
 (0)