Merge pull request #254 from jorilallo/jori/document-edit-view

Don't count a view when entering editing
This commit is contained in:
Jori Lallo
2017-09-17 13:05:47 -07:00
committed by GitHub

View File

@@ -105,7 +105,7 @@ type Props = {
this.props.ui.setActiveDocument(document);
// Cache data if user enters edit mode and cancels
this.editCache = document.text;
document.view();
if (!this.isEditing) document.view();
// Update url to match the current one
this.props.history.replace(
@@ -118,6 +118,12 @@ type Props = {
}
};
get isEditing() {
return (
this.props.match.path === matchDocumentEdit || this.props.newDocument
);
}
get document() {
if (this.newDocument) return this.newDocument;
return this.props.documents.getByUrl(
@@ -201,7 +207,6 @@ type Props = {
render() {
const isNew = this.props.newDocument;
const isMoving = this.props.match.path === matchDocumentMove;
const isEditing = this.props.match.path === matchDocumentEdit || isNew;
const isFetching = !this.document;
const titleText = get(this.document, 'title', '');
const document = this.document;
@@ -232,7 +237,7 @@ type Props = {
onDragEnter={this.onStartDragging}
onDragLeave={this.onStopDragging}
onDrop={this.onStopDragging}
disabled={isEditing}
disabled={this.isEditing}
>
<Flex justify="center" auto>
<Prompt
@@ -248,15 +253,19 @@ type Props = {
onChange={this.onChange}
onSave={this.onSave}
onCancel={this.onCancel}
readOnly={!isEditing}
readOnly={!this.isEditing}
/>
<Meta align="center" justify="flex-end" readOnly={!isEditing}>
<Meta
align="center"
justify="flex-end"
readOnly={!this.isEditing}
>
<Flex align="center">
{!isNew &&
!isEditing &&
!this.isEditing &&
<Collaborators document={document} />}
<HeaderAction>
{isEditing
{this.isEditing
? <SaveAction
isSaving={this.isSaving}
onClick={this.onSave.bind(this, true)}
@@ -270,16 +279,17 @@ type Props = {
Edit
</a>}
</HeaderAction>
{isEditing &&
{this.isEditing &&
<HeaderAction>
<a onClick={this.onCancel}>Cancel</a>
</HeaderAction>}
{!this.isEditing &&
<HeaderAction>
<DocumentMenu document={document} />
</HeaderAction>}
{!this.isEditing && <Separator />}
<HeaderAction>
<DocumentMenu document={document} />
</HeaderAction>
{!isEditing && <Separator />}
<HeaderAction>
{!isEditing &&
{!this.isEditing &&
<a onClick={this.onClickNew}>
New
</a>}