mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
cancel comment edit
This commit is contained in:
parent
89076da435
commit
b9ac33d881
5 changed files with 31 additions and 1 deletions
|
@ -169,6 +169,7 @@
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: white;
|
color: white;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
padding: 0 $gap;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
fill: white;
|
fill: white;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React, { FC, useCallback, KeyboardEventHandler, useEffect, useMemo } from 'react';
|
import React, { FC, useCallback, KeyboardEventHandler, useEffect, useMemo } from 'react';
|
||||||
import { Textarea } from '~/components/input/Textarea';
|
import { Textarea } from '~/components/input/Textarea';
|
||||||
import { CommentWrapper } from '~/components/containers/CommentWrapper';
|
|
||||||
import * as styles from './styles.scss';
|
import * as styles from './styles.scss';
|
||||||
import { Filler } from '~/components/containers/Filler';
|
import { Filler } from '~/components/containers/Filler';
|
||||||
import { Button } from '~/components/input/Button';
|
import { Button } from '~/components/input/Button';
|
||||||
|
@ -30,6 +29,7 @@ const mapStateToProps = (state: IState) => ({
|
||||||
|
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
nodePostComment: NODE_ACTIONS.nodePostComment,
|
nodePostComment: NODE_ACTIONS.nodePostComment,
|
||||||
|
nodeCancelCommentEdit: NODE_ACTIONS.nodeCancelCommentEdit,
|
||||||
nodeSetCommentData: NODE_ACTIONS.nodeSetCommentData,
|
nodeSetCommentData: NODE_ACTIONS.nodeSetCommentData,
|
||||||
uploadUploadFiles: UPLOAD_ACTIONS.uploadUploadFiles,
|
uploadUploadFiles: UPLOAD_ACTIONS.uploadUploadFiles,
|
||||||
};
|
};
|
||||||
|
@ -48,6 +48,7 @@ const CommentFormUnconnected: FC<IProps> = ({
|
||||||
nodePostComment,
|
nodePostComment,
|
||||||
nodeSetCommentData,
|
nodeSetCommentData,
|
||||||
uploadUploadFiles,
|
uploadUploadFiles,
|
||||||
|
nodeCancelCommentEdit,
|
||||||
}) => {
|
}) => {
|
||||||
const onInputChange = useCallback(
|
const onInputChange = useCallback(
|
||||||
event => {
|
event => {
|
||||||
|
@ -196,6 +197,10 @@ const CommentFormUnconnected: FC<IProps> = ({
|
||||||
[images, audios]
|
[images, audios]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onCancelEdit = useCallback(() => {
|
||||||
|
nodeCancelCommentEdit(id);
|
||||||
|
}, [nodeCancelCommentEdit, comment.id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={onSubmit} className={styles.wrap}>
|
<form onSubmit={onSubmit} className={styles.wrap}>
|
||||||
<div className={styles.input}>
|
<div className={styles.input}>
|
||||||
|
@ -252,6 +257,12 @@ const CommentFormUnconnected: FC<IProps> = ({
|
||||||
|
|
||||||
{(is_sending_comment || is_uploading_files) && <LoaderCircle size={20} />}
|
{(is_sending_comment || is_uploading_files) && <LoaderCircle size={20} />}
|
||||||
|
|
||||||
|
{id !== 0 && (
|
||||||
|
<Button size="small" color="link" type="button" onClick={onCancelEdit}>
|
||||||
|
Отмена
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
color="gray"
|
color="gray"
|
||||||
|
|
|
@ -50,6 +50,11 @@ export const nodePostComment = (id: number, is_before: boolean) => ({
|
||||||
type: NODE_ACTIONS.POST_COMMENT,
|
type: NODE_ACTIONS.POST_COMMENT,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const nodeCancelCommentEdit = (id: number) => ({
|
||||||
|
id,
|
||||||
|
type: NODE_ACTIONS.CANCEL_COMMENT_EDIT,
|
||||||
|
});
|
||||||
|
|
||||||
export const nodeSetSendingComment = (is_sending_comment: boolean) => ({
|
export const nodeSetSendingComment = (is_sending_comment: boolean) => ({
|
||||||
is_sending_comment,
|
is_sending_comment,
|
||||||
type: NODE_ACTIONS.SET_SENDING_COMMENT,
|
type: NODE_ACTIONS.SET_SENDING_COMMENT,
|
||||||
|
|
|
@ -27,6 +27,7 @@ export const NODE_ACTIONS = {
|
||||||
LOCK: `${prefix}LOCK`,
|
LOCK: `${prefix}LOCK`,
|
||||||
LOCK_COMMENT: `${prefix}LOCK_COMMENT`,
|
LOCK_COMMENT: `${prefix}LOCK_COMMENT`,
|
||||||
EDIT_COMMENT: `${prefix}EDIT_COMMENT`,
|
EDIT_COMMENT: `${prefix}EDIT_COMMENT`,
|
||||||
|
CANCEL_COMMENT_EDIT: `${prefix}CANCEL_COMMENT_EDIT`,
|
||||||
CREATE: `${prefix}CREATE`,
|
CREATE: `${prefix}CREATE`,
|
||||||
|
|
||||||
SET_SAVE_ERRORS: `${prefix}SET_SAVE_ERRORS`,
|
SET_SAVE_ERRORS: `${prefix}SET_SAVE_ERRORS`,
|
||||||
|
|
|
@ -26,6 +26,7 @@ import {
|
||||||
nodeLockComment,
|
nodeLockComment,
|
||||||
nodeEditComment,
|
nodeEditComment,
|
||||||
nodeSet,
|
nodeSet,
|
||||||
|
nodeCancelCommentEdit,
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import {
|
import {
|
||||||
postNode,
|
postNode,
|
||||||
|
@ -197,6 +198,16 @@ function* onPostComment({ id, is_before }: ReturnType<typeof nodePostComment>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function* onCancelCommentEdit({ id }: ReturnType<typeof nodeCancelCommentEdit>) {
|
||||||
|
const { comment_data } = yield select(selectNode);
|
||||||
|
|
||||||
|
yield put(
|
||||||
|
nodeSet({
|
||||||
|
comment_data: omit([id.toString()], comment_data),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function* onUpdateTags({ id, tags }: ReturnType<typeof nodeUpdateTags>) {
|
function* onUpdateTags({ id, tags }: ReturnType<typeof nodeUpdateTags>) {
|
||||||
yield delay(1000);
|
yield delay(1000);
|
||||||
const {
|
const {
|
||||||
|
@ -311,6 +322,7 @@ export default function* nodeSaga() {
|
||||||
yield takeLatest(NODE_ACTIONS.GOTO_NODE, onNodeGoto);
|
yield takeLatest(NODE_ACTIONS.GOTO_NODE, onNodeGoto);
|
||||||
yield takeLatest(NODE_ACTIONS.LOAD_NODE, onNodeLoad);
|
yield takeLatest(NODE_ACTIONS.LOAD_NODE, onNodeLoad);
|
||||||
yield takeLatest(NODE_ACTIONS.POST_COMMENT, onPostComment);
|
yield takeLatest(NODE_ACTIONS.POST_COMMENT, onPostComment);
|
||||||
|
yield takeLatest(NODE_ACTIONS.CANCEL_COMMENT_EDIT, onCancelCommentEdit);
|
||||||
yield takeLatest(NODE_ACTIONS.UPDATE_TAGS, onUpdateTags);
|
yield takeLatest(NODE_ACTIONS.UPDATE_TAGS, onUpdateTags);
|
||||||
yield takeLatest(NODE_ACTIONS.CREATE, onCreateSaga);
|
yield takeLatest(NODE_ACTIONS.CREATE, onCreateSaga);
|
||||||
yield takeLatest(NODE_ACTIONS.EDIT, onEditSaga);
|
yield takeLatest(NODE_ACTIONS.EDIT, onEditSaga);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue