From 877c01f723be96266047f6d34f1357583b55a8d7 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 23 Mar 2021 19:22:15 -0700 Subject: [PATCH] feat: Show 'Edit' button when visiting share link as signed in user with permission (#1980) --- app/scenes/Document/components/Container.js | 1 - app/scenes/Document/components/Document.js | 35 ++++---- app/scenes/Document/components/Header.js | 92 ++++++++++++--------- server/api/documents.js | 9 +- server/api/documents.test.js | 1 + shared/i18n/locales/en_US/translation.json | 2 +- 6 files changed, 79 insertions(+), 61 deletions(-) diff --git a/app/scenes/Document/components/Container.js b/app/scenes/Document/components/Container.js index 2b708f7dd..dc603eb52 100644 --- a/app/scenes/Document/components/Container.js +++ b/app/scenes/Document/components/Container.js @@ -4,7 +4,6 @@ import Flex from "components/Flex"; const Container = styled(Flex)` position: relative; - margin-top: ${(props) => (props.isShare ? "50px" : "0")}; `; export default Container; diff --git a/app/scenes/Document/components/Document.js b/app/scenes/Document/components/Document.js index b396bb29a..7db950283 100644 --- a/app/scenes/Document/components/Document.js +++ b/app/scenes/Document/components/Document.js @@ -9,7 +9,6 @@ import { Prompt, Route, withRouter } from "react-router-dom"; import type { RouterHistory, Match } from "react-router-dom"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; - import AuthStore from "stores/AuthStore"; import UiStore from "stores/UiStore"; import Document from "models/Document"; @@ -325,8 +324,7 @@ class DocumentScene extends React.Component { const headings = this.editor.current ? this.editor.current.getHeadings() : []; - const showContents = - (ui.tocVisible && readOnly) || (isShare && !!headings.length); + const showContents = ui.tocVisible && readOnly; return ( @@ -361,22 +359,21 @@ class DocumentScene extends React.Component { /> )} - {!isShare && ( -
- )} +
+ + + + ); + + if (isShare) { + return ( +
} + /> + ); + } + return ( <> - - - - - )} + {canEdit && editAction} {canEdit && can.createChildDocument && ( { expect(body.data.id).toEqual(document.id); expect(body.data.createdBy.id).toEqual(user.id); expect(body.data.updatedBy.id).toEqual(user.id); + expect(body.policies[0].abilities.update).toEqual(true); }); it("should return draft document from shareId with token", async () => { diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 6be04c691..49f953ba5 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -243,6 +243,7 @@ "Collections are for grouping your documents. They work best when organized around a topic or internal team — Product or Engineering for example.": "Collections are for grouping your documents. They work best when organized around a topic or internal team — Product or Engineering for example.", "Creating": "Creating", "Create": "Create", + "Edit {{noun}}": "Edit {{noun}}", "Hide contents": "Hide contents", "Show contents": "Show contents", "Archived": "Archived", @@ -250,7 +251,6 @@ "Share": "Share", "Save Draft": "Save Draft", "Done Editing": "Done Editing", - "Edit {{noun}}": "Edit {{noun}}", "New from template": "New from template", "Publish": "Publish", "Publishing": "Publishing",