diff --git a/src/scenes/DocumentScene/DocumentScene.js b/src/scenes/DocumentScene/DocumentScene.js
index 909dc86b3..9406cf9e2 100644
--- a/src/scenes/DocumentScene/DocumentScene.js
+++ b/src/scenes/DocumentScene/DocumentScene.js
@@ -1,7 +1,6 @@
import React from 'react';
import { toJS } from 'mobx';
-import _isEqual from 'lodash/isEqual';
-import { Link } from 'react-router';
+import { Link, browserHistory } from 'react-router';
import { observer } from 'mobx-react';
import store from './DocumentSceneStore';
@@ -52,6 +51,11 @@ class DocumentScene extends React.Component {
}
}
+ onEdit = () => {
+ const url = `/documents/${store.document.id}/edit`;
+ browserHistory.push(url);
+ }
+
onDelete = () => {
if (confirm("Are you sure you want to delete this document?")) {
store.deleteDocument();
@@ -67,14 +71,13 @@ class DocumentScene extends React.Component {
}
handleChange = (tree) => {
- // Only update when tree changes, otherwise link clicks toggle tree handleChanges changes
- if (!_isEqual(toJS(tree), toJS(store.document.atlas.navigationTree))) {
- store.updateNavigationTree(tree);
- }
+ store.updateNavigationTree(tree);
}
render() {
const doc = store.document;
+ const allowDelete = doc && doc.atlas.type === 'atlas' &&
+ doc.id !== doc.atlas.navigationTree.id;
let title;
let titleText;
let actions;
@@ -86,11 +89,9 @@ class DocumentScene extends React.Component {
New document
) : null }
-
- Edit
-
-
+
+ { allowDelete && }
);
diff --git a/src/scenes/DocumentScene/DocumentSceneStore.js b/src/scenes/DocumentScene/DocumentSceneStore.js
index ed4946943..560f8ca70 100644
--- a/src/scenes/DocumentScene/DocumentSceneStore.js
+++ b/src/scenes/DocumentScene/DocumentSceneStore.js
@@ -1,3 +1,4 @@
+import _isEqual from 'lodash/isEqual';
import { observable, action, computed } from 'mobx';
import { client } from 'utils/ApiClient';
import { browserHistory } from 'react-router';
@@ -44,6 +45,11 @@ const store = new class DocumentSceneStore {
}
@action updateNavigationTree = async (tree) => {
+ // Only update when tree changes
+ if (_isEqual(toJS(tree), toJS(this.document.atlas.navigationTree))) {
+ return true;
+ }
+
this.isFetching = true;
try {
@@ -60,4 +66,4 @@ const store = new class DocumentSceneStore {
}
}();
-export default store;
\ No newline at end of file
+export default store;