Skip to content

Commit 4de0c65

Browse files
authored
Merge pull request #1647 from processing/chore/connect-previewframe
[#1590] Connect PreviewFrame in FullView
2 parents 4da310b + 5b11b87 commit 4de0c65

File tree

2 files changed

+34
-65
lines changed

2 files changed

+34
-65
lines changed

client/modules/IDE/components/PreviewFrame.jsx

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -359,22 +359,38 @@ PreviewFrame.defaultProps = {
359359
cmController: {}
360360
};
361361

362-
const mapStateToProps = state => ({
363-
files: state.files,
364-
htmlFile: getHTMLFile(state.files),
365-
content:
366-
(state.files.find(file => file.isSelectedFile) ||
367-
state.files.find(file => file.name === 'sketch.js') ||
368-
state.files.find(file => file.name !== 'root')).content,
369-
isPlaying: state.ide.isPlaying,
370-
isAccessibleOutputPlaying: state.ide.isAccessibleOutputPlaying,
371-
previewIsRefreshing: state.ide.previewIsRefreshing,
372-
textOutput: state.preferences.textOutput,
373-
gridOutput: state.preferences.gridOutput,
374-
soundOutput: state.preferences.soundOutput,
375-
language: state.preferences.language,
376-
autorefresh: state.preferences.autorefresh,
377-
});
362+
function mapStateToProps(state, ownProps) {
363+
if (ownProps.fullView) {
364+
return {
365+
files: state.files,
366+
htmlFile: getHTMLFile(state.files),
367+
isPlaying: true,
368+
isAccessibleOutputPlaying: false,
369+
textOutput: false,
370+
gridOutput: false,
371+
soundOutput: false,
372+
language: state.preferences.language,
373+
autorefresh: false,
374+
previewIsRefreshing: false
375+
};
376+
}
377+
return {
378+
files: state.files,
379+
htmlFile: getHTMLFile(state.files),
380+
content:
381+
(state.files.find(file => file.isSelectedFile) ||
382+
state.files.find(file => file.name === 'sketch.js') ||
383+
state.files.find(file => file.name !== 'root')).content,
384+
isPlaying: state.ide.isPlaying,
385+
isAccessibleOutputPlaying: state.ide.isAccessibleOutputPlaying,
386+
previewIsRefreshing: state.ide.previewIsRefreshing,
387+
textOutput: state.preferences.textOutput,
388+
gridOutput: state.preferences.gridOutput,
389+
soundOutput: state.preferences.soundOutput,
390+
language: state.preferences.language,
391+
autorefresh: state.preferences.autorefresh
392+
};
393+
}
378394

379395

380396
const mapDispatchToProps = {

client/modules/IDE/pages/FullView.jsx

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ import { bindActionCreators } from 'redux';
55
import { connect } from 'react-redux';
66
import PreviewFrame from '../components/PreviewFrame';
77
import PreviewNav from '../../../components/PreviewNav';
8-
import { getHTMLFile, getJSFiles, getCSSFiles } from '../reducers/files';
98
import * as ProjectActions from '../actions/project';
109

1110
class FullView extends React.Component {
1211
componentDidMount() {
1312
this.props.getProject(this.props.params.project_id, this.props.params.username);
1413
}
1514

16-
ident = () => {}
17-
1815
render() {
1916
return (
2017
<div className="fullscreen-preview">
@@ -27,26 +24,7 @@ class FullView extends React.Component {
2724
/>
2825
<main className="preview-frame-holder">
2926
<PreviewFrame
30-
htmlFile={this.props.htmlFile}
31-
jsFiles={this.props.jsFiles}
32-
cssFiles={this.props.cssFiles}
33-
files={this.props.files}
34-
head={
35-
<link type="text/css" rel="stylesheet" href="/preview-styles.css" />
36-
}
3727
fullView
38-
isPlaying
39-
isAccessibleOutputPlaying={false}
40-
textOutput={false}
41-
gridOutput={false}
42-
soundOutput={false}
43-
dispatchConsoleEvent={this.ident}
44-
endSketchRefresh={this.ident}
45-
previewIsRefreshing={false}
46-
setBlobUrl={this.ident}
47-
stopSketch={this.ident}
48-
expandConsole={this.ident}
49-
clearConsole={this.ident}
5028
/>
5129
</main>
5230
</div>
@@ -65,37 +43,12 @@ FullView.propTypes = {
6543
username: PropTypes.string
6644
})
6745
}).isRequired,
68-
htmlFile: PropTypes.shape({
69-
id: PropTypes.string.isRequired,
70-
content: PropTypes.string.isRequired,
71-
name: PropTypes.string.isRequired
72-
}).isRequired,
73-
jsFiles: PropTypes.arrayOf(PropTypes.shape({
74-
id: PropTypes.string.isRequired,
75-
content: PropTypes.string.isRequired,
76-
name: PropTypes.string.isRequired
77-
})).isRequired,
78-
cssFiles: PropTypes.arrayOf(PropTypes.shape({
79-
id: PropTypes.string.isRequired,
80-
content: PropTypes.string.isRequired,
81-
name: PropTypes.string.isRequired
82-
})).isRequired,
83-
getProject: PropTypes.func.isRequired,
84-
files: PropTypes.arrayOf(PropTypes.shape({
85-
id: PropTypes.string.isRequired,
86-
content: PropTypes.string.isRequired,
87-
name: PropTypes.string.isRequired
88-
})).isRequired,
46+
getProject: PropTypes.func.isRequired
8947
};
9048

9149
function mapStateToProps(state) {
9250
return {
93-
user: state.user,
94-
htmlFile: getHTMLFile(state.files),
95-
jsFiles: getJSFiles(state.files),
96-
cssFiles: getCSSFiles(state.files),
97-
project: state.project,
98-
files: state.files
51+
project: state.project
9952
};
10053
}
10154

0 commit comments

Comments
 (0)