mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-10 04:22:00 +10:00
fix: add cancel button for editing comments (#580)
* fix: add cancel button for editing comments * cleanup --------- Co-authored-by: Philipinho <16838612+Philipinho@users.noreply.github.com>
This commit is contained in:
@ -4,13 +4,26 @@ import { useTranslation } from "react-i18next";
|
|||||||
type CommentActionsProps = {
|
type CommentActionsProps = {
|
||||||
onSave: () => void;
|
onSave: () => void;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
|
onCancel?: () => void;
|
||||||
|
isCommentEditor?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
function CommentActions({ onSave, isLoading }: CommentActionsProps) {
|
function CommentActions({
|
||||||
|
onSave,
|
||||||
|
isLoading,
|
||||||
|
onCancel,
|
||||||
|
isCommentEditor,
|
||||||
|
}: CommentActionsProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group justify="flex-end" pt={2} wrap="nowrap">
|
<Group justify="flex-end" pt="sm" wrap="nowrap">
|
||||||
|
{isCommentEditor && (
|
||||||
|
<Button size="compact-sm" variant="default" onClick={onCancel}>
|
||||||
|
{t("Cancel")}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
<Button size="compact-sm" loading={isLoading} onClick={onSave}>
|
<Button size="compact-sm" loading={isLoading} onClick={onSave}>
|
||||||
{t("Save")}
|
{t("Save")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -58,6 +58,9 @@ function CommentListItem({ comment }: CommentListItemProps) {
|
|||||||
function handleEditToggle() {
|
function handleEditToggle() {
|
||||||
setIsEditing(true);
|
setIsEditing(true);
|
||||||
}
|
}
|
||||||
|
function cancelEdit() {
|
||||||
|
setIsEditing(false);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box ref={ref} pb="xs">
|
<Box ref={ref} pb="xs">
|
||||||
@ -115,6 +118,8 @@ function CommentListItem({ comment }: CommentListItemProps) {
|
|||||||
<CommentActions
|
<CommentActions
|
||||||
onSave={handleUpdateComment}
|
onSave={handleUpdateComment}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
|
onCancel={cancelEdit}
|
||||||
|
isCommentEditor={true}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user