diff --git a/app/components/Breadcrumb.js b/app/components/Breadcrumb.js index 5d9cb08482..388daaeff1 100644 --- a/app/components/Breadcrumb.js +++ b/app/components/Breadcrumb.js @@ -51,7 +51,7 @@ const Breadcrumb = observer(({ document, collections, onlyText }: Props) => { } const isTemplate = document.template; - const isDraft = !document.publishedAt && !document.template; + const isDraft = !document.publishedAt && !isTemplate; const isNestedDocument = path.length > 1; const lastPath = path.length ? path[path.length - 1] : undefined; const menuPath = isNestedDocument ? path.slice(0, -1) : []; diff --git a/app/components/Sidebar/Main.js b/app/components/Sidebar/Main.js index b8bf774969..ee4d1c7774 100644 --- a/app/components/Sidebar/Main.js +++ b/app/components/Sidebar/Main.js @@ -126,7 +126,8 @@ class MainSidebar extends React.Component { active={ documents.active ? !documents.active.publishedAt && - !documents.active.isDeleted + !documents.active.isDeleted && + !documents.active.isTemplate : undefined } /> diff --git a/app/components/Sidebar/Settings.js b/app/components/Sidebar/Settings.js index 94242fff24..cbe0c8cad5 100644 --- a/app/components/Sidebar/Settings.js +++ b/app/components/Sidebar/Settings.js @@ -9,6 +9,7 @@ import { ProfileIcon, PadlockIcon, CodeIcon, + ShapesIcon, UserIcon, GroupIcon, LinkIcon, diff --git a/app/components/Tab.js b/app/components/Tab.js index afdfc07d52..9992625e59 100644 --- a/app/components/Tab.js +++ b/app/components/Tab.js @@ -10,7 +10,7 @@ type Props = { const StyledNavLink = styled(NavLink)` position: relative; - top: 1px; + bottom: -1px; display: inline-block; font-weight: 500; @@ -43,4 +43,18 @@ function Tab({ theme, ...rest }: Props) { return ; } -export default withTheme(Tab); +const TabWithTheme = withTheme(Tab); + +const RightTabWithTheme = styled(TabWithTheme)` + position: absolute; + right: 0; + + margin-left: 24px; + margin-right: 0; +`; + +export function RightTab(props: Props) { + return ; +} + +export default TabWithTheme; diff --git a/app/components/Tabs.js b/app/components/Tabs.js index e61c3fed58..3e0606cd5d 100644 --- a/app/components/Tabs.js +++ b/app/components/Tabs.js @@ -2,6 +2,7 @@ import styled from "styled-components"; const Tabs = styled.nav` + position: relative; border-bottom: 1px solid ${props => props.theme.divider}; margin-top: 22px; margin-bottom: 12px; diff --git a/app/menus/NewDocumentMenu.js b/app/menus/NewDocumentMenu.js index ff87242948..05470151c9 100644 --- a/app/menus/NewDocumentMenu.js +++ b/app/menus/NewDocumentMenu.js @@ -42,13 +42,14 @@ class NewDocumentMenu extends React.Component { if (this.redirectTo) return ; const { collections, policies, label, ...rest } = this.props; + const singleCollection = collections.orderedData.length === 1; return ( } small> - New doc… + New doc{singleCollection ? "" : "…"} ) } @@ -65,7 +66,7 @@ class NewDocumentMenu extends React.Component { onClick={() => this.handleNewDocument(collection.id)} disabled={!can.update} > - {collection.name} +  {collection.name} ); })} diff --git a/app/menus/NewTemplateMenu.js b/app/menus/NewTemplateMenu.js new file mode 100644 index 0000000000..3a310740c9 --- /dev/null +++ b/app/menus/NewTemplateMenu.js @@ -0,0 +1,70 @@ +// @flow +import * as React from "react"; +import { observable } from "mobx"; +import { inject, observer } from "mobx-react"; +import { Redirect } from "react-router-dom"; +import { PlusIcon } from "outline-icons"; + +import { newDocumentUrl } from "utils/routeHelpers"; +import CollectionsStore from "stores/CollectionsStore"; +import PoliciesStore from "stores/PoliciesStore"; +import { DropdownMenu, DropdownMenuItem } from "components/DropdownMenu"; +import Button from "components/Button"; +import CollectionIcon from "components/CollectionIcon"; + +type Props = { + label?: React.Node, + collections: CollectionsStore, + policies: PoliciesStore, +}; + +@observer +class NewTemplateMenu extends React.Component { + @observable redirectTo: ?string; + + componentDidUpdate() { + this.redirectTo = undefined; + } + + handleNewDocument = (collectionId: string) => { + this.redirectTo = newDocumentUrl(collectionId, { + template: true, + }); + }; + + render() { + if (this.redirectTo) return ; + + const { collections, policies, label, ...rest } = this.props; + + return ( + } small> + New template… + + ) + } + {...rest} + > + Choose a collection… + {collections.orderedData.map(collection => { + const can = policies.abilities(collection.id); + + return ( + this.handleNewDocument(collection.id)} + disabled={!can.update} + > +  {collection.name} + + ); + })} + + ); + } +} + +export default inject("collections", "policies")(NewTemplateMenu); diff --git a/app/models/Document.js b/app/models/Document.js index 0cc9ea8503..3563b03094 100644 --- a/app/models/Document.js +++ b/app/models/Document.js @@ -79,6 +79,11 @@ export default class Document extends BaseModel { return !!this.deletedAt; } + @computed + get isTemplate(): boolean { + return !!this.template; + } + @computed get isDraft(): boolean { return !this.publishedAt; diff --git a/app/routes.js b/app/routes.js index 6db88b5679..dde9b634ed 100644 --- a/app/routes.js +++ b/app/routes.js @@ -11,7 +11,6 @@ import Trash from "scenes/Trash"; import Collection from "scenes/Collection"; import KeyedDocument from "scenes/Document/KeyedDocument"; import DocumentNew from "scenes/DocumentNew"; -import TemplateNew from "scenes/TemplateNew"; import Search from "scenes/Search"; import Settings from "scenes/Settings"; import Details from "scenes/Settings/Details"; @@ -53,7 +52,6 @@ export default function Routes() { - diff --git a/app/scenes/Collection.js b/app/scenes/Collection.js index 3546cbc0bd..a67b1fa72f 100644 --- a/app/scenes/Collection.js +++ b/app/scenes/Collection.js @@ -34,7 +34,7 @@ import Flex from "components/Flex"; import Modal from "components/Modal"; import CollectionMembers from "scenes/CollectionMembers"; import Tabs from "components/Tabs"; -import Tab from "components/Tab"; +import Tab, { RightTab } from "components/Tab"; import PaginatedDocumentList from "components/PaginatedDocumentList"; import CollectionIcon from "components/CollectionIcon"; @@ -241,9 +241,12 @@ class CollectionScene extends React.Component { A–Z - + Templates - + diff --git a/app/scenes/Document/components/Editor.js b/app/scenes/Document/components/Editor.js index 92a89c69fb..0d816b9705 100644 --- a/app/scenes/Document/components/Editor.js +++ b/app/scenes/Document/components/Editor.js @@ -80,7 +80,9 @@ class DocumentEditor extends React.Component { type="text" onChange={onChangeTitle} onKeyDown={this.handleTitleKeyDown} - placeholder="Start with a title…" + placeholder={ + document.template ? "Start your template…" : "Start with a title…" + } value={!title && readOnly ? "Untitled" : title} style={startsWithEmojiAndSpace ? { marginLeft: "-1.2em" } : undefined} readOnlyWriteCheckboxes diff --git a/app/scenes/Document/components/Header.js b/app/scenes/Document/components/Header.js index d33ba9d2f9..4d878a947d 100644 --- a/app/scenes/Document/components/Header.js +++ b/app/scenes/Document/components/Header.js @@ -133,6 +133,7 @@ class Header extends React.Component { const share = shares.getByDocumentId(document.id); const isPubliclyShared = share && share.published; + const isTemplate = document.template; const can = policies.abilities(document.id); const canShareDocuments = auth.team && auth.team.sharing && can.share; const canToggleEmbeds = auth.team && auth.team.documentEmbeds; @@ -314,7 +315,9 @@ class Header extends React.Component { )} {canEdit && - document.template && ( + isTemplate && + !isDraft && + !isRevision && ( +