fix: Improve placeholder for new docs from template

Remove 'templates' tab on collection (overkill)
Fix some language document -> template
This commit is contained in:
Tom Moor committed 2020-08-04 21:22:54 -07:00
1 parent df4ebd7c08
commit 2814dfff62
8 files changed
+41 -37

No files matched your search

+1 -15
View File
@@ -43,18 +43,4 @@ function Tab({ theme, ...rest }: Props) {
return <StyledNavLink {...rest} activeStyle={activeStyle} />;
}
const TabWithTheme = withTheme(Tab);
const RightTabWithTheme = styled(TabWithTheme)`
position: absolute;
right: 0;
margin-left: 24px;
margin-right: 0;
`;
export function RightTab(props: Object) {
return <RightTabWithTheme {...props} />;
}
export default TabWithTheme;
export default withTheme(Tab);
+1 -1
View File
@@ -264,7 +264,7 @@ class DocumentMenu extends React.Component<Props> {
)}
</DropdownMenu>
<Modal
title="Delete document"
title={`Delete ${this.props.document.noun}`}
onRequestClose={this.handleCloseDeleteModal}
isOpen={this.showDeleteModal}
>
+3 -3
View File
@@ -3,7 +3,7 @@ import * as React from "react";
import { observable } from "mobx";
import { observer } from "mobx-react";
import { Redirect } from "react-router-dom";
import { PlusIcon, DocumentIcon } from "outline-icons";
import { EditIcon, DocumentIcon } from "outline-icons";
import styled from "styled-components";
import { newDocumentUrl } from "utils/routeHelpers";
@@ -59,8 +59,8 @@ class NewFromTemplateMenu extends React.Component<Props> {
{...rest}
>
<DropdownMenuItem onClick={() => this.handleNewDocument(collection.id)}>
<PlusIcon />
<span>New document</span>
<EditIcon />
<span>Blank document</span>
</DropdownMenuItem>
<Header>Start from a template…</Header>
{templates.map(template => (
+29
View File
@@ -35,14 +35,26 @@ export default class Document extends BaseModel {
title: string;
emoji: string;
template: boolean;
templateId: ?string;
parentDocumentId: ?string;
publishedAt: ?string;
archivedAt: string;
deletedAt: ?string;
url: string;
urlId: string;
originalTitle: string;
revision: number;
constructor(fields: Object, store: DocumentsStore) {
super(fields, store);
this.originalTitle = this.title;
if (this.isNew && this.isFromTemplate) {
this.title = "";
}
}
get emoji() {
const { emoji } = parseTitle(this.title);
return emoji;
@@ -102,6 +114,23 @@ export default class Document extends BaseModel {
return addDays(new Date(this.deletedAt), 30).toString();
}
@computed
get isNew(): boolean {
return this.createdAt === this.updatedAt;
}
@computed
get isFromTemplate(): boolean {
return !!this.templateId;
}
@computed
get placeholder(): ?string {
return this.isNew && this.isFromTemplate
? this.originalTitle
: this.isTemplate ? "Start your template…" : "Start with a title…";
}
@action
share = async () => {
return this.store.rootStore.shares.create({ documentId: this.id });
+1 -15
View File
@@ -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, { RightTab } from "components/Tab";
import Tab from "components/Tab";
import PaginatedDocumentList from "components/PaginatedDocumentList";
import CollectionIcon from "components/CollectionIcon";
import NewFromTemplateMenu from "../menus/NewFromTemplateMenu";
@@ -256,12 +256,6 @@ class CollectionScene extends React.Component<Props> {
<Tab to={collectionUrl(collection.id, "alphabetical")} exact>
A–Z
</Tab>
<RightTab
to={collectionUrl(collection.id, "templates")}
exact
>
Templates
</RightTab>
</Tabs>
<Switch>
<Route path={collectionUrl(collection.id, "alphabetical")}>
@@ -298,14 +292,6 @@ class CollectionScene extends React.Component<Props> {
showPin
/>
</Route>
<Route path={collectionUrl(collection.id, "templates")}>
<PaginatedDocumentList
key="templates"
documents={documents.templatesInCollection(collection.id)}
fetch={documents.fetchRecentlyUpdated /* TODO */}
options={{ collectionId: collection.id }}
/>
</Route>
<Route path={collectionUrl(collection.id)}>
<PaginatedDocumentList
documents={documents.recentlyUpdatedInCollection(
+1 -3
View File
@@ -80,9 +80,7 @@ class DocumentEditor extends React.Component<Props> {
type="text"
onChange={onChangeTitle}
onKeyDown={this.handleTitleKeyDown}
placeholder={
document.template ? "Start your template…" : "Start with a title…"
}
placeholder={document.placeholder}
value={!title && readOnly ? document.titleWithDefault : title}
style={startsWithEmojiAndSpace ? { marginLeft: "-1.2em" } : undefined}
readOnlyWriteCheckboxes
+4
View File
@@ -143,6 +143,10 @@ Document.associate = models => {
as: "team",
foreignKey: "teamId",
});
Document.belongsTo(models.Document, {
as: "document",
foreignKey: "templateId",
});
Document.belongsTo(models.User, {
as: "createdBy",
foreignKey: "createdById",
+1
View File
@@ -55,6 +55,7 @@ export default async function present(document: Document, options: ?Options) {
deletedAt: document.deletedAt,
teamId: document.teamId,
template: document.template,
templateId: document.templateId,
collaborators: [],
starred: document.starred ? !!document.starred.length : undefined,
revision: document.revisionCount,