mirror of
https://github.com/outline/outline.git
synced 2026-12-04 18:34:54 +03:00
fix: Improve placeholder for new docs from template
Remove 'templates' tab on collection (overkill) Fix some language document -> template
This commit is contained in:
1 parent
df4ebd7c08
commit
2814dfff62
8 files changed
+41
-37
No files matched your search
+1
-15
@@ -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);
|
||||
@@ -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,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 => (
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user