Merge branch 'master' into jori/document-404

This commit is contained in:
Jori Lallo
2017-09-11 01:31:29 -04:00
committed by GitHub
51 changed files with 401 additions and 492 deletions

View File

@@ -5,7 +5,7 @@ import styled from 'styled-components';
import { observer, inject } from 'mobx-react';
import { withRouter, Prompt } from 'react-router';
import Flex from 'components/Flex';
import { layout } from 'styles/constants';
import { color, layout } from 'styles/constants';
import Document from 'models/Document';
import UiStore from 'stores/UiStore';
@@ -15,7 +15,6 @@ import SaveAction from './components/SaveAction';
import LoadingPlaceholder from 'components/LoadingPlaceholder';
import Editor from 'components/Editor';
import DropToImport from 'components/DropToImport';
import { HeaderAction } from 'components/Layout';
import LoadingIndicator from 'components/LoadingIndicator';
import Collaborators from 'components/Collaborators';
import CenteredContent from 'components/CenteredContent';
@@ -110,6 +109,11 @@ type Props = {
this.props.history.push(url);
};
onClickNew = () => {
if (!this.document) return;
this.props.history.push(`${this.document.collection.url}/new`);
};
onSave = async (redirect: boolean = false) => {
if (this.document && !this.document.allowSave) return;
let document = this.document;
@@ -230,13 +234,22 @@ type Props = {
}
isNew={!!isNew}
/>
: <a onClick={this.onClickEdit}>Edit</a>}
: <a onClick={this.onClickEdit}>
Edit
</a>}
</HeaderAction>
<HeaderAction>
{isEditing
? <a onClick={this.onCancel}>Cancel</a>
: <Menu document={document} />}
</HeaderAction>
{!isEditing && <Separator />}
<HeaderAction>
{!isEditing &&
<a onClick={this.onClickNew}>
New
</a>}
</HeaderAction>
{isEditing &&
<HeaderAction>
<a onClick={this.onCancel}>Cancel</a>
</HeaderAction>}
{!isEditing && <Menu document={document} />}
</Flex>
</Meta>
</Flex>
@@ -246,6 +259,32 @@ type Props = {
}
}
const Separator = styled.div`
margin-left: 12px;
width: 1px;
height: 20px;
background: ${color.slateLight};
`;
const HeaderAction = styled(Flex)`
justify-content: center;
align-items: center;
min-height: 43px;
color: ${color.text};
padding: 0 0 0 14px;
a,
svg {
color: ${color.text};
opacity: .8;
transition: opacity 100ms ease-in-out;
&:hover {
opacity: 1;
}
}
`;
const DropHere = styled(Flex)`
pointer-events: none;
position: fixed;