From 9f8e7be755b254bdd33505275b7ac988013b2f56 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 21 Apr 2020 21:43:01 -0700 Subject: [PATCH] fix: Restore ability to disable embeds on a document (#1238) closes #1237 --- app/menus/DocumentMenu.js | 14 ++++++++++++++ app/models/Document.js | 16 ++++++++++++++-- app/scenes/Document/components/Document.js | 3 ++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/menus/DocumentMenu.js b/app/menus/DocumentMenu.js index 6b9bc5ccb..6d1a9da83 100644 --- a/app/menus/DocumentMenu.js +++ b/app/menus/DocumentMenu.js @@ -123,6 +123,7 @@ class DocumentMenu extends React.Component { document, position, className, + showToggleEmbeds, showPrint, showPin, auth, @@ -177,6 +178,19 @@ class DocumentMenu extends React.Component { Share link… )} + {showToggleEmbeds && ( + + {document.embedsDisabled ? ( + + Enable embeds + + ) : ( + + Disable embeds + + )} + + )} {canViewHistory && (
diff --git a/app/models/Document.js b/app/models/Document.js index 0dbeab8d2..e64fd7aa3 100644 --- a/app/models/Document.js +++ b/app/models/Document.js @@ -1,5 +1,5 @@ // @flow -import { action, set, computed } from 'mobx'; +import { action, set, observable, computed } from 'mobx'; import pkg from 'rich-markdown-editor/package.json'; import addDays from 'date-fns/add_days'; import invariant from 'invariant'; @@ -15,7 +15,8 @@ import DocumentsStore from 'stores/DocumentsStore'; type SaveOptions = { publish?: boolean, done?: boolean, autosave?: boolean }; export default class Document extends BaseModel { - isSaving: boolean; + @observable isSaving: boolean = false; + @observable embedsDisabled: boolean = false; store: DocumentsStore; collaborators: User[]; @@ -110,6 +111,17 @@ export default class Document extends BaseModel { return this.store.restore(this, revision); }; + @action + enableEmbeds = () => { + this.embedsDisabled = false; + }; + + @action + disableEmbeds = () => { + this.embedsDisabled = true; + debugger; + }; + @action pin = async () => { this.pinned = true; diff --git a/app/scenes/Document/components/Document.js b/app/scenes/Document/components/Document.js index 7dfe4d27d..2a6b79de4 100644 --- a/app/scenes/Document/components/Document.js +++ b/app/scenes/Document/components/Document.js @@ -275,7 +275,8 @@ class DocumentScene extends React.Component { return ; } - const disableEmbeds = team && team.documentEmbeds === false; + const disableEmbeds = + (team && team.documentEmbeds === false) || document.embedsDisabled; return (