A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix: question add reopen operation
shuai57804fc4d9ba
diff --git a/i18n/en_US.yaml b/i18n/en_US.yamlindex 535fddf8..5dd61252 100644--- a/i18n/en_US.yaml+++ b/i18n/en_US.yaml@@ -713,6 +713,10 @@ ui:<p>Are you sure you want to add another answer?</p><p>You could use theedit link to refine and improve your existing answer, instead.</p>empty: Answer cannot be empty.+ reopen:+ title: Reopen this post+ content: Are you sure you want to reopen?+ success: This post has been reopeneddelete:title: Delete this postquestion: >-diff --git a/ui/src/components/Operate/index.tsx b/ui/src/components/Operate/index.tsxindex da27b7f4..846db738 100644--- a/ui/src/components/Operate/index.tsx+++ b/ui/src/components/Operate/index.tsx@@ -6,7 +6,12 @@ import { useTranslation } from 'react-i18next';import { Modal } from '@/components';import { useReportModal, useToast } from '@/hooks';import Share from '../Share';-import { deleteQuestion, deleteAnswer, editCheck } from '@/services';+import {+ deleteQuestion,+ deleteAnswer,+ editCheck,+ reopenQuestion,+} from '@/services';import { tryNormalLogged } from '@/utils/guard';interface IProps {@@ -32,7 +37,11 @@ const Index: FC<IProps> = ({const { t } = useTranslation('translation', { keyPrefix: 'delete' });const toast = useToast();const reportModal = useReportModal();- const closeModal = useReportModal();++ const refershQuestion = () => {+ callback?.('default');+ };+ const closeModal = useReportModal(refershQuestion);const editUrl =type === 'answer' ? `/posts/${qid}/${aid}/edit` : `/posts/${qid}/edit`;@@ -106,6 +115,25 @@ const Index: FC<IProps> = ({});};+ const handleReopen = () => {+ Modal.confirm({+ title: t('title', { keyPrefix: 'question_detail.reopen' }),+ content: t('content', { keyPrefix: 'question_detail.reopen' }),+ cancelBtnVariant: 'link',+ onConfirm: () => {+ reopenQuestion({+ question_id: qid,+ }).then(() => {+ toast.onShow({+ msg: t('success', { keyPrefix: 'question_detail.reopen' }),+ variant: 'success',+ });+ refershQuestion();+ });+ },+ });+ };+const handleAction = (action) => {if (!tryNormalLogged(true)) {return;@@ -121,6 +149,10 @@ const Index: FC<IProps> = ({if (action === 'close') {handleClose();}++ if (action === 'reopen') {+ handleReopen();+ }};return (diff --git a/ui/src/pages/Questions/Detail/index.tsx b/ui/src/pages/Questions/Detail/index.tsxindex 2cdc40c0..8be1cbe8 100644--- a/ui/src/pages/Questions/Detail/index.tsx+++ b/ui/src/pages/Questions/Detail/index.tsx@@ -89,6 +89,12 @@ const Index = () => {}, 1000);return;}++ if (type === 'default') {+ window.scrollTo(0, 0);+ getDetail();+ return;+ }requestAnswers();};diff --git a/ui/src/services/common.ts b/ui/src/services/common.tsindex 903c7aec..18e46490 100644--- a/ui/src/services/common.ts+++ b/ui/src/services/common.ts@@ -248,3 +248,7 @@ export const changeEmailVerify = (params: { code: string }) => {export const getAppSettings = () => {return request.get<Type.SiteSettings>('/answer/api/v1/siteinfo');};++export const reopenQuestion = (params: { question_id: string }) => {+ return request.put('/answer/api/v1/question/reopen', params);+};