diff --git a/packages/app/src/app/overmind/effects/fakeGql/comments/mutations.ts b/packages/app/src/app/overmind/effects/fakeGql/comments/mutations.ts
index 45cc81b4032..bce979a3081 100644
--- a/packages/app/src/app/overmind/effects/fakeGql/comments/mutations.ts
+++ b/packages/app/src/app/overmind/effects/fakeGql/comments/mutations.ts
@@ -137,7 +137,11 @@ export const updateReply: Query<
UpdateReplyResponse,
UpdateReplyVariables
> = gql`
- mutation updateReply($replyId: String!, $commentId: String!) {
+ mutation updateReply(
+ $replyId: String!
+ $commentId: String!
+ $comment: String!
+ ) {
updateReply(replyId: $replyId, commentId: $commentId, comment: $comment) {
id
replies {
diff --git a/packages/app/src/app/overmind/namespaces/editor/actions.ts b/packages/app/src/app/overmind/namespaces/editor/actions.ts
index 354a777f909..5626e129b53 100755
--- a/packages/app/src/app/overmind/namespaces/editor/actions.ts
+++ b/packages/app/src/app/overmind/namespaces/editor/actions.ts
@@ -1479,7 +1479,7 @@ export const updateComment: AsyncAction<{
id: string;
data: {
comment?: string;
- isResolved: boolean;
+ isResolved?: boolean;
};
}> = async ({ effects, state }, { id, data }) => {
if (!state.editor.currentSandbox) {
@@ -1493,7 +1493,7 @@ export const updateComment: AsyncAction<{
currentComment &&
state.editor.comments[sandboxId][id].id === currentComment.id;
- if ('isResolved' in data) {
+ if ('isResolved' in data && data.isResolved) {
state.editor.comments[sandboxId][id].isResolved = data.isResolved;
if (updateIsCurrent && currentComment) {
currentComment.isResolved = data.isResolved;
@@ -1587,9 +1587,12 @@ export const updateReply: AsyncAction<{
});
} catch (error) {
effects.notificationToast.error(
- 'Unable to update your comment, please try again'
+ 'Unable to update your reply, please try again'
);
- state.editor.comments[sandboxId][commentId] = old;
+ state.editor.comments[sandboxId][commentId] = {
+ ...old,
+ replies: old.replies,
+ };
}
};
diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Comment.tsx b/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Markdown.tsx
similarity index 98%
rename from packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Comment.tsx
rename to packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Markdown.tsx
index 56f256a499b..a867c01fab3 100644
--- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Comment.tsx
+++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Markdown.tsx
@@ -5,7 +5,7 @@ import { Text, Element, Link } from '@codesandbox/components';
import css from '@styled-system/css';
import { Code } from './Code';
-export const Comment = ({ source }) => {
+export const Markdown = ({ source }) => {
const { state } = useOvermind();
const privateSandbox =
state.editor.currentSandbox.privacy === 1 ||
diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Reply.tsx b/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Reply.tsx
index e34be7fb94d..cabd11fa96b 100644
--- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Reply.tsx
+++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Reply.tsx
@@ -1,16 +1,18 @@
-import React from 'react';
+import React, { useState } from 'react';
import { formatDistance } from 'date-fns';
import css from '@styled-system/css';
import {
Element,
+ Button,
Stack,
Avatar,
Text,
Link,
Menu,
+ Textarea,
} from '@codesandbox/components';
import { useOvermind } from 'app/overmind';
-import { Comment } from './Comment';
+import { Markdown } from './Markdown';
type ReplyProps = {
id: string;
@@ -28,6 +30,8 @@ export const Reply = ({
content,
}: ReplyProps) => {
const { state, actions } = useOvermind();
+ const [edit, setEdit] = useState(false);
+ const [value, setValue] = useState(content);
return (
<>
@@ -65,7 +69,9 @@ export const Reply = ({
>
Delete
- Edit
+ setEdit(true)}>
+ Edit Reply
+
@@ -73,7 +79,7 @@ export const Reply = ({
-
+ {!edit ? (
+
+ ) : (
+ <>
+
+
+
+
+
+
+
+ >
+ )}
>
);
diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/index.tsx b/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/index.tsx
index 45c0e3715d0..a2292699751 100644
--- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/index.tsx
+++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/index.tsx
@@ -12,9 +12,11 @@ import {
Text,
Link,
IconButton,
+ Button,
+ Menu,
} from '@codesandbox/components';
import { useOvermind } from 'app/overmind';
-import { Comment } from './Comment';
+import { Markdown } from './Markdown';
import { Reply } from './Reply';
export const CommentDialog = props =>
@@ -23,7 +25,10 @@ export const CommentDialog = props =>
export const Dialog = props => {
const { state, actions } = useOvermind();
const [value, setValue] = useState('');
+
+ const [edit, setEdit] = useState(false);
const comment = state.editor.currentComment;
+ const [editValue, setEditValue] = useState(comment.originalMessage.content);
const [position, setPosition] = useState({
x: props.x || 200,
y: props.y || 100,
@@ -110,26 +115,57 @@ export const Dialog = props => {
{comment && (
<>
-
-
-
-
- {comment.originalMessage.author.username}
-
-
- {formatDistance(new Date(comment.insertedAt), new Date(), {
- addSuffix: true,
- })}
-
+
+
+
+
+
+ {comment.originalMessage.author.username}
+
+
+ {formatDistance(new Date(comment.insertedAt), new Date(), {
+ addSuffix: true,
+ })}
+
+
+ {state.user.id === comment.originalMessage.author.id && (
+
+
+
+ )}
{
borderColor: 'sideBar.border',
})}
>
-
+ {!edit ? (
+
+ ) : (
+ <>
+
+
+
+
+
+
+
+ >
+ )}
>
)}