Compare commits

..

43 Commits

Author SHA1 Message Date
Tom Moor 9bcf5b0292 fix: race, avoid update event if no text changed 2020-11-16 21:25:40 -08:00
Tom Moor 3b4aa02c67 fix: various connection issues 2020-11-16 21:25:16 -08:00
Tom Moor 375d658231 skip backlink title rewriting for now 2020-11-16 21:25:07 -08:00
Tom Moor 70ea77ce01 hook up awareness to UI
fix header disappearing
2020-11-15 20:06:41 -08:00
Tom Moor cea1d808d1 Bump deps 2020-11-15 12:24:01 -08:00
Tom Moor bea8b85cf9 Merge develop 2020-11-15 11:23:04 -08:00
Tom Moor abeccb8a4c stash 2020-11-08 15:58:00 -08:00
Tom Moor c8d3d26044 Merge branch 'develop' of github.com:outline/outline into yjs 2020-11-05 23:05:16 -08:00
Tom Moor ec5a7d79f5 flow 2020-11-05 18:41:22 -08:00
Tom Moor 30d31b35ac fix: Issue with inflating clientIds in pud 2020-11-04 19:12:55 -08:00
Tom Moor 8abf2436dd wip 2020-11-01 19:52:34 -08:00
Tom Moor 4df75bda7b Remove unneeded applyUpdate 2020-11-01 15:52:11 -08:00
Tom Moor 220546c40a fix: Multiplayer cursors in headings 2020-11-01 13:06:13 -08:00
Tom Moor b96ffe59db Merge develop 2020-11-01 13:02:58 -08:00
Tom Moor 2676a7e8cf events 2020-10-26 23:25:19 -07:00
Tom Moor 5e9e4fb028 Merge branch 'develop' into yjs 2020-10-26 21:39:57 -07:00
Tom Moor 551b1620e0 fix: Flag without realtime editing 2020-10-26 19:27:49 -07:00
Tom Moor b8569ed8de remove flag sidebar item for now 2020-10-25 19:37:13 -07:00
Tom Moor 8d1a707dd0 basic offline messaging 2020-10-25 19:36:10 -07:00
Tom Moor 9877cf1f4e install 2020-10-25 19:13:29 -07:00
Tom Moor 50fbcd8d85 Merge develop 2020-10-25 19:11:21 -07:00
Tom Moor 359d228771 lint 2020-10-25 19:10:31 -07:00
Tom Moor 0347620c75 fix: Update collaboratorIds 2020-10-25 14:42:28 -07:00
Tom Moor cb362511a5 Load from db 2020-10-25 10:40:39 -07:00
Tom Moor 700db463fc fix: Awareness state not available if server dies and restarts 2020-10-24 19:46:08 -07:00
Tom Moor a28dfa77ee fix: Race condition when setting up socket listeners 2020-10-24 19:45:51 -07:00
Tom Moor d8bc6515dd race 2020-10-23 10:06:44 -07:00
Tom Moor 0776b78e25 wip 2020-10-19 07:33:43 -07:00
Tom Moor 4256e7ec87 flow 2020-10-18 22:32:04 -07:00
Tom Moor e723124f8f lint 2020-10-18 22:26:36 -07:00
Tom Moor c2fbd78622 flow-types 2020-10-18 22:16:42 -07:00
Tom Moor 17cbeab409 refactor 2020-10-18 21:36:24 -07:00
Tom Moor 37d456a0fb refactor 2020-10-18 15:37:50 -07:00
Tom Moor 48a0ba0dec refactor, resolve memory leak 2020-10-17 17:47:04 -07:00
Tom Moor f454467bf1 event filtering 2020-10-17 13:21:48 -07:00
Tom Moor f21f660543 stash 2020-10-16 16:19:29 -07:00
Tom Moor 50637bc7ce local cache, more brand-like colors 2020-10-15 23:03:05 -07:00
Tom Moor acb61d5e0c Match editing color to avatar and brand 2020-10-15 22:43:42 -07:00
Tom Moor 7dcbaa9c5c cursors 2020-10-15 22:10:30 -07:00
Tom Moor ae1761e517 wip 2020-10-15 20:24:44 -07:00
Tom Moor 7166378c32 Restore old functionality, put new functionality behind flag 2020-10-13 08:43:53 -07:00
Tom Moor 2719321430 refactoring 2020-10-11 23:06:15 -07:00
Tom Moor a7f2c7edb3 rough, but working 2020-10-11 20:54:31 -07:00
162 changed files with 5736 additions and 8632 deletions
-7
View File
@@ -24,11 +24,6 @@ DEBUG=cache,presenters,events
SLACK_KEY=get_a_key_from_slack
SLACK_SECRET=get_the_secret_of_above_key
# To configure Google auth, you'll need to create an OAuth Client ID at
# => https://console.cloud.google.com/apis/credentials
#
# When configuring the Client ID, add an Authorized redirect URI:
# https://<your Outline URL>/auth/google.callback
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
@@ -65,5 +60,3 @@ SMTP_REPLY_EMAIL=
# Custom logo that displays on the authentication screen, scaled to height: 60px
# TEAM_LOGO=https://example.com/images/logo.png
DEFAULT_LANGUAGE=en_US
+4
View File
@@ -11,6 +11,10 @@
.*/node_modules/react-side-effect/.*
.*/node_modules/fbjs/.*
.*/node_modules/config-chain/.*
.*/node_modules/yjs/.*
.*/node_modules/@tommoor/y-prosemirror/.*
.*/node_modules/y-protocols/.*
.*/node_modules/lib0/.*
.*/server/scripts/.*
*.test.js
-10
View File
@@ -1,10 +0,0 @@
# Set to true to add reviewers to pull requests
addReviewers: true
# A list of reviewers to be added to pull requests (GitHub user name)
reviewers:
- tommoor
# A list of keywords to be skipped the process that add reviewers if pull requests include it
skipKeywords:
- wip
+2 -2
View File
@@ -3,7 +3,7 @@ Business Source License 1.1
Parameters
Licensor: General Outline, Inc.
Licensed Work: Outline 0.51.0
Licensed Work: Outline 0.49.0
The Licensed Work is (c) 2020 General Outline, Inc.
Additional Use Grant: You may make use of the Licensed Work, provided that
you may not use the Licensed Work for a Document
@@ -15,7 +15,7 @@ Additional Use Grant: You may make use of the Licensed Work, provided that
Licensed Work by creating teams and documents
controlled by such third parties.
Change Date: 2023-12-13
Change Date: 2023-10-26
Change License: Apache License, Version 2.0
-2
View File
@@ -12,7 +12,6 @@
<a href="https://circleci.com/gh/outline/outline" rel="nofollow"><img src="https://circleci.com/gh/outline/outline.svg?style=shield&amp;circle-token=c0c4c2f39990e277385d5c1ae96169c409eb887a"></a>
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat"></a>
<a href="https://github.com/styled-components/styled-components"><img src="https://img.shields.io/badge/style-%F0%9F%92%85%20styled--components-orange.svg"></a>
<a href="https://translate.getoutline.com/project/outline"><img src="https://badges.crowdin.net/outline/localized.svg"></a>
</p>
This is the source code that runs [**Outline**](https://www.getoutline.com) and all the associated services. If you want to use Outline then you don't need to run this code, we offer a hosted version of the app at [getoutline.com](https://www.getoutline.com).
@@ -165,7 +164,6 @@ However, before working on a pull request please let the core team know by creat
If youre looking for ways to get started, here's a list of ways to help us improve Outline:
* [Translation](TRANSLATION.md) into other languages
* Issues with [`good first issue`](https://github.com/outline/outline/labels/good%20first%20issue) label
* Performance improvements, both on server and frontend
* Developer happiness and documentation
-34
View File
@@ -1,34 +0,0 @@
# Translation
Outline is localized through community contributions. The text in Outline's user interface is in American English by default, we're very thankful for all help that the community provides bringing the app to different languages.
## Externalizing strings
Before a string can be translated, it must be externalized. This is the process where English strings in the source code are wrapped in a function that retrieves the translated string for the users language.
For externalization we use [react-i18next](https://react.i18next.com/), this provides the hooks [useTranslation](https://react.i18next.com/latest/usetranslation-hook) and the [Trans](https://react.i18next.com/latest/trans-component) component for wrapping English text.
PR's are accepted for wrapping English strings in the codebase that were not previously externalized.
## Translating strings
To manage the translation process we use [CrowdIn](https://translate.getoutline.com/), it keeps track of which strings in which languages still need translating, synchronizes with the codebase automatically, and provides a great editor interface.
You'll need to create a free account to use CrowdIn. Once you have joined, you can provide translations by following these steps:
1. Select the language for which you want to contribute (or vote for) a translation (below the language you can see the progress of the translation)
![CrowdIn UI](https://i.imgur.com/AkbDY60.png)
2. Please choose the translation.json file from your desired language
3. Once a file is selected, all the strings associated with the version are displayed on the left side. To display the untranslated strings first, select the filter icon next to the search bar and select “All, Untranslated First”.The red square next to an English string shows that a string has not been translated yet. To provide a translation, select a string on the left side, provide a translation in the target language in the text box in the right side (singular and plural) and press the save button. As soon as a translation has been provided by another user (green square next to string), you can also vote on a translation provided by another user. The translation with the most votes is used unless a different translation has been approved by a proof reader. ![Editor UI](https://i.imgur.com/pldZCRs.png)
## Proofreading
Once a translation has been provided, a proof reader can approve the translation and mark it for use in Outline.
If you are interested in becoming a proof reader, please contact one of the project managers in the Outline CrowdIn project or contact [@tommoor](https://github.com/tommoor). Similarly, if your language is not listed in the list of CrowdIn languages, please contact our project managers or [send us an email](https://www.getoutline.com/contact) so we can add your language.
## Release
Updated translations are automatically PR'd against the codebase by a bot and will be merged regularly so that new translations appear in the next release of Outline.
-18
View File
@@ -1,18 +0,0 @@
/* eslint-disable flowtype/require-valid-file-annotation */
export default class Queue {
name;
constructor(name) {
this.name = name;
}
process = (fn) => {
console.log(`Registered function ${this.name}`);
this.processFn = fn;
};
add = (data) => {
console.log(`Running ${this.name}`);
return this.processFn({ data });
};
}
+7 -19
View File
@@ -1,30 +1,18 @@
// @flow
import { observer } from "mobx-react";
import { observer, inject } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { Redirect } from "react-router-dom";
import { isCustomSubdomain } from "shared/utils/domains";
import AuthStore from "stores/AuthStore";
import LoadingIndicator from "components/LoadingIndicator";
import useStores from "../hooks/useStores";
import env from "env";
type Props = {
children: React.Node,
auth: AuthStore,
children?: React.Node,
};
const Authenticated = ({ children }: Props) => {
const { auth } = useStores();
const { i18n } = useTranslation();
const language = auth.user && auth.user.language;
// Watching for language changes here as this is the earliest point we have
// the user available and means we can start loading translations faster
React.useEffect(() => {
if (i18n.language !== language) {
i18n.changeLanguage(language);
}
}, [i18n, language]);
const Authenticated = observer(({ auth, children }: Props) => {
if (auth.authenticated) {
const { user, team } = auth;
const { hostname } = window.location;
@@ -55,6 +43,6 @@ const Authenticated = ({ children }: Props) => {
auth.logout(true);
return <Redirect to="/" />;
};
});
export default observer(Authenticated);
export default inject("auth")(Authenticated);
+7 -14
View File
@@ -4,7 +4,6 @@ import { observable } from "mobx";
import { observer } from "mobx-react";
import { EditIcon } from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import styled from "styled-components";
import User from "models/User";
import UserProfile from "scenes/UserProfile";
@@ -17,7 +16,6 @@ type Props = {
isEditing: boolean,
isCurrentUser: boolean,
lastViewedAt: string,
t: TFunction,
};
@observer
@@ -39,25 +37,20 @@ class AvatarWithPresence extends React.Component<Props> {
isPresent,
isEditing,
isCurrentUser,
t,
} = this.props;
const action = isPresent
? isEditing
? t("currently editing")
: t("currently viewing")
: t("viewed {{ timeAgo }} ago", {
timeAgo: distanceInWordsToNow(new Date(lastViewedAt)),
});
return (
<>
<Tooltip
tooltip={
<Centered>
<strong>{user.name}</strong> {isCurrentUser && `(${t("You")})`}
<strong>{user.name}</strong> {isCurrentUser && "(You)"}
<br />
{action}
{isPresent
? isEditing
? "currently editing"
: "currently viewing"
: `viewed ${distanceInWordsToNow(new Date(lastViewedAt))} ago`}
</Centered>
}
placement="bottom"
@@ -90,4 +83,4 @@ const AvatarWrapper = styled.div`
transition: opacity 250ms ease-in-out;
`;
export default withTranslation()<AvatarWithPresence>(AvatarWithPresence);
export default AvatarWithPresence;
+10 -17
View File
@@ -1,5 +1,5 @@
// @flow
import { observer } from "mobx-react";
import { observer, inject } from "mobx-react";
import {
ArchiveIcon,
EditIcon,
@@ -10,7 +10,6 @@ import {
TrashIcon,
} from "outline-icons";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import styled from "styled-components";
import breakpoint from "styled-components-breakpoint";
@@ -20,7 +19,6 @@ import Document from "models/Document";
import CollectionIcon from "components/CollectionIcon";
import Flex from "components/Flex";
import BreadcrumbMenu from "./BreadcrumbMenu";
import useStores from "hooks/useStores";
import { collectionUrl } from "utils/routeHelpers";
type Props = {
@@ -30,15 +28,13 @@ type Props = {
};
function Icon({ document }) {
const { t } = useTranslation();
if (document.isDeleted) {
return (
<>
<CollectionName to="/trash">
<TrashIcon color="currentColor" />
&nbsp;
<span>{t("Trash")}</span>
<span>Trash</span>
</CollectionName>
<Slash />
</>
@@ -50,7 +46,7 @@ function Icon({ document }) {
<CollectionName to="/archive">
<ArchiveIcon color="currentColor" />
&nbsp;
<span>{t("Archive")}</span>
<span>Archive</span>
</CollectionName>
<Slash />
</>
@@ -62,7 +58,7 @@ function Icon({ document }) {
<CollectionName to="/drafts">
<EditIcon color="currentColor" />
&nbsp;
<span>{t("Drafts")}</span>
<span>Drafts</span>
</CollectionName>
<Slash />
</>
@@ -74,7 +70,7 @@ function Icon({ document }) {
<CollectionName to="/templates">
<ShapesIcon color="currentColor" />
&nbsp;
<span>{t("Templates")}</span>
<span>Templates</span>
</CollectionName>
<Slash />
</>
@@ -83,23 +79,20 @@ function Icon({ document }) {
return null;
}
const Breadcrumb = ({ document, onlyText }: Props) => {
const { collections } = useStores();
const { t } = useTranslation();
const Breadcrumb = observer(({ document, collections, onlyText }: Props) => {
let collection = collections.get(document.collectionId);
if (!collection) {
if (!document.deletedAt) return <div />;
collection = {
id: document.collectionId,
name: t("Deleted Collection"),
name: "Deleted Collection",
color: "currentColor",
};
}
const path = collection.pathToDocument
? collection.pathToDocument(document.id).slice(0, -1)
? collection.pathToDocument(document).slice(0, -1)
: [];
if (onlyText === true) {
@@ -148,7 +141,7 @@ const Breadcrumb = ({ document, onlyText }: Props) => {
)}
</Wrapper>
);
};
});
const Wrapper = styled(Flex)`
display: none;
@@ -209,4 +202,4 @@ const CollectionName = styled(Link)`
overflow: hidden;
`;
export default observer(Breadcrumb);
export default inject("collections")(Breadcrumb);
+1 -3
View File
@@ -20,9 +20,7 @@ type Props = {
@observer
class Collaborators extends React.Component<Props> {
componentDidMount() {
if (!this.props.document.isDeleted) {
this.props.views.fetchPage({ documentId: this.props.document.id });
}
this.props.views.fetchPage({ documentId: this.props.document.id });
}
render() {
+18 -16
View File
@@ -1,14 +1,14 @@
// @flow
import { observer } from "mobx-react";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import styled from "styled-components";
import AuthStore from "stores/AuthStore";
import CollectionsStore from "stores/CollectionsStore";
import Document from "models/Document";
import Breadcrumb from "components/Breadcrumb";
import Flex from "components/Flex";
import Time from "components/Time";
import useStores from "hooks/useStores";
const Container = styled(Flex)`
color: ${(props) => props.theme.textTertiary};
@@ -23,6 +23,8 @@ const Modified = styled.span`
`;
type Props = {
collections: CollectionsStore,
auth: AuthStore,
showCollection?: boolean,
showPublished?: boolean,
showLastViewed?: boolean,
@@ -32,6 +34,8 @@ type Props = {
};
function DocumentMeta({
auth,
collections,
showPublished,
showCollection,
showLastViewed,
@@ -40,8 +44,6 @@ function DocumentMeta({
to,
...rest
}: Props) {
const { t } = useTranslation();
const { collections, auth } = useStores();
const {
modifiedSinceViewed,
updatedAt,
@@ -65,37 +67,37 @@ function DocumentMeta({
if (deletedAt) {
content = (
<span>
{t("deleted")} <Time dateTime={deletedAt} addSuffix />
deleted <Time dateTime={deletedAt} addSuffix />
</span>
);
} else if (archivedAt) {
content = (
<span>
{t("archived")} <Time dateTime={archivedAt} addSuffix />
archived <Time dateTime={archivedAt} addSuffix />
</span>
);
} else if (createdAt === updatedAt) {
content = (
<span>
{t("created")} <Time dateTime={updatedAt} addSuffix />
created <Time dateTime={updatedAt} addSuffix />
</span>
);
} else if (publishedAt && (publishedAt === updatedAt || showPublished)) {
content = (
<span>
{t("published")} <Time dateTime={publishedAt} addSuffix />
published <Time dateTime={publishedAt} addSuffix />
</span>
);
} else if (isDraft) {
content = (
<span>
{t("saved")} <Time dateTime={updatedAt} addSuffix />
saved <Time dateTime={updatedAt} addSuffix />
</span>
);
} else {
content = (
<Modified highlight={modifiedSinceViewed}>
{t("updated")} <Time dateTime={updatedAt} addSuffix />
updated <Time dateTime={updatedAt} addSuffix />
</Modified>
);
}
@@ -110,25 +112,25 @@ function DocumentMeta({
if (!lastViewedAt) {
return (
<>
&nbsp;<Modified highlight>{t("Never viewed")}</Modified>
&nbsp;<Modified highlight>Never viewed</Modified>
</>
);
}
return (
<span>
&nbsp;{t("Viewed")} <Time dateTime={lastViewedAt} addSuffix shorten />
&nbsp;Viewed <Time dateTime={lastViewedAt} addSuffix shorten />
</span>
);
};
return (
<Container align="center" {...rest}>
{updatedByMe ? t("You") : updatedBy.name}&nbsp;
{updatedByMe ? "You" : updatedBy.name}&nbsp;
{to ? <Link to={to}>{content}</Link> : content}
{showCollection && collection && (
<span>
&nbsp;{t("in")}&nbsp;
&nbsp;in&nbsp;
<strong>
<Breadcrumb document={document} onlyText />
</strong>
@@ -140,4 +142,4 @@ function DocumentMeta({
);
}
export default observer(DocumentMeta);
export default inject("collections", "auth")(observer(DocumentMeta));
@@ -3,7 +3,6 @@ import { observable } from "mobx";
import { observer } from "mobx-react";
import { StarredIcon, PlusIcon } from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { Link, Redirect } from "react-router-dom";
import styled, { withTheme } from "styled-components";
import Document from "models/Document";
@@ -26,7 +25,6 @@ type Props = {
showPin?: boolean,
showDraft?: boolean,
showTemplate?: boolean,
t: TFunction,
};
const SEARCH_RESULT_REGEX = /<b\b[^>]*>(.*?)<\/b>/gi;
@@ -74,7 +72,6 @@ class DocumentPreview extends React.Component<Props> {
showTemplate,
highlight,
context,
t,
} = this.props;
if (this.redirectTo) {
@@ -94,7 +91,7 @@ class DocumentPreview extends React.Component<Props> {
>
<Heading>
<Title text={document.titleWithDefault} highlight={highlight} />
{document.isNew && <Badge yellow>{t("New")}</Badge>}
{document.isNew && <Badge yellow>New</Badge>}
{!document.isDraft &&
!document.isArchived &&
!document.isTemplate && (
@@ -107,16 +104,12 @@ class DocumentPreview extends React.Component<Props> {
</Actions>
)}
{document.isDraft && showDraft && (
<Tooltip
tooltip={t("Only visible to you")}
delay={500}
placement="top"
>
<Badge>{t("Draft")}</Badge>
<Tooltip tooltip="Only visible to you" delay={500} placement="top">
<Badge>Draft</Badge>
</Tooltip>
)}
{document.isTemplate && showTemplate && (
<Badge primary>{t("Template")}</Badge>
<Badge primary>Template</Badge>
)}
<SecondaryActions>
{document.isTemplate &&
@@ -127,7 +120,7 @@ class DocumentPreview extends React.Component<Props> {
icon={<PlusIcon />}
neutral
>
{t("New doc")}
New doc
</Button>
)}
&nbsp;
@@ -244,4 +237,4 @@ const ResultContext = styled(Highlight)`
margin-bottom: 0.25em;
`;
export default withTranslation()<DocumentPreview>(DocumentPreview);
export default DocumentPreview;
+31 -32
View File
@@ -5,7 +5,7 @@ import { observer, inject } from "mobx-react";
import * as React from "react";
import Dropzone from "react-dropzone";
import { withRouter, type RouterHistory, type Match } from "react-router-dom";
import styled, { css } from "styled-components";
import { createGlobalStyle } from "styled-components";
import DocumentsStore from "stores/DocumentsStore";
import UiStore from "stores/UiStore";
import LoadingIndicator from "components/LoadingIndicator";
@@ -17,6 +17,8 @@ type Props = {
children: React.Node,
collectionId: string,
documentId?: string,
activeClassName?: string,
rejectClassName?: string,
ui: UiStore,
documents: DocumentsStore,
disabled: boolean,
@@ -26,6 +28,18 @@ type Props = {
staticContext: Object,
};
export const GlobalStyles = createGlobalStyle`
.activeDropZone {
border-radius: 4px;
background: ${(props) => props.theme.slateDark};
svg { fill: ${(props) => props.theme.white}; }
}
.activeDropZone a {
color: ${(props) => props.theme.white} !important;
}
`;
@observer
class DropToImport extends React.Component<Props> {
@observable isImporting: boolean = false;
@@ -68,7 +82,17 @@ class DropToImport extends React.Component<Props> {
};
render() {
const { documents } = this.props;
const {
documentId,
collectionId,
documents,
disabled,
location,
match,
history,
staticContext,
...rest
} = this.props;
if (this.props.disabled) return this.props.children;
@@ -77,41 +101,16 @@ class DropToImport extends React.Component<Props> {
accept={documents.importFileTypes.join(", ")}
onDropAccepted={this.onDropAccepted}
style={EMPTY_OBJECT}
noClick
disableClick
disablePreview
multiple
{...rest}
>
{({
getRootProps,
getInputProps,
isDragActive,
isDragAccept,
isDragReject,
}) => (
<DropzoneContainer {...getRootProps()} {...{ isDragActive }}>
<input {...getInputProps()} />
{this.isImporting && <LoadingIndicator />}
{this.props.children}
</DropzoneContainer>
)}
{this.isImporting && <LoadingIndicator />}
{this.props.children}
</Dropzone>
);
}
}
const DropzoneContainer = styled("div")`
border-radius: 4px;
${({ isDragActive, theme }) =>
isDragActive &&
css`
background: ${theme.slateDark};
a {
color: ${theme.white} !important;
}
svg {
fill: ${theme.white};
}
`}
`;
export default inject("documents", "ui")(withRouter(DropToImport));
+3 -5
View File
@@ -5,7 +5,6 @@ import { observer } from "mobx-react";
import { MoreIcon } from "outline-icons";
import { rgba } from "polished";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { PortalWithState } from "react-portal";
import styled from "styled-components";
import { fadeAndScaleIn } from "shared/styles/animations";
@@ -28,7 +27,6 @@ type Props = {|
hover?: boolean,
style?: Object,
position?: "left" | "right" | "center",
t: TFunction,
|};
@observer
@@ -152,7 +150,7 @@ class DropdownMenu extends React.Component<Props> {
};
render() {
const { className, hover, label, children, t } = this.props;
const { className, hover, label, children } = this.props;
return (
<div className={className}>
@@ -179,7 +177,7 @@ class DropdownMenu extends React.Component<Props> {
{label || (
<NudeButton
id={`${this.id}button`}
aria-label={t("More options")}
aria-label="More options"
aria-haspopup="true"
aria-expanded={isOpen ? "true" : "false"}
aria-controls={this.id}
@@ -286,4 +284,4 @@ export const Header = styled.h3`
margin: 1em 12px 0.5em;
`;
export default withTranslation()<DropdownMenu>(DropdownMenu);
export default DropdownMenu;
+107 -129
View File
@@ -1,7 +1,6 @@
// @flow
import { lighten } from "polished";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { withRouter, type RouterHistory } from "react-router-dom";
import styled, { withTheme } from "styled-components";
import UiStore from "stores/UiStore";
@@ -29,129 +28,60 @@ type PropsWithRef = Props & {
history: RouterHistory,
};
function Editor(props: PropsWithRef) {
const { id, ui, history } = props;
const { t } = useTranslation();
class Editor extends React.Component<PropsWithRef> {
onUploadImage = async (file: File) => {
const result = await uploadFile(file, { documentId: this.props.id });
return result.url;
};
const onUploadImage = React.useCallback(
async (file: File) => {
const result = await uploadFile(file, { documentId: id });
return result.url;
},
[id]
);
onClickLink = (href: string, event: MouseEvent) => {
// on page hash
if (href[0] === "#") {
window.location.href = href;
return;
}
const onClickLink = React.useCallback(
(href: string, event: MouseEvent) => {
// on page hash
if (href[0] === "#") {
window.location.href = href;
return;
}
if (isInternalUrl(href) && !event.metaKey && !event.shiftKey) {
// relative
let navigateTo = href;
if (isInternalUrl(href) && !event.metaKey && !event.shiftKey) {
// relative
let navigateTo = href;
// probably absolute
if (href[0] !== "/") {
try {
const url = new URL(href);
navigateTo = url.pathname + url.hash;
} catch (err) {
navigateTo = href;
}
// probably absolute
if (href[0] !== "/") {
try {
const url = new URL(href);
navigateTo = url.pathname + url.hash;
} catch (err) {
navigateTo = href;
}
history.push(navigateTo);
} else if (href) {
window.open(href, "_blank");
}
},
[history]
);
const onShowToast = React.useCallback(
(message: string) => {
if (ui) {
ui.showToast(message);
}
},
[ui]
);
this.props.history.push(navigateTo);
} else if (href) {
window.open(href, "_blank");
}
};
const dictionary = React.useMemo(() => {
return {
addColumnAfter: t("Insert column after"),
addColumnBefore: t("Insert column before"),
addRowAfter: t("Insert row after"),
addRowBefore: t("Insert row before"),
alignCenter: t("Align center"),
alignLeft: t("Align left"),
alignRight: t("Align right"),
bulletList: t("Bulleted list"),
checkboxList: t("Todo list"),
codeBlock: t("Code block"),
codeCopied: t("Copied to clipboard"),
codeInline: t("Code"),
createLink: t("Create link"),
createLinkError: t("Sorry, an error occurred creating the link"),
createNewDoc: t("Create a new doc"),
deleteColumn: t("Delete column"),
deleteRow: t("Delete row"),
deleteTable: t("Delete table"),
em: t("Italic"),
embedInvalidLink: t("Sorry, that link wont work for this embed type"),
findOrCreateDoc: `${t("Find or create a doc")}`,
h1: t("Big heading"),
h2: t("Medium heading"),
h3: t("Small heading"),
heading: t("Heading"),
hr: t("Divider"),
image: t("Image"),
imageUploadError: t("Sorry, an error occurred uploading the image"),
info: t("Info"),
infoNotice: t("Info notice"),
link: t("Link"),
linkCopied: t("Link copied to clipboard"),
mark: t("Highlight"),
newLineEmpty: `${t("Type '/' to insert")}`,
newLineWithSlash: `${t("Keep typing to filter")}`,
noResults: t("No results"),
openLink: t("Open link"),
orderedList: t("Ordered list"),
pasteLink: `${t("Paste a link")}`,
pasteLinkWithTitle: (service: string) =>
t("Paste a {{service}} link…", { service }),
placeholder: t("Placeholder"),
quote: t("Quote"),
removeLink: t("Remove link"),
searchOrPasteLink: `${t("Search or paste a link")}`,
strikethrough: t("Strikethrough"),
strong: t("Bold"),
subheading: t("Subheading"),
table: t("Table"),
tip: t("Tip"),
tipNotice: t("Tip notice"),
warning: t("Warning"),
warningNotice: t("Warning notice"),
};
}, [t]);
onShowToast = (message: string) => {
if (this.props.ui) {
this.props.ui.showToast(message);
}
};
return (
<ErrorBoundary reloadOnChunkMissing>
<StyledEditor
ref={props.forwardedRef}
uploadImage={onUploadImage}
onClickLink={onClickLink}
onShowToast={onShowToast}
embeds={props.disableEmbeds ? EMPTY_ARRAY : embeds}
tooltip={EditorTooltip}
dictionary={dictionary}
{...props}
/>
</ErrorBoundary>
);
render() {
return (
<ErrorBoundary reloadOnChunkMissing>
<StyledEditor
ref={this.props.forwardedRef}
uploadImage={this.onUploadImage}
onClickLink={this.onClickLink}
onShowToast={this.onShowToast}
embeds={this.props.disableEmbeds ? EMPTY_ARRAY : embeds}
tooltip={EditorTooltip}
{...this.props}
/>
</ErrorBoundary>
);
}
}
const StyledEditor = styled(RichMarkdownEditor)`
@@ -162,26 +92,60 @@ const StyledEditor = styled(RichMarkdownEditor)`
transition: ${(props) => props.theme.backgroundTransition};
}
& * {
box-sizing: content-box;
}
.notice-block.tip,
.notice-block.warning {
font-weight: 500;
}
.heading-name {
pointer-events: none;
.ProseMirror {
.ProseMirror-yjs-cursor {
position: relative;
margin-left: -1px;
margin-right: -1px;
border-left: 1px solid black;
border-right: 1px solid black;
height: 1em;
word-break: normal;
&:after {
content: "";
display: block;
position: absolute;
left: -8px;
right: -8px;
top: 0;
bottom: 0;
}
> div {
opacity: 0;
position: absolute;
top: -1.8em;
font-size: 13px;
background-color: rgb(250, 129, 0);
font-style: normal;
line-height: normal;
user-select: none;
white-space: nowrap;
color: white;
padding: 2px 6px;
font-weight: 500;
border-radius: 4px;
pointer-events: none;
left: -1px;
}
&:hover {
> div {
opacity: 1;
transition: opacity 100ms ease-in-out;
}
}
}
}
/* pseudo element allows us to add spacing for fixed header */
/* ref: https://stackoverflow.com/a/28824157 */
.heading-name::before {
content: "";
display: ${(props) => (props.readOnly ? "block" : "none")};
height: 72px;
margin: -72px 0 0;
.heading-name {
pointer-events: none;
}
.heading-name:first-child {
@@ -223,3 +187,17 @@ const EditorWithRouterAndTheme = withRouter(withTheme(Editor));
export default React.forwardRef<Props, typeof Editor>((props, ref) => (
<EditorWithRouterAndTheme {...props} forwardedRef={ref} />
));
// > .ProseMirror-yjs-cursor:first-child {
// margin-top: 16px;
// }
// p:first-child,
// h1:first-child,
// h2:first-child,
// h3:first-child,
// h4:first-child,
// h5:first-child,
// h6:first-child {
// margin-top: 16px;
// }
+5 -5
View File
@@ -1,20 +1,20 @@
// @flow
import { observer } from "mobx-react";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { Link } from "react-router-dom";
import styled from "styled-components";
import parseDocumentSlug from "shared/utils/parseDocumentSlug";
import DocumentsStore from "stores/DocumentsStore";
import DocumentMetaWithViews from "components/DocumentMetaWithViews";
import Editor from "components/Editor";
import useStores from "hooks/useStores";
type Props = {
url: string,
documents: DocumentsStore,
children: (React.Node) => React.Node,
};
function HoverPreviewDocument({ url, children }: Props) {
const { documents } = useStores();
function HoverPreviewDocument({ url, documents, children }: Props) {
const slug = parseDocumentSlug(url);
documents.prefetchDocument(slug, {
@@ -50,4 +50,4 @@ const Heading = styled.h2`
color: ${(props) => props.theme.text};
`;
export default observer(HoverPreviewDocument);
export default inject("documents")(observer(HoverPreviewDocument));
+3 -6
View File
@@ -22,7 +22,6 @@ import {
VehicleIcon,
} from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import styled from "styled-components";
import { DropdownMenu } from "components/DropdownMenu";
import Flex from "components/Flex";
@@ -127,7 +126,6 @@ type Props = {
onChange: (color: string, icon: string) => void,
icon: string,
color: string,
t: TFunction,
};
function preventEventBubble(event) {
@@ -169,13 +167,12 @@ class IconPicker extends React.Component<Props> {
};
render() {
const { t } = this.props;
const Component = icons[this.props.icon || "collection"].component;
return (
<Wrapper ref={(ref) => (this.node = ref)}>
<label>
<LabelText>{t("Icon")}</LabelText>
<LabelText>Icon</LabelText>
</label>
<DropdownMenu
onOpen={this.handleOpen}
@@ -200,7 +197,7 @@ class IconPicker extends React.Component<Props> {
})}
</Icons>
<Flex onClick={preventEventBubble}>
<React.Suspense fallback={<Loading>{t("Loading")}</Loading>}>
<React.Suspense fallback={<Loading>Loading</Loading>}>
<ColorPicker
color={this.props.color}
onChange={(color) =>
@@ -249,4 +246,4 @@ const Wrapper = styled("div")`
position: relative;
`;
export default withTranslation()<IconPicker>(IconPicker);
export default IconPicker;
+4 -9
View File
@@ -3,7 +3,6 @@ import { observable } from "mobx";
import { observer } from "mobx-react";
import { SearchIcon } from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import keydown from "react-keydown";
import { withRouter, type RouterHistory } from "react-router-dom";
import styled, { withTheme } from "styled-components";
@@ -17,7 +16,6 @@ type Props = {
source: string,
placeholder?: string,
collectionId?: string,
t: TFunction,
};
@observer
@@ -26,7 +24,7 @@ class InputSearch extends React.Component<Props> {
@observable focused: boolean = false;
@keydown("meta+f")
focus(ev: SyntheticEvent<>) {
focus(ev) {
ev.preventDefault();
if (this.input) {
@@ -34,7 +32,7 @@ class InputSearch extends React.Component<Props> {
}
}
handleSearchInput = (ev: SyntheticInputEvent<>) => {
handleSearchInput = (ev) => {
ev.preventDefault();
this.props.history.push(
searchUrl(ev.target.value, {
@@ -53,8 +51,7 @@ class InputSearch extends React.Component<Props> {
};
render() {
const { t } = this.props;
const { theme, placeholder = `${t("Search")}` } = this.props;
const { theme, placeholder = "Search…" } = this.props;
return (
<InputMaxWidth
@@ -79,6 +76,4 @@ const InputMaxWidth = styled(Input)`
max-width: 30vw;
`;
export default withTranslation()<InputSearch>(
withTheme(withRouter(InputSearch))
);
export default withTheme(withRouter(InputSearch));
+3 -16
View File
@@ -20,17 +20,11 @@ const Select = styled.select`
}
`;
const Wrapper = styled.label`
display: block;
max-width: ${(props) => (props.short ? "350px" : "100%")};
`;
type Option = { label: string, value: string };
export type Props = {
value?: string,
label?: string,
short?: boolean,
className?: string,
labelHidden?: boolean,
options: Option[],
@@ -49,19 +43,12 @@ class InputSelect extends React.Component<Props> {
};
render() {
const {
label,
className,
labelHidden,
options,
short,
...rest
} = this.props;
const { label, className, labelHidden, options, ...rest } = this.props;
const wrappedLabel = <LabelText>{label}</LabelText>;
return (
<Wrapper short={short}>
<label>
{label &&
(labelHidden ? (
<VisuallyHidden>{wrappedLabel}</VisuallyHidden>
@@ -77,7 +64,7 @@ class InputSelect extends React.Component<Props> {
))}
</Select>
</Outline>
</Wrapper>
</label>
);
}
}
-90
View File
@@ -1,90 +0,0 @@
// @flow
import { find } from "lodash";
import * as React from "react";
import { Trans, useTranslation } from "react-i18next";
import styled from "styled-components";
import { languages, languageOptions } from "shared/i18n";
import Flex from "components/Flex";
import NoticeTip from "components/NoticeTip";
import useCurrentUser from "hooks/useCurrentUser";
import useStores from "hooks/useStores";
import { detectLanguage } from "utils/language";
function Icon(props) {
return (
<svg
width="32"
height="32"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M21 18H16L14 16V6C14 4.89543 14.8954 4 16 4H28C29.1046 4 30 4.89543 30 6V16C30 17.1046 29.1046 18 28 18H27L25.4142 19.5858C24.6332 20.3668 23.3668 20.3668 22.5858 19.5858L21 18ZM16 15.1716V6H28V16H27H26.1716L25.5858 16.5858L24 18.1716L22.4142 16.5858L21.8284 16H21H16.8284L16 15.1716Z"
fill="#2B2F35"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M16 13H4C2.89543 13 2 13.8954 2 15V25C2 26.1046 2.89543 27 4 27H5L6.58579 28.5858C7.36684 29.3668 8.63316 29.3668 9.41421 28.5858L11 27H16C17.1046 27 18 26.1046 18 25V15C18 13.8954 17.1046 13 16 13ZM9 17L6 16.9681C6 16.9681 5 17.016 5 18C5 18.984 6 19 6 19H8.5H10C10 19 9.57627 20.1885 8.38983 21.0831C7.20339 21.9777 5.7197 23 5.7197 23C5.7197 23 4.99153 23.6054 5.5 24.5C6.00847 25.3946 7 24.8403 7 24.8403L9.74576 22.8722L11.9492 24.6614C11.9492 24.6614 12.6271 25.3771 13.3051 24.4825C13.9831 23.5879 13.3051 23.0512 13.3051 23.0512L11.1017 21.262C11.1017 21.262 11.5 21 12 20L12.5 19H14C14 19 15 19.0319 15 18C15 16.9681 14 16.9681 14 16.9681L11 17V16C11 16 11.0169 15 10 15C8.98305 15 9 16 9 16V17Z"
fill="#2B2F35"
/>
<path
d="M23.6672 12.5221L23.5526 12.1816H23.1934H20.8818H20.5215L20.4075 12.5235L20.082 13.5H19.2196L21.2292 8.10156H21.8774L21.5587 9.06116L20.7633 11.4562L20.5449 12.1138H21.2378H22.8374H23.5327L23.3114 11.4546L22.5072 9.05959L22.1855 8.10156H22.768L24.7887 13.5H23.9964L23.6672 12.5221Z"
fill="#2B2F35"
stroke="#2B2F35"
/>
</svg>
);
}
export default function LanguagePrompt() {
const { auth, ui } = useStores();
const { t } = useTranslation();
const user = useCurrentUser();
const language = detectLanguage();
if (language === "en_US" || language === user.language) {
return null;
}
if (!languages.includes(language)) {
return null;
}
const option = find(languageOptions, (o) => o.value === language);
const optionLabel = option ? option.label : "";
return (
<NoticeTip>
<Flex align="center">
<LanguageIcon />
<span>
<Trans>
Outline is available in your language {{ optionLabel }}, would you
like to change?
</Trans>
<br />
<a
onClick={() => {
auth.updateUser({
language,
});
ui.setLanguagePromptDismissed();
}}
>
{t("Change Language")}
</a>{" "}
&middot; <a onClick={ui.setLanguagePromptDismissed}>{t("Dismiss")}</a>
</span>
</Flex>
</NoticeTip>
);
}
const LanguageIcon = styled(Icon)`
margin-right: 12px;
`;
+10 -25
View File
@@ -3,7 +3,6 @@ import { observable } from "mobx";
import { observer, inject } from "mobx-react";
import * as React from "react";
import { Helmet } from "react-helmet";
import { withTranslation, type TFunction } from "react-i18next";
import keydown from "react-keydown";
import { Switch, Route, Redirect } from "react-router-dom";
import styled, { withTheme } from "styled-components";
@@ -15,6 +14,7 @@ import ErrorSuspended from "scenes/ErrorSuspended";
import KeyboardShortcuts from "scenes/KeyboardShortcuts";
import Analytics from "components/Analytics";
import DocumentHistory from "components/DocumentHistory";
import { GlobalStyles } from "components/DropToImport";
import Flex from "components/Flex";
import { LoadingIndicatorBar } from "components/LoadingIndicator";
@@ -37,8 +37,6 @@ type Props = {
ui: UiStore,
notifications?: React.Node,
theme: Theme,
i18n: Object,
t: TFunction,
};
@observer
@@ -47,7 +45,7 @@ class Layout extends React.Component<Props> {
@observable redirectTo: ?string;
@observable keyboardShortcutsOpen: boolean = false;
constructor(props: Props) {
constructor(props) {
super();
this.updateBackground(props);
}
@@ -60,16 +58,11 @@ class Layout extends React.Component<Props> {
}
}
updateBackground(props: Props) {
updateBackground(props) {
// ensure the wider page color always matches the theme
window.document.body.style.background = props.theme.background;
}
@keydown("meta+.")
handleToggleSidebar() {
this.props.ui.toggleCollapsedSidebar();
}
@keydown("shift+/")
handleOpenKeyboardShortcuts() {
if (this.props.ui.editMode) return;
@@ -81,7 +74,7 @@ class Layout extends React.Component<Props> {
};
@keydown(["t", "/", "meta+k"])
goToSearch(ev: SyntheticEvent<>) {
goToSearch(ev) {
if (this.props.ui.editMode) return;
ev.preventDefault();
ev.stopPropagation();
@@ -95,7 +88,7 @@ class Layout extends React.Component<Props> {
}
render() {
const { auth, t, ui } = this.props;
const { auth, ui } = this.props;
const { user, team } = auth;
const showSidebar = auth.authenticated && user && team;
@@ -124,11 +117,7 @@ class Layout extends React.Component<Props> {
</Switch>
)}
<Content
auto
justify="center"
sidebarCollapsed={ui.editMode || ui.sidebarCollapsed}
>
<Content auto justify="center" editMode={ui.editMode}>
{this.props.children}
</Content>
@@ -142,10 +131,11 @@ class Layout extends React.Component<Props> {
<Modal
isOpen={this.keyboardShortcutsOpen}
onRequestClose={this.handleCloseKeyboardShortcuts}
title={t("Keyboard shortcuts")}
title="Keyboard shortcuts"
>
<KeyboardShortcuts />
</Modal>
<GlobalStyles />
</Container>
);
}
@@ -168,13 +158,8 @@ const Content = styled(Flex)`
}
${breakpoint("tablet")`
margin-left: ${(props) =>
props.sidebarCollapsed
? props.theme.sidebarCollapsedWidth
: props.theme.sidebarWidth};
margin-left: ${(props) => (props.editMode ? 0 : props.theme.sidebarWidth)};
`};
`;
export default withTranslation()<Layout>(
inject("auth", "ui", "documents")(withTheme(Layout))
);
export default inject("auth", "ui", "documents")(withTheme(Layout));
-22
View File
@@ -1,22 +0,0 @@
// @flow
import styled from "styled-components";
const Notice = styled.p`
background: ${(props) => props.theme.brand.marine};
color: ${(props) => props.theme.almostBlack};
padding: 10px 12px;
margin-top: 24px;
border-radius: 4px;
position: relative;
a {
color: ${(props) => props.theme.almostBlack};
font-weight: 500;
}
a:hover {
text-decoration: underline;
}
`;
export default Notice;
+12 -16
View File
@@ -12,7 +12,6 @@ import {
PlusIcon,
} from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import styled from "styled-components";
import AuthStore from "stores/AuthStore";
@@ -35,7 +34,6 @@ type Props = {
auth: AuthStore,
documents: DocumentsStore,
policies: PoliciesStore,
t: TFunction,
};
@observer
@@ -67,7 +65,7 @@ class MainSidebar extends React.Component<Props> {
};
render() {
const { auth, documents, policies, t } = this.props;
const { auth, documents, policies } = this.props;
const { user, team } = auth;
if (!user || !team) return null;
@@ -92,7 +90,7 @@ class MainSidebar extends React.Component<Props> {
to="/home"
icon={<HomeIcon color="currentColor" />}
exact={false}
label={t("Home")}
label="Home"
/>
<SidebarLink
to={{
@@ -100,20 +98,20 @@ class MainSidebar extends React.Component<Props> {
state: { fromMenu: true },
}}
icon={<SearchIcon color="currentColor" />}
label={t("Search")}
label="Search"
exact={false}
/>
<SidebarLink
to="/starred"
icon={<StarredIcon color="currentColor" />}
exact={false}
label={t("Starred")}
label="Starred"
/>
<SidebarLink
to="/templates"
icon={<ShapesIcon color="currentColor" />}
exact={false}
label={t("Templates")}
label="Templates"
active={
documents.active ? documents.active.template : undefined
}
@@ -123,7 +121,7 @@ class MainSidebar extends React.Component<Props> {
icon={<EditIcon color="currentColor" />}
label={
<Drafts align="center">
{t("Drafts")}
Drafts
{documents.totalDrafts > 0 && (
<Bubble count={documents.totalDrafts} />
)}
@@ -148,7 +146,7 @@ class MainSidebar extends React.Component<Props> {
to="/archive"
icon={<ArchiveIcon color="currentColor" />}
exact={false}
label={t("Archive")}
label="Archive"
active={
documents.active
? documents.active.isArchived && !documents.active.isDeleted
@@ -159,7 +157,7 @@ class MainSidebar extends React.Component<Props> {
to="/trash"
icon={<TrashIcon color="currentColor" />}
exact={false}
label={t("Trash")}
label="Trash"
active={
documents.active ? documents.active.isDeleted : undefined
}
@@ -169,21 +167,21 @@ class MainSidebar extends React.Component<Props> {
to="/settings/people"
onClick={this.handleInviteModalOpen}
icon={<PlusIcon color="currentColor" />}
label={t("Invite people…")}
label="Invite people…"
/>
)}
</Section>
</Scrollable>
</Flex>
<Modal
title={t("Invite people")}
title="Invite people"
onRequestClose={this.handleInviteModalClose}
isOpen={this.inviteModalOpen}
>
<Invite onSubmit={this.handleInviteModalClose} />
</Modal>
<Modal
title={t("Create a collection")}
title="Create a collection"
onRequestClose={this.handleCreateCollectionModalClose}
isOpen={this.createCollectionModalOpen}
>
@@ -198,6 +196,4 @@ const Drafts = styled(Flex)`
height: 24px;
`;
export default withTranslation()<MainSidebar>(
inject("documents", "policies", "auth")(MainSidebar)
);
export default inject("documents", "policies", "auth")(MainSidebar);
+14 -18
View File
@@ -13,7 +13,6 @@ import {
ExpandedIcon,
} from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import type { RouterHistory } from "react-router-dom";
import styled from "styled-components";
import AuthStore from "stores/AuthStore";
@@ -37,7 +36,6 @@ type Props = {
history: RouterHistory,
policies: PoliciesStore,
auth: AuthStore,
t: TFunction,
};
@observer
@@ -47,7 +45,7 @@ class SettingsSidebar extends React.Component<Props> {
};
render() {
const { policies, t, auth } = this.props;
const { policies, auth } = this.props;
const { team } = auth;
if (!team) return null;
@@ -58,7 +56,7 @@ class SettingsSidebar extends React.Component<Props> {
<HeaderBlock
subheading={
<ReturnToApp align="center">
<BackIcon color="currentColor" /> {t("Return to App")}
<BackIcon color="currentColor" /> Return to App
</ReturnToApp>
}
teamName={team.name}
@@ -73,17 +71,17 @@ class SettingsSidebar extends React.Component<Props> {
<SidebarLink
to="/settings"
icon={<ProfileIcon color="currentColor" />}
label={t("Profile")}
label="Profile"
/>
<SidebarLink
to="/settings/notifications"
icon={<EmailIcon color="currentColor" />}
label={t("Notifications")}
label="Notifications"
/>
<SidebarLink
to="/settings/tokens"
icon={<CodeIcon color="currentColor" />}
label={t("API Tokens")}
label="API Tokens"
/>
</Section>
<Section>
@@ -92,44 +90,44 @@ class SettingsSidebar extends React.Component<Props> {
<SidebarLink
to="/settings/details"
icon={<TeamIcon color="currentColor" />}
label={t("Details")}
label="Details"
/>
)}
{can.update && (
<SidebarLink
to="/settings/security"
icon={<PadlockIcon color="currentColor" />}
label={t("Security")}
label="Security"
/>
)}
<SidebarLink
to="/settings/people"
icon={<UserIcon color="currentColor" />}
exact={false}
label={t("People")}
label="People"
/>
<SidebarLink
to="/settings/groups"
icon={<GroupIcon color="currentColor" />}
exact={false}
label={t("Groups")}
label="Groups"
/>
<SidebarLink
to="/settings/shares"
icon={<LinkIcon color="currentColor" />}
label={t("Share Links")}
label="Share Links"
/>
{can.export && (
<SidebarLink
to="/settings/export"
icon={<DocumentIcon color="currentColor" />}
label={t("Export Data")}
label="Export Data"
/>
)}
</Section>
{can.update && (
<Section>
<Header>{t("Integrations")}</Header>
<Header>Integrations</Header>
<SidebarLink
to="/settings/integrations/slack"
icon={<SlackIcon color="currentColor" />}
@@ -146,7 +144,7 @@ class SettingsSidebar extends React.Component<Props> {
)}
{can.update && !isHosted && (
<Section>
<Header>{t("Installation")}</Header>
<Header>Installation</Header>
<Version />
</Section>
)}
@@ -166,6 +164,4 @@ const ReturnToApp = styled(Flex)`
height: 16px;
`;
export default withTranslation()<SettingsSidebar>(
inject("auth", "policies")(SettingsSidebar)
);
export default inject("auth", "policies")(SettingsSidebar);
+4 -32
View File
@@ -8,7 +8,6 @@ import styled from "styled-components";
import breakpoint from "styled-components-breakpoint";
import Fade from "components/Fade";
import Flex from "components/Flex";
import CollapseToggle, { Button } from "./components/CollapseToggle";
import usePrevious from "hooks/usePrevious";
import useStores from "hooks/useStores";
@@ -27,18 +26,14 @@ function Sidebar({ location, children }: Props) {
if (location !== previousLocation) {
ui.hideMobileSidebar();
}
}, [ui, location, previousLocation]);
}, [ui, location]);
const content = (
<Container
editMode={ui.editMode}
mobileSidebarVisible={ui.mobileSidebarVisible}
collapsed={ui.editMode || ui.sidebarCollapsed}
column
>
<CollapseToggle
collapsed={ui.sidebarCollapsed}
onClick={ui.toggleCollapsedSidebar}
/>
<Toggle
onClick={ui.toggleMobileSidebar}
mobileSidebarVisible={ui.mobileSidebarVisible}
@@ -68,7 +63,7 @@ const Container = styled(Flex)`
bottom: 0;
width: 100%;
background: ${(props) => props.theme.sidebarBackground};
transition: box-shadow, 100ms, ease-in-out, left 100ms ease-out,
transition: left 100ms ease-out,
${(props) => props.theme.backgroundTransition};
margin-left: ${(props) => (props.mobileSidebarVisible ? 0 : "-100%")};
z-index: ${(props) => props.theme.depths.sidebar};
@@ -95,33 +90,10 @@ const Container = styled(Flex)`
}
${breakpoint("tablet")`
left: ${(props) =>
props.collapsed
? `calc(-${props.theme.sidebarWidth} + ${props.theme.sidebarCollapsedWidth})`
: 0};
left: ${(props) => (props.editMode ? `-${props.theme.sidebarWidth}` : 0)};
width: ${(props) => props.theme.sidebarWidth};
margin: 0;
z-index: 3;
&:hover,
&:focus-within {
left: 0;
box-shadow: ${(props) =>
props.collapsed ? "rgba(0, 0, 0, 0.2) 1px 0 4px" : "none"};
& ${Button} {
opacity: .75;
}
& ${Button}:hover {
opacity: 1;
}
}
&:not(:hover):not(:focus-within) > div {
opacity: ${(props) => (props.collapsed ? "0" : "1")};
transition: opacity 100ms ease-in-out;
}
`};
`;
@@ -1,59 +0,0 @@
// @flow
import { NextIcon, BackIcon } from "outline-icons";
import * as React from "react";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import Tooltip from "components/Tooltip";
import { meta } from "utils/keyboard";
type Props = {|
collapsed: boolean,
onClick?: () => void,
|};
function CollapseToggle({ collapsed, ...rest }: Props) {
const { t } = useTranslation();
return (
<Tooltip
tooltip={collapsed ? t("Expand") : t("Collapse")}
shortcut={`${meta}+.`}
delay={500}
placement="bottom"
>
<Button {...rest} aria-hidden>
{collapsed ? (
<NextIcon color="currentColor" />
) : (
<BackIcon color="currentColor" />
)}
</Button>
</Tooltip>
);
}
export const Button = styled.button`
display: block;
position: absolute;
top: 28px;
right: 8px;
border: 0;
width: 24px;
height: 24px;
z-index: 1;
font-weight: 600;
color: ${(props) => props.theme.sidebarText};
background: ${(props) => props.theme.sidebarItemBackground};
transition: opacity 100ms ease-in-out;
border-radius: 4px;
opacity: 0;
cursor: pointer;
padding: 0;
&:hover {
color: ${(props) => props.theme.white};
background: ${(props) => props.theme.primary};
}
`;
export default CollapseToggle;
@@ -1,109 +1,96 @@
// @flow
import { observable } from "mobx";
import { observer } from "mobx-react";
import * as React from "react";
import { useDrop } from "react-dnd";
import DocumentsStore from "stores/DocumentsStore";
import UiStore from "stores/UiStore";
import Collection from "models/Collection";
import Document from "models/Document";
import CollectionIcon from "components/CollectionIcon";
import DropToImport from "components/DropToImport";
import Flex from "components/Flex";
import DocumentLink from "./DocumentLink";
import EditableTitle from "./EditableTitle";
import SidebarLink from "./SidebarLink";
import useStores from "hooks/useStores";
import CollectionMenu from "menus/CollectionMenu";
type Props = {|
collection: Collection,
ui: UiStore,
canUpdate: boolean,
documents: DocumentsStore,
activeDocument: ?Document,
prefetchDocument: (id: string) => Promise<void>,
|};
function CollectionLink({
collection,
activeDocument,
prefetchDocument,
canUpdate,
ui,
}: Props) {
const [menuOpen, setMenuOpen] = React.useState(false);
@observer
class CollectionLink extends React.Component<Props> {
@observable menuOpen = false;
const handleTitleChange = React.useCallback(
async (name: string) => {
await collection.save({ name });
},
[collection]
);
handleTitleChange = async (name: string) => {
await this.props.collection.save({ name });
};
const { documents, policies } = useStores();
const expanded = collection.id === ui.activeCollectionId;
render() {
const {
collection,
documents,
activeDocument,
prefetchDocument,
canUpdate,
ui,
} = this.props;
const expanded = collection.id === ui.activeCollectionId;
// Droppable
const [{ isOver, canDrop }, drop] = useDrop({
accept: "document",
drop: (item, monitor) => {
if (!collection) return;
documents.move(item.id, collection.id);
},
canDrop: (item, monitor) => {
return policies.abilities(collection.id).update;
},
collect: (monitor) => ({
isOver: !!monitor.isOver(),
canDrop: monitor.canDrop(),
}),
});
return (
<>
<div ref={drop}>
<DropToImport key={collection.id} collectionId={collection.id}>
<SidebarLink
key={collection.id}
to={collection.url}
icon={
<CollectionIcon collection={collection} expanded={expanded} />
}
iconColor={collection.color}
expanded={expanded}
menuOpen={menuOpen}
isActiveDrop={isOver && canDrop}
label={
<EditableTitle
title={collection.name}
onSubmit={handleTitleChange}
canUpdate={canUpdate}
/>
}
exact={false}
menu={
<CollectionMenu
position="right"
return (
<DropToImport
key={collection.id}
collectionId={collection.id}
activeClassName="activeDropZone"
>
<SidebarLink
key={collection.id}
to={collection.url}
icon={<CollectionIcon collection={collection} expanded={expanded} />}
iconColor={collection.color}
expanded={expanded}
hideDisclosure
menuOpen={this.menuOpen}
label={
<EditableTitle
title={collection.name}
onSubmit={this.handleTitleChange}
canUpdate={canUpdate}
/>
}
exact={false}
menu={
<CollectionMenu
position="right"
collection={collection}
onOpen={() => (this.menuOpen = true)}
onClose={() => (this.menuOpen = false)}
/>
}
>
<Flex column>
{collection.documents.map((node) => (
<DocumentLink
key={node.id}
node={node}
documents={documents}
collection={collection}
onOpen={() => setMenuOpen(true)}
onClose={() => setMenuOpen(false)}
activeDocument={activeDocument}
prefetchDocument={prefetchDocument}
canUpdate={canUpdate}
depth={1.5}
/>
}
></SidebarLink>
</DropToImport>
</div>
{expanded &&
collection.documents.map((node) => (
<DocumentLink
key={node.id}
node={node}
collection={collection}
activeDocument={activeDocument}
prefetchDocument={prefetchDocument}
canUpdate={canUpdate}
depth={1.5}
/>
))}
</>
);
))}
</Flex>
</SidebarLink>
</DropToImport>
);
}
}
export default observer(CollectionLink);
export default CollectionLink;
@@ -2,7 +2,6 @@
import { observer, inject } from "mobx-react";
import { PlusIcon } from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import keydown from "react-keydown";
import { withRouter, type RouterHistory } from "react-router-dom";
@@ -25,7 +24,6 @@ type Props = {
documents: DocumentsStore,
onCreateCollection: () => void,
ui: UiStore,
t: TFunction,
};
@observer
@@ -54,13 +52,14 @@ class Collections extends React.Component<Props> {
}
render() {
const { collections, ui, policies, documents, t } = this.props;
const { collections, ui, policies, documents } = this.props;
const content = (
<>
{collections.orderedData.map((collection) => (
<CollectionLink
key={collection.id}
documents={documents}
collection={collection}
activeDocument={documents.active}
prefetchDocument={documents.prefetchDocument}
@@ -72,7 +71,7 @@ class Collections extends React.Component<Props> {
to="/collections"
onClick={this.props.onCreateCollection}
icon={<PlusIcon color="currentColor" />}
label={`${t("New collection")}`}
label="New collection"
exact
/>
</>
@@ -80,7 +79,7 @@ class Collections extends React.Component<Props> {
return (
<Flex column>
<Header>{t("Collections")}</Header>
<Header>Collections</Header>
{collections.isLoaded ? (
this.isPreloaded ? (
content
@@ -95,6 +94,9 @@ class Collections extends React.Component<Props> {
}
}
export default withTranslation()<Collections>(
inject("collections", "ui", "documents", "policies")(withRouter(Collections))
);
export default inject(
"collections",
"ui",
"documents",
"policies"
)(withRouter(Collections));
+122 -182
View File
@@ -1,22 +1,22 @@
// @flow
import { observable } from "mobx";
import { observer } from "mobx-react";
import { CollapsedIcon } from "outline-icons";
import * as React from "react";
import { useDrag, useDrop } from "react-dnd";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import DocumentsStore from "stores/DocumentsStore";
import Collection from "models/Collection";
import Document from "models/Document";
import DropToImport from "components/DropToImport";
import Fade from "components/Fade";
import Flex from "components/Flex";
import EditableTitle from "./EditableTitle";
import SidebarLink from "./SidebarLink";
import useStores from "hooks/useStores";
import DocumentMenu from "menus/DocumentMenu";
import { type NavigationNode } from "types";
type Props = {|
node: NavigationNode,
documents: DocumentsStore,
canUpdate: boolean,
collection?: Collection,
activeDocument: ?Document,
@@ -25,199 +25,139 @@ type Props = {|
depth: number,
|};
function DocumentLink({
node,
collection,
activeDocument,
activeDocumentRef,
prefetchDocument,
depth,
canUpdate,
}: Props) {
const { documents, policies } = useStores();
const { t } = useTranslation();
@observer
class DocumentLink extends React.Component<Props> {
@observable menuOpen = false;
const isActiveDocument = activeDocument && activeDocument.id === node.id;
const hasChildDocuments = !!node.children.length;
const document = documents.get(node.id);
const { fetchChildDocuments } = documents;
React.useEffect(() => {
if (isActiveDocument && hasChildDocuments) {
fetchChildDocuments(node.id);
componentDidMount() {
if (this.isActiveDocument() && this.hasChildDocuments()) {
this.props.documents.fetchChildDocuments(this.props.node.id);
}
}, [fetchChildDocuments, node, hasChildDocuments, isActiveDocument]);
}
const pathToNode = React.useMemo(
() =>
collection && collection.pathToDocument(node.id).map((entry) => entry.id),
[collection, node]
);
componentDidUpdate(prevProps: Props) {
if (prevProps.activeDocument !== this.props.activeDocument) {
if (this.isActiveDocument() && this.hasChildDocuments()) {
this.props.documents.fetchChildDocuments(this.props.node.id);
}
}
}
const showChildren = React.useMemo(() => {
return !!(
hasChildDocuments &&
handleMouseEnter = (ev: SyntheticEvent<>) => {
const { node, prefetchDocument } = this.props;
ev.stopPropagation();
ev.preventDefault();
prefetchDocument(node.id);
};
handleTitleChange = async (title: string) => {
const document = this.props.documents.get(this.props.node.id);
if (!document) return;
await this.props.documents.update({
id: document.id,
lastRevision: document.revision,
text: document.text,
title,
});
};
isActiveDocument = () => {
return (
this.props.activeDocument &&
this.props.activeDocument.id === this.props.node.id
);
};
hasChildDocuments = () => {
return !!this.props.node.children.length;
};
render() {
const {
node,
documents,
collection,
activeDocument,
activeDocumentRef,
prefetchDocument,
depth,
canUpdate,
} = this.props;
const showChildren = !!(
activeDocument &&
collection &&
(collection
.pathToDocument(activeDocument.id)
.pathToDocument(activeDocument)
.map((entry) => entry.id)
.includes(node.id) ||
isActiveDocument)
this.isActiveDocument())
);
}, [hasChildDocuments, activeDocument, isActiveDocument, node, collection]);
const document = documents.get(node.id);
const title = node.title || "Untitled";
const [expanded, setExpanded] = React.useState(showChildren);
React.useEffect(() => {
if (showChildren) {
setExpanded(showChildren);
}
}, [showChildren]);
const handleDisclosureClick = React.useCallback(
(ev: SyntheticEvent<>) => {
ev.preventDefault();
ev.stopPropagation();
setExpanded(!expanded);
},
[expanded]
);
const handleMouseEnter = React.useCallback(
(ev: SyntheticEvent<>) => {
prefetchDocument(node.id);
},
[prefetchDocument, node]
);
const handleTitleChange = React.useCallback(
async (title: string) => {
if (!document) return;
await documents.update({
id: document.id,
lastRevision: document.revision,
text: document.text,
title,
});
},
[documents, document]
);
const [menuOpen, setMenuOpen] = React.useState(false);
const isMoving = documents.movingDocumentId === node.id;
// Draggable
const [{ isDragging }, drag] = useDrag({
item: { type: "document", ...node, depth, active: isActiveDocument },
collect: (monitor) => ({
isDragging: !!monitor.isDragging(),
}),
canDrag: (monitor) => {
return policies.abilities(node.id).move;
},
});
// Droppable
const [{ isOver, canDrop }, drop] = useDrop({
accept: "document",
drop: async (item, monitor) => {
if (!collection) return;
documents.move(item.id, collection.id, node.id);
},
canDrop: (item, monitor) =>
pathToNode && !pathToNode.includes(monitor.getItem().id),
collect: (monitor) => ({
isOver: !!monitor.isOver(),
canDrop: monitor.canDrop(),
}),
});
return (
<>
<Draggable
return (
<Flex
column
key={node.id}
ref={drag}
$isDragging={isDragging}
$isMoving={isMoving}
ref={this.isActiveDocument() ? activeDocumentRef : undefined}
onMouseEnter={this.handleMouseEnter}
>
<div ref={drop}>
<DropToImport documentId={node.id} activeClassName="activeDropZone">
<SidebarLink
innerRef={isActiveDocument ? activeDocumentRef : undefined}
onMouseEnter={handleMouseEnter}
to={{
pathname: node.url,
state: { title: node.title },
}}
label={
<>
{hasChildDocuments && (
<Disclosure
expanded={expanded && !isDragging}
onClick={handleDisclosureClick}
/>
)}
<EditableTitle
title={node.title || t("Untitled")}
onSubmit={handleTitleChange}
<DropToImport documentId={node.id} activeClassName="activeDropZone">
<SidebarLink
to={{
pathname: node.url,
state: { title: node.title },
}}
expanded={showChildren ? true : undefined}
label={
<EditableTitle
title={title}
onSubmit={this.handleTitleChange}
canUpdate={canUpdate}
/>
}
depth={depth}
exact={false}
menuOpen={this.menuOpen}
menu={
document ? (
<Fade>
<DocumentMenu
position="right"
document={document}
onOpen={() => (this.menuOpen = true)}
onClose={() => (this.menuOpen = false)}
/>
</Fade>
) : undefined
}
>
{this.hasChildDocuments() && (
<DocumentChildren column>
{node.children.map((childNode) => (
<DocumentLink
key={childNode.id}
collection={collection}
node={childNode}
documents={documents}
activeDocument={activeDocument}
prefetchDocument={prefetchDocument}
depth={depth + 1}
canUpdate={canUpdate}
/>
</>
}
isActiveDrop={isOver && canDrop}
depth={depth}
exact={false}
menuOpen={menuOpen}
menu={
document && !isMoving ? (
<Fade>
<DocumentMenu
position="right"
document={document}
onOpen={() => setMenuOpen(true)}
onClose={() => setMenuOpen(false)}
/>
</Fade>
) : undefined
}
/>
</DropToImport>
</div>
</Draggable>
{expanded && !isDragging && (
<>
{node.children.map((childNode) => (
<ObservedDocumentLink
key={childNode.id}
collection={collection}
node={childNode}
activeDocument={activeDocument}
prefetchDocument={prefetchDocument}
depth={depth + 1}
canUpdate={canUpdate}
/>
))}
</>
)}
</>
);
))}
</DocumentChildren>
)}
</SidebarLink>
</DropToImport>
</Flex>
);
}
}
const Draggable = styled("div")`
opacity: ${(props) => (props.$isDragging || props.$isMoving ? 0.5 : 1)};
pointer-events: ${(props) => (props.$isMoving ? "none" : "all")};
`;
const DocumentChildren = styled(Flex)``;
const Disclosure = styled(CollapsedIcon)`
position: absolute;
left: -24px;
${({ expanded }) => !expanded && "transform: rotate(-90deg);"};
`;
const ObservedDocumentLink = observer(DocumentLink);
export default ObservedDocumentLink;
export default DocumentLink;
@@ -82,7 +82,6 @@ function EditableTitle({ title, onSubmit, canUpdate }: Props) {
const Input = styled.input`
margin-left: -4px;
color: ${(props) => props.theme.sidebarText};
background: ${(props) => props.theme.background};
width: calc(100% - 10px);
border-radius: 3px;
@@ -61,7 +61,7 @@ const Header = styled.button`
display: flex;
align-items: center;
flex-shrink: 0;
padding: 20px 24px;
padding: 16px 24px;
position: relative;
background: none;
line-height: inherit;
@@ -1,23 +1,25 @@
// @flow
import { observer } from "mobx-react";
import { CollapsedIcon } from "outline-icons";
import * as React from "react";
import { withRouter, NavLink } from "react-router-dom";
import styled, { withTheme } from "styled-components";
import Flex from "components/Flex";
import { type Theme } from "types";
type Props = {
to?: string | Object,
href?: string | Object,
innerRef?: (?HTMLElement) => void,
onClick?: (SyntheticEvent<>) => void,
onMouseEnter?: (SyntheticEvent<>) => void,
children?: React.Node,
icon?: React.Node,
expanded?: boolean,
label?: React.Node,
menu?: React.Node,
menuOpen?: boolean,
hideDisclosure?: boolean,
iconColor?: string,
active?: boolean,
isActiveDrop?: boolean,
theme: Theme,
exact?: boolean,
depth?: number,
@@ -27,50 +29,75 @@ function SidebarLink({
icon,
children,
onClick,
onMouseEnter,
to,
label,
active,
isActiveDrop,
menu,
menuOpen,
hideDisclosure,
theme,
exact,
href,
innerRef,
depth,
...rest
}: Props) {
const [expanded, setExpanded] = React.useState(rest.expanded);
const style = React.useMemo(() => {
return {
paddingLeft: `${(depth || 0) * 16 + 16}px`,
};
}, [depth]);
React.useEffect(() => {
if (rest.expanded !== undefined) {
setExpanded(rest.expanded);
}
}, [rest.expanded]);
const handleClick = React.useCallback(
(ev: SyntheticEvent<>) => {
ev.preventDefault();
ev.stopPropagation();
setExpanded(!expanded);
},
[expanded]
);
const handleExpand = React.useCallback(() => {
setExpanded(true);
}, []);
const showDisclosure = !!children && !hideDisclosure;
const activeStyle = {
color: theme.text,
fontWeight: 600,
background: theme.sidebarItemBackground,
fontWeight: 600,
...style,
};
return (
<StyledNavLink
$isActiveDrop={isActiveDrop}
activeStyle={isActiveDrop ? undefined : activeStyle}
style={active ? activeStyle : style}
onClick={onClick}
onMouseEnter={onMouseEnter}
exact={exact !== false}
to={to}
as={to ? undefined : href ? "a" : "div"}
href={href}
ref={innerRef}
>
{icon && <IconWrapper>{icon}</IconWrapper>}
<Label>{label}</Label>
{menu && <Action menuOpen={menuOpen}>{menu}</Action>}
</StyledNavLink>
<Wrapper column>
<StyledNavLink
activeStyle={activeStyle}
style={active ? activeStyle : style}
onClick={onClick}
exact={exact !== false}
to={to}
as={to ? undefined : href ? "a" : "div"}
href={href}
>
{icon && <IconWrapper>{icon}</IconWrapper>}
<Label onClick={handleExpand}>
{showDisclosure && (
<Disclosure expanded={expanded} onClick={handleClick} />
)}
{label}
</Label>
{menu && <Action menuOpen={menuOpen}>{menu}</Action>}
</StyledNavLink>
{expanded && children}
</Wrapper>
);
}
@@ -106,20 +133,12 @@ const StyledNavLink = styled(NavLink)`
text-overflow: ellipsis;
padding: 4px 16px;
border-radius: 4px;
background: ${(props) =>
props.$isActiveDrop ? props.theme.slateDark : "inherit"};
color: ${(props) =>
props.$isActiveDrop ? props.theme.white : props.theme.sidebarText};
color: ${(props) => props.theme.sidebarText};
font-size: 15px;
cursor: pointer;
svg {
${(props) => (props.$isActiveDrop ? `fill: ${props.theme.white};` : "")}
}
&:hover {
color: ${(props) =>
props.$isActiveDrop ? props.theme.white : props.theme.text};
color: ${(props) => props.theme.text};
}
&:focus {
@@ -134,6 +153,10 @@ const StyledNavLink = styled(NavLink)`
}
`;
const Wrapper = styled(Flex)`
position: relative;
`;
const Label = styled.div`
position: relative;
width: 100%;
@@ -141,4 +164,11 @@ const Label = styled.div`
line-height: 1.6;
`;
export default withRouter(withTheme(SidebarLink));
const Disclosure = styled(CollapsedIcon)`
position: absolute;
left: -24px;
${({ expanded }) => !expanded && "transform: rotate(-90deg);"};
`;
export default withRouter(withTheme(observer(SidebarLink)));
+34 -36
View File
@@ -3,7 +3,6 @@ import distanceInWordsToNow from "date-fns/distance_in_words_to_now";
import format from "date-fns/format";
import * as React from "react";
import Tooltip from "components/Tooltip";
import useStores from "hooks/useStores";
let callbacks = [];
@@ -29,45 +28,44 @@ type Props = {
shorten?: boolean,
};
function Time(props: Props) {
const { auth } = useStores();
const [_, setMinutesMounted] = React.useState(0); // eslint-disable-line no-unused-vars
const callback = React.useRef();
class Time extends React.Component<Props> {
removeEachMinuteCallback: () => void;
React.useEffect(() => {
callback.current = eachMinute(() => {
setMinutesMounted((state) => ++state);
componentDidMount() {
this.removeEachMinuteCallback = eachMinute(() => {
this.forceUpdate();
});
return () => {
if (callback.current) {
callback.current();
}
};
}, []);
const { shorten, addSuffix } = props;
let content = distanceInWordsToNow(props.dateTime, {
addSuffix,
locale: auth.user ? auth.user.language : undefined,
});
if (shorten) {
content = content
.replace("about", "")
.replace("less than a minute ago", "just now")
.replace("minute", "min");
}
return (
<Tooltip
tooltip={format(props.dateTime, "MMMM Do, YYYY h:mm a")}
delay={props.tooltipDelay}
placement="bottom"
>
<time dateTime={props.dateTime}>{props.children || content}</time>
</Tooltip>
);
componentWillUnmount() {
this.removeEachMinuteCallback();
}
render() {
const { shorten, addSuffix } = this.props;
let content = distanceInWordsToNow(this.props.dateTime, {
addSuffix,
});
if (shorten) {
content = content
.replace("about", "")
.replace("less than a minute ago", "just now")
.replace("minute", "min");
}
return (
<Tooltip
tooltip={format(this.props.dateTime, "MMMM Do, YYYY h:mm a")}
delay={this.props.tooltipDelay}
placement="bottom"
>
<time dateTime={this.props.dateTime}>
{this.props.children || content}
</time>
</Tooltip>
);
}
}
export default Time;
-9
View File
@@ -1,9 +0,0 @@
// @flow
import invariant from "invariant";
import useStores from "./useStores";
export default function useCurrentUser() {
const { auth } = useStores();
invariant(auth.user, "user required");
return auth.user;
}
+9 -15
View File
@@ -3,11 +3,9 @@ import "mobx-react-lite/batchingForReactDom";
import "focus-visible";
import { Provider } from "mobx-react";
import * as React from "react";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
import { render } from "react-dom";
import { BrowserRouter as Router } from "react-router-dom";
import { initI18n } from "shared/i18n";
import stores from "stores";
import ErrorBoundary from "components/ErrorBoundary";
import ScrollToTop from "components/ScrollToTop";
@@ -16,8 +14,6 @@ import Toasts from "components/Toasts";
import Routes from "./routes";
import env from "env";
initI18n();
const element = document.getElementById("root");
if (element) {
@@ -25,16 +21,14 @@ if (element) {
<ErrorBoundary>
<Provider {...stores}>
<Theme>
<DndProvider backend={HTML5Backend}>
<Router>
<>
<ScrollToTop>
<Routes />
</ScrollToTop>
<Toasts />
</>
</Router>
</DndProvider>
<Router>
<>
<ScrollToTop>
<Routes />
</ScrollToTop>
<Toasts />
</>
</Router>
</Theme>
</Provider>
</ErrorBoundary>,
+14 -18
View File
@@ -3,7 +3,6 @@ import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import { SunIcon, MoonIcon } from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { Link } from "react-router-dom";
import styled from "styled-components";
import AuthStore from "stores/AuthStore";
@@ -24,7 +23,6 @@ type Props = {
label: React.Node,
ui: UiStore,
auth: AuthStore,
t: TFunction,
};
@observer
@@ -44,14 +42,14 @@ class AccountMenu extends React.Component<Props> {
};
render() {
const { ui, t } = this.props;
const { ui } = this.props;
return (
<>
<Modal
isOpen={this.keyboardShortcutsOpen}
onRequestClose={this.handleCloseKeyboardShortcuts}
title={t("Keyboard shortcuts")}
title="Keyboard shortcuts"
>
<KeyboardShortcuts />
</Modal>
@@ -60,23 +58,23 @@ class AccountMenu extends React.Component<Props> {
label={this.props.label}
>
<DropdownMenuItem as={Link} to={settings()}>
{t("Settings")}
Settings
</DropdownMenuItem>
<DropdownMenuItem onClick={this.handleOpenKeyboardShortcuts}>
{t("Keyboard shortcuts")}
Keyboard shortcuts
</DropdownMenuItem>
<DropdownMenuItem href={developers()} target="_blank">
{t("API documentation")}
API documentation
</DropdownMenuItem>
<hr />
<DropdownMenuItem href={changelog()} target="_blank">
{t("Changelog")}
Changelog
</DropdownMenuItem>
<DropdownMenuItem href={mailToUrl()} target="_blank">
{t("Send us feedback")}
Send us feedback
</DropdownMenuItem>
<DropdownMenuItem href={githubIssuesUrl()} target="_blank">
{t("Report a bug")}
Report a bug
</DropdownMenuItem>
<hr />
<DropdownMenu
@@ -89,7 +87,7 @@ class AccountMenu extends React.Component<Props> {
label={
<DropdownMenuItem>
<ChangeTheme justify="space-between">
{t("Appearance")}
Appearance
{ui.resolvedTheme === "light" ? <SunIcon /> : <MoonIcon />}
</ChangeTheme>
</DropdownMenuItem>
@@ -100,24 +98,24 @@ class AccountMenu extends React.Component<Props> {
onClick={() => ui.setTheme("system")}
selected={ui.theme === "system"}
>
{t("System")}
System
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => ui.setTheme("light")}
selected={ui.theme === "light"}
>
{t("Light")}
Light
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => ui.setTheme("dark")}
selected={ui.theme === "dark"}
>
{t("Dark")}
Dark
</DropdownMenuItem>
</DropdownMenu>
<hr />
<DropdownMenuItem onClick={this.handleLogout}>
{t("Log out")}
Log out
</DropdownMenuItem>
</DropdownMenu>
</>
@@ -129,6 +127,4 @@ const ChangeTheme = styled(Flex)`
width: 100%;
`;
export default withTranslation()<AccountMenu>(
inject("ui", "auth")(AccountMenu)
);
export default inject("ui", "auth")(AccountMenu);
+15 -16
View File
@@ -2,7 +2,6 @@
import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { withRouter, type RouterHistory } from "react-router-dom";
import DocumentsStore from "stores/DocumentsStore";
import PoliciesStore from "stores/PoliciesStore";
@@ -28,7 +27,6 @@ type Props = {
history: RouterHistory,
onOpen?: () => void,
onClose?: () => void,
t: TFunction,
};
@observer
@@ -114,7 +112,6 @@ class CollectionMenu extends React.Component<Props> {
position,
onOpen,
onClose,
t,
} = this.props;
const can = policies.abilities(collection.id);
@@ -131,7 +128,7 @@ class CollectionMenu extends React.Component<Props> {
</VisuallyHidden>
<Modal
title={t("Collection permissions")}
title="Collection permissions"
onRequestClose={this.handleMembersModalClose}
isOpen={this.showCollectionMembers}
>
@@ -146,12 +143,12 @@ class CollectionMenu extends React.Component<Props> {
<DropdownMenuItems
items={[
{
title: t("New document"),
title: "New document",
visible: !!(collection && can.update),
onClick: this.onNewDocument,
},
{
title: t("Import document"),
title: "Import document",
visible: !!(collection && can.update),
onClick: this.onImportDocument,
},
@@ -159,22 +156,22 @@ class CollectionMenu extends React.Component<Props> {
type: "separator",
},
{
title: `${t("Edit")}`,
title: "Edit",
visible: !!(collection && can.update),
onClick: this.handleEditCollectionOpen,
},
{
title: `${t("Permissions")}`,
title: "Permissions",
visible: !!(collection && can.update),
onClick: this.handleMembersModalOpen,
},
{
title: `${t("Export")}`,
title: "Export",
visible: !!(collection && can.export),
onClick: this.handleExportCollectionOpen,
},
{
title: `${t("Delete")}`,
title: "Delete",
visible: !!(collection && can.delete),
onClick: this.handleDeleteCollectionOpen,
},
@@ -182,7 +179,7 @@ class CollectionMenu extends React.Component<Props> {
/>
</DropdownMenu>
<Modal
title={t("Edit collection")}
title="Edit collection"
isOpen={this.showCollectionEdit}
onRequestClose={this.handleEditCollectionClose}
>
@@ -192,7 +189,7 @@ class CollectionMenu extends React.Component<Props> {
/>
</Modal>
<Modal
title={t("Delete collection")}
title="Delete collection"
isOpen={this.showCollectionDelete}
onRequestClose={this.handleDeleteCollectionClose}
>
@@ -202,7 +199,7 @@ class CollectionMenu extends React.Component<Props> {
/>
</Modal>
<Modal
title={t("Export collection")}
title="Export collection"
isOpen={this.showCollectionExport}
onRequestClose={this.handleExportCollectionClose}
>
@@ -216,6 +213,8 @@ class CollectionMenu extends React.Component<Props> {
}
}
export default withTranslation()<CollectionMenu>(
inject("ui", "documents", "policies")(withRouter(CollectionMenu))
);
export default inject(
"ui",
"documents",
"policies"
)(withRouter(CollectionMenu));
+30 -41
View File
@@ -2,7 +2,6 @@
import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { Redirect } from "react-router-dom";
import AuthStore from "stores/AuthStore";
import CollectionStore from "stores/CollectionsStore";
@@ -39,7 +38,6 @@ type Props = {
label?: React.Node,
onOpen?: () => void,
onClose?: () => void,
t: TFunction,
};
@observer
@@ -85,8 +83,7 @@ class DocumentMenu extends React.Component<Props> {
// when duplicating, go straight to the duplicated document content
this.redirectTo = duped.url;
const { t } = this.props;
this.props.ui.showToast(t("Document duplicated"));
this.props.ui.showToast("Document duplicated");
};
handleOpenTemplateModal = () => {
@@ -103,8 +100,7 @@ class DocumentMenu extends React.Component<Props> {
handleArchive = async (ev: SyntheticEvent<>) => {
await this.props.document.archive();
const { t } = this.props;
this.props.ui.showToast(t("Document archived"));
this.props.ui.showToast("Document archived");
};
handleRestore = async (
@@ -112,14 +108,12 @@ class DocumentMenu extends React.Component<Props> {
options?: { collectionId: string }
) => {
await this.props.document.restore(options);
const { t } = this.props;
this.props.ui.showToast(t("Document restored"));
this.props.ui.showToast("Document restored");
};
handleUnpublish = async (ev: SyntheticEvent<>) => {
await this.props.document.unpublish();
const { t } = this.props;
this.props.ui.showToast(t("Document unpublished"));
this.props.ui.showToast("Document unpublished");
};
handlePin = (ev: SyntheticEvent<>) => {
@@ -170,7 +164,6 @@ class DocumentMenu extends React.Component<Props> {
label,
onOpen,
onClose,
t,
} = this.props;
const can = policies.abilities(document.id);
@@ -190,17 +183,17 @@ class DocumentMenu extends React.Component<Props> {
<DropdownMenuItems
items={[
{
title: t("Restore"),
title: "Restore",
visible: !!can.unarchive,
onClick: this.handleRestore,
},
{
title: t("Restore"),
title: "Restore",
visible: !!(collection && can.restore),
onClick: this.handleRestore,
},
{
title: `${t("Restore")}`,
title: "Restore",
visible: !collection && !!can.restore,
style: {
left: -170,
@@ -211,7 +204,7 @@ class DocumentMenu extends React.Component<Props> {
items: [
{
type: "heading",
title: t("Choose a collection"),
title: "Choose a collection",
},
...collections.orderedData.map((collection) => {
const can = policies.abilities(collection.id);
@@ -231,37 +224,37 @@ class DocumentMenu extends React.Component<Props> {
],
},
{
title: t("Unpin"),
title: "Unpin",
onClick: this.handleUnpin,
visible: !!(showPin && document.pinned && can.unpin),
},
{
title: t("Pin to collection"),
title: "Pin to collection",
onClick: this.handlePin,
visible: !!(showPin && !document.pinned && can.pin),
},
{
title: t("Unstar"),
title: "Unstar",
onClick: this.handleUnstar,
visible: document.isStarred && !!can.unstar,
},
{
title: t("Star"),
title: "Star",
onClick: this.handleStar,
visible: !document.isStarred && !!can.star,
},
{
title: `${t("Share link")}`,
title: "Share link",
onClick: this.handleShareLink,
visible: canShareDocuments,
},
{
title: t("Enable embeds"),
title: "Enable embeds",
onClick: document.enableEmbeds,
visible: !!showToggleEmbeds && document.embedsDisabled,
},
{
title: t("Disable embeds"),
title: "Disable embeds",
onClick: document.disableEmbeds,
visible: !!showToggleEmbeds && !document.embedsDisabled,
},
@@ -269,42 +262,42 @@ class DocumentMenu extends React.Component<Props> {
type: "separator",
},
{
title: t("New nested document"),
title: "New nested document",
onClick: this.handleNewChild,
visible: !!can.createChildDocument,
},
{
title: `${t("Create template")}`,
title: "Create template",
onClick: this.handleOpenTemplateModal,
visible: !!can.update && !document.isTemplate,
},
{
title: t("Edit"),
title: "Edit",
onClick: this.handleEdit,
visible: !!can.update,
},
{
title: t("Duplicate"),
title: "Duplicate",
onClick: this.handleDuplicate,
visible: !!can.update,
},
{
title: t("Unpublish"),
title: "Unpublish",
onClick: this.handleUnpublish,
visible: !!can.unpublish,
},
{
title: t("Archive"),
title: "Archive",
onClick: this.handleArchive,
visible: !!can.archive,
},
{
title: `${t("Delete")}`,
title: "Delete",
onClick: this.handleDelete,
visible: !!can.delete,
},
{
title: `${t("Move")}`,
title: "Move",
onClick: this.handleMove,
visible: !!can.move,
},
@@ -312,17 +305,17 @@ class DocumentMenu extends React.Component<Props> {
type: "separator",
},
{
title: t("History"),
title: "History",
onClick: this.handleDocumentHistory,
visible: canViewHistory,
},
{
title: t("Download"),
title: "Download",
onClick: this.handleExport,
visible: !!can.download,
},
{
title: t("Print"),
title: "Print",
onClick: window.print,
visible: !!showPrint,
},
@@ -330,9 +323,7 @@ class DocumentMenu extends React.Component<Props> {
/>
</DropdownMenu>
<Modal
title={t("Delete {{ documentName }}", {
documentName: this.props.document.noun,
})}
title={`Delete ${this.props.document.noun}`}
onRequestClose={this.handleCloseDeleteModal}
isOpen={this.showDeleteModal}
>
@@ -342,7 +333,7 @@ class DocumentMenu extends React.Component<Props> {
/>
</Modal>
<Modal
title={t("Create template")}
title="Create template"
onRequestClose={this.handleCloseTemplateModal}
isOpen={this.showTemplateModal}
>
@@ -352,7 +343,7 @@ class DocumentMenu extends React.Component<Props> {
/>
</Modal>
<Modal
title={t("Share document")}
title="Share document"
onRequestClose={this.handleCloseShareModal}
isOpen={this.showShareModal}
>
@@ -366,6 +357,4 @@ class DocumentMenu extends React.Component<Props> {
}
}
export default withTranslation()<DocumentMenu>(
inject("ui", "auth", "collections", "policies")(DocumentMenu)
);
export default inject("ui", "auth", "collections", "policies")(DocumentMenu);
+7 -11
View File
@@ -2,7 +2,6 @@
import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { withRouter, type RouterHistory } from "react-router-dom";
import PoliciesStore from "stores/PoliciesStore";
import UiStore from "stores/UiStore";
@@ -21,7 +20,6 @@ type Props = {
onMembers: () => void,
onOpen?: () => void,
onClose?: () => void,
t: TFunction,
};
@observer
@@ -48,13 +46,13 @@ class GroupMenu extends React.Component<Props> {
};
render() {
const { policies, group, onOpen, onClose, t } = this.props;
const { policies, group, onOpen, onClose } = this.props;
const can = policies.abilities(group.id);
return (
<>
<Modal
title={t("Edit group")}
title="Edit group"
onRequestClose={this.handleEditModalClose}
isOpen={this.editModalOpen}
>
@@ -65,7 +63,7 @@ class GroupMenu extends React.Component<Props> {
</Modal>
<Modal
title={t("Delete group")}
title="Delete group"
onRequestClose={this.handleDeleteModalClose}
isOpen={this.deleteModalOpen}
>
@@ -78,7 +76,7 @@ class GroupMenu extends React.Component<Props> {
<DropdownMenuItems
items={[
{
title: `${t("Members")}`,
title: "Members",
onClick: this.props.onMembers,
visible: !!(group && can.read),
},
@@ -86,12 +84,12 @@ class GroupMenu extends React.Component<Props> {
type: "separator",
},
{
title: `${t("Edit")}`,
title: "Edit",
onClick: this.onEdit,
visible: !!(group && can.update),
},
{
title: `${t("Delete")}`,
title: "Delete",
onClick: this.onDelete,
visible: !!(group && can.delete),
},
@@ -103,6 +101,4 @@ class GroupMenu extends React.Component<Props> {
}
}
export default withTranslation()<GroupMenu>(
inject("policies")(withRouter(GroupMenu))
);
export default inject("policies")(withRouter(GroupMenu));
+7 -11
View File
@@ -2,7 +2,6 @@
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
import * as React from "react";
import { Trans, withTranslation, type TFunction } from "react-i18next";
import { Redirect } from "react-router-dom";
import CollectionsStore from "stores/CollectionsStore";
@@ -15,7 +14,6 @@ type Props = {
label?: React.Node,
document: Document,
collections: CollectionsStore,
t: TFunction,
};
@observer
@@ -41,9 +39,8 @@ class NewChildDocumentMenu extends React.Component<Props> {
render() {
if (this.redirectTo) return <Redirect to={this.redirectTo} push />;
const { label, document, collections, t } = this.props;
const { label, document, collections } = this.props;
const collection = collections.get(document.collectionId);
const collectionName = collection ? collection.name : t("collection");
return (
<DropdownMenu label={label}>
@@ -51,14 +48,15 @@ class NewChildDocumentMenu extends React.Component<Props> {
items={[
{
title: (
<Trans>
New document in <strong>{{ collectionName }}</strong>
</Trans>
<span>
New document in{" "}
<strong>{collection ? collection.name : "collection"}</strong>
</span>
),
onClick: this.handleNewDocument,
},
{
title: t("New nested document"),
title: "New nested document",
onClick: this.handleNewChild,
},
]}
@@ -68,6 +66,4 @@ class NewChildDocumentMenu extends React.Component<Props> {
}
}
export default withTranslation()<NewChildDocumentMenu>(
inject("collections")(NewChildDocumentMenu)
);
export default inject("collections")(NewChildDocumentMenu);
+5 -17
View File
@@ -3,7 +3,6 @@ import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import { PlusIcon } from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { Redirect } from "react-router-dom";
import CollectionsStore from "stores/CollectionsStore";
@@ -20,7 +19,6 @@ type Props = {
documents: DocumentsStore,
collections: CollectionsStore,
policies: PoliciesStore,
t: TFunction,
};
@observer
@@ -31,14 +29,7 @@ class NewDocumentMenu extends React.Component<Props> {
this.redirectTo = undefined;
}
handleNewDocument = (
collectionId: string,
options?: {
parentDocumentId?: string,
template?: boolean,
templateId?: string,
}
) => {
handleNewDocument = (collectionId: string, options) => {
this.redirectTo = newDocumentUrl(collectionId, options);
};
@@ -53,7 +44,7 @@ class NewDocumentMenu extends React.Component<Props> {
render() {
if (this.redirectTo) return <Redirect to={this.redirectTo} push />;
const { collections, documents, policies, label, t, ...rest } = this.props;
const { collections, documents, policies, label, ...rest } = this.props;
const singleCollection = collections.orderedData.length === 1;
return (
@@ -61,15 +52,14 @@ class NewDocumentMenu extends React.Component<Props> {
label={
label || (
<Button icon={<PlusIcon />} small>
{t("New doc")}
{singleCollection ? "" : "…"}
New doc{singleCollection ? "" : "…"}
</Button>
)
}
onOpen={this.onOpen}
{...rest}
>
<Header>{t("Choose a collection")}</Header>
<Header>Choose a collection</Header>
<DropdownMenuItems
items={collections.orderedData.map((collection) => ({
onClick: () => this.handleNewDocument(collection.id),
@@ -87,6 +77,4 @@ class NewDocumentMenu extends React.Component<Props> {
}
}
export default withTranslation()<NewDocumentMenu>(
inject("collections", "documents", "policies")(NewDocumentMenu)
);
export default inject("collections", "documents", "policies")(NewDocumentMenu);
+4 -8
View File
@@ -3,7 +3,6 @@ import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import { PlusIcon } from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { Redirect } from "react-router-dom";
import CollectionsStore from "stores/CollectionsStore";
@@ -18,7 +17,6 @@ type Props = {
label?: React.Node,
collections: CollectionsStore,
policies: PoliciesStore,
t: TFunction,
};
@observer
@@ -38,20 +36,20 @@ class NewTemplateMenu extends React.Component<Props> {
render() {
if (this.redirectTo) return <Redirect to={this.redirectTo} push />;
const { collections, policies, label, t, ...rest } = this.props;
const { collections, policies, label, ...rest } = this.props;
return (
<DropdownMenu
label={
label || (
<Button icon={<PlusIcon />} small>
{t("New template")}
New template
</Button>
)
}
{...rest}
>
<Header>{t("Choose a collection")}</Header>
<Header>Choose a collection</Header>
<DropdownMenuItems
items={collections.orderedData.map((collection) => ({
onClick: () => this.handleNewDocument(collection.id),
@@ -69,6 +67,4 @@ class NewTemplateMenu extends React.Component<Props> {
}
}
export default withTranslation()<NewTemplateMenu>(
inject("collections", "policies")(NewTemplateMenu)
);
export default inject("collections", "policies")(NewTemplateMenu);
+6 -12
View File
@@ -1,7 +1,6 @@
// @flow
import { inject } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { withRouter, type RouterHistory } from "react-router-dom";
import UiStore from "stores/UiStore";
@@ -20,25 +19,22 @@ type Props = {
className?: string,
label: React.Node,
ui: UiStore,
t: TFunction,
};
class RevisionMenu extends React.Component<Props> {
handleRestore = async (ev: SyntheticEvent<>) => {
ev.preventDefault();
await this.props.document.restore({ revisionId: this.props.revision.id });
const { t } = this.props;
this.props.ui.showToast(t("Document restored"));
this.props.ui.showToast("Document restored");
this.props.history.push(this.props.document.url);
};
handleCopy = () => {
const { t } = this.props;
this.props.ui.showToast(t("Link copied"));
this.props.ui.showToast("Link copied");
};
render() {
const { className, label, onOpen, onClose, t } = this.props;
const { className, label, onOpen, onClose } = this.props;
const url = `${window.location.origin}${documentHistoryUrl(
this.props.document,
this.props.revision.id
@@ -52,17 +48,15 @@ class RevisionMenu extends React.Component<Props> {
label={label}
>
<DropdownMenuItem onClick={this.handleRestore}>
{t("Restore version")}
Restore version
</DropdownMenuItem>
<hr />
<CopyToClipboard text={url} onCopy={this.handleCopy}>
<DropdownMenuItem>{t("Copy link")}</DropdownMenuItem>
<DropdownMenuItem>Copy link</DropdownMenuItem>
</CopyToClipboard>
</DropdownMenu>
);
}
}
export default withTranslation()<RevisionMenu>(
withRouter(inject("ui")(RevisionMenu))
);
export default withRouter(inject("ui")(RevisionMenu));
+7 -11
View File
@@ -2,7 +2,6 @@
import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { Redirect } from "react-router-dom";
import SharesStore from "stores/SharesStore";
@@ -17,7 +16,6 @@ type Props = {
shares: SharesStore,
ui: UiStore,
share: Share,
t: TFunction,
};
@observer
@@ -38,38 +36,36 @@ class ShareMenu extends React.Component<Props> {
try {
await this.props.shares.revoke(this.props.share);
const { t } = this.props;
this.props.ui.showToast(t("Share link revoked"));
this.props.ui.showToast("Share link revoked");
} catch (err) {
this.props.ui.showToast(err.message);
}
};
handleCopy = () => {
const { t } = this.props;
this.props.ui.showToast(t("Share link copied"));
this.props.ui.showToast("Share link copied");
};
render() {
if (this.redirectTo) return <Redirect to={this.redirectTo} push />;
const { share, onOpen, onClose, t } = this.props;
const { share, onOpen, onClose } = this.props;
return (
<DropdownMenu onOpen={onOpen} onClose={onClose}>
<CopyToClipboard text={share.url} onCopy={this.handleCopy}>
<DropdownMenuItem>{t("Copy link")}</DropdownMenuItem>
<DropdownMenuItem>Copy link</DropdownMenuItem>
</CopyToClipboard>
<DropdownMenuItem onClick={this.handleGoToDocument}>
{t("Go to document")}
Go to document
</DropdownMenuItem>
<hr />
<DropdownMenuItem onClick={this.handleRevoke}>
{t("Revoke link")}
Revoke link
</DropdownMenuItem>
</DropdownMenu>
);
}
}
export default withTranslation()<ShareMenu>(inject("shares", "ui")(ShareMenu));
export default inject("shares", "ui")(ShareMenu);
+4 -10
View File
@@ -2,7 +2,6 @@
import { observer, inject } from "mobx-react";
import { DocumentIcon } from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import styled from "styled-components";
import DocumentsStore from "stores/DocumentsStore";
import Document from "models/Document";
@@ -12,13 +11,12 @@ import { DropdownMenu, DropdownMenuItem } from "components/DropdownMenu";
type Props = {
document: Document,
documents: DocumentsStore,
t: TFunction,
};
@observer
class TemplatesMenu extends React.Component<Props> {
render() {
const { documents, document, t, ...rest } = this.props;
const { documents, document, ...rest } = this.props;
const templates = documents.templatesInCollection(document.collectionId);
if (!templates.length) {
@@ -30,7 +28,7 @@ class TemplatesMenu extends React.Component<Props> {
position="left"
label={
<Button disclosure neutral>
{t("Templates")}
Templates
</Button>
}
{...rest}
@@ -44,9 +42,7 @@ class TemplatesMenu extends React.Component<Props> {
<div>
<strong>{template.titleWithDefault}</strong>
<br />
<Author>
{t("By {{ author }}", { author: template.createdBy.name })}
</Author>
<Author>By {template.createdBy.name}</Author>
</div>
</DropdownMenuItem>
))}
@@ -59,6 +55,4 @@ const Author = styled.div`
font-size: 13px;
`;
export default withTranslation()<TemplatesMenu>(
inject("documents")(TemplatesMenu)
);
export default inject("documents")(TemplatesMenu);
+13 -30
View File
@@ -2,7 +2,6 @@
import { inject, observer } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import UsersStore from "stores/UsersStore";
import User from "models/User";
import { DropdownMenu } from "components/DropdownMenu";
@@ -11,20 +10,16 @@ import DropdownMenuItems from "components/DropdownMenu/DropdownMenuItems";
type Props = {
user: User,
users: UsersStore,
t: TFunction,
};
@observer
class UserMenu extends React.Component<Props> {
handlePromote = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { user, users, t } = this.props;
const { user, users } = this.props;
if (
!window.confirm(
t(
"Are you sure you want to make {{ userName }} an admin? Admins can modify team and billing information.",
{ userName: user.name }
)
`Are you want to make ${user.name} an admin? Admins can modify team and billing information.`
)
) {
return;
@@ -34,14 +29,8 @@ class UserMenu extends React.Component<Props> {
handleDemote = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { user, users, t } = this.props;
if (
!window.confirm(
t("Are you sure you want to make {{ userName }} a member?", {
userName: user.name,
})
)
) {
const { user, users } = this.props;
if (!window.confirm(`Are you want to make ${user.name} a member?`)) {
return;
}
users.demote(user);
@@ -49,12 +38,10 @@ class UserMenu extends React.Component<Props> {
handleSuspend = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { user, users, t } = this.props;
const { user, users } = this.props;
if (
!window.confirm(
t(
"Are you sure you want to suspend this account? Suspended users will be prevented from logging in."
)
"Are you want to suspend this account? Suspended users will be prevented from logging in."
)
) {
return;
@@ -75,23 +62,19 @@ class UserMenu extends React.Component<Props> {
};
render() {
const { user, t } = this.props;
const { user } = this.props;
return (
<DropdownMenu>
<DropdownMenuItems
items={[
{
title: t("Make {{ userName }} a member…", {
userName: user.name,
}),
title: `Make ${user.name} a member…`,
onClick: this.handleDemote,
visible: user.isAdmin,
},
{
title: t("Make {{ userName }} an admin…", {
userName: user.name,
}),
title: `Make ${user.name} an admin…`,
onClick: this.handlePromote,
visible: !user.isAdmin && !user.isSuspended,
},
@@ -99,17 +82,17 @@ class UserMenu extends React.Component<Props> {
type: "separator",
},
{
title: `${t("Revoke invite")}`,
title: "Revoke invite",
onClick: this.handleRevoke,
visible: user.isInvited,
},
{
title: t("Activate account"),
title: "Reactivate account",
onClick: this.handleActivate,
visible: !user.isInvited && user.isSuspended,
},
{
title: `${t("Suspend account")}`,
title: "Suspend account",
onClick: this.handleSuspend,
visible: !user.isInvited && !user.isSuspended,
},
@@ -120,4 +103,4 @@ class UserMenu extends React.Component<Props> {
}
}
export default withTranslation()<UserMenu>(inject("users")(UserMenu));
export default inject("users")(UserMenu);
+2 -2
View File
@@ -79,12 +79,12 @@ export default class Collection extends BaseModel {
return result;
}
pathToDocument(documentId: string) {
pathToDocument(document: Document) {
let path;
const traveler = (nodes, previousPath) => {
nodes.forEach((childNode) => {
const newPath = [...previousPath, childNode];
if (childNode.id === documentId) {
if (childNode.id === document.id) {
path = newPath;
return;
}
+1 -6
View File
@@ -206,11 +206,6 @@ export default class Document extends BaseModel {
@action
view = () => {
// we don't record views for documents in the trash
if (this.isDeleted || !this.publishedAt) {
return;
}
return this.store.rootStore.views.create({ documentId: this.id });
};
@@ -268,7 +263,7 @@ export default class Document extends BaseModel {
};
move = (collectionId: string, parentDocumentId: ?string) => {
return this.store.move(this.id, collectionId, parentDocumentId);
return this.store.move(this, collectionId, parentDocumentId);
};
duplicate = () => {
+1
View File
@@ -10,6 +10,7 @@ class Team extends BaseModel {
googleConnected: boolean;
sharing: boolean;
documentEmbeds: boolean;
multiplayerEditor: boolean;
guestSignin: boolean;
subdomain: ?string;
domain: ?string;
+1 -1
View File
@@ -7,11 +7,11 @@ class User extends BaseModel {
id: string;
name: string;
email: string;
color: string;
isAdmin: boolean;
lastActiveAt: string;
isSuspended: boolean;
createdAt: string;
language: string;
@computed
get isInvited(): boolean {
+67
View File
@@ -0,0 +1,67 @@
// @flow
import {
ySyncPlugin,
yCursorPlugin,
yUndoPlugin,
undo,
redo,
} from "@tommoor/y-prosemirror";
import { keymap } from "prosemirror-keymap";
import { Extension } from "rich-markdown-editor";
// import { IndexeddbPersistence } from "y-indexeddb";
import * as Y from "yjs";
export default class MultiplayerExtension extends Extension {
get name() {
return "multiplayer";
}
get plugins() {
const { user, provider, doc } = this.options;
const type = doc.get("prosemirror", Y.XmlFragment);
provider.on("status", ({ status }) => {
if (status === "connected") {
provider.awareness.setLocalStateField("user", {
color: user.color,
name: user.name,
id: user.id,
});
}
});
provider.once("sync", () => {
const assignUser = (tr) => {
const clientIds = Array.from(doc.store.clients.keys());
if (
tr.local &&
tr.changed.size > 0 &&
!clientIds.includes(doc.clientID)
) {
const permanentUserData = new Y.PermanentUserData(doc);
permanentUserData.setUserMapping(doc, doc.clientID, user.id);
doc.off("afterTransaction", assignUser);
}
};
doc.on("afterTransaction", assignUser);
});
// const dbProvider = new IndexeddbPersistence(doc.documentId, doc);
// dbProvider.whenSynced.then(() => {
// console.log("loaded data from indexed db");
// });
return [
ySyncPlugin(type),
yCursorPlugin(provider.awareness),
yUndoPlugin(),
keymap({
"Mod-z": undo,
"Mod-y": redo,
"Mod-Shift-z": redo,
}),
];
}
}
+356
View File
@@ -0,0 +1,356 @@
// Based on example implementation, modified to work with existing sockets
// https://github.com/yjs/y-websocket/blob/master/src/y-websocket.js
// @flow
import * as bc from "lib0/broadcastchannel.js";
import * as decoding from "lib0/decoding.js";
import * as encoding from "lib0/encoding.js";
import * as mutex from "lib0/mutex.js";
import { Observable } from "lib0/observable.js";
import { Socket } from "socket.io-client";
import * as awarenessProtocol from "y-protocols/awareness.js";
import * as syncProtocol from "y-protocols/sync.js";
import * as Y from "yjs";
import {
MESSAGE_SYNC,
MESSAGE_AWARENESS,
MESSAGE_QUERY_AWARENESS,
} from "shared/constants";
const readMessage = (
provider: WebsocketProvider,
buff: Uint8Array,
emitSynced: boolean
): encoding.Encoder => {
const decoder = decoding.createDecoder(buff);
const encoder = encoding.createEncoder();
const messageType = decoding.readVarUint(decoder);
switch (messageType) {
case MESSAGE_SYNC: {
encoding.writeVarUint(encoder, MESSAGE_SYNC);
const syncMessageType = syncProtocol.readSyncMessage(
decoder,
encoder,
provider.doc,
provider
);
if (
emitSynced &&
syncMessageType === syncProtocol.messageYjsSyncStep2 &&
!provider.synced
) {
provider.synced = true;
}
break;
}
case MESSAGE_QUERY_AWARENESS:
encoding.writeVarUint(encoder, MESSAGE_AWARENESS);
encoding.writeVarUint8Array(
encoder,
awarenessProtocol.encodeAwarenessUpdate(
provider.awareness,
Array.from(provider.awareness.getStates().keys())
)
);
break;
case MESSAGE_AWARENESS:
awarenessProtocol.applyAwarenessUpdate(
provider.awareness,
decoding.readVarUint8Array(decoder),
provider
);
break;
default:
console.error("Unable to compute message");
return encoder;
}
return encoder;
};
const broadcastMessage = (provider: WebsocketProvider, buff: ArrayBuffer) => {
if (provider.wsconnected) {
provider.wsPublish(buff);
}
if (provider.bcconnected) {
provider.mux(() => {
bc.publish(provider.documentId, buff);
});
}
};
/**
* Websocket Provider for Yjs. Syncs the shared document using socket.io socket
*/
export class WebsocketProvider extends Observable {
constructor(
socket: Socket,
documentId: string,
userId: string,
doc: Y.Doc,
{
awareness = new awarenessProtocol.Awareness(doc),
resyncInterval = 0,
}: {
awareness: awarenessProtocol.Awareness,
resyncInterval: number,
} = {}
) {
super();
this.socket = socket;
this.bcChannel = documentId;
this.documentId = documentId;
this.userId = userId;
this.doc = doc;
this.awareness = awareness;
this.wsconnected = false;
this.bcconnected = false;
this.shouldConnect = true;
this.mux = mutex.createMutex();
this._synced = false;
this._resyncInterval = 0;
if (resyncInterval > 0) {
this._resyncInterval = setInterval(() => {
if (this.ws) {
// resend sync step 1
const encoder = encoding.createEncoder();
encoding.writeVarUint(encoder, MESSAGE_SYNC);
syncProtocol.writeSyncStep1(encoder, doc);
this.wsPublish(encoding.toUint8Array(encoder));
}
}, resyncInterval);
}
this.doc.on("update", this._updateHandler);
window.addEventListener("beforeunload", this._unloadHandler);
awareness.on("update", this._awarenessUpdateHandler);
this.connect();
}
_unloadHandler = () => {
awarenessProtocol.removeAwarenessStates(
this.awareness,
[this.doc.clientID],
"window unload"
);
};
_bcSubscriber = (data: ArrayBuffer) => {
this.mux(() => {
const encoder = readMessage(this, new Uint8Array(data), false);
if (encoding.length(encoder) > 1) {
bc.publish(this.bcChannel, encoding.toUint8Array(encoder));
}
});
};
/**
* Listens to Yjs updates and sends them to remote peers (ws and broadcastchannel)
*/
_updateHandler = (update: Uint8Array, origin: any) => {
if (origin !== this || origin === null) {
const encoder = encoding.createEncoder();
encoding.writeVarUint(encoder, MESSAGE_SYNC);
syncProtocol.writeUpdate(encoder, update);
broadcastMessage(this, encoding.toUint8Array(encoder));
}
};
_awarenessUpdateHandler = ({ added, updated, removed }: any, origin: any) => {
const changedClients = added.concat(updated).concat(removed);
const encoder = encoding.createEncoder();
encoding.writeVarUint(encoder, MESSAGE_AWARENESS);
encoding.writeVarUint8Array(
encoder,
awarenessProtocol.encodeAwarenessUpdate(this.awareness, changedClients)
);
broadcastMessage(this, encoding.toUint8Array(encoder));
};
get synced() {
return this._synced;
}
set synced(state: boolean) {
if (this._synced !== state) {
this._synced = state;
this.emit("sync", [state]);
}
}
destroy() {
if (this._resyncInterval !== 0) {
clearInterval(this._resyncInterval);
}
this.disconnect();
this.awareness.off("update", this._awarenessUpdateHandler);
this.doc.off("update", this._updateHandler);
this.awareness.destroy();
window.removeEventListener("beforeunload", this._unloadHandler);
super.destroy();
}
connectBc() {
if (!this.bcconnected) {
bc.subscribe(this.bcChannel, this._bcSubscriber);
this.bcconnected = true;
}
// send sync step1 to bc
this.mux(() => {
// write sync step 1
const encoderSync = encoding.createEncoder();
encoding.writeVarUint(encoderSync, MESSAGE_SYNC);
syncProtocol.writeSyncStep1(encoderSync, this.doc);
bc.publish(this.bcChannel, encoding.toUint8Array(encoderSync));
// broadcast local state
const encoderState = encoding.createEncoder();
encoding.writeVarUint(encoderState, MESSAGE_SYNC);
syncProtocol.writeSyncStep2(encoderState, this.doc);
bc.publish(this.bcChannel, encoding.toUint8Array(encoderState));
// write queryAwareness
const encoderAwarenessQuery = encoding.createEncoder();
encoding.writeVarUint(encoderAwarenessQuery, MESSAGE_QUERY_AWARENESS);
bc.publish(this.bcChannel, encoding.toUint8Array(encoderAwarenessQuery));
// broadcast local awareness state
const encoderAwarenessState = encoding.createEncoder();
encoding.writeVarUint(encoderAwarenessState, MESSAGE_AWARENESS);
encoding.writeVarUint8Array(
encoderAwarenessState,
awarenessProtocol.encodeAwarenessUpdate(this.awareness, [
this.doc.clientID,
])
);
bc.publish(this.bcChannel, encoding.toUint8Array(encoderAwarenessState));
});
}
disconnectBc() {
// broadcast message with local awareness state set to null (indicating disconnect)
const encoder = encoding.createEncoder();
encoding.writeVarUint(encoder, MESSAGE_AWARENESS);
encoding.writeVarUint8Array(
encoder,
awarenessProtocol.encodeAwarenessUpdate(
this.awareness,
[this.doc.clientID],
new Map()
)
);
broadcastMessage(this, encoding.toUint8Array(encoder));
if (this.bcconnected) {
bc.unsubscribe(this.bcChannel, this._bcSubscriber);
this.bcconnected = false;
}
}
wsPublish(data: ArrayBuffer) {
if (!data) return;
this.socket.binary(true).emit("sync", {
documentId: this.documentId,
userId: this.userId,
data,
});
}
_wsMessageHandler = (event: {
documentId: string,
userId: string,
data: ArrayBuffer,
}) => {
if (event.documentId === this.documentId) {
const encoder = readMessage(this, new Uint8Array(event.data), true);
if (encoding.length(encoder) > 1) {
this.wsPublish(encoding.toUint8Array(encoder));
}
}
};
_wsCloseHandler = () => {
awarenessProtocol.removeAwarenessStates(
this.awareness,
Array.from(this.awareness.getStates().keys()),
this
);
this.emit("status", [
{
status: "disconnected",
},
]);
};
_wsJoinHandler = (event: { documentId: string, userId: string }) => {
if (event.userId !== this.userId || event.documentId !== this.documentId) {
return;
}
console.log("user.join");
this.awareness.setLocalState({});
this.emit("status", [
{
status: "connected",
},
]);
console.log("writing sync step 1");
// always send sync step 1 when connected
const encoder = encoding.createEncoder();
encoding.writeVarUint(encoder, MESSAGE_SYNC);
syncProtocol.writeSyncStep1(encoder, this.doc);
this.wsPublish(encoding.toUint8Array(encoder));
// broadcast local awareness state
if (this.awareness.getLocalState() !== null) {
console.log("broadcast awareness state");
const encoderAwarenessState = encoding.createEncoder();
encoding.writeVarUint(encoderAwarenessState, MESSAGE_AWARENESS);
encoding.writeVarUint8Array(
encoderAwarenessState,
awarenessProtocol.encodeAwarenessUpdate(this.awareness, [
this.doc.clientID,
])
);
this.wsPublish(encoding.toUint8Array(encoderAwarenessState));
}
};
connectWs() {
this.socket.on("document.sync", this._wsMessageHandler);
this.socket.on("disconnect", this._wsCloseHandler);
this.socket.on("user.join", this._wsJoinHandler);
}
disconnectWs() {
this.socket.off("document.sync", this._wsMessageHandler);
this.socket.off("disconnect", this._wsCloseHandler);
this.socket.off("user.join", this._wsJoinHandler);
}
disconnect() {
this.shouldConnect = false;
this.disconnectWs();
this.disconnectBc();
}
connect() {
this.shouldConnect = true;
if (!this.wsconnected) {
this.wsconnected = true;
this.connectWs();
this.connectBc();
}
}
}
+2
View File
@@ -1,6 +1,7 @@
// @flow
import * as React from "react";
import { Switch, Route } from "react-router-dom";
import Features from "scenes/Settings/Features";
import Settings from "scenes/Settings";
import Details from "scenes/Settings/Details";
import Export from "scenes/Settings/Export";
@@ -18,6 +19,7 @@ export default function SettingsRoutes() {
<Switch>
<Route exact path="/settings" component={Settings} />
<Route exact path="/settings/details" component={Details} />
<Route exact path="/settings/features" component={Features} />
<Route exact path="/settings/security" component={Security} />
<Route exact path="/settings/people" component={People} />
<Route exact path="/settings/people/:filter" component={People} />
+20 -21
View File
@@ -1,7 +1,6 @@
// @flow
import { observer, inject } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import DocumentsStore from "stores/DocumentsStore";
import CenteredContent from "components/CenteredContent";
@@ -15,26 +14,26 @@ type Props = {
documents: DocumentsStore,
};
function Archive(props: Props) {
const { t } = useTranslation();
const { documents } = props;
@observer
class Archive extends React.Component<Props> {
render() {
const { documents } = this.props;
return (
<CenteredContent column auto>
<PageTitle title={t("Archive")} />
<Heading>{t("Archive")}</Heading>
<PaginatedDocumentList
documents={documents.archived}
fetch={documents.fetchArchived}
heading={<Subheading>{t("Documents")}</Subheading>}
empty={
<Empty>{t("The document archive is empty at the moment.")}</Empty>
}
showCollection
showTemplate
/>
</CenteredContent>
);
return (
<CenteredContent column auto>
<PageTitle title="Archive" />
<Heading>Archive</Heading>
<PaginatedDocumentList
documents={documents.archived}
fetch={documents.fetchArchived}
heading={<Subheading>Documents</Subheading>}
empty={<Empty>The document archive is empty at the moment.</Empty>}
showCollection
showTemplate
/>
</CenteredContent>
);
}
}
export default inject("documents")(observer(Archive));
export default inject("documents")(Archive);
+24 -31
View File
@@ -4,7 +4,6 @@ import { observer, inject } from "mobx-react";
import { NewDocumentIcon, PlusIcon, PinIcon } from "outline-icons";
import * as React from "react";
import { withTranslation, Trans, type TFunction } from "react-i18next";
import { Redirect, Link, Switch, Route, type Match } from "react-router-dom";
import styled, { withTheme } from "styled-components";
@@ -48,7 +47,6 @@ type Props = {
policies: PoliciesStore,
match: Match,
theme: Theme,
t: TFunction,
};
@observer
@@ -66,7 +64,7 @@ class CollectionScene extends React.Component<Props> {
}
}
componentDidUpdate(prevProps: Props) {
componentDidUpdate(prevProps) {
const { id } = this.props.match.params;
if (this.collection) {
@@ -134,7 +132,7 @@ class CollectionScene extends React.Component<Props> {
};
renderActions() {
const { match, policies, t } = this.props;
const { match, policies } = this.props;
const can = policies.abilities(match.params.id || "");
return (
@@ -144,19 +142,19 @@ class CollectionScene extends React.Component<Props> {
<Action>
<InputSearch
source="collection"
placeholder={`${t("Search in collection")}`}
placeholder="Search in collection"
collectionId={match.params.id}
/>
</Action>
<Action>
<Tooltip
tooltip={t("New document")}
tooltip="New document"
shortcut="n"
delay={500}
placement="bottom"
>
<Button onClick={this.onNewDocument} icon={<PlusIcon />}>
{t("New doc")}
New doc
</Button>
</Tooltip>
</Action>
@@ -171,7 +169,7 @@ class CollectionScene extends React.Component<Props> {
}
render() {
const { documents, theme, t } = this.props;
const { documents, theme } = this.props;
if (this.redirectTo) return <Redirect to={this.redirectTo} push />;
if (!this.isFetching && !this.collection) return <Search notFound />;
@@ -181,7 +179,6 @@ class CollectionScene extends React.Component<Props> {
: [];
const hasPinnedDocuments = !!pinnedDocuments.length;
const collection = this.collection;
const collectionName = collection ? collection.name : "";
return (
<CenteredContent>
@@ -191,28 +188,26 @@ class CollectionScene extends React.Component<Props> {
{collection.isEmpty ? (
<Centered column>
<HelpText>
<Trans>
<strong>{{ collectionName }}</strong> doesnt contain any
documents yet.
</Trans>
<strong>{collection.name}</strong> doesnt contain any
documents yet.
<br />
<Trans>Get started by creating a new one!</Trans>
Get started by creating a new one!
</HelpText>
<Wrapper>
<Link to={newDocumentUrl(collection.id)}>
<Button icon={<NewDocumentIcon color={theme.buttonText} />}>
{t("Create a document")}
Create a document
</Button>
</Link>
&nbsp;&nbsp;
{collection.private && (
<Button onClick={this.onPermissions} neutral>
{t("Manage members")}
Manage members
</Button>
)}
</Wrapper>
<Modal
title={t("Collection permissions")}
title="Collection permissions"
onRequestClose={this.handlePermissionsModalClose}
isOpen={this.permissionsModalOpen}
>
@@ -223,7 +218,7 @@ class CollectionScene extends React.Component<Props> {
/>
</Modal>
<Modal
title={t("Edit collection")}
title="Edit collection"
onRequestClose={this.handleEditModalClose}
isOpen={this.editModalOpen}
>
@@ -254,7 +249,7 @@ class CollectionScene extends React.Component<Props> {
{hasPinnedDocuments && (
<>
<Subheading>
<TinyPinIcon size={18} /> {t("Pinned")}
<TinyPinIcon size={18} /> Pinned
</Subheading>
<DocumentList documents={pinnedDocuments} showPin />
</>
@@ -262,16 +257,16 @@ class CollectionScene extends React.Component<Props> {
<Tabs>
<Tab to={collectionUrl(collection.id)} exact>
{t("Recently updated")}
Recently updated
</Tab>
<Tab to={collectionUrl(collection.id, "recent")} exact>
{t("Recently published")}
Recently published
</Tab>
<Tab to={collectionUrl(collection.id, "old")} exact>
{t("Least recently updated")}
Least recently updated
</Tab>
<Tab to={collectionUrl(collection.id, "alphabetical")} exact>
{t("AZ")}
AZ
</Tab>
</Tabs>
<Switch>
@@ -356,11 +351,9 @@ const Wrapper = styled(Flex)`
margin: 10px 0;
`;
export default withTranslation()<CollectionScene>(
inject(
"collections",
"policies",
"documents",
"ui"
)(withTheme(CollectionScene))
);
export default inject(
"collections",
"policies",
"documents",
"ui"
)(withTheme(CollectionScene));
+11 -19
View File
@@ -2,7 +2,6 @@
import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import UiStore from "stores/UiStore";
import Collection from "models/Collection";
import Button from "components/Button";
@@ -17,7 +16,6 @@ type Props = {
collection: Collection,
ui: UiStore,
onSubmit: () => void,
t: TFunction,
};
@observer
@@ -32,7 +30,6 @@ class CollectionEdit extends React.Component<Props> {
handleSubmit = async (ev: SyntheticEvent<*>) => {
ev.preventDefault();
this.isSaving = true;
const { t } = this.props;
try {
await this.props.collection.save({
@@ -43,7 +40,7 @@ class CollectionEdit extends React.Component<Props> {
private: this.private,
});
this.props.onSubmit();
this.props.ui.showToast(t("The collection was updated"));
this.props.ui.showToast("The collection was updated");
} catch (err) {
this.props.ui.showToast(err.message);
} finally {
@@ -51,7 +48,7 @@ class CollectionEdit extends React.Component<Props> {
}
};
handleDescriptionChange = (getValue: () => string) => {
handleDescriptionChange = (getValue) => {
this.description = getValue();
};
@@ -69,20 +66,17 @@ class CollectionEdit extends React.Component<Props> {
};
render() {
const { t } = this.props;
return (
<Flex column>
<form onSubmit={this.handleSubmit}>
<HelpText>
{t(
"You can edit the name and other details at any time, however doing so often might confuse your team mates."
)}
You can edit the name and other details at any time, however doing
so often might confuse your team mates.
</HelpText>
<Flex>
<Input
type="text"
label={t("Name")}
label="Name"
onChange={this.handleNameChange}
value={this.name}
required
@@ -98,29 +92,27 @@ class CollectionEdit extends React.Component<Props> {
</Flex>
<InputRich
id={this.props.collection.id}
label={t("Description")}
label="Description"
onChange={this.handleDescriptionChange}
defaultValue={this.description || ""}
placeholder={t("More details about this collection…")}
placeholder="More details about this collection…"
minHeight={68}
maxHeight={200}
/>
<Switch
id="private"
label={t("Private collection")}
label="Private collection"
onChange={this.handlePrivateChange}
checked={this.private}
/>
<HelpText>
{t(
"A private collection will only be visible to invited team members."
)}
A private collection will only be visible to invited team members.
</HelpText>
<Button
type="submit"
disabled={this.isSaving || !this.props.collection.name}
>
{this.isSaving ? `${t("Saving")}` : t("Save")}
{this.isSaving ? "Saving" : "Save"}
</Button>
</form>
</Flex>
@@ -128,4 +120,4 @@ class CollectionEdit extends React.Component<Props> {
}
}
export default withTranslation()<CollectionEdit>(inject("ui")(CollectionEdit));
export default inject("ui")(CollectionEdit);
@@ -3,14 +3,12 @@ import { debounce } from "lodash";
import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import styled from "styled-components";
import AuthStore from "stores/AuthStore";
import CollectionGroupMembershipsStore from "stores/CollectionGroupMembershipsStore";
import GroupsStore from "stores/GroupsStore";
import UiStore from "stores/UiStore";
import Collection from "models/Collection";
import Group from "models/Group";
import GroupNew from "scenes/GroupNew";
import Button from "components/Button";
import Empty from "components/Empty";
@@ -28,7 +26,6 @@ type Props = {
collectionGroupMemberships: CollectionGroupMembershipsStore,
groups: GroupsStore,
onSubmit: () => void,
t: TFunction,
};
@observer
@@ -55,56 +52,50 @@ class AddGroupsToCollection extends React.Component<Props> {
});
}, 250);
handleAddGroup = (group: Group) => {
const { t } = this.props;
handleAddGroup = (group) => {
try {
this.props.collectionGroupMemberships.create({
collectionId: this.props.collection.id,
groupId: group.id,
permission: "read_write",
});
this.props.ui.showToast(
t("{{ groupName }} was added to the collection", {
groupName: group.name,
})
);
this.props.ui.showToast(`${group.name} was added to the collection`);
} catch (err) {
this.props.ui.showToast(t("Could not add user"));
this.props.ui.showToast("Could not add user");
console.error(err);
}
};
render() {
const { groups, collection, auth, t } = this.props;
const { groups, collection, auth } = this.props;
const { user, team } = auth;
if (!user || !team) return null;
return (
<Flex column>
<HelpText>
{t("Cant find the group youre looking for?")}{" "}
Cant find the group youre looking for?{" "}
<a role="button" onClick={this.handleNewGroupModalOpen}>
{t("Create a group")}
Create a group
</a>
.
</HelpText>
<Input
type="search"
placeholder={`${t("Search by group name")}`}
placeholder="Search by group name"
value={this.query}
onChange={this.handleFilter}
label={t("Search groups")}
label="Search groups"
labelHidden
flex
/>
<PaginatedList
empty={
this.query ? (
<Empty>{t("No groups matching your search")}</Empty>
<Empty>No groups matching your search</Empty>
) : (
<Empty>{t("No groups left to add")}</Empty>
<Empty>No groups left to add</Empty>
)
}
items={groups.notInCollection(collection.id, this.query)}
@@ -117,7 +108,7 @@ class AddGroupsToCollection extends React.Component<Props> {
renderActions={() => (
<ButtonWrap>
<Button onClick={() => this.handleAddGroup(item)} neutral>
{t("Add")}
Add
</Button>
</ButtonWrap>
)}
@@ -125,7 +116,7 @@ class AddGroupsToCollection extends React.Component<Props> {
)}
/>
<Modal
title={t("Create a group")}
title="Create a group"
onRequestClose={this.handleNewGroupModalClose}
isOpen={this.newGroupModalOpen}
>
@@ -140,11 +131,9 @@ const ButtonWrap = styled.div`
margin-left: 6px;
`;
export default withTranslation()<AddGroupsToCollection>(
inject(
"auth",
"groups",
"collectionGroupMemberships",
"ui"
)(AddGroupsToCollection)
);
export default inject(
"auth",
"groups",
"collectionGroupMemberships",
"ui"
)(AddGroupsToCollection);
@@ -3,13 +3,11 @@ import { debounce } from "lodash";
import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import AuthStore from "stores/AuthStore";
import MembershipsStore from "stores/MembershipsStore";
import UiStore from "stores/UiStore";
import UsersStore from "stores/UsersStore";
import Collection from "models/Collection";
import User from "models/User";
import Invite from "scenes/Invite";
import Empty from "components/Empty";
import Flex from "components/Flex";
@@ -26,7 +24,6 @@ type Props = {
memberships: MembershipsStore,
users: UsersStore,
onSubmit: () => void,
t: TFunction,
};
@observer
@@ -53,43 +50,40 @@ class AddPeopleToCollection extends React.Component<Props> {
});
}, 250);
handleAddUser = (user: User) => {
const { t } = this.props;
handleAddUser = (user) => {
try {
this.props.memberships.create({
collectionId: this.props.collection.id,
userId: user.id,
permission: "read_write",
});
this.props.ui.showToast(
t("{{ userName }} was added to the collection", { userName: user.name })
);
this.props.ui.showToast(`${user.name} was added to the collection`);
} catch (err) {
this.props.ui.showToast(t("Could not add user"));
this.props.ui.showToast("Could not add user");
}
};
render() {
const { users, collection, auth, t } = this.props;
const { users, collection, auth } = this.props;
const { user, team } = auth;
if (!user || !team) return null;
return (
<Flex column>
<HelpText>
{t("Need to add someone whos not yet on the team yet?")}{" "}
Need to add someone whos not yet on the team yet?{" "}
<a role="button" onClick={this.handleInviteModalOpen}>
{t("Invite people to {{ teamName }}", { teamName: team.name })}
Invite people to {team.name}
</a>
.
</HelpText>
<Input
type="search"
placeholder={`${t("Search by name")}`}
placeholder="Search by name"
value={this.query}
onChange={this.handleFilter}
label={t("Search people")}
label="Search people"
autoFocus
labelHidden
flex
@@ -97,9 +91,9 @@ class AddPeopleToCollection extends React.Component<Props> {
<PaginatedList
empty={
this.query ? (
<Empty>{t("No people matching your search")}</Empty>
<Empty>No people matching your search</Empty>
) : (
<Empty>{t("No people left to add")}</Empty>
<Empty>No people left to add</Empty>
)
}
items={users.notInCollection(collection.id, this.query)}
@@ -114,7 +108,7 @@ class AddPeopleToCollection extends React.Component<Props> {
)}
/>
<Modal
title={t("Invite people")}
title="Invite people"
onRequestClose={this.handleInviteModalClose}
isOpen={this.inviteModalOpen}
>
@@ -125,6 +119,9 @@ class AddPeopleToCollection extends React.Component<Props> {
}
}
export default withTranslation()<AddPeopleToCollection>(
inject("auth", "users", "memberships", "ui")(AddPeopleToCollection)
);
export default inject(
"auth",
"users",
"memberships",
"ui"
)(AddPeopleToCollection);
@@ -1,6 +1,5 @@
// @flow
import * as React from "react";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import CollectionGroupMembership from "models/CollectionGroupMembership";
import Group from "models/Group";
@@ -8,6 +7,10 @@ import { DropdownMenu, DropdownMenuItem } from "components/DropdownMenu";
import GroupListItem from "components/GroupListItem";
import InputSelect from "components/InputSelect";
const PERMISSIONS = [
{ label: "Read only", value: "read" },
{ label: "Read & Edit", value: "read_write" },
];
type Props = {
group: Group,
collectionGroupMembership: ?CollectionGroupMembership,
@@ -21,16 +24,6 @@ const MemberListItem = ({
onUpdate,
onRemove,
}: Props) => {
const { t } = useTranslation();
const PERMISSIONS = React.useMemo(
() => [
{ label: t("Read only"), value: "read" },
{ label: t("Read & Edit"), value: "read_write" },
],
[t]
);
return (
<GroupListItem
group={group}
@@ -39,7 +32,7 @@ const MemberListItem = ({
renderActions={({ openMembersModal }) => (
<>
<Select
label={t("Permissions")}
label="Permissions"
options={PERMISSIONS}
value={
collectionGroupMembership
@@ -52,12 +45,10 @@ const MemberListItem = ({
<ButtonWrap>
<DropdownMenu>
<DropdownMenuItem onClick={openMembersModal}>
{t("Members")}
Members
</DropdownMenuItem>
<hr />
<DropdownMenuItem onClick={onRemove}>
{t("Remove")}
</DropdownMenuItem>
<DropdownMenuItem onClick={onRemove}>Remove</DropdownMenuItem>
</DropdownMenu>
</ButtonWrap>
</>
@@ -1,6 +1,5 @@
// @flow
import * as React from "react";
import { Trans, useTranslation } from "react-i18next";
import styled from "styled-components";
import Membership from "models/Membership";
import User from "models/User";
@@ -13,6 +12,10 @@ import InputSelect from "components/InputSelect";
import ListItem from "components/List/Item";
import Time from "components/Time";
const PERMISSIONS = [
{ label: "Read only", value: "read" },
{ label: "Read & Edit", value: "read_write" },
];
type Props = {
user: User,
membership?: ?Membership,
@@ -30,30 +33,20 @@ const MemberListItem = ({
onAdd,
canEdit,
}: Props) => {
const { t } = useTranslation();
const PERMISSIONS = React.useMemo(
() => [
{ label: t("Read only"), value: "read" },
{ label: t("Read & Edit"), value: "read_write" },
],
[t]
);
return (
<ListItem
title={user.name}
subtitle={
<>
{user.lastActiveAt ? (
<Trans>
<>
Active <Time dateTime={user.lastActiveAt} /> ago
</Trans>
</>
) : (
t("Never signed in")
"Never signed in"
)}
{user.isInvited && <Badge>{t("Invited")}</Badge>}
{user.isAdmin && <Badge primary={user.isAdmin}>{t("Admin")}</Badge>}
{user.isInvited && <Badge>Invited</Badge>}
{user.isAdmin && <Badge primary={user.isAdmin}>Admin</Badge>}
</>
}
image={<Avatar src={user.avatarUrl} size={40} />}
@@ -61,7 +54,7 @@ const MemberListItem = ({
<Flex align="center">
{canEdit && onUpdate && (
<Select
label={t("Permissions")}
label="Permissions"
options={PERMISSIONS}
value={membership ? membership.permission : undefined}
onChange={(ev) => onUpdate(ev.target.value)}
@@ -71,14 +64,12 @@ const MemberListItem = ({
&nbsp;&nbsp;
{canEdit && onRemove && (
<DropdownMenu>
<DropdownMenuItem onClick={onRemove}>
{t("Remove")}
</DropdownMenuItem>
<DropdownMenuItem onClick={onRemove}>Remove</DropdownMenuItem>
</DropdownMenu>
)}
{canEdit && onAdd && (
<Button onClick={onAdd} neutral>
{t("Add")}
Add
</Button>
)}
</Flex>
@@ -1,7 +1,6 @@
// @flow
import { PlusIcon } from "outline-icons";
import * as React from "react";
import { Trans, useTranslation } from "react-i18next";
import User from "models/User";
import Avatar from "components/Avatar";
import Badge from "components/Badge";
@@ -16,8 +15,6 @@ type Props = {
};
const UserListItem = ({ user, onAdd, canEdit }: Props) => {
const { t } = useTranslation();
return (
<ListItem
title={user.name}
@@ -25,20 +22,20 @@ const UserListItem = ({ user, onAdd, canEdit }: Props) => {
subtitle={
<>
{user.lastActiveAt ? (
<Trans>
<>
Active <Time dateTime={user.lastActiveAt} /> ago
</Trans>
</>
) : (
t("Never signed in")
"Never signed in"
)}
{user.isInvited && <Badge>{t("Invited")}</Badge>}
{user.isAdmin && <Badge primary={user.isAdmin}>{t("Admin")}</Badge>}
{user.isInvited && <Badge>Invited</Badge>}
{user.isAdmin && <Badge primary={user.isAdmin}>Admin</Badge>}
</>
}
actions={
canEdit ? (
<Button type="button" onClick={onAdd} icon={<PlusIcon />} neutral>
{t("Add")}
Add
</Button>
) : undefined
}
+11 -19
View File
@@ -3,7 +3,6 @@ import { intersection } from "lodash";
import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { withRouter, type RouterHistory } from "react-router-dom";
import CollectionsStore from "stores/CollectionsStore";
import UiStore from "stores/UiStore";
@@ -21,7 +20,6 @@ type Props = {
ui: UiStore,
collections: CollectionsStore,
onSubmit: () => void,
t: TFunction,
};
@observer
@@ -86,7 +84,7 @@ class CollectionNew extends React.Component<Props> {
this.hasOpenedIconPicker = true;
};
handleDescriptionChange = (getValue: () => string) => {
handleDescriptionChange = (getValue) => {
this.description = getValue();
};
@@ -100,19 +98,17 @@ class CollectionNew extends React.Component<Props> {
};
render() {
const { t } = this.props;
return (
<form onSubmit={this.handleSubmit}>
<HelpText>
{t(
"Collections are for grouping your knowledge base. They work best when organized around a topic or internal team — Product or Engineering for example."
)}
Collections are for grouping your knowledge base. They work best when
organized around a topic or internal team Product or Engineering for
example.
</HelpText>
<Flex>
<Input
type="text"
label={t("Name")}
label="Name"
onChange={this.handleNameChange}
value={this.name}
required
@@ -128,33 +124,29 @@ class CollectionNew extends React.Component<Props> {
/>
</Flex>
<InputRich
label={t("Description")}
label="Description"
onChange={this.handleDescriptionChange}
defaultValue={this.description || ""}
placeholder={t("More details about this collection…")}
placeholder="More details about this collection…"
minHeight={68}
maxHeight={200}
/>
<Switch
id="private"
label={t("Private collection")}
label="Private collection"
onChange={this.handlePrivateChange}
checked={this.private}
/>
<HelpText>
{t(
"A private collection will only be visible to invited team members."
)}
A private collection will only be visible to invited team members.
</HelpText>
<Button type="submit" disabled={this.isSaving || !this.name}>
{this.isSaving ? `${t("Creating")}` : t("Create")}
{this.isSaving ? "Creating" : "Create"}
</Button>
</form>
);
}
}
export default withTranslation()<CollectionNew>(
inject("collections", "ui")(withRouter(CollectionNew))
);
export default inject("collections", "ui")(withRouter(CollectionNew));
+64 -60
View File
@@ -1,77 +1,81 @@
// @flow
import { observer } from "mobx-react";
import { observer, inject } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { Switch, Route } from "react-router-dom";
import AuthStore from "stores/AuthStore";
import DocumentsStore from "stores/DocumentsStore";
import Actions, { Action } from "components/Actions";
import CenteredContent from "components/CenteredContent";
import InputSearch from "components/InputSearch";
import LanguagePrompt from "components/LanguagePrompt";
import PageTitle from "components/PageTitle";
import Tab from "components/Tab";
import Tabs from "components/Tabs";
import PaginatedDocumentList from "../components/PaginatedDocumentList";
import useStores from "../hooks/useStores";
import NewDocumentMenu from "menus/NewDocumentMenu";
function Dashboard() {
const { documents, ui, auth } = useStores();
const { t } = useTranslation();
type Props = {
documents: DocumentsStore,
auth: AuthStore,
};
if (!auth.user || !auth.team) return null;
const user = auth.user.id;
@observer
class Dashboard extends React.Component<Props> {
render() {
const { documents, auth } = this.props;
if (!auth.user || !auth.team) return null;
const user = auth.user.id;
return (
<CenteredContent>
<PageTitle title={t("Home")} />
{!ui.languagePromptDismissed && <LanguagePrompt />}
<h1>{t("Home")}</h1>
<Tabs>
<Tab to="/home" exact>
{t("Recently updated")}
</Tab>
<Tab to="/home/recent" exact>
{t("Recently viewed")}
</Tab>
<Tab to="/home/created">{t("Created by me")}</Tab>
</Tabs>
<Switch>
<Route path="/home/recent">
<PaginatedDocumentList
key="recent"
documents={documents.recentlyViewed}
fetch={documents.fetchRecentlyViewed}
showCollection
/>
</Route>
<Route path="/home/created">
<PaginatedDocumentList
key="created"
documents={documents.createdByUser(user)}
fetch={documents.fetchOwned}
options={{ user }}
showCollection
/>
</Route>
<Route path="/home">
<PaginatedDocumentList
documents={documents.recentlyUpdated}
fetch={documents.fetchRecentlyUpdated}
showCollection
/>
</Route>
</Switch>
<Actions align="center" justify="flex-end">
<Action>
<InputSearch source="dashboard" />
</Action>
<Action>
<NewDocumentMenu />
</Action>
</Actions>
</CenteredContent>
);
return (
<CenteredContent>
<PageTitle title="Home" />
<h1>Home</h1>
<Tabs>
<Tab to="/home" exact>
Recently updated
</Tab>
<Tab to="/home/recent" exact>
Recently viewed
</Tab>
<Tab to="/home/created">Created by me</Tab>
</Tabs>
<Switch>
<Route path="/home/recent">
<PaginatedDocumentList
key="recent"
documents={documents.recentlyViewed}
fetch={documents.fetchRecentlyViewed}
showCollection
/>
</Route>
<Route path="/home/created">
<PaginatedDocumentList
key="created"
documents={documents.createdByUser(user)}
fetch={documents.fetchOwned}
options={{ user }}
showCollection
/>
</Route>
<Route path="/home">
<PaginatedDocumentList
documents={documents.recentlyUpdated}
fetch={documents.fetchRecentlyUpdated}
showCollection
/>
</Route>
</Switch>
<Actions align="center" justify="flex-end">
<Action>
<InputSearch source="dashboard" />
</Action>
<Action>
<NewDocumentMenu />
</Action>
</Actions>
</CenteredContent>
);
}
}
export default observer(Dashboard);
export default inject("documents", "auth")(Dashboard);
+33 -15
View File
@@ -9,6 +9,7 @@ import type { RouterHistory, Match } from "react-router-dom";
import { withRouter } from "react-router-dom";
import { withTheme } from "styled-components";
import parseDocumentSlug from "shared/utils/parseDocumentSlug";
import AuthStore from "stores/AuthStore";
import DocumentsStore from "stores/DocumentsStore";
import PoliciesStore from "stores/PoliciesStore";
import RevisionsStore from "stores/RevisionsStore";
@@ -30,6 +31,7 @@ import { matchDocumentEdit, updateDocumentUrl } from "utils/routeHelpers";
type Props = {|
match: Match,
location: LocationWithState,
auth: AuthStore,
shares: SharesStore,
documents: DocumentsStore,
policies: PoliciesStore,
@@ -217,7 +219,7 @@ class DataLoader extends React.Component<Props> {
};
render() {
const { location, policies, ui } = this.props;
const { location, policies, auth, ui } = this.props;
if (this.error) {
return this.error instanceof OfflineError ? (
@@ -227,10 +229,11 @@ class DataLoader extends React.Component<Props> {
);
}
const team = auth.team;
const document = this.document;
const revision = this.revision;
if (!document) {
if (!document || !team) {
return (
<>
<Loading location={location} />
@@ -240,21 +243,36 @@ class DataLoader extends React.Component<Props> {
}
const abilities = policies.abilities(document.id);
const key = this.isEditing ? "editing" : "read-only";
const key = team.multiplayerEditor
? ""
: this.isEditing
? "editing"
: "read-only";
return (
<SocketPresence documentId={document.id} isEditing={this.isEditing}>
{this.isEditing && <HideSidebar ui={ui} />}
<DocumentComponent
key={key}
document={document}
revision={revision}
abilities={abilities}
location={location}
readOnly={!this.isEditing || !abilities.update || document.isArchived}
onSearchLink={this.onSearchLink}
onCreateLink={this.onCreateLink}
/>
<SocketPresence
documentId={document.id}
userId={auth.user ? auth.user.id : undefined}
isMultiplayer={team.multiplayerEditor}
>
{(multiplayer) => (
<>
{this.isEditing && <HideSidebar ui={ui} />}
<DocumentComponent
key={key}
document={document}
revision={revision}
abilities={abilities}
location={location}
multiplayer={multiplayer}
readOnly={
!this.isEditing || !abilities.update || document.isArchived
}
onSearchLink={this.onSearchLink}
onCreateLink={this.onCreateLink}
/>
</>
)}
</SocketPresence>
);
}
+47 -8
View File
@@ -9,7 +9,7 @@ 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 * as Y from "yjs";
import AuthStore from "stores/AuthStore";
import UiStore from "stores/UiStore";
import Document from "models/Document";
@@ -30,6 +30,8 @@ import Header from "./Header";
import KeyboardShortcutsButton from "./KeyboardShortcutsButton";
import MarkAsViewed from "./MarkAsViewed";
import References from "./References";
import MultiplayerExtension from "multiplayer/MultiplayerExtension";
import { WebsocketProvider } from "multiplayer/WebsocketProvider";
import { type LocationWithState, type Theme } from "types";
import { isCustomDomain } from "utils/domains";
import { emojiToUrl } from "utils/emoji";
@@ -60,6 +62,12 @@ type Props = {
document: Document,
revision: Revision,
readOnly: boolean,
multiplayer: {
isConnected: boolean,
isReconnecting: boolean,
provider: ?WebsocketProvider,
doc: Y.Doc,
},
onCreateLink: (title: string) => string,
onSearchLink: (term: string) => any,
theme: Theme,
@@ -195,7 +203,7 @@ class DocumentScene extends React.Component<Props> {
autosave?: boolean,
} = {}
) => {
const { document } = this.props;
const { document, auth } = this.props;
// prevent saves when we are already saving
if (document.isSaving) return;
@@ -223,10 +231,14 @@ class DocumentScene extends React.Component<Props> {
this.isPublishing = !!options.publish;
try {
const savedDocument = await document.save({
...options,
lastRevision: this.lastRevision,
});
let savedDocument = document;
if (!auth.team || !auth.team.multiplayerEditor) {
savedDocument = await document.save({
...options,
lastRevision: this.lastRevision,
});
}
this.isDirty = false;
this.lastRevision = savedDocument.revision;
@@ -311,8 +323,10 @@ class DocumentScene extends React.Component<Props> {
auth,
ui,
match,
multiplayer,
} = this.props;
const team = auth.team;
const user = auth.user;
const isShare = !!match.params.shareId;
const value = revision ? revision.text : document.text;
@@ -350,7 +364,12 @@ class DocumentScene extends React.Component<Props> {
{!readOnly && (
<>
<Prompt
when={this.isDirty && !this.isUploading}
when={
this.isDirty &&
!this.isUploading &&
!!team &&
!team.multiplayerEditor
}
message={DISCARD_CHANGES}
/>
<Prompt
@@ -409,6 +428,16 @@ class DocumentScene extends React.Component<Props> {
)}
</Notice>
)}
{team &&
multiplayer &&
!multiplayer.isConnected &&
team.multiplayerEditor && (
<Notice muted>
Connection lost. Any edits will sync once youre back
online.{" "}
{multiplayer.isReconnecting && "Trying to reconnect…"}
</Notice>
)}
<React.Suspense fallback={<LoadingPlaceholder />}>
<Flex auto={!readOnly}>
{showContents && <Contents headings={headings} />}
@@ -422,7 +451,7 @@ class DocumentScene extends React.Component<Props> {
title={revision ? revision.title : this.title}
document={document}
value={readOnly ? value : undefined}
defaultValue={value}
defaultValue={team && team.multiplayerEditor ? "" : value}
disableEmbeds={disableEmbeds}
onImageUploadStart={this.onImageUploadStart}
onImageUploadStop={this.onImageUploadStop}
@@ -436,6 +465,16 @@ class DocumentScene extends React.Component<Props> {
readOnly={readOnly}
readOnlyWriteCheckboxes={readOnly && abilities.update}
ui={this.props.ui}
extensions={
team && team.multiplayerEditor && !isShare && !revision
? [
new MultiplayerExtension({
user,
...multiplayer,
}),
]
: undefined
}
/>
</Flex>
{readOnly && !isShare && !revision && (
+1 -6
View File
@@ -54,7 +54,7 @@ class DocumentEditor extends React.Component<Props> {
if (event.key === "Enter") {
event.preventDefault();
if (event.metaKey) {
this.props.onSave({ done: true });
this.props.onSave({ publish: true, done: true });
return;
}
@@ -67,11 +67,6 @@ class DocumentEditor extends React.Component<Props> {
this.focusAtStart();
return;
}
if (event.key === "p" && event.metaKey && event.shiftKey) {
event.preventDefault();
this.props.onSave({ publish: true, done: true });
return;
}
if (event.key === "s" && event.metaKey) {
event.preventDefault();
this.props.onSave({});
+27 -35
View File
@@ -11,8 +11,7 @@ import {
} from "outline-icons";
import { transparentize, darken } from "polished";
import * as React from "react";
import { withTranslation, Trans, type TFunction } from "react-i18next";
import { Redirect } from "react-router-dom";
import { withRouter, type RouterHistory } from "react-router-dom";
import styled from "styled-components";
import breakpoint from "styled-components-breakpoint";
import AuthStore from "stores/AuthStore";
@@ -51,19 +50,18 @@ type Props = {
publishingIsDisabled: boolean,
savingIsDisabled: boolean,
onDiscard: () => void,
history: RouterHistory,
onSave: ({
done?: boolean,
publish?: boolean,
autosave?: boolean,
}) => void,
t: TFunction,
};
@observer
class Header extends React.Component<Props> {
@observable isScrolled = false;
@observable showShareModal = false;
@observable redirectTo: ?string;
componentDidMount() {
window.addEventListener("scroll", this.handleScroll);
@@ -80,15 +78,17 @@ class Header extends React.Component<Props> {
handleScroll = throttle(this.updateIsScrolled, 50);
handleEdit = () => {
this.redirectTo = editDocumentUrl(this.props.document);
this.props.history.push(editDocumentUrl(this.props.document));
};
handleNewFromTemplate = () => {
const { document } = this.props;
const { document, history } = this.props;
this.redirectTo = newDocumentUrl(document.collectionId, {
templateId: document.id,
});
history.push(
newDocumentUrl(document.collectionId, {
templateId: document.id,
})
);
};
handleSave = () => {
@@ -118,8 +118,6 @@ class Header extends React.Component<Props> {
};
render() {
if (this.redirectTo) return <Redirect to={this.redirectTo} push />;
const {
shares,
document,
@@ -133,7 +131,6 @@ class Header extends React.Component<Props> {
publishingIsDisabled,
ui,
auth,
t,
} = this.props;
const share = shares.getByDocumentId(document.id);
@@ -156,7 +153,7 @@ class Header extends React.Component<Props> {
<Modal
isOpen={this.showShareModal}
onRequestClose={this.handleCloseShareModal}
title={t("Share document")}
title="Share document"
>
<DocumentShare
document={document}
@@ -169,9 +166,7 @@ class Header extends React.Component<Props> {
<>
<Slash />
<Tooltip
tooltip={
ui.tocVisible ? t("Hide contents") : t("Show contents")
}
tooltip={ui.tocVisible ? "Hide contents" : "Show contents"}
shortcut={`ctrl+${meta}+h`}
delay={250}
placement="bottom"
@@ -195,15 +190,14 @@ class Header extends React.Component<Props> {
{this.isScrolled && (
<Title onClick={this.handleClickTitle}>
<Fade>
{document.title}{" "}
{document.isArchived && <Badge>{t("Archived")}</Badge>}
{document.title} {document.isArchived && <Badge>Archived</Badge>}
</Fade>
</Title>
)}
<Wrapper align="center" justify="flex-end">
{isSaving && !isPublishing && (
<Action>
<Status>{t("Saving")}</Status>
<Status>Saving</Status>
</Action>
)}
&nbsp;
@@ -223,10 +217,10 @@ class Header extends React.Component<Props> {
<Tooltip
tooltip={
isPubliclyShared ? (
<Trans>
<>
Anyone with the link <br />
can view this document
</Trans>
</>
) : (
""
)
@@ -240,7 +234,7 @@ class Header extends React.Component<Props> {
neutral
small
>
{t("Share")}
Share
</Button>
</Tooltip>
</Action>
@@ -249,7 +243,7 @@ class Header extends React.Component<Props> {
<>
<Action>
<Tooltip
tooltip={t("Save")}
tooltip="Save"
shortcut={`${meta}+enter`}
delay={500}
placement="bottom"
@@ -261,7 +255,7 @@ class Header extends React.Component<Props> {
neutral={isDraft}
small
>
{isDraft ? t("Save Draft") : t("Done Editing")}
{isDraft ? "Save Draft" : "Done Editing"}
</Button>
</Tooltip>
</Action>
@@ -270,7 +264,7 @@ class Header extends React.Component<Props> {
{canEdit && (
<Action>
<Tooltip
tooltip={t("Edit {{noun}}", { noun: document.noun })}
tooltip={`Edit ${document.noun}`}
shortcut="e"
delay={500}
placement="bottom"
@@ -281,7 +275,7 @@ class Header extends React.Component<Props> {
neutral
small
>
{t("Edit")}
Edit
</Button>
</Tooltip>
</Action>
@@ -292,13 +286,13 @@ class Header extends React.Component<Props> {
document={document}
label={
<Tooltip
tooltip={t("New document")}
tooltip="New document"
shortcut="n"
delay={500}
placement="bottom"
>
<Button icon={<PlusIcon />} neutral>
{t("New doc")}
New doc
</Button>
</Tooltip>
}
@@ -313,25 +307,25 @@ class Header extends React.Component<Props> {
primary
small
>
{t("New from template")}
New from template
</Button>
</Action>
)}
{can.update && isDraft && !isRevision && (
<Action>
<Tooltip
tooltip={t("Publish")}
tooltip="Publish"
shortcut={`${meta}+shift+p`}
delay={500}
placement="bottom"
>
<Button
onClick={this.handlePublish}
title={t("Publish document")}
title="Publish document"
disabled={publishingIsDisabled}
small
>
{isPublishing ? `${t("Publishing")}` : t("Publish")}
{isPublishing ? "Publishing" : "Publish"}
</Button>
</Tooltip>
</Action>
@@ -431,6 +425,4 @@ const Title = styled.div`
`};
`;
export default withTranslation()<Header>(
inject("auth", "ui", "policies", "shares")(Header)
);
export default inject("auth", "ui", "policies", "shares")(withRouter(Header));
+1 -6
View File
@@ -1,6 +1,5 @@
// @flow
import * as React from "react";
import { useTranslation } from "react-i18next";
import CenteredContent from "components/CenteredContent";
import LoadingPlaceholder from "components/LoadingPlaceholder";
import PageTitle from "components/PageTitle";
@@ -12,13 +11,9 @@ type Props = {|
|};
export default function Loading({ location }: Props) {
const { t } = useTranslation();
return (
<Container column auto>
<PageTitle
title={location.state ? location.state.title : t("Untitled")}
/>
<PageTitle title={location.state ? location.state.title : "Untitled"} />
<CenteredContent>
<LoadingPlaceholder />
</CenteredContent>
@@ -16,9 +16,8 @@ class MarkAsViewed extends React.Component<Props> {
const { document } = this.props;
this.viewTimeout = setTimeout(async () => {
const view = await document.view();
if (view) {
if (document.publishedAt) {
const view = await document.view();
document.updateLastViewed(view);
}
}, MARK_AS_VIEWED_AFTER);
@@ -1,77 +1,106 @@
// @flow
import * as React from "react";
import { USER_PRESENCE_INTERVAL } from "shared/constants";
import * as Y from "yjs";
import { SocketContext } from "components/SocketProvider";
import useStores from "hooks/useStores";
import { WebsocketProvider } from "multiplayer/WebsocketProvider";
type Props = {
children?: React.Node,
children: ({
provider: ?WebsocketProvider,
isReconnecting: boolean,
isConnected: boolean,
doc: Y.Doc,
}) => React.Node,
isMultiplayer: boolean,
documentId: string,
isEditing: boolean,
userId?: string,
};
export default class SocketPresence extends React.Component<Props> {
static contextType = SocketContext;
previousContext: any;
editingInterval: IntervalID;
export default function SocketPresence(props: Props) {
const { presence } = useStores();
const context = React.useContext(SocketContext);
const [isConnected, setConnected] = React.useState(
context ? context.connected : false
);
const [isReconnecting, setReconnecting] = React.useState(false);
const [doc] = React.useState(() =>
props.isMultiplayer ? new Y.Doc() : undefined
);
const [provider] = React.useState(() =>
props.isMultiplayer && props.userId
? new WebsocketProvider(context, props.documentId, props.userId, doc)
: undefined
);
componentDidMount() {
this.editingInterval = setInterval(() => {
if (this.props.isEditing) {
this.emitPresence();
React.useEffect(() => {
return () => {
console.log("destroy");
provider.destroy();
};
}, []);
const awareness = provider && provider.awareness;
React.useEffect(() => {
const onUpdate = () => {
presence.updateFromAwareness(props.documentId, awareness);
};
if (awareness) {
awareness.on("update", onUpdate);
}
return () => {
if (awareness) {
awareness.off("update", onUpdate);
}
}, USER_PRESENCE_INTERVAL);
this.setupOnce();
}
};
}, [presence, props.documentId, awareness]);
componentDidUpdate(prevProps: Props) {
this.setupOnce();
React.useEffect(() => {
console.log("useEffect", context);
if (!context) return;
if (prevProps.isEditing !== this.props.isEditing) {
this.emitPresence();
}
}
const emitJoin = () => {
if (!context) return;
context.emit("join", { documentId: props.documentId });
};
componentWillUnmount() {
if (this.context) {
this.context.emit("leave", { documentId: this.props.documentId });
this.context.off("authenticated", this.emitJoin);
const updateStatus = () => {
setConnected(context.connected);
};
const reconnectingStopped = () => {
setReconnecting(false);
};
context.on("connect", updateStatus);
context.on("disconnect", updateStatus);
context.on("reconnect", reconnectingStopped);
context.on("reconnect_attempt", setReconnecting);
context.on("reconnect_failed", reconnectingStopped);
context.on("authenticated", emitJoin);
if (context.authenticated) {
emitJoin();
}
clearInterval(this.editingInterval);
}
return () => {
if (!context) return;
context.emit("leave", { documentId: props.documentId });
context.off("authenticated", emitJoin);
context.off("connect", updateStatus);
context.off("disconnect", updateStatus);
context.off("reconnect", reconnectingStopped);
context.off("reconnect_attempt", setReconnecting);
context.off("reconnect_failed", reconnectingStopped);
};
}, [context, props.documentId, props.userId]);
setupOnce = () => {
if (this.context && this.context !== this.previousContext) {
this.previousContext = this.context;
if (this.context.authenticated) {
this.emitJoin();
}
this.context.on("authenticated", () => {
this.emitJoin();
});
}
};
emitJoin = () => {
if (!this.context) return;
this.context.emit("join", {
documentId: this.props.documentId,
isEditing: this.props.isEditing,
});
};
emitPresence = () => {
if (!this.context) return;
this.context.emit("presence", {
documentId: this.props.documentId,
isEditing: this.props.isEditing,
});
};
render() {
return this.props.children || null;
}
return props.children({
isConnected,
isReconnecting,
provider,
doc,
});
}
+8 -14
View File
@@ -3,7 +3,6 @@ import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import queryString from "query-string";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import { type RouterHistory } from "react-router-dom";
import styled from "styled-components";
import DocumentsStore from "stores/DocumentsStore";
@@ -26,7 +25,6 @@ type Props = {|
documents: DocumentsStore,
history: RouterHistory,
location: LocationWithState,
t: TFunction,
|};
@observer
@@ -35,7 +33,7 @@ class Drafts extends React.Component<Props> {
this.props.location.search
);
componentDidUpdate(prevProps: Props) {
componentDidUpdate(prevProps) {
if (prevProps.location.search !== this.props.location.search) {
this.handleQueryChange();
}
@@ -45,10 +43,7 @@ class Drafts extends React.Component<Props> {
this.params = new URLSearchParams(this.props.location.search);
};
handleFilterChange = (search: {
dateFilter?: ?string,
collectionId?: ?string,
}) => {
handleFilterChange = (search) => {
this.props.history.replace({
pathname: this.props.location.pathname,
search: queryString.stringify({
@@ -69,7 +64,6 @@ class Drafts extends React.Component<Props> {
}
render() {
const { t } = this.props;
const { drafts, fetchDrafts } = this.props.documents;
const isFiltered = this.collectionId || this.dateFilter;
const options = {
@@ -79,10 +73,10 @@ class Drafts extends React.Component<Props> {
return (
<CenteredContent column auto>
<PageTitle title={t("Drafts")} />
<Heading>{t("Drafts")}</Heading>
<PageTitle title="Drafts" />
<Heading>Drafts</Heading>
<Subheading>
{t("Documents")}
Documents
<Filters>
<CollectionFilter
collectionId={this.collectionId}
@@ -101,8 +95,8 @@ class Drafts extends React.Component<Props> {
empty={
<Empty>
{isFiltered
? t("No documents found for your filters.")
: t("Youve not got any drafts at the moment.")}
? "No documents found for your filters."
: "Youve not got any drafts at the moment."}
</Empty>
}
fetch={fetchDrafts}
@@ -137,4 +131,4 @@ const Filters = styled(Flex)`
}
`;
export default withTranslation()<Drafts>(inject("documents")(Drafts));
export default inject("documents")(Drafts);
+4 -9
View File
@@ -1,23 +1,18 @@
// @flow
import * as React from "react";
import { useTranslation, Trans } from "react-i18next";
import { Link } from "react-router-dom";
import CenteredContent from "components/CenteredContent";
import Empty from "components/Empty";
import PageTitle from "components/PageTitle";
const Error404 = () => {
const { t } = useTranslation();
return (
<CenteredContent>
<PageTitle title={t("Not found")} />
<h1>{t("Not found")}</h1>
<PageTitle title="Not Found" />
<h1>Not found</h1>
<Empty>
<Trans>
We were unable to find the page youre looking for. Go to the{" "}
<Link to="/home">homepage</Link>?
</Trans>
We were unable to find the page youre looking for. Go to the{" "}
<Link to="/home">homepage</Link>?
</Empty>
</CenteredContent>
);
+3 -6
View File
@@ -1,18 +1,15 @@
// @flow
import * as React from "react";
import { useTranslation } from "react-i18next";
import CenteredContent from "components/CenteredContent";
import Empty from "components/Empty";
import PageTitle from "components/PageTitle";
const ErrorOffline = () => {
const { t } = useTranslation();
return (
<CenteredContent>
<PageTitle title={t("Offline")} />
<h1>{t("Offline")}</h1>
<Empty>{t("We were unable to load the document while offline.")}</Empty>
<PageTitle title="Offline" />
<h1>Offline</h1>
<Empty>We were unable to load the document while offline.</Empty>
</CenteredContent>
);
};
+8 -16
View File
@@ -1,37 +1,29 @@
// @flow
import { inject, observer } from "mobx-react";
import * as React from "react";
import { useTranslation, Trans } from "react-i18next";
import AuthStore from "stores/AuthStore";
import CenteredContent from "components/CenteredContent";
import PageTitle from "components/PageTitle";
const ErrorSuspended = ({ auth }: { auth: AuthStore }) => {
const { t } = useTranslation();
const ErrorSuspended = observer(({ auth }: { auth: AuthStore }) => {
return (
<CenteredContent>
<PageTitle title={t("Your account has been suspended")} />
<PageTitle title="Your account has been suspended" />
<h1>
<span role="img" aria-label="Warning sign">
</span>{" "}
{t("Your account has been suspended")}
Your account has been suspended
</h1>
<p>
<Trans>
A team admin (
<strong>
{{ suspendedContactEmail: auth.suspendedContactEmail }}
</strong>
) has suspended your account. To re-activate your account, please
reach out to them directly.
</Trans>
A team admin (<strong>{auth.suspendedContactEmail}</strong>) has
suspended your account. To re-activate your account, please reach out to
them directly.
</p>
</CenteredContent>
);
};
});
export default inject("auth")(observer(ErrorSuspended));
export default inject("auth")(ErrorSuspended);
+18 -23
View File
@@ -3,13 +3,11 @@ import { debounce } from "lodash";
import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import AuthStore from "stores/AuthStore";
import GroupMembershipsStore from "stores/GroupMembershipsStore";
import UiStore from "stores/UiStore";
import UsersStore from "stores/UsersStore";
import Group from "models/Group";
import User from "models/User";
import Invite from "scenes/Invite";
import Empty from "components/Empty";
import Flex from "components/Flex";
@@ -26,7 +24,6 @@ type Props = {
groupMemberships: GroupMembershipsStore,
users: UsersStore,
onSubmit: () => void,
t: TFunction,
};
@observer
@@ -53,45 +50,40 @@ class AddPeopleToGroup extends React.Component<Props> {
});
}, 250);
handleAddUser = async (user: User) => {
const { t } = this.props;
handleAddUser = async (user) => {
try {
await this.props.groupMemberships.create({
groupId: this.props.group.id,
userId: user.id,
});
this.props.ui.showToast(
t(`{{userName}} was added to the group`, { userName: user.name })
);
this.props.ui.showToast(`${user.name} was added to the group`);
} catch (err) {
this.props.ui.showToast(t("Could not add user"));
this.props.ui.showToast("Could not add user");
}
};
render() {
const { users, group, auth, t } = this.props;
const { users, group, auth } = this.props;
const { user, team } = auth;
if (!user || !team) return null;
return (
<Flex column>
<HelpText>
{t(
"Add team members below to give them access to the group. Need to add someone whos not yet on the team yet?"
)}{" "}
Add team members below to give them access to the group. Need to add
someone whos not yet on the team yet?{" "}
<a role="button" onClick={this.handleInviteModalOpen}>
{t("Invite them to {{teamName}}", { teamName: team.name })}
Invite them to {team.name}
</a>
.
</HelpText>
<Input
type="search"
placeholder={`${t("Search by name")}`}
placeholder="Search by name"
value={this.query}
onChange={this.handleFilter}
label={t("Search people")}
label="Search people"
labelHidden
autoFocus
flex
@@ -99,9 +91,9 @@ class AddPeopleToGroup extends React.Component<Props> {
<PaginatedList
empty={
this.query ? (
<Empty>{t("No people matching your search")}</Empty>
<Empty>No people matching your search</Empty>
) : (
<Empty>{t("No people left to add")}</Empty>
<Empty>No people left to add</Empty>
)
}
items={users.notInGroup(group.id, this.query)}
@@ -116,7 +108,7 @@ class AddPeopleToGroup extends React.Component<Props> {
)}
/>
<Modal
title={t("Invite people")}
title="Invite people"
onRequestClose={this.handleInviteModalClose}
isOpen={this.inviteModalOpen}
>
@@ -127,6 +119,9 @@ class AddPeopleToGroup extends React.Component<Props> {
}
}
export default withTranslation()<AddPeopleToGroup>(
inject("auth", "users", "groupMemberships", "ui")(AddPeopleToGroup)
);
export default inject(
"auth",
"users",
"groupMemberships",
"ui"
)(AddPeopleToGroup);
+13 -16
View File
@@ -3,14 +3,12 @@ import { observable } from "mobx";
import { inject, observer } from "mobx-react";
import { PlusIcon } from "outline-icons";
import * as React from "react";
import { withTranslation, type TFunction } from "react-i18next";
import AuthStore from "stores/AuthStore";
import GroupMembershipsStore from "stores/GroupMembershipsStore";
import PoliciesStore from "stores/PoliciesStore";
import UiStore from "stores/UiStore";
import UsersStore from "stores/UsersStore";
import Group from "models/Group";
import User from "models/User";
import Button from "components/Button";
import Empty from "components/Empty";
import Flex from "components/Flex";
@@ -28,7 +26,6 @@ type Props = {
users: UsersStore,
policies: PoliciesStore,
groupMemberships: GroupMembershipsStore,
t: TFunction,
};
@observer
@@ -43,24 +40,20 @@ class GroupMembers extends React.Component<Props> {
this.addModalOpen = false;
};
handleRemoveUser = async (user: User) => {
const { t } = this.props;
handleRemoveUser = async (user) => {
try {
await this.props.groupMemberships.delete({
groupId: this.props.group.id,
userId: user.id,
});
this.props.ui.showToast(
t(`{{userName}} was removed from the group`, { userName: user.name })
);
this.props.ui.showToast(`${user.name} was removed from the group`);
} catch (err) {
this.props.ui.showToast(t("Could not remove user"));
this.props.ui.showToast("Could not remove user");
}
};
render() {
const { group, users, groupMemberships, policies, t, auth } = this.props;
const { group, users, groupMemberships, policies, auth } = this.props;
const { user } = auth;
if (!user) return null;
@@ -82,7 +75,7 @@ class GroupMembers extends React.Component<Props> {
icon={<PlusIcon />}
neutral
>
{t("Add people")}
Add people
</Button>
</span>
</>
@@ -97,7 +90,7 @@ class GroupMembers extends React.Component<Props> {
items={users.inGroup(group.id)}
fetch={groupMemberships.fetchPage}
options={{ id: group.id }}
empty={<Empty>{t("This group has no members.")}</Empty>}
empty={<Empty>This group has no members.</Empty>}
renderItem={(item) => (
<GroupMemberListItem
key={item.id}
@@ -126,6 +119,10 @@ class GroupMembers extends React.Component<Props> {
}
}
export default withTranslation()<GroupMembers>(
inject("auth", "users", "policies", "groupMemberships", "ui")(GroupMembers)
);
export default inject(
"auth",
"users",
"policies",
"groupMemberships",
"ui"
)(GroupMembers);
+44 -42
View File
@@ -1,6 +1,5 @@
// @flow
import * as React from "react";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import Flex from "components/Flex";
import HelpText from "components/HelpText";
@@ -8,150 +7,153 @@ import Key from "components/Key";
import { meta } from "utils/keyboard";
function KeyboardShortcuts() {
const { t } = useTranslation();
return (
<Flex column>
<HelpText>
{t(
"Outline is designed to be fast and easy to use. All of your usual keyboard shortcuts work here, and theres Markdown too."
)}
Outline is designed to be fast and easy to use. All of your usual
keyboard shortcuts work here, and theres Markdown too.
</HelpText>
<h2>{t("Navigation")}</h2>
<h2>Navigation</h2>
<List>
<Keys>
<Key>n</Key>
</Keys>
<Label>{t("New document in current collection")}</Label>
<Label>New document in current collection</Label>
<Keys>
<Key>e</Key>
</Keys>
<Label>{t("Edit current document")}</Label>
<Label>Edit current document</Label>
<Keys>
<Key>m</Key>
</Keys>
<Label>{t("Move current document")}</Label>
<Label>Move current document</Label>
<Keys>
<Key>/</Key> or <Key>t</Key>
</Keys>
<Label>{t("Jump to search")}</Label>
<Label>Jump to search</Label>
<Keys>
<Key>d</Key>
</Keys>
<Label>{t("Jump to dashboard")}</Label>
<Label>Jump to dashboard</Label>
<Keys>
<Key>{meta}</Key> + <Key>Ctrl</Key> + <Key>h</Key>
</Keys>
<Label>{t("Table of contents")}</Label>
<Label>Table of contents</Label>
<Keys>
<Key>?</Key>
</Keys>
<Label>{t("Open this guide")}</Label>
<Label>Open this guide</Label>
</List>
<h2>{t("Editor")}</h2>
<h2>Editor</h2>
<List>
<Keys>
<Key>{meta}</Key> + <Key>Enter</Key>
</Keys>
<Label>{t("Save and exit document edit mode")}</Label>
<Label>Save and exit document edit mode</Label>
<Keys>
<Key>{meta}</Key> + <Key>Shift</Key> + <Key>p</Key>
</Keys>
<Label>{t("Publish and exit document edit mode")}</Label>
<Label>Publish and exit document edit mode</Label>
<Keys>
<Key>{meta}</Key> + <Key>s</Key>
</Keys>
<Label>{t("Save document and continue editing")}</Label>
<Label>Save document and continue editing</Label>
<Keys>
<Key>{meta}</Key> + <Key>Esc</Key>
</Keys>
<Label>{t("Cancel editing")}</Label>
<Label>Cancel editing</Label>
<Keys>
<Key>{meta}</Key> + <Key>b</Key>
</Keys>
<Label>{t("Bold")}</Label>
<Label>Bold</Label>
<Keys>
<Key>{meta}</Key> + <Key>i</Key>
</Keys>
<Label>{t("Italic")}</Label>
<Label>Italic</Label>
<Keys>
<Key>{meta}</Key> + <Key>u</Key>
</Keys>
<Label>{t("Underline")}</Label>
<Label>Underline</Label>
<Keys>
<Key>{meta}</Key> + <Key>d</Key>
</Keys>
<Label>{t("Strikethrough")}</Label>
<Label>Strikethrough</Label>
<Keys>
<Key>{meta}</Key> + <Key>k</Key>
</Keys>
<Label>{t("Link")}</Label>
<Label>Link</Label>
<Keys>
<Key>{meta}</Key> + <Key>z</Key>
</Keys>
<Label>{t("Undo")}</Label>
<Label>Undo</Label>
<Keys>
<Key>{meta}</Key> + <Key>Shift</Key> + <Key>z</Key>
</Keys>
<Label>{t("Redo")}</Label>
<Label>Redo</Label>
</List>
<h2>{t("Markdown")}</h2>
<h2>Markdown</h2>
<List>
<Keys>
<Key>#</Key> <Key>Space</Key>
</Keys>
<Label>{t("Large header")}</Label>
<Label>Large header</Label>
<Keys>
<Key>##</Key> <Key>Space</Key>
</Keys>
<Label>{t("Medium header")}</Label>
<Label>Medium header</Label>
<Keys>
<Key>###</Key> <Key>Space</Key>
</Keys>
<Label>{t("Small header")}</Label>
<Label>Small header</Label>
<Keys>
<Key>1.</Key> <Key>Space</Key>
</Keys>
<Label>{t("Numbered list")}</Label>
<Label>Numbered list</Label>
<Keys>
<Key>-</Key> <Key>Space</Key>
</Keys>
<Label>{t("Bulleted list")}</Label>
<Label>Bulleted list</Label>
<Keys>
<Key>[ ]</Key> <Key>Space</Key>
</Keys>
<Label>{t("Todo list")}</Label>
<Label>Todo list</Label>
<Keys>
<Key>&gt;</Key> <Key>Space</Key>
</Keys>
<Label>{t("Blockquote")}</Label>
<Label>Blockquote</Label>
<Keys>
<Key>---</Key>
</Keys>
<Label>{t("Horizontal divider")}</Label>
<Label>Horizontal divider</Label>
<Keys>
<Key>{"```"}</Key>
</Keys>
<Label>{t("Code block")}</Label>
<Label>Code block</Label>
<Keys>
<Key>{":::"}</Key>
</Keys>
<Label>{t("Info notice")}</Label>
<Label>Info notice</Label>
<Keys>_italic_</Keys>
<Label>{t("Italic")}</Label>
<Label>Italic</Label>
<Keys>**bold**</Keys>
<Label>{t("Bold")}</Label>
<Label>Bold</Label>
<Keys>~~strikethrough~~</Keys>
<Label>{t("Strikethrough")}</Label>
<Label>Strikethrough</Label>
<Keys>{"`code`"}</Keys>
<Label>{t("Inline code")}</Label>
<Label>Inline code</Label>
<Keys>==highlight==</Keys>
<Label>{t("Highlight")}</Label>
<Label>highlight</Label>
</List>
</Flex>
);
+18 -33
View File
@@ -7,7 +7,6 @@ import { PlusIcon } from "outline-icons";
import queryString from "query-string";
import * as React from "react";
import ReactDOM from "react-dom";
import { withTranslation, Trans, type TFunction } from "react-i18next";
import keydown from "react-keydown";
import { withRouter, Link } from "react-router-dom";
import type { RouterHistory, Match } from "react-router-dom";
@@ -45,12 +44,11 @@ type Props = {
documents: DocumentsStore,
users: UsersStore,
notFound: ?boolean,
t: TFunction,
};
@observer
class Search extends React.Component<Props> {
firstDocument: ?React.Component<any>;
firstDocument: ?React.Component<typeof DocumentPreview>;
lastQuery: string = "";
@observable
@@ -69,7 +67,7 @@ class Search extends React.Component<Props> {
}
}
componentDidUpdate(prevProps: Props) {
componentDidUpdate(prevProps) {
if (prevProps.location.search !== this.props.location.search) {
this.handleQueryChange();
}
@@ -83,7 +81,7 @@ class Search extends React.Component<Props> {
this.props.history.goBack();
}
handleKeyDown = (ev: SyntheticKeyboardEvent<>) => {
handleKeyDown = (ev) => {
if (ev.key === "Enter") {
this.fetchResults();
return;
@@ -126,12 +124,7 @@ class Search extends React.Component<Props> {
this.fetchResultsDebounced();
};
handleFilterChange = (search: {
collectionId?: ?string,
userId?: ?string,
dateFilter?: ?string,
includeArchived?: ?string,
}) => {
handleFilterChange = (search) => {
this.props.history.replace({
pathname: this.props.location.pathname,
search: queryString.stringify({
@@ -177,7 +170,7 @@ class Search extends React.Component<Props> {
get title() {
const query = this.query;
const title = this.props.t("Search");
const title = "Search";
if (query) return `${query} ${title}`;
return title;
}
@@ -238,19 +231,20 @@ class Search extends React.Component<Props> {
trailing: true,
});
updateLocation = (query: string) => {
updateLocation = (query) => {
this.props.history.replace({
pathname: searchUrl(query),
search: this.props.location.search,
});
};
setFirstDocumentRef = (ref: any) => {
setFirstDocumentRef = (ref) => {
// $FlowFixMe
this.firstDocument = ref;
};
render() {
const { documents, notFound, location, t } = this.props;
const { documents, notFound, location } = this.props;
const results = documents.searchResults(this.query);
const showEmpty = !this.isLoading && this.query && results.length === 0;
const showShortcutTip =
@@ -262,15 +256,12 @@ class Search extends React.Component<Props> {
{this.isLoading && <LoadingIndicator />}
{notFound && (
<div>
<h1>{t("Not Found")}</h1>
<Empty>
{t("We were unable to find the page youre looking for.")}
</Empty>
<h1>Not Found</h1>
<Empty>We were unable to find the page youre looking for.</Empty>
</div>
)}
<ResultsWrapper pinToTop={this.pinToTop} column auto>
<SearchField
placeholder={`${t("Search")}`}
onKeyDown={this.handleKeyDown}
onChange={this.updateLocation}
defaultValue={this.query}
@@ -278,10 +269,8 @@ class Search extends React.Component<Props> {
{showShortcutTip && (
<Fade>
<HelpText small>
<Trans>
Use the <strong>{{ meta }}+K</strong> shortcut to search from
anywhere in your knowledge base
</Trans>
Use the <strong>{meta}+K</strong> shortcut to search from
anywhere in Outline
</HelpText>
</Fade>
)}
@@ -315,10 +304,8 @@ class Search extends React.Component<Props> {
<Fade>
<Centered column>
<HelpText>
<Trans>
No documents found for your search filters. <br />
Create a new document?
</Trans>
No documents found for your search filters. <br />
Create a new document?
</HelpText>
<Wrapper>
{this.collectionId ? (
@@ -327,14 +314,14 @@ class Search extends React.Component<Props> {
icon={<PlusIcon />}
primary
>
{t("New doc")}
New doc
</Button>
) : (
<NewDocumentMenu />
)}
&nbsp;&nbsp;
<Button as={Link} to="/search" neutral>
{t("Clear filters")}
Clear filters
</Button>
</Wrapper>
</Centered>
@@ -427,6 +414,4 @@ const Filters = styled(Flex)`
}
`;
export default withTranslation()<Search>(
withRouter(inject("documents")(Search))
);
export default withRouter(inject("documents")(Search));
+1 -2
View File
@@ -8,7 +8,6 @@ import { type Theme } from "types";
type Props = {
onChange: (string) => void,
defaultValue?: string,
placeholder?: string,
theme: Theme,
};
@@ -45,7 +44,7 @@ class SearchField extends React.Component<Props> {
ref={(ref) => (this.input = ref)}
onChange={this.handleChange}
spellCheck="false"
placeholder={this.props.placeholder}
placeholder="Search…"
type="search"
autoFocus
/>
+70
View File
@@ -0,0 +1,70 @@
// @flow
import { debounce } from "lodash";
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
import * as React from "react";
import AuthStore from "stores/AuthStore";
import UiStore from "stores/UiStore";
import CenteredContent from "components/CenteredContent";
import Checkbox from "components/Checkbox";
import HelpText from "components/HelpText";
import PageTitle from "components/PageTitle";
type Props = {
auth: AuthStore,
ui: UiStore,
};
@observer
class Features extends React.Component<Props> {
form: ?HTMLFormElement;
@observable multiplayerEditor: boolean;
componentDidMount() {
const { auth } = this.props;
if (auth.team) {
this.multiplayerEditor = auth.team.multiplayerEditor;
}
}
handleChange = async (ev: SyntheticInputEvent<*>) => {
switch (ev.target.name) {
case "multiplayerEditor":
this.multiplayerEditor = ev.target.checked;
break;
default:
}
await this.props.auth.updateTeam({
multiplayerEditor: this.multiplayerEditor,
});
this.showSuccessMessage();
};
showSuccessMessage = debounce(() => {
this.props.ui.showToast("Settings saved");
}, 500);
render() {
return (
<CenteredContent>
<PageTitle title="Labs" />
<h1>Labs</h1>
<HelpText>
Enable experimental features that are still under development.
</HelpText>
<Checkbox
label="Multiplayer editor"
name="multiplayerEditor"
checked={this.multiplayerEditor}
onChange={this.handleChange}
note="Allow multiple team members to edit documents at the same time"
/>
</CenteredContent>
);
}
}
export default inject("auth", "ui")(Features);
+14 -55
View File
@@ -2,9 +2,7 @@
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
import * as React from "react";
import { Trans, withTranslation, type TFunction } from "react-i18next";
import styled from "styled-components";
import { languageOptions } from "shared/i18n";
import AuthStore from "stores/AuthStore";
import UiStore from "stores/UiStore";
@@ -12,16 +10,13 @@ import UserDelete from "scenes/UserDelete";
import Button from "components/Button";
import CenteredContent from "components/CenteredContent";
import Flex from "components/Flex";
import HelpText from "components/HelpText";
import Input, { LabelText } from "components/Input";
import InputSelect from "components/InputSelect";
import PageTitle from "components/PageTitle";
import ImageUpload from "./components/ImageUpload";
type Props = {
auth: AuthStore,
ui: UiStore,
t: TFunction,
};
@observer
@@ -32,12 +27,10 @@ class Profile extends React.Component<Props> {
@observable name: string;
@observable avatarUrl: ?string;
@observable showDeleteModal: boolean = false;
@observable language: string;
componentDidMount() {
if (this.props.auth.user) {
this.name = this.props.auth.user.name;
this.language = this.props.auth.user.language;
}
}
@@ -46,16 +39,13 @@ class Profile extends React.Component<Props> {
}
handleSubmit = async (ev: SyntheticEvent<>) => {
const { t } = this.props;
ev.preventDefault();
await this.props.auth.updateUser({
name: this.name,
avatarUrl: this.avatarUrl,
language: this.language,
});
this.props.ui.showToast(t("Profile saved"));
this.props.ui.showToast("Profile saved");
};
handleNameChange = (ev: SyntheticInputEvent<*>) => {
@@ -63,22 +53,16 @@ class Profile extends React.Component<Props> {
};
handleAvatarUpload = async (avatarUrl: string) => {
const { t } = this.props;
this.avatarUrl = avatarUrl;
await this.props.auth.updateUser({
avatarUrl: this.avatarUrl,
});
this.props.ui.showToast(t("Profile picture updated"));
this.props.ui.showToast("Profile picture updated");
};
handleAvatarError = (error: ?string) => {
const { t } = this.props;
this.props.ui.showToast(error || t("Unable to upload new profile picture"));
};
handleLanguageChange = (ev: SyntheticInputEvent<*>) => {
this.language = ev.target.value;
this.props.ui.showToast(error || "Unable to upload new avatar");
};
toggleDeleteAccount = () => {
@@ -90,17 +74,16 @@ class Profile extends React.Component<Props> {
}
render() {
const { t } = this.props;
const { user, isSaving } = this.props.auth;
if (!user) return null;
const avatarUrl = this.avatarUrl || user.avatarUrl;
return (
<CenteredContent>
<PageTitle title={t("Profile")} />
<h1>{t("Profile")}</h1>
<PageTitle title="Profile" />
<h1>Profile</h1>
<ProfilePicture column>
<LabelText>{t("Photo")}</LabelText>
<LabelText>Photo</LabelText>
<AvatarContainer>
<ImageUpload
onSuccess={this.handleAvatarUpload}
@@ -108,55 +91,31 @@ class Profile extends React.Component<Props> {
>
<Avatar src={avatarUrl} />
<Flex auto align="center" justify="center">
{t("Upload")}
Upload
</Flex>
</ImageUpload>
</AvatarContainer>
</ProfilePicture>
<form onSubmit={this.handleSubmit} ref={(ref) => (this.form = ref)}>
<Input
label={t("Full name")}
label="Full name"
autoComplete="name"
value={this.name}
onChange={this.handleNameChange}
required
short
/>
<br />
<InputSelect
label={t("Language")}
options={languageOptions}
value={this.language}
onChange={this.handleLanguageChange}
short
/>
<HelpText small>
<Trans>
Please note that translations are currently in early access.
<br />
Community contributions are accepted though our{" "}
<a
href="https://translate.getoutline.com"
target="_blank"
rel="noreferrer"
>
translation portal
</a>
</Trans>
.
</HelpText>
<Button type="submit" disabled={isSaving || !this.isValid}>
{isSaving ? `${t("Saving")}` : t("Save")}
{isSaving ? "Saving" : "Save"}
</Button>
</form>
<DangerZone>
<LabelText>{t("Delete Account")}</LabelText>
<LabelText>Delete Account</LabelText>
<p>
{t(
"You may delete your account at any time, note that this is unrecoverable"
)}
. <a onClick={this.toggleDeleteAccount}>{t("Delete account")}</a>.
You may delete your account at any time, note that this is
unrecoverable.{" "}
<a onClick={this.toggleDeleteAccount}>Delete account</a>.
</p>
</DangerZone>
{this.showDeleteModal && (
@@ -211,4 +170,4 @@ const Avatar = styled.img`
${avatarStyles};
`;
export default withTranslation()<Profile>(inject("auth", "ui")(Profile));
export default inject("auth", "ui")(Profile);
@@ -28,7 +28,7 @@ class ImageUpload extends React.Component<Props> {
@observable isUploading: boolean = false;
@observable isCropping: boolean = false;
@observable zoom: number = 1;
@observable file: File;
file: File;
avatarEditorRef: AvatarEditor;
static defaultProps = {
@@ -128,12 +128,7 @@ class ImageUpload extends React.Component<Props> {
style={EMPTY_OBJECT}
disablePreview
>
{({ getRootProps, getInputProps, isDragActive }) => (
<div {...getRootProps()} {...{ isDragActive }}>
<input {...getInputProps()} />
{this.props.children}
</div>
)}
{this.props.children}
</Dropzone>
);
}
+41 -39
View File
@@ -1,8 +1,9 @@
// @flow
import { observer } from "mobx-react";
import { observer, inject } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { type Match } from "react-router-dom";
import DocumentsStore from "stores/DocumentsStore";
import Actions, { Action } from "components/Actions";
import CenteredContent from "components/CenteredContent";
import Empty from "components/Empty";
@@ -12,50 +13,51 @@ import PageTitle from "components/PageTitle";
import PaginatedDocumentList from "components/PaginatedDocumentList";
import Tab from "components/Tab";
import Tabs from "components/Tabs";
import useStores from "hooks/useStores";
import NewDocumentMenu from "menus/NewDocumentMenu";
type Props = {
documents: DocumentsStore,
match: Match,
};
function Starred(props: Props) {
const { documents } = useStores();
const { t } = useTranslation();
const { fetchStarred, starred, starredAlphabetical } = documents;
const { sort } = props.match.params;
@observer
class Starred extends React.Component<Props> {
render() {
const { fetchStarred, starred, starredAlphabetical } = this.props.documents;
const { sort } = this.props.match.params;
return (
<CenteredContent column auto>
<PageTitle title={t("Starred")} />
<Heading>{t("Starred")}</Heading>
<PaginatedDocumentList
heading={
<Tabs>
<Tab to="/starred" exact>
{t("Recently updated")}
</Tab>
<Tab to="/starred/alphabetical" exact>
{t("Alphabetical")}
</Tab>
</Tabs>
}
empty={<Empty>{t("Youve not starred any documents yet.")}</Empty>}
fetch={fetchStarred}
documents={sort === "alphabetical" ? starredAlphabetical : starred}
showCollection
/>
return (
<CenteredContent column auto>
<PageTitle title="Starred" />
<Heading>Starred</Heading>
<PaginatedDocumentList
heading={
<Tabs>
<Tab to="/starred" exact>
Recently Updated
</Tab>
<Tab to="/starred/alphabetical" exact>
Alphabetical
</Tab>
</Tabs>
}
empty={<Empty>Youve not starred any documents yet.</Empty>}
fetch={fetchStarred}
documents={sort === "alphabetical" ? starredAlphabetical : starred}
showCollection
/>
<Actions align="center" justify="flex-end">
<Action>
<InputSearch source="starred" />
</Action>
<Action>
<NewDocumentMenu />
</Action>
</Actions>
</CenteredContent>
);
<Actions align="center" justify="flex-end">
<Action>
<InputSearch source="starred" />
</Action>
<Action>
<NewDocumentMenu />
</Action>
</Actions>
</CenteredContent>
);
}
}
export default observer(Starred);
export default inject("documents")(Starred);
+49 -43
View File
@@ -1,9 +1,9 @@
// @flow
import { observer } from "mobx-react";
import { observer, inject } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { type Match } from "react-router-dom";
import DocumentsStore from "stores/DocumentsStore";
import Actions, { Action } from "components/Actions";
import CenteredContent from "components/CenteredContent";
import Empty from "components/Empty";
@@ -12,54 +12,60 @@ import PageTitle from "components/PageTitle";
import PaginatedDocumentList from "components/PaginatedDocumentList";
import Tab from "components/Tab";
import Tabs from "components/Tabs";
import useStores from "hooks/useStores";
import NewTemplateMenu from "menus/NewTemplateMenu";
type Props = {
documents: DocumentsStore,
match: Match,
};
function Templates(props: Props) {
const { documents } = useStores();
const { t } = useTranslation();
const { fetchTemplates, templates, templatesAlphabetical } = documents;
const { sort } = props.match.params;
@observer
class Templates extends React.Component<Props> {
render() {
const {
fetchTemplates,
templates,
templatesAlphabetical,
} = this.props.documents;
const { sort } = this.props.match.params;
return (
<CenteredContent column auto>
<PageTitle title={t("Templates")} />
<Heading>{t("Templates")}</Heading>
<PaginatedDocumentList
heading={
<Tabs>
<Tab to="/templates" exact>
{t("Recently updated")}
</Tab>
<Tab to="/templates/alphabetical" exact>
{t("Alphabetical")}
</Tab>
</Tabs>
}
empty={
<Empty>
{t(
"There are no templates just yet. You can create templates to help your team create consistent and accurate documentation."
)}
</Empty>
}
fetch={fetchTemplates}
documents={sort === "alphabetical" ? templatesAlphabetical : templates}
showCollection
showDraft
/>
return (
<CenteredContent column auto>
<PageTitle title="Templates" />
<Heading>Templates</Heading>
<PaginatedDocumentList
heading={
<Tabs>
<Tab to="/templates" exact>
Recently Updated
</Tab>
<Tab to="/templates/alphabetical" exact>
Alphabetical
</Tab>
</Tabs>
}
empty={
<Empty>
There are no templates just yet. You can create templates to help
your team create consistent and accurate documentation.
</Empty>
}
fetch={fetchTemplates}
documents={
sort === "alphabetical" ? templatesAlphabetical : templates
}
showCollection
showDraft
/>
<Actions align="center" justify="flex-end">
<Action>
<NewTemplateMenu />
</Action>
</Actions>
</CenteredContent>
);
<Actions align="center" justify="flex-end">
<Action>
<NewTemplateMenu />
</Action>
</Actions>
</CenteredContent>
);
}
}
export default observer(Templates);
export default inject("documents")(Templates);
+26 -21
View File
@@ -1,34 +1,39 @@
// @flow
import { observer } from "mobx-react";
import { observer, inject } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import DocumentsStore from "stores/DocumentsStore";
import CenteredContent from "components/CenteredContent";
import Empty from "components/Empty";
import Heading from "components/Heading";
import PageTitle from "components/PageTitle";
import PaginatedDocumentList from "components/PaginatedDocumentList";
import Subheading from "components/Subheading";
import useStores from "hooks/useStores";
function Trash() {
const { t } = useTranslation();
const { documents } = useStores();
type Props = {
documents: DocumentsStore,
};
return (
<CenteredContent column auto>
<PageTitle title={t("Trash")} />
<Heading>{t("Trash")}</Heading>
<PaginatedDocumentList
documents={documents.deleted}
fetch={documents.fetchDeleted}
heading={<Subheading>{t("Documents")}</Subheading>}
empty={<Empty>{t("Trash is empty at the moment.")}</Empty>}
showCollection
showTemplate
/>
</CenteredContent>
);
@observer
class Trash extends React.Component<Props> {
render() {
const { documents } = this.props;
return (
<CenteredContent column auto>
<PageTitle title="Trash" />
<Heading>Trash</Heading>
<PaginatedDocumentList
documents={documents.deleted}
fetch={documents.fetchDeleted}
heading={<Subheading>Documents</Subheading>}
empty={<Empty>Trash is empty at the moment.</Empty>}
showCollection
showTemplate
/>
</CenteredContent>
);
}
}
export default observer(Trash);
export default inject("documents")(Trash);
+59 -65
View File
@@ -1,12 +1,13 @@
// @flow
import distanceInWordsToNow from "date-fns/distance_in_words_to_now";
import { observer } from "mobx-react";
import { inject, observer } from "mobx-react";
import { EditIcon } from "outline-icons";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { withRouter, type RouterHistory } from "react-router-dom";
import styled from "styled-components";
import { settings } from "shared/utils/routeHelpers";
import AuthStore from "stores/AuthStore";
import DocumentsStore from "stores/DocumentsStore";
import User from "models/User";
import Avatar from "components/Avatar";
import Badge from "components/Badge";
@@ -16,77 +17,70 @@ import HelpText from "components/HelpText";
import Modal from "components/Modal";
import PaginatedDocumentList from "components/PaginatedDocumentList";
import Subheading from "components/Subheading";
import useCurrentUser from "hooks/useCurrentUser";
import useStores from "hooks/useStores";
type Props = {
user: User,
auth: AuthStore,
documents: DocumentsStore,
history: RouterHistory,
onRequestClose: () => void,
};
function UserProfile(props: Props) {
const { t } = useTranslation();
const { documents } = useStores();
const currentUser = useCurrentUser();
const { user, ...rest } = props;
@observer
class UserProfile extends React.Component<Props> {
render() {
const { user, auth, documents, ...rest } = this.props;
if (!user) return null;
const isCurrentUser = auth.user && auth.user.id === user.id;
if (!user) return null;
const isCurrentUser = currentUser.id === user.id;
return (
<Modal
title={
<Flex align="center">
<Avatar src={user.avatarUrl} size={38} />
<span>&nbsp;{user.name}</span>
return (
<Modal
title={
<Flex align="center">
<Avatar src={user.avatarUrl} size={38} />
<span>&nbsp;{user.name}</span>
</Flex>
}
{...rest}
>
<Flex column>
<Meta>
{isCurrentUser
? "You joined"
: user.lastActiveAt
? "Joined"
: "Invited"}{" "}
{distanceInWordsToNow(new Date(user.createdAt))} ago.
{user.isAdmin && (
<StyledBadge admin={user.isAdmin}>Admin</StyledBadge>
)}
{user.isSuspended && <Badge>Suspended</Badge>}
{isCurrentUser && (
<Edit>
<Button
onClick={() => this.props.history.push(settings())}
icon={<EditIcon />}
neutral
>
Edit Profile
</Button>
</Edit>
)}
</Meta>
<PaginatedDocumentList
documents={documents.createdByUser(user.id)}
fetch={documents.fetchOwned}
options={{ user: user.id }}
heading={<Subheading>Recently updated</Subheading>}
empty={
<HelpText>{user.name} hasnt updated any documents yet.</HelpText>
}
showCollection
/>
</Flex>
}
{...rest}
>
<Flex column>
<Meta>
{isCurrentUser
? t("You joined")
: user.lastActiveAt
? t("Joined")
: t("Invited")}{" "}
{t("{{ time }} ago.", {
time: distanceInWordsToNow(new Date(user.createdAt)),
})}
{user.isAdmin && (
<StyledBadge admin={user.isAdmin}>{t("Admin")}</StyledBadge>
)}
{user.isSuspended && <Badge>{t("Suspended")}</Badge>}
{isCurrentUser && (
<Edit>
<Button
onClick={() => props.history.push(settings())}
icon={<EditIcon />}
neutral
>
{t("Edit Profile")}
</Button>
</Edit>
)}
</Meta>
<PaginatedDocumentList
documents={documents.createdByUser(user.id)}
fetch={documents.fetchOwned}
options={{ user: user.id }}
heading={<Subheading>{t("Recently updated")}</Subheading>}
empty={
<HelpText>
{t("{{ userName }} hasnt updated any documents yet.", {
userName: user.name,
})}
</HelpText>
}
showCollection
/>
</Flex>
</Modal>
);
</Modal>
);
}
}
const Edit = styled.span`
@@ -104,4 +98,4 @@ const Meta = styled(HelpText)`
margin-top: -12px;
`;
export default withRouter(observer(UserProfile));
export default inject("documents", "auth")(withRouter(UserProfile));
+26
View File
@@ -34,6 +34,32 @@ export default class PresenceStore {
this.data.set(documentId, existing);
}
@action updateFromAwareness(documentId: string, awareness: any) {
const existing = this.data.get(documentId) || new Map();
const clients = Array.from(awareness.states.values());
const userIds = clients.map((client) => client.user && client.user.id);
existing.forEach((value, key) => {
if (!userIds.includes(key)) {
existing.delete(key);
}
});
clients.forEach((client) => {
if (!client.user) {
return;
}
const userId = client.user.id;
existing.set(userId, {
isEditing: !!client.cursor,
userId,
});
});
this.data.set(documentId, existing);
}
// called when a user presence message is received user.presence websocket
// message.
// While in edit mode a message is sent every USER_PRESENCE_INTERVAL, if
+10 -19
View File
@@ -19,7 +19,6 @@ export default class DocumentsStore extends BaseStore<Document> {
@observable searchCache: Map<string, SearchResult[]> = new Map();
@observable starredIds: Map<string, boolean> = new Map();
@observable backlinks: Map<string, string[]> = new Map();
@observable movingDocumentId: ?string;
importFileTypes: string[] = [
"text/markdown",
@@ -212,7 +211,6 @@ export default class DocumentsStore extends BaseStore<Document> {
const { data } = res;
runInAction("DocumentsStore#fetchBacklinks", () => {
data.forEach(this.add);
this.addPolicies(res.policies);
this.backlinks.set(
documentId,
data.map((doc) => doc.id)
@@ -238,7 +236,6 @@ export default class DocumentsStore extends BaseStore<Document> {
const { data } = res;
runInAction("DocumentsStore#fetchChildDocuments", () => {
data.forEach(this.add);
this.addPolicies(res.policies);
});
};
@@ -451,26 +448,20 @@ export default class DocumentsStore extends BaseStore<Document> {
@action
move = async (
documentId: string,
document: Document,
collectionId: string,
parentDocumentId: ?string
) => {
this.movingDocumentId = documentId;
const res = await client.post("/documents.move", {
id: document.id,
collectionId,
parentDocumentId,
});
invariant(res && res.data, "Data not available");
try {
const res = await client.post("/documents.move", {
id: documentId,
collectionId,
parentDocumentId,
});
invariant(res && res.data, "Data not available");
res.data.documents.forEach(this.add);
res.data.collections.forEach(this.rootStore.collections.add);
this.addPolicies(res.policies);
} finally {
this.movingDocumentId = undefined;
}
res.data.documents.forEach(this.add);
res.data.collections.forEach(this.rootStore.collections.add);
this.addPolicies(res.policies);
};
@action
+1 -3
View File
@@ -1,6 +1,6 @@
// @flow
import invariant from "invariant";
import { sortBy, filter, find, isUndefined } from "lodash";
import { sortBy, filter, find } from "lodash";
import { action, computed } from "mobx";
import Share from "models/Share";
import BaseStore from "./BaseStore";
@@ -47,8 +47,6 @@ export default class SharesStore extends BaseStore<Share> {
try {
const res = await client.post(`/${this.modelName}s.info`, { documentId });
if (isUndefined(res)) return;
invariant(res && res.data, "Data should be available");
this.addPolicies(res.policies);
-28
View File
@@ -9,9 +9,6 @@ import type { Toast } from "types";
const UI_STORE = "UI_STORE";
class UiStore {
// has the user seen the prompt to change the UI language and actioned it
@observable languagePromptDismissed: boolean;
// theme represents the users UI preference (defaults to system)
@observable theme: "light" | "dark" | "system";
@@ -23,7 +20,6 @@ class UiStore {
@observable editMode: boolean = false;
@observable tocVisible: boolean = false;
@observable mobileSidebarVisible: boolean = false;
@observable sidebarCollapsed: boolean = false;
@observable toasts: Map<string, Toast> = new Map();
constructor() {
@@ -51,8 +47,6 @@ class UiStore {
}
// persisted keys
this.languagePromptDismissed = data.languagePromptDismissed;
this.sidebarCollapsed = data.sidebarCollapsed;
this.tocVisible = data.tocVisible;
this.theme = data.theme || "system";
@@ -74,11 +68,6 @@ class UiStore {
}
};
@action
setLanguagePromptDismissed = () => {
this.languagePromptDismissed = true;
};
@action
setActiveDocument = (document: Document): void => {
this.activeDocumentId = document.id;
@@ -109,21 +98,6 @@ class UiStore {
this.activeCollectionId = undefined;
};
@action
collapseSidebar = () => {
this.sidebarCollapsed = true;
};
@action
expandSidebar = () => {
this.sidebarCollapsed = false;
};
@action
toggleCollapsedSidebar = () => {
this.sidebarCollapsed = !this.sidebarCollapsed;
};
@action
showTableOfContents = () => {
this.tocVisible = true;
@@ -207,8 +181,6 @@ class UiStore {
get asJson(): string {
return JSON.stringify({
tocVisible: this.tocVisible,
sidebarCollapsed: this.sidebarCollapsed,
languagePromptDismissed: this.languagePromptDismissed,
theme: this.theme,
});
}
-2
View File
@@ -110,8 +110,6 @@ class ApiClient {
download(blob, trim(fileName, '"'));
return;
} else if (success && response.status === 204) {
return;
} else if (success) {
return response.json();
}
-7
View File
@@ -1,7 +0,0 @@
// @flow
export function detectLanguage() {
const [ln, r] = navigator.language.split("-");
const region = (r || ln).toUpperCase();
return `${ln}_${region}`;
}
-5
View File
@@ -1,5 +0,0 @@
commit_message: "fix: New %language% translations from Crowdin [ci skip]"
append_commit_message: false
files:
- source: /shared/i18n/locales/en_US/translation.json
translation: /shared/i18n/locales/%locale_with_underscore%/translation.json
+74
View File
@@ -0,0 +1,74 @@
// flow-typed signature: 2db53ec5dbb577a4e27bc465cd4670f3
// flow-typed version: <<STUB>>/y-prosemirror_v^0.3.7/flow_v0.104.0
/**
* This is an autogenerated libdef stub for:
*
* '@tommoor/y-prosemirror'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
// @flow
declare module "@tommoor/y-prosemirror" {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module "@tommoor/y-prosemirror/dist/test" {
declare module.exports: any;
}
declare module "@tommoor/y-prosemirror/src/lib" {
declare module.exports: any;
}
declare module "@tommoor/y-prosemirror/src/plugins/cursor-plugin" {
declare module.exports: any;
}
declare module "@tommoor/y-prosemirror/src/plugins/sync-plugin" {
declare module.exports: any;
}
declare module "@tommoor/y-prosemirror/src/plugins/undo-plugin" {
declare module.exports: any;
}
declare module "@tommoor/y-prosemirror/src/y-prosemirror" {
declare module.exports: any;
}
// Filename aliases
declare module "@tommoor/y-prosemirror/dist/test.js" {
declare module.exports: $Exports<"@tommoor/y-prosemirror/dist/test">;
}
declare module "@tommoor/y-prosemirror/src/lib.js" {
declare module.exports: $Exports<"@tommoor/y-prosemirror/src/lib">;
}
declare module "@tommoor/y-prosemirror/src/plugins/cursor-plugin.js" {
declare module.exports: $Exports<
"@tommoor/y-prosemirror/src/plugins/cursor-plugin"
>;
}
declare module "@tommoor/y-prosemirror/src/plugins/sync-plugin.js" {
declare module.exports: $Exports<
"@tommoor/y-prosemirror/src/plugins/sync-plugin"
>;
}
declare module "@tommoor/y-prosemirror/src/plugins/undo-plugin.js" {
declare module.exports: $Exports<
"@tommoor/y-prosemirror/src/plugins/undo-plugin"
>;
}
declare module "@tommoor/y-prosemirror/src/y-prosemirror.js" {
declare module.exports: $Exports<"@tommoor/y-prosemirror/src/y-prosemirror">;
}
+377
View File
@@ -0,0 +1,377 @@
// flow-typed signature: 97da878aea98698d6c06f8a696bb62af
// flow-typed version: <<STUB>>/lib0_v0.2.34/flow_v0.104.0
/**
* This is an autogenerated libdef stub for:
*
* 'lib0'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
// @flow
declare module "lib0" {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module "lib0/array" {
declare module.exports: any;
}
declare module "lib0/bin/gendocs" {
declare module.exports: any;
}
declare module "lib0/binary" {
declare module.exports: any;
}
declare module "lib0/broadcastchannel" {
declare module.exports: any;
}
declare module "lib0/buffer" {
declare module.exports: any;
}
declare module "lib0/component" {
declare module.exports: any;
}
declare module "lib0/conditions" {
declare module.exports: any;
}
declare module "lib0/decoding" {
declare module.exports: any;
}
declare module "lib0/diff" {
declare module.exports: any;
}
declare module "lib0/dist/test" {
declare module.exports: any;
}
declare module "lib0/dom" {
declare module.exports: any;
}
declare module "lib0/encoding" {
declare module.exports: any;
}
declare module "lib0/environment" {
declare module.exports: any;
}
declare module "lib0/error" {
declare module.exports: any;
}
declare module "lib0/eventloop" {
declare module.exports: any;
}
declare module "lib0/function" {
declare module.exports: any;
}
declare module "lib0/indexeddb" {
declare module.exports: any;
}
declare module "lib0/isomorphic" {
declare module.exports: any;
}
declare module "lib0/iterator" {
declare module.exports: any;
}
declare module "lib0/json" {
declare module.exports: any;
}
declare module "lib0/logging" {
declare module.exports: any;
}
declare module "lib0/map" {
declare module.exports: any;
}
declare module "lib0/math" {
declare module.exports: any;
}
declare module "lib0/metric" {
declare module.exports: any;
}
declare module "lib0/mutex" {
declare module.exports: any;
}
declare module "lib0/number" {
declare module.exports: any;
}
declare module "lib0/object" {
declare module.exports: any;
}
declare module "lib0/observable" {
declare module.exports: any;
}
declare module "lib0/pair" {
declare module.exports: any;
}
declare module "lib0/prng" {
declare module.exports: any;
}
declare module "lib0/prng/Mt19937" {
declare module.exports: any;
}
declare module "lib0/prng/Xoroshiro128plus" {
declare module.exports: any;
}
declare module "lib0/prng/Xorshift32" {
declare module.exports: any;
}
declare module "lib0/promise" {
declare module.exports: any;
}
declare module "lib0/queue" {
declare module.exports: any;
}
declare module "lib0/random" {
declare module.exports: any;
}
declare module "lib0/set" {
declare module.exports: any;
}
declare module "lib0/sort" {
declare module.exports: any;
}
declare module "lib0/statistics" {
declare module.exports: any;
}
declare module "lib0/storage" {
declare module.exports: any;
}
declare module "lib0/string" {
declare module.exports: any;
}
declare module "lib0/symbol" {
declare module.exports: any;
}
declare module "lib0/test" {
declare module.exports: any;
}
declare module "lib0/testing" {
declare module.exports: any;
}
declare module "lib0/time" {
declare module.exports: any;
}
declare module "lib0/tree" {
declare module.exports: any;
}
declare module "lib0/url" {
declare module.exports: any;
}
declare module "lib0/websocket" {
declare module.exports: any;
}
// Filename aliases
declare module "lib0/array.js" {
declare module.exports: $Exports<"lib0/array">;
}
declare module "lib0/bin/gendocs.js" {
declare module.exports: $Exports<"lib0/bin/gendocs">;
}
declare module "lib0/binary.js" {
declare module.exports: $Exports<"lib0/binary">;
}
declare module "lib0/broadcastchannel.js" {
declare module.exports: $Exports<"lib0/broadcastchannel">;
}
declare module "lib0/buffer.js" {
declare module.exports: $Exports<"lib0/buffer">;
}
declare module "lib0/component.js" {
declare module.exports: $Exports<"lib0/component">;
}
declare module "lib0/conditions.js" {
declare module.exports: $Exports<"lib0/conditions">;
}
declare module "lib0/decoding.js" {
declare module.exports: $Exports<"lib0/decoding">;
}
declare module "lib0/dist/decoding.cjs" {
declare module.exports: $Exports<"lib0/decoding">;
}
declare module "lib0/diff.js" {
declare module.exports: $Exports<"lib0/diff">;
}
declare module "lib0/dist/test.js" {
declare module.exports: $Exports<"lib0/dist/test">;
}
declare module "lib0/dom.js" {
declare module.exports: $Exports<"lib0/dom">;
}
declare module "lib0/encoding.js" {
declare module.exports: $Exports<"lib0/encoding">;
}
declare module "lib0/dist/encoding.cjs" {
declare module.exports: $Exports<"lib0/encoding">;
}
declare module "lib0/environment.js" {
declare module.exports: $Exports<"lib0/environment">;
}
declare module "lib0/error.js" {
declare module.exports: $Exports<"lib0/error">;
}
declare module "lib0/eventloop.js" {
declare module.exports: $Exports<"lib0/eventloop">;
}
declare module "lib0/function.js" {
declare module.exports: $Exports<"lib0/function">;
}
declare module "lib0/index" {
declare module.exports: $Exports<"lib0">;
}
declare module "lib0/index.js" {
declare module.exports: $Exports<"lib0">;
}
declare module "lib0/indexeddb.js" {
declare module.exports: $Exports<"lib0/indexeddb">;
}
declare module "lib0/isomorphic.js" {
declare module.exports: $Exports<"lib0/isomorphic">;
}
declare module "lib0/iterator.js" {
declare module.exports: $Exports<"lib0/iterator">;
}
declare module "lib0/json.js" {
declare module.exports: $Exports<"lib0/json">;
}
declare module "lib0/logging.js" {
declare module.exports: $Exports<"lib0/logging">;
}
declare module "lib0/map.js" {
declare module.exports: $Exports<"lib0/map">;
}
declare module "lib0/math.js" {
declare module.exports: $Exports<"lib0/math">;
}
declare module "lib0/metric.js" {
declare module.exports: $Exports<"lib0/metric">;
}
declare module "lib0/mutex.js" {
declare module.exports: $Exports<"lib0/mutex">;
}
declare module "lib0/dist/mutex.cjs" {
declare module.exports: $Exports<"lib0/mutex">;
}
declare module "lib0/number.js" {
declare module.exports: $Exports<"lib0/number">;
}
declare module "lib0/object.js" {
declare module.exports: $Exports<"lib0/object">;
}
declare module "lib0/observable.js" {
declare module.exports: $Exports<"lib0/observable">;
}
declare module "lib0/pair.js" {
declare module.exports: $Exports<"lib0/pair">;
}
declare module "lib0/prng.js" {
declare module.exports: $Exports<"lib0/prng">;
}
declare module "lib0/prng/Mt19937.js" {
declare module.exports: $Exports<"lib0/prng/Mt19937">;
}
declare module "lib0/prng/Xoroshiro128plus.js" {
declare module.exports: $Exports<"lib0/prng/Xoroshiro128plus">;
}
declare module "lib0/prng/Xorshift32.js" {
declare module.exports: $Exports<"lib0/prng/Xorshift32">;
}
declare module "lib0/promise.js" {
declare module.exports: $Exports<"lib0/promise">;
}
declare module "lib0/queue.js" {
declare module.exports: $Exports<"lib0/queue">;
}
declare module "lib0/random.js" {
declare module.exports: $Exports<"lib0/random">;
}
declare module "lib0/set.js" {
declare module.exports: $Exports<"lib0/set">;
}
declare module "lib0/sort.js" {
declare module.exports: $Exports<"lib0/sort">;
}
declare module "lib0/statistics.js" {
declare module.exports: $Exports<"lib0/statistics">;
}
declare module "lib0/storage.js" {
declare module.exports: $Exports<"lib0/storage">;
}
declare module "lib0/string.js" {
declare module.exports: $Exports<"lib0/string">;
}
declare module "lib0/symbol.js" {
declare module.exports: $Exports<"lib0/symbol">;
}
declare module "lib0/test.js" {
declare module.exports: $Exports<"lib0/test">;
}
declare module "lib0/testing.js" {
declare module.exports: $Exports<"lib0/testing">;
}
declare module "lib0/time.js" {
declare module.exports: $Exports<"lib0/time">;
}
declare module "lib0/tree.js" {
declare module.exports: $Exports<"lib0/tree">;
}
declare module "lib0/url.js" {
declare module.exports: $Exports<"lib0/url">;
}
declare module "lib0/websocket.js" {
declare module.exports: $Exports<"lib0/websocket">;
}
+56
View File
@@ -0,0 +1,56 @@
// flow-typed signature: c69369aa4bc769d5f1d4f6ec9c76d8f2
// flow-typed version: c6154227d1/react-dropzone_v4.x.x/flow_>=v0.104.x
declare module "react-dropzone" {
declare type ChildrenProps = {
draggedFiles: Array<File>,
acceptedFiles: Array<File>,
rejectedFiles: Array<File>,
isDragActive: boolean,
isDragAccept: boolean,
isDragReject: boolean,
...
}
declare type DropzoneFile = File & { preview?: string, ... }
declare type DropzoneProps = {
accept?: string,
children?: React$Node | (ChildrenProps) => React$Node,
disableClick?: boolean,
disabled?: boolean,
disablePreview?: boolean,
preventDropOnDocument?: boolean,
inputProps?: Object,
multiple?: boolean,
name?: string,
maxSize?: number,
minSize?: number,
className?: string,
activeClassName?: string,
acceptClassName?: string,
rejectClassName?: string,
disabledClassName?: string,
style?: Object,
activeStyle?: Object,
acceptStyle?: Object,
rejectStyle?: Object,
disabledStyle?: Object,
onClick?: (event: SyntheticMouseEvent<>) => mixed,
onDrop?: (acceptedFiles: Array<DropzoneFile>, rejectedFiles: Array<DropzoneFile>, event: SyntheticDragEvent<>) => mixed,
onDropAccepted?: (acceptedFiles: Array<DropzoneFile>, event: SyntheticDragEvent<>) => mixed,
onDropRejected?: (rejectedFiles: Array<DropzoneFile>, event: SyntheticDragEvent<>) => mixed,
onDragStart?: (event: SyntheticDragEvent<>) => mixed,
onDragEnter?: (event: SyntheticDragEvent<>) => mixed,
onDragOver?: (event: SyntheticDragEvent<>) => mixed,
onDragLeave?: (event: SyntheticDragEvent<>) => mixed,
onFileDialogCancel?: () => mixed,
...
};
declare class Dropzone extends React$Component<DropzoneProps> {
open(): void;
}
declare module.exports: typeof Dropzone;
}
-109
View File
@@ -1,109 +0,0 @@
// @flow
declare module "react-i18next" {
declare type TFunction = (key?: ?string, data?: ?Object) => string;
declare type TranslatorProps = {|
t: TFunction,
i18nLoadedAt: Date,
i18n: Object,
|};
declare type TranslatorPropsVoid = {
t: TFunction | void,
i18nLoadedAt: Date | void,
i18n: Object | void,
};
declare type Translator<P: {}, Component: React$ComponentType<P>> = (
WrappedComponent: Component
) => React$Element<
$Diff<React$ElementConfig<Component>, TranslatorPropsVoid>
>;
declare type TranslateOptions = $Shape<{
wait: boolean,
nsMode: "default" | "fallback",
bindi18n: false | string,
bindStore: false | string,
withRef: boolean,
translateFuncName: string,
i18n: Object,
usePureComponent: boolean,
}>;
declare type UseTranslationResponse = {
t: TFunction,
i18n: Object,
ready: boolean,
};
declare type Namespace =
| string
| Array<string>
| (($Diff<P, TranslatorPropsVoid>) => string | Array<string>);
declare function useTranslation(
ns?: Namespace,
options?: TranslateOptions
): UseTranslationResponse;
declare function withTranslation(
ns?: Namespace,
options?: {
withRef?: boolean,
}
): <P>(component: React.ComponentType<P>) => Translator<P, Component>;
declare type I18nProps = {
i18n?: Object,
ns?: string | Array<string>,
children: (t: TFunction, { i18n: Object, t: TFunction }) => React$Node,
initialI18nStore?: Object,
initialLanguage?: string,
};
declare var I18n: React$ComponentType<I18nProps>;
declare type InterpolateProps = {
className?: string,
dangerouslySetInnerHTMLPartElement?: string,
i18n?: Object,
i18nKey?: string,
options?: Object,
parent?: string,
style?: Object,
t?: TFunction,
useDangerouslySetInnerHTML?: boolean,
};
declare var Interpolate: React$ComponentType<InterpolateProps>;
declare type TransProps = {
count?: number,
parent?: string,
i18n?: Object,
i18nKey?: string,
t?: TFunction,
};
declare var Trans: React$ComponentType<TransProps>;
declare type ProviderProps = { i18n: Object, children: React$Element<*> };
declare var I18nextProvider: React$ComponentType<ProviderProps>;
declare type NamespacesProps = {
components: Array<React$ComponentType<*>>,
i18n: { loadNamespaces: Function },
};
declare function loadNamespaces(props: NamespacesProps): Promise<void>;
declare var initReactI18next: {
type: "3rdParty",
init: (instance: Object) => void,
};
declare function setDefaults(options: TranslateOptions): void;
declare function getDefaults(): TranslateOptions;
declare function getI18n(): Object;
declare function setI18n(instance: Object): void;
}
+39
View File
@@ -0,0 +1,39 @@
// flow-typed signature: 71e55e30d387153cf804d226f95c0ad8
// flow-typed version: <<STUB>>/y-indexeddb_v^9.0.5/flow_v0.104.0
/**
* This is an autogenerated libdef stub for:
*
* 'y-indexeddb'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'y-indexeddb' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'y-indexeddb/dist/test' {
declare module.exports: any;
}
declare module 'y-indexeddb/src/y-indexeddb' {
declare module.exports: any;
}
// Filename aliases
declare module 'y-indexeddb/dist/test.js' {
declare module.exports: $Exports<'y-indexeddb/dist/test'>;
}
declare module 'y-indexeddb/src/y-indexeddb.js' {
declare module.exports: $Exports<'y-indexeddb/src/y-indexeddb'>;
}
+67
View File
@@ -0,0 +1,67 @@
// flow-typed signature: 3ef5e4dd42591ff15af5f507abd6aa97
// flow-typed version: <<STUB>>/y-protocols_v^1.0.1/flow_v0.104.0
/**
* This is an autogenerated libdef stub for:
*
* 'y-protocols'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
// @flow
declare module "y-protocols" {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module "y-protocols/auth" {
declare module.exports: any;
}
declare module "y-protocols/awareness" {
declare module.exports: any;
}
declare module "y-protocols/awareness.test" {
declare module.exports: any;
}
declare module "y-protocols/dist/test" {
declare module.exports: any;
}
declare module "y-protocols/sync" {
declare module.exports: any;
}
// Filename aliases
declare module "y-protocols/auth.js" {
declare module.exports: $Exports<"y-protocols/auth">;
}
declare module "y-protocols/awareness.js" {
declare module.exports: $Exports<"y-protocols/awareness">;
}
declare module "y-protocols/dist/awareness.cjs" {
declare module.exports: $Exports<"y-protocols/awareness">;
}
declare module "y-protocols/awareness.test.js" {
declare module.exports: $Exports<"y-protocols/awareness.test">;
}
declare module "y-protocols/dist/test.js" {
declare module.exports: $Exports<"y-protocols/dist/test">;
}
declare module "y-protocols/sync.js" {
declare module.exports: $Exports<"y-protocols/sync">;
}
declare module "y-protocols/dist/sync.cjs" {
declare module.exports: $Exports<"y-protocols/sync">;
}

Some files were not shown because too many files have changed in this diff Show More