feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
import { AnimatePresence } from "framer-motion";
|
|
|
|
import { observer } from "mobx-react";
|
2024-07-02 06:55:16 -04:00
|
|
|
import { DoneIcon } from "outline-icons";
|
|
|
|
import queryString from "query-string";
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
import * as React from "react";
|
|
|
|
import { useTranslation } from "react-i18next";
|
2024-07-02 06:55:16 -04:00
|
|
|
import { useHistory, useLocation, useRouteMatch } from "react-router-dom";
|
|
|
|
import styled, { css } from "styled-components";
|
2023-12-28 21:31:40 -05:00
|
|
|
import { ProsemirrorData } from "@shared/types";
|
2024-07-02 06:55:16 -04:00
|
|
|
import Button from "~/components/Button";
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
import Empty from "~/components/Empty";
|
|
|
|
import Flex from "~/components/Flex";
|
2023-02-27 19:50:35 -05:00
|
|
|
import Scrollable from "~/components/Scrollable";
|
2024-07-02 06:55:16 -04:00
|
|
|
import Tooltip from "~/components/Tooltip";
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
import useCurrentUser from "~/hooks/useCurrentUser";
|
|
|
|
import useFocusedComment from "~/hooks/useFocusedComment";
|
2023-02-27 19:50:35 -05:00
|
|
|
import useKeyDown from "~/hooks/useKeyDown";
|
2023-12-28 21:31:40 -05:00
|
|
|
import usePersistedState from "~/hooks/usePersistedState";
|
2023-04-13 06:41:58 +05:30
|
|
|
import usePolicy from "~/hooks/usePolicy";
|
2024-07-02 06:55:16 -04:00
|
|
|
import useQuery from "~/hooks/useQuery";
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
import useStores from "~/hooks/useStores";
|
2024-07-02 06:55:16 -04:00
|
|
|
import { bigPulse } from "~/styles/animations";
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
import CommentForm from "./CommentForm";
|
|
|
|
import CommentThread from "./CommentThread";
|
|
|
|
import Sidebar from "./SidebarLayout";
|
|
|
|
|
|
|
|
function Comments() {
|
|
|
|
const { ui, comments, documents } = useStores();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const user = useCurrentUser();
|
2024-07-02 06:55:16 -04:00
|
|
|
const location = useLocation();
|
|
|
|
const history = useHistory();
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
const match = useRouteMatch<{ documentSlug: string }>();
|
2024-07-02 06:55:16 -04:00
|
|
|
const params = useQuery();
|
|
|
|
const [pulse, setPulse] = React.useState(false);
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
const document = documents.getByUrl(match.params.documentSlug);
|
|
|
|
const focusedComment = useFocusedComment();
|
2023-12-28 12:51:33 -04:00
|
|
|
const can = usePolicy(document);
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
|
2023-03-05 16:59:29 -05:00
|
|
|
useKeyDown("Escape", () => document && ui.collapseComments(document?.id));
|
2023-02-27 19:50:35 -05:00
|
|
|
|
2023-12-28 21:31:40 -05:00
|
|
|
const [draft, onSaveDraft] = usePersistedState<ProsemirrorData | undefined>(
|
|
|
|
`draft-${document?.id}-new`,
|
|
|
|
undefined
|
|
|
|
);
|
|
|
|
|
2024-07-02 06:55:16 -04:00
|
|
|
const viewingResolved = params.get("resolved") === "";
|
|
|
|
const resolvedThreads = document
|
|
|
|
? comments.resolvedThreadsInDocument(document.id)
|
|
|
|
: [];
|
|
|
|
const resolvedThreadsCount = resolvedThreads.length;
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
setPulse(true);
|
|
|
|
const timeout = setTimeout(() => setPulse(false), 250);
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
clearTimeout(timeout);
|
|
|
|
setPulse(false);
|
|
|
|
};
|
|
|
|
}, [resolvedThreadsCount]);
|
|
|
|
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
if (!document) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2024-07-02 06:55:16 -04:00
|
|
|
const threads = (
|
|
|
|
viewingResolved
|
|
|
|
? resolvedThreads
|
|
|
|
: comments.unresolvedThreadsInDocument(document.id)
|
|
|
|
).filter((thread) => thread.createdById === user.id);
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
const hasComments = threads.length > 0;
|
|
|
|
|
2024-07-02 06:55:16 -04:00
|
|
|
const toggleViewingResolved = () => {
|
|
|
|
history.push({
|
|
|
|
search: queryString.stringify({
|
|
|
|
...queryString.parse(location.search),
|
|
|
|
resolved: viewingResolved ? undefined : "",
|
|
|
|
}),
|
|
|
|
pathname: location.pathname,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
return (
|
2023-02-27 19:50:35 -05:00
|
|
|
<Sidebar
|
2024-07-02 06:55:16 -04:00
|
|
|
title={
|
|
|
|
<Flex align="center" justify="space-between" auto>
|
|
|
|
{viewingResolved ? (
|
|
|
|
<React.Fragment key="resolved">
|
|
|
|
<span>{t("Resolved comments")}</span>
|
|
|
|
<Tooltip delay={500} content={t("View comments")}>
|
|
|
|
<ResolvedButton
|
|
|
|
neutral
|
|
|
|
borderOnHover
|
|
|
|
icon={<DoneIcon />}
|
|
|
|
onClick={toggleViewingResolved}
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</React.Fragment>
|
|
|
|
) : (
|
|
|
|
<React.Fragment>
|
|
|
|
<span>{t("Comments")}</span>
|
|
|
|
<Tooltip delay={250} content={t("View resolved comments")}>
|
|
|
|
<ResolvedButton
|
|
|
|
neutral
|
|
|
|
borderOnHover
|
|
|
|
icon={<DoneIcon outline />}
|
|
|
|
onClick={toggleViewingResolved}
|
|
|
|
$pulse={pulse}
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
|
|
|
</Flex>
|
|
|
|
}
|
2023-03-05 16:59:29 -05:00
|
|
|
onClose={() => ui.collapseComments(document?.id)}
|
2023-02-27 19:50:35 -05:00
|
|
|
scrollable={false}
|
|
|
|
>
|
2023-04-02 11:41:28 -04:00
|
|
|
<Scrollable
|
|
|
|
id="comments"
|
2024-04-24 22:53:56 -04:00
|
|
|
bottomShadow={!focusedComment}
|
2023-04-02 11:41:28 -04:00
|
|
|
hiddenScrollbars
|
|
|
|
topShadow
|
|
|
|
>
|
2023-02-27 19:50:35 -05:00
|
|
|
<Wrapper $hasComments={hasComments}>
|
|
|
|
{hasComments ? (
|
|
|
|
threads.map((thread) => (
|
|
|
|
<CommentThread
|
|
|
|
key={thread.id}
|
|
|
|
comment={thread}
|
|
|
|
document={document}
|
|
|
|
recessed={!!focusedComment && focusedComment.id !== thread.id}
|
|
|
|
focused={focusedComment?.id === thread.id}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
) : (
|
|
|
|
<NoComments align="center" justify="center" auto>
|
2024-07-02 06:55:16 -04:00
|
|
|
<PositionedEmpty>
|
|
|
|
{viewingResolved
|
|
|
|
? t("No resolved comments")
|
|
|
|
: t("No comments yet")}
|
|
|
|
</PositionedEmpty>
|
2023-02-27 19:50:35 -05:00
|
|
|
</NoComments>
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
)}
|
2023-02-27 19:50:35 -05:00
|
|
|
</Wrapper>
|
|
|
|
</Scrollable>
|
|
|
|
<AnimatePresence initial={false}>
|
2024-07-02 06:55:16 -04:00
|
|
|
{!focusedComment && can.comment && !viewingResolved && (
|
2023-02-27 19:50:35 -05:00
|
|
|
<NewCommentForm
|
2023-12-28 21:31:40 -05:00
|
|
|
draft={draft}
|
|
|
|
onSaveDraft={onSaveDraft}
|
2023-02-27 19:50:35 -05:00
|
|
|
documentId={document.id}
|
|
|
|
placeholder={`${t("Add a comment")}…`}
|
|
|
|
autoFocus={false}
|
|
|
|
dir={document.dir}
|
|
|
|
animatePresence
|
|
|
|
standalone
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</AnimatePresence>
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
</Sidebar>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-07-02 06:55:16 -04:00
|
|
|
const ResolvedButton = styled(Button)<{ $pulse: boolean }>`
|
|
|
|
${(props) =>
|
|
|
|
props.$pulse &&
|
|
|
|
css`
|
|
|
|
animation: ${bigPulse} 250ms 1;
|
|
|
|
`}
|
|
|
|
`;
|
|
|
|
|
2023-04-05 09:39:30 -04:00
|
|
|
const PositionedEmpty = styled(Empty)`
|
|
|
|
position: absolute;
|
|
|
|
top: calc(50vh - 30px);
|
|
|
|
transform: translateY(-50%);
|
|
|
|
`;
|
|
|
|
|
feat: Comments (#4911)
* Comment model
* Framework, model, policy, presenter, api endpoint etc
* Iteration, first pass of UI
* fixes, refactors
* Comment commands
* comment socket support
* typing indicators
* comment component, styling
* wip
* right sidebar resize
* fix: CMD+Enter submit
* Add usePersistedState
fix: Main page scrolling on comment highlight
* drafts
* Typing indicator
* refactor
* policies
* Click thread to highlight
Improve comment timestamps
* padding
* Comment menu v1
* Change comments to use editor
* Basic comment editing
* fix: Hide commenting button when disabled at team level
* Enable opening sidebar without mark
* Move selected comment to location state
* Add comment delete confirmation
* Add comment count to document meta
* fix: Comment sidebar togglable
Add copy link to comment
* stash
* Restore History changes
* Refactor right sidebar to allow for comment animation
* Update to new router best practices
* stash
* Various improvements
* stash
* Handle click outside
* Fix incorrect placeholder in input
fix: Input box appearing on other sessions erroneously
* stash
* fix: Don't leave orphaned child comments
* styling
* stash
* Enable comment toggling again
* Edit styling, merge conflicts
* fix: Cannot navigate from insights to comments
* Remove draft comment mark on click outside
* Fix: Empty comment sidebar, tsc
* Remove public toggle
* fix: All comments are recessed
fix: Comments should not be printed
* fix: Associated mark should be removed on comment delete
* Revert unused changes
* Empty state, basic RTL support
* Create dont toggle comment mark
* Make it feel more snappy
* Highlight active comment in text
* fix animation
* RTL support
* Add reply CTA
* Translations
2023-02-25 15:03:05 -05:00
|
|
|
const NoComments = styled(Flex)`
|
|
|
|
padding-bottom: 65px;
|
|
|
|
height: 100%;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Wrapper = styled.div<{ $hasComments: boolean }>`
|
|
|
|
padding-bottom: ${(props) => (props.$hasComments ? "50vh" : "0")};
|
|
|
|
height: ${(props) => (props.$hasComments ? "auto" : "100%")};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const NewCommentForm = styled(CommentForm)<{ dir?: "ltr" | "rtl" }>`
|
|
|
|
padding: 12px;
|
|
|
|
padding-right: ${(props) => (props.dir !== "rtl" ? "18px" : "12px")};
|
|
|
|
padding-left: ${(props) => (props.dir === "rtl" ? "18px" : "12px")};
|
|
|
|
`;
|
|
|
|
|
|
|
|
export default observer(Comments);
|