2020-08-05 20:08:23 +02:00
|
|
|
import React, { useEffect } from 'react';
|
2020-06-09 21:51:57 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2020-06-15 22:46:56 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { withRouter } from 'react-router';
|
|
|
|
import { useState } from 'react';
|
2020-07-15 22:24:12 +02:00
|
|
|
import styled from 'styled-components';
|
2020-06-12 21:09:30 +02:00
|
|
|
|
2020-06-15 22:46:56 +02:00
|
|
|
// Imports to be Refactored
|
|
|
|
import { bindActionCreators } from 'redux';
|
2020-07-24 21:30:14 +02:00
|
|
|
|
2020-06-15 22:46:56 +02:00
|
|
|
import * as IDEActions from '../actions/ide';
|
|
|
|
import * as ProjectActions from '../actions/project';
|
2020-08-13 21:32:50 +02:00
|
|
|
import * as ConsoleActions from '../actions/console';
|
2020-08-13 23:29:39 +02:00
|
|
|
import * as PreferencesActions from '../actions/preferences';
|
2020-08-24 15:03:56 +02:00
|
|
|
import * as EditorAccessibilityActions from '../actions/editorAccessibility';
|
2020-06-15 22:46:56 +02:00
|
|
|
|
|
|
|
// Local Imports
|
|
|
|
import Editor from '../components/Editor';
|
2020-08-17 20:45:55 +02:00
|
|
|
|
|
|
|
import { PlayIcon, MoreIcon, FolderIcon, PreferencesIcon, TerminalIcon, SaveIcon } from '../../../common/icons';
|
2020-08-12 15:55:54 +02:00
|
|
|
import UnsavedChangesDotIcon from '../../../images/unsaved-changes-dot.svg';
|
2020-06-15 22:46:56 +02:00
|
|
|
|
2020-06-16 22:38:43 +02:00
|
|
|
import IconButton from '../../../components/mobile/IconButton';
|
|
|
|
import Header from '../../../components/mobile/Header';
|
|
|
|
import Screen from '../../../components/mobile/MobileScreen';
|
|
|
|
import Footer from '../../../components/mobile/Footer';
|
2020-06-18 21:01:13 +02:00
|
|
|
import IDEWrapper from '../../../components/mobile/IDEWrapper';
|
2020-08-07 19:09:17 +02:00
|
|
|
import MobileExplorer from '../../../components/mobile/Explorer';
|
2020-07-15 22:24:12 +02:00
|
|
|
import Console from '../components/Console';
|
|
|
|
import { remSize } from '../../../theme';
|
2020-08-07 20:03:18 +02:00
|
|
|
|
2020-07-21 17:14:58 +02:00
|
|
|
import ActionStrip from '../../../components/mobile/ActionStrip';
|
2020-07-30 19:30:45 +02:00
|
|
|
import useAsModal from '../../../components/useAsModal';
|
2020-07-29 21:01:40 +02:00
|
|
|
import Dropdown from '../../../components/Dropdown';
|
2020-06-16 22:23:49 +02:00
|
|
|
|
2020-08-17 20:21:37 +02:00
|
|
|
|
2020-08-13 23:29:39 +02:00
|
|
|
import { useEffectWithComparison, useEventListener } from '../../../utils/custom-hooks';
|
|
|
|
|
|
|
|
import * as device from '../../../utils/device';
|
2020-07-21 17:14:58 +02:00
|
|
|
|
2020-08-12 15:56:46 +02:00
|
|
|
const withChangeDot = (title, unsavedChanges = false) => (
|
2020-08-12 15:55:54 +02:00
|
|
|
<span>
|
|
|
|
{title}
|
|
|
|
<span className="editor__unsaved-changes">
|
|
|
|
{unsavedChanges &&
|
|
|
|
<UnsavedChangesDotIcon role="img" aria-label="Sketch has unsaved changes" focusable="false" />}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
);
|
2020-08-17 20:45:55 +02:00
|
|
|
const getRootFile = files => files && files.filter(file => file.name === 'root')[0];
|
|
|
|
const getRootFileID = files => (root => root && root.id)(getRootFile(files));
|
2020-08-12 15:55:54 +02:00
|
|
|
|
2020-07-21 17:14:58 +02:00
|
|
|
const Expander = styled.div`
|
|
|
|
height: ${props => (props.expanded ? remSize(160) : remSize(27))};
|
2020-07-20 23:51:42 +02:00
|
|
|
`;
|
|
|
|
|
2020-07-29 23:09:22 +02:00
|
|
|
const NavItem = styled.li`
|
|
|
|
position: relative;
|
|
|
|
`;
|
|
|
|
|
2020-08-20 21:27:40 +02:00
|
|
|
const getNavOptions = (username = undefined, logoutUser = () => {}, toggleForceDesktop = () => {}) =>
|
2020-08-05 20:08:23 +02:00
|
|
|
(username
|
|
|
|
? [
|
2020-08-19 23:20:47 +02:00
|
|
|
{ icon: PreferencesIcon, title: 'Preferences', href: '/preferences', },
|
|
|
|
{ icon: PreferencesIcon, title: 'My Stuff', href: `/${username}/sketches` },
|
|
|
|
{ icon: PreferencesIcon, title: 'Examples', href: '/p5/sketches' },
|
2020-08-20 20:59:05 +02:00
|
|
|
{ icon: PreferencesIcon, title: 'Original Editor', action: toggleForceDesktop, },
|
2020-08-12 15:19:06 +02:00
|
|
|
{ icon: PreferencesIcon, title: 'Logout', action: logoutUser, },
|
2020-08-05 20:08:23 +02:00
|
|
|
]
|
|
|
|
: [
|
2020-08-19 23:20:47 +02:00
|
|
|
{ icon: PreferencesIcon, title: 'Preferences', href: '/preferences', },
|
|
|
|
{ icon: PreferencesIcon, title: 'Examples', href: '/p5/sketches' },
|
2020-08-20 21:27:40 +02:00
|
|
|
{ icon: PreferencesIcon, title: 'Original Editor', action: toggleForceDesktop, },
|
2020-08-12 15:19:06 +02:00
|
|
|
{ icon: PreferencesIcon, title: 'Login', href: '/login', },
|
2020-08-05 20:08:23 +02:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2020-08-13 22:02:39 +02:00
|
|
|
|
2020-08-13 22:22:03 +02:00
|
|
|
const isUserOwner = ({ project, user }) =>
|
|
|
|
project && project.owner && project.owner.id === user.id;
|
|
|
|
|
2020-08-13 23:57:42 +02:00
|
|
|
const canSaveProject = (project, user) =>
|
|
|
|
isUserOwner({ project, user }) || (user.authenticated && !project.owner);
|
|
|
|
|
2020-08-13 23:29:39 +02:00
|
|
|
// TODO: This could go into <Editor />
|
|
|
|
const handleGlobalKeydown = (props, cmController) => (e) => {
|
|
|
|
const {
|
|
|
|
user, project, ide,
|
|
|
|
setAllAccessibleOutput,
|
|
|
|
saveProject, cloneProject, showErrorModal, startSketch, stopSketch,
|
|
|
|
expandSidebar, collapseSidebar, expandConsole, collapseConsole,
|
|
|
|
closeNewFolderModal, closeUploadFileModal, closeNewFileModal
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
|
|
const isMac = device.isMac();
|
|
|
|
|
|
|
|
// const ctrlDown = (e.metaKey && this.isMac) || (e.ctrlKey && !this.isMac);
|
|
|
|
const ctrlDown = (isMac ? e.metaKey : e.ctrlKey);
|
|
|
|
|
|
|
|
if (ctrlDown) {
|
|
|
|
if (e.shiftKey) {
|
|
|
|
if (e.keyCode === 13) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
stopSketch();
|
|
|
|
} else if (e.keyCode === 13) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
startSketch();
|
|
|
|
// 50 === 2
|
|
|
|
} else if (e.keyCode === 50
|
|
|
|
) {
|
|
|
|
e.preventDefault();
|
|
|
|
setAllAccessibleOutput(false);
|
|
|
|
// 49 === 1
|
|
|
|
} else if (e.keyCode === 49) {
|
|
|
|
e.preventDefault();
|
|
|
|
setAllAccessibleOutput(true);
|
|
|
|
}
|
|
|
|
} else if (e.keyCode === 83) {
|
|
|
|
// 83 === s
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2020-08-17 19:53:22 +02:00
|
|
|
if (canSaveProject(project, user)) saveProject(cmController.getContent(), false, true);
|
2020-08-13 23:29:39 +02:00
|
|
|
else if (user.authenticated) cloneProject();
|
|
|
|
else showErrorModal('forceAuthentication');
|
|
|
|
|
|
|
|
// 13 === enter
|
|
|
|
} else if (e.keyCode === 66) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (!ide.sidebarIsExpanded) expandSidebar();
|
|
|
|
else collapseSidebar();
|
|
|
|
}
|
|
|
|
} else if (e.keyCode === 192 && e.ctrlKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (ide.consoleIsExpanded) collapseConsole();
|
|
|
|
else expandConsole();
|
|
|
|
} else if (e.keyCode === 27) {
|
|
|
|
if (ide.newFolderModalVisible) closeNewFolderModal();
|
|
|
|
else if (ide.uploadFileModalVisible) closeUploadFileModal();
|
|
|
|
else if (ide.modalIsVisible) closeNewFileModal();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-13 22:22:03 +02:00
|
|
|
const autosave = (autosaveInterval, setAutosaveInterval) => (props, prevProps) => {
|
|
|
|
const {
|
2020-08-24 15:03:56 +02:00
|
|
|
autosaveProject, preferences, ide, selectedFile: file, project
|
2020-08-13 22:22:03 +02:00
|
|
|
} = props;
|
|
|
|
|
|
|
|
const { selectedFile: oldFile } = prevProps;
|
|
|
|
|
2020-08-17 19:53:22 +02:00
|
|
|
const doAutosave = () => autosaveProject(true);
|
|
|
|
|
2020-08-13 22:22:03 +02:00
|
|
|
if (isUserOwner(props) && project.id) {
|
|
|
|
if (preferences.autosave && ide.unsavedChanges && !ide.justOpenedProject) {
|
|
|
|
if (file.name === oldFile.name && file.content !== oldFile.content) {
|
|
|
|
if (autosaveInterval) {
|
|
|
|
clearTimeout(autosaveInterval);
|
2020-08-13 22:02:39 +02:00
|
|
|
}
|
|
|
|
console.log('will save project in 20 seconds');
|
2020-08-17 19:53:22 +02:00
|
|
|
setAutosaveInterval(setTimeout(doAutosave, 20000));
|
2020-08-13 22:02:39 +02:00
|
|
|
}
|
2020-08-13 22:22:03 +02:00
|
|
|
} else if (autosaveInterval && !preferences.autosave) {
|
|
|
|
clearTimeout(autosaveInterval);
|
|
|
|
setAutosaveInterval(null);
|
2020-08-13 22:02:39 +02:00
|
|
|
}
|
2020-08-13 22:22:03 +02:00
|
|
|
} else if (autosaveInterval) {
|
|
|
|
clearTimeout(autosaveInterval);
|
|
|
|
setAutosaveInterval(null);
|
2020-08-13 22:02:39 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-24 15:03:56 +02:00
|
|
|
// ide, preferences, project, selectedFile, user, params, unsavedChanges, expandConsole, collapseConsole,
|
|
|
|
// stopSketch, startSketch, getProject, clearPersistedState, autosaveProject, saveProject, files
|
|
|
|
|
2020-06-22 20:10:20 +02:00
|
|
|
const MobileIDEView = (props) => {
|
2020-08-24 15:03:56 +02:00
|
|
|
// const {
|
|
|
|
// preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage,
|
|
|
|
// selectedFile, updateFileContent, files, user, params,
|
|
|
|
// closeEditorOptions, showEditorOptions, logoutUser,
|
|
|
|
// startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console,
|
|
|
|
// showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch, getProject, clearPersistedState, setUnsavedChanges,
|
|
|
|
// toggleForceDesktop
|
|
|
|
// } = props;
|
|
|
|
|
2020-06-15 22:59:11 +02:00
|
|
|
const {
|
2020-08-17 20:21:37 +02:00
|
|
|
ide, preferences, project, selectedFile, user, params, unsavedChanges, expandConsole, collapseConsole,
|
2020-08-24 15:03:56 +02:00
|
|
|
stopSketch, startSketch, getProject, clearPersistedState, autosaveProject, saveProject, files,
|
|
|
|
toggleForceDesktop, logoutUser
|
2020-06-15 22:59:11 +02:00
|
|
|
} = props;
|
2020-06-12 21:09:30 +02:00
|
|
|
|
2020-08-13 23:29:39 +02:00
|
|
|
|
|
|
|
const [cmController, setCmController] = useState(null); // eslint-disable-line
|
2020-06-16 21:25:40 +02:00
|
|
|
|
2020-07-30 21:13:00 +02:00
|
|
|
const { username } = user;
|
2020-08-12 16:27:22 +02:00
|
|
|
const { consoleIsExpanded } = ide;
|
|
|
|
const { name: filename } = selectedFile;
|
2020-07-22 00:03:22 +02:00
|
|
|
|
2020-08-05 20:27:22 +02:00
|
|
|
// Force state reset
|
|
|
|
useEffect(clearPersistedState, []);
|
2020-08-13 21:32:50 +02:00
|
|
|
useEffect(() => {
|
|
|
|
stopSketch();
|
|
|
|
collapseConsole();
|
|
|
|
}, []);
|
2020-08-05 20:27:22 +02:00
|
|
|
|
2020-08-05 20:08:23 +02:00
|
|
|
// Load Project
|
2020-08-05 20:27:22 +02:00
|
|
|
const [currentProjectID, setCurrentProjectID] = useState(null);
|
2020-08-05 20:08:23 +02:00
|
|
|
useEffect(() => {
|
2020-08-06 15:08:41 +02:00
|
|
|
if (!username) return;
|
2020-08-05 20:27:22 +02:00
|
|
|
if (params.project_id && !currentProjectID) {
|
|
|
|
if (params.project_id !== project.id) {
|
2020-08-06 15:08:41 +02:00
|
|
|
getProject(params.project_id, params.username);
|
2020-08-05 20:27:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
setCurrentProjectID(params.project_id);
|
2020-08-06 15:08:41 +02:00
|
|
|
}, [params, project, username]);
|
2020-08-05 20:08:23 +02:00
|
|
|
|
2020-08-07 19:09:17 +02:00
|
|
|
// Screen Modals
|
2020-08-06 20:59:22 +02:00
|
|
|
const [toggleNavDropdown, NavDropDown] = useAsModal(<Dropdown
|
2020-08-20 21:27:40 +02:00
|
|
|
items={getNavOptions(username, logoutUser, toggleForceDesktop)}
|
2020-08-06 20:59:22 +02:00
|
|
|
align="right"
|
|
|
|
/>);
|
|
|
|
|
2020-08-07 23:32:50 +02:00
|
|
|
const [toggleExplorer, Explorer] = useAsModal(toggle =>
|
|
|
|
(<MobileExplorer
|
|
|
|
id={getRootFileID(files)}
|
|
|
|
canEdit={false}
|
|
|
|
onPressClose={toggle}
|
|
|
|
/>), true);
|
2020-08-05 20:08:23 +02:00
|
|
|
|
2020-08-13 22:22:03 +02:00
|
|
|
// TODO: This behavior could move to <Editor />
|
|
|
|
const [autosaveInterval, setAutosaveInterval] = useState(null);
|
|
|
|
useEffectWithComparison(autosave(autosaveInterval, setAutosaveInterval), {
|
2020-08-17 19:57:48 +02:00
|
|
|
autosaveProject, preferences, ide, selectedFile, project, user
|
2020-08-13 22:22:03 +02:00
|
|
|
});
|
2020-08-13 22:02:39 +02:00
|
|
|
|
2020-08-13 23:57:42 +02:00
|
|
|
useEventListener('keydown', handleGlobalKeydown(props, cmController), false, [props]);
|
2020-08-13 23:29:39 +02:00
|
|
|
|
2020-08-17 20:21:37 +02:00
|
|
|
const projectActions =
|
2020-08-17 20:45:55 +02:00
|
|
|
[{
|
|
|
|
icon: TerminalIcon, aria: 'Toggle console open/closed', action: consoleIsExpanded ? collapseConsole : expandConsole, inverted: true
|
|
|
|
},
|
|
|
|
{ icon: SaveIcon, aria: 'Save project', action: () => saveProject(cmController.getContent(), false, true) },
|
|
|
|
{ icon: FolderIcon, aria: 'Open files explorer', action: toggleExplorer }
|
2020-08-17 20:21:37 +02:00
|
|
|
];
|
2020-08-13 23:29:39 +02:00
|
|
|
|
2020-06-15 22:46:56 +02:00
|
|
|
return (
|
2020-06-23 20:54:09 +02:00
|
|
|
<Screen fullscreen>
|
2020-08-06 20:59:22 +02:00
|
|
|
<Explorer />
|
2020-07-01 00:11:48 +02:00
|
|
|
<Header
|
2020-08-12 15:56:46 +02:00
|
|
|
title={withChangeDot(project.name, unsavedChanges)}
|
2020-08-12 16:27:22 +02:00
|
|
|
subtitle={filename}
|
2020-07-01 00:11:48 +02:00
|
|
|
>
|
2020-07-29 23:09:22 +02:00
|
|
|
<NavItem>
|
2020-08-21 23:01:01 +02:00
|
|
|
|
2020-07-29 22:52:57 +02:00
|
|
|
<IconButton
|
2020-08-06 20:59:22 +02:00
|
|
|
onClick={toggleNavDropdown}
|
2020-07-29 22:52:57 +02:00
|
|
|
icon={MoreIcon}
|
|
|
|
aria-label="Options"
|
|
|
|
/>
|
|
|
|
<NavDropDown />
|
2020-07-29 23:09:22 +02:00
|
|
|
</NavItem>
|
2020-07-29 22:52:57 +02:00
|
|
|
<li>
|
2020-08-19 23:20:47 +02:00
|
|
|
<IconButton to="/preview" onClick={() => { startSketch(); }} icon={PlayIcon} aria-label="Run sketch" />
|
2020-07-29 22:52:57 +02:00
|
|
|
</li>
|
2020-06-15 22:59:11 +02:00
|
|
|
</Header>
|
2020-06-12 21:09:30 +02:00
|
|
|
|
2020-06-18 21:01:13 +02:00
|
|
|
<IDEWrapper>
|
2020-08-13 23:29:39 +02:00
|
|
|
<Editor provideController={setCmController} />
|
2020-06-18 21:01:13 +02:00
|
|
|
</IDEWrapper>
|
2020-07-22 20:37:44 +02:00
|
|
|
|
2020-07-20 23:51:42 +02:00
|
|
|
<Footer>
|
2020-08-12 16:27:22 +02:00
|
|
|
{consoleIsExpanded && (
|
2020-07-24 23:11:10 +02:00
|
|
|
<Expander expanded>
|
|
|
|
<Console />
|
|
|
|
</Expander>
|
|
|
|
)}
|
2020-08-17 20:21:37 +02:00
|
|
|
<ActionStrip actions={projectActions} />
|
2020-07-15 22:24:12 +02:00
|
|
|
</Footer>
|
2020-06-15 22:46:56 +02:00
|
|
|
</Screen>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-08-13 23:29:39 +02:00
|
|
|
const handleGlobalKeydownProps = {
|
|
|
|
expandConsole: PropTypes.func.isRequired,
|
|
|
|
collapseConsole: PropTypes.func.isRequired,
|
|
|
|
expandSidebar: PropTypes.func.isRequired,
|
|
|
|
collapseSidebar: PropTypes.func.isRequired,
|
|
|
|
|
|
|
|
setAllAccessibleOutput: PropTypes.func.isRequired,
|
|
|
|
saveProject: PropTypes.func.isRequired,
|
|
|
|
cloneProject: PropTypes.func.isRequired,
|
|
|
|
showErrorModal: PropTypes.func.isRequired,
|
|
|
|
|
|
|
|
closeNewFolderModal: PropTypes.func.isRequired,
|
|
|
|
closeUploadFileModal: PropTypes.func.isRequired,
|
|
|
|
closeNewFileModal: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
2020-06-22 20:10:20 +02:00
|
|
|
MobileIDEView.propTypes = {
|
2020-06-15 22:46:56 +02:00
|
|
|
ide: PropTypes.shape({
|
|
|
|
consoleIsExpanded: PropTypes.bool.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
|
2020-08-13 22:22:03 +02:00
|
|
|
preferences: PropTypes.shape({
|
|
|
|
}).isRequired,
|
|
|
|
|
2020-06-15 22:46:56 +02:00
|
|
|
project: PropTypes.shape({
|
|
|
|
id: PropTypes.string,
|
|
|
|
name: PropTypes.string.isRequired,
|
|
|
|
owner: PropTypes.shape({
|
|
|
|
username: PropTypes.string,
|
2020-07-24 23:11:10 +02:00
|
|
|
id: PropTypes.string,
|
2020-06-15 22:46:56 +02:00
|
|
|
}),
|
|
|
|
}).isRequired,
|
|
|
|
|
|
|
|
|
|
|
|
selectedFile: PropTypes.shape({
|
|
|
|
id: PropTypes.string.isRequired,
|
|
|
|
content: PropTypes.string.isRequired,
|
2020-07-24 23:11:10 +02:00
|
|
|
name: PropTypes.string.isRequired,
|
2020-06-15 22:46:56 +02:00
|
|
|
}).isRequired,
|
|
|
|
|
|
|
|
files: PropTypes.arrayOf(PropTypes.shape({
|
|
|
|
id: PropTypes.string.isRequired,
|
|
|
|
name: PropTypes.string.isRequired,
|
2020-07-24 23:11:10 +02:00
|
|
|
content: PropTypes.string.isRequired,
|
2020-06-15 22:46:56 +02:00
|
|
|
})).isRequired,
|
|
|
|
|
2020-08-20 20:59:05 +02:00
|
|
|
toggleForceDesktop: PropTypes.func.isRequired,
|
2020-06-15 22:46:56 +02:00
|
|
|
|
2020-06-15 23:59:21 +02:00
|
|
|
user: PropTypes.shape({
|
|
|
|
authenticated: PropTypes.bool.isRequired,
|
|
|
|
id: PropTypes.string,
|
2020-07-24 23:11:10 +02:00
|
|
|
username: PropTypes.string,
|
2020-06-15 23:59:21 +02:00
|
|
|
}).isRequired,
|
2020-08-05 20:27:22 +02:00
|
|
|
|
2020-08-12 15:19:06 +02:00
|
|
|
logoutUser: PropTypes.func.isRequired,
|
|
|
|
|
2020-08-05 20:27:22 +02:00
|
|
|
getProject: PropTypes.func.isRequired,
|
|
|
|
clearPersistedState: PropTypes.func.isRequired,
|
2020-08-06 15:08:41 +02:00
|
|
|
params: PropTypes.shape({
|
|
|
|
project_id: PropTypes.string,
|
|
|
|
username: PropTypes.string
|
|
|
|
}).isRequired,
|
2020-08-12 16:27:22 +02:00
|
|
|
|
|
|
|
startSketch: PropTypes.func.isRequired,
|
2020-08-24 15:03:56 +02:00
|
|
|
|
|
|
|
unsavedChanges: PropTypes.bool.isRequired,
|
2020-08-13 22:22:03 +02:00
|
|
|
autosaveProject: PropTypes.func.isRequired,
|
2020-08-13 23:29:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
...handleGlobalKeydownProps
|
2020-06-15 22:46:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
2020-07-24 23:11:10 +02:00
|
|
|
selectedFile:
|
|
|
|
state.files.find(file => file.isSelectedFile) ||
|
2020-06-15 22:46:56 +02:00
|
|
|
state.files.find(file => file.name === 'sketch.js') ||
|
|
|
|
state.files.find(file => file.name !== 'root'),
|
|
|
|
ide: state.ide,
|
2020-08-18 22:24:20 +02:00
|
|
|
files: state.files,
|
2020-08-12 16:27:22 +02:00
|
|
|
unsavedChanges: state.ide.unsavedChanges,
|
2020-06-15 22:46:56 +02:00
|
|
|
preferences: state.preferences,
|
|
|
|
user: state.user,
|
|
|
|
project: state.project,
|
|
|
|
toast: state.toast,
|
2020-07-24 23:11:10 +02:00
|
|
|
console: state.console,
|
2020-06-15 22:46:56 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-08-12 16:31:37 +02:00
|
|
|
const mapDispatchToProps = dispatch => bindActionCreators({
|
|
|
|
...ProjectActions,
|
2020-08-13 21:32:50 +02:00
|
|
|
...IDEActions,
|
2020-08-13 23:29:39 +02:00
|
|
|
...ConsoleActions,
|
2020-08-24 15:03:56 +02:00
|
|
|
...PreferencesActions,
|
|
|
|
...EditorAccessibilityActions
|
2020-08-12 16:31:37 +02:00
|
|
|
}, dispatch);
|
2020-06-15 22:46:56 +02:00
|
|
|
|
2020-06-22 20:10:20 +02:00
|
|
|
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(MobileIDEView));
|