✨ add files tab
This commit is contained in:
parent
d1b4d8d4e3
commit
dfedc81f66
3 changed files with 54 additions and 11 deletions
22
client/components/mobile/Explorer.jsx
Normal file
22
client/components/mobile/Explorer.jsx
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import Sidebar from './Sidebar';
|
||||||
|
import ConnectedFileNode from '../../modules/IDE/components/FileNode';
|
||||||
|
|
||||||
|
|
||||||
|
const Explorer = ({ id, canEdit }) => (
|
||||||
|
<Sidebar title="Files">
|
||||||
|
<ConnectedFileNode id={id} canEdit={canEdit} />
|
||||||
|
</Sidebar>
|
||||||
|
);
|
||||||
|
|
||||||
|
Explorer.propTypes = {
|
||||||
|
id: PropTypes.number.isRequired,
|
||||||
|
canEdit: PropTypes.bool
|
||||||
|
};
|
||||||
|
Explorer.defaultProps = {
|
||||||
|
canEdit: false
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Explorer;
|
|
@ -2,10 +2,10 @@ import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { remSize, prop, common } from '../theme';
|
import { remSize, prop, common } from '../../theme';
|
||||||
import Header from './mobile/Header';
|
import Header from './Header';
|
||||||
import IconButton from './mobile/IconButton';
|
import IconButton from './IconButton';
|
||||||
import { ExitIcon } from '../common/icons';
|
import { ExitIcon } from '../../common/icons';
|
||||||
|
|
||||||
|
|
||||||
const SidebarWrapper = styled.div`
|
const SidebarWrapper = styled.div`
|
||||||
|
@ -20,23 +20,26 @@ const SidebarWrapper = styled.div`
|
||||||
box-shadow: 0 6px 6px 0 rgba(0,0,0,0.10);
|
box-shadow: 0 6px 6px 0 rgba(0,0,0,0.10);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Sidebar = ({ title, onPressClose }) => (
|
const Sidebar = ({ title, onPressClose, children }) => (
|
||||||
<SidebarWrapper>
|
<SidebarWrapper>
|
||||||
{title &&
|
{title &&
|
||||||
<Header slim title={title} fixed={false}>
|
<Header slim title={title} fixed={false}>
|
||||||
<IconButton onPress={onPressClose} icon={ExitIcon} aria-label="Return to ide view" />
|
<IconButton onPress={onPressClose} icon={ExitIcon} aria-label="Return to ide view" />
|
||||||
</Header>}
|
</Header>}
|
||||||
|
{children}
|
||||||
</SidebarWrapper>
|
</SidebarWrapper>
|
||||||
);
|
);
|
||||||
|
|
||||||
Sidebar.propTypes = {
|
Sidebar.propTypes = {
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
onPressClose: PropTypes.func.isRequired,
|
onPressClose: PropTypes.func,
|
||||||
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]),
|
||||||
};
|
};
|
||||||
|
|
||||||
Sidebar.defaultProps = {
|
Sidebar.defaultProps = {
|
||||||
title: null,
|
title: null,
|
||||||
// onPressClose: PropTypes.func.isRequired,
|
children: [],
|
||||||
|
onPressClose: () => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import Header from '../../../components/mobile/Header';
|
||||||
import Screen from '../../../components/mobile/MobileScreen';
|
import Screen from '../../../components/mobile/MobileScreen';
|
||||||
import Footer from '../../../components/mobile/Footer';
|
import Footer from '../../../components/mobile/Footer';
|
||||||
import IDEWrapper from '../../../components/mobile/IDEWrapper';
|
import IDEWrapper from '../../../components/mobile/IDEWrapper';
|
||||||
|
import MobileExplorer from '../../../components/mobile/Explorer';
|
||||||
import Console from '../components/Console';
|
import Console from '../components/Console';
|
||||||
import { remSize } from '../../../theme';
|
import { remSize } from '../../../theme';
|
||||||
// import OverlayManager from '../../../components/OverlayManager';
|
// import OverlayManager from '../../../components/OverlayManager';
|
||||||
|
@ -34,11 +35,28 @@ import ActionStrip from '../../../components/mobile/ActionStrip';
|
||||||
import useAsModal from '../../../components/useAsModal';
|
import useAsModal from '../../../components/useAsModal';
|
||||||
import { PreferencesIcon } from '../../../common/icons';
|
import { PreferencesIcon } from '../../../common/icons';
|
||||||
import Dropdown from '../../../components/Dropdown';
|
import Dropdown from '../../../components/Dropdown';
|
||||||
import Sidebar from '../../../components/Sidebar';
|
import Sidebar from '../../../components/mobile/Sidebar';
|
||||||
|
|
||||||
|
|
||||||
|
const getRootFile = files => files && files.filter(file => file.name === 'root')[0];
|
||||||
|
const getRootFileID = files => (root => root && root.id)(getRootFile(files));
|
||||||
|
|
||||||
const isUserOwner = ({ project, user }) =>
|
const isUserOwner = ({ project, user }) =>
|
||||||
project.owner && project.owner.id === user.id;
|
project.owner && project.owner.id === user.id;
|
||||||
|
|
||||||
|
|
||||||
|
// const userCanEditProject = (props) => {
|
||||||
|
// let canEdit;
|
||||||
|
// if (!props.owner) {
|
||||||
|
// canEdit = true;
|
||||||
|
// } else if (props.user.authenticated && props.owner.id === props.user.id) {
|
||||||
|
// canEdit = true;
|
||||||
|
// } else {
|
||||||
|
// canEdit = false;
|
||||||
|
// }
|
||||||
|
// return canEdit;
|
||||||
|
// };
|
||||||
|
|
||||||
const Expander = styled.div`
|
const Expander = styled.div`
|
||||||
height: ${props => (props.expanded ? remSize(160) : remSize(27))};
|
height: ${props => (props.expanded ? remSize(160) : remSize(27))};
|
||||||
`;
|
`;
|
||||||
|
@ -75,6 +93,7 @@ const MobileIDEView = (props) => {
|
||||||
|
|
||||||
const { username } = user;
|
const { username } = user;
|
||||||
|
|
||||||
|
|
||||||
// Force state reset
|
// Force state reset
|
||||||
useEffect(clearPersistedState, []);
|
useEffect(clearPersistedState, []);
|
||||||
useEffect(stopSketch, []);
|
useEffect(stopSketch, []);
|
||||||
|
@ -91,14 +110,13 @@ const MobileIDEView = (props) => {
|
||||||
setCurrentProjectID(params.project_id);
|
setCurrentProjectID(params.project_id);
|
||||||
}, [params, project, username]);
|
}, [params, project, username]);
|
||||||
|
|
||||||
|
// Screen Modals
|
||||||
const [toggleNavDropdown, NavDropDown] = useAsModal(<Dropdown
|
const [toggleNavDropdown, NavDropDown] = useAsModal(<Dropdown
|
||||||
items={getNatOptions(username)}
|
items={getNatOptions(username)}
|
||||||
align="right"
|
align="right"
|
||||||
/>);
|
/>);
|
||||||
|
|
||||||
const [toggleExplorer, Explorer] = useAsModal(<Sidebar
|
const [toggleExplorer, Explorer] = useAsModal(<MobileExplorer id={getRootFileID(files)} canEdit={false} />, true);
|
||||||
title="Files"
|
|
||||||
/>, true);
|
|
||||||
|
|
||||||
// toggle sidebar starting opened
|
// toggle sidebar starting opened
|
||||||
useEffect(toggleExplorer, []);
|
useEffect(toggleExplorer, []);
|
||||||
|
|
Loading…
Reference in a new issue