Skip to content

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: modal confrim render content in the p tag

shuai838c8f58b83b
diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml
index a1b7b70b..039e2e5e 100644
--- a/i18n/en_US.yaml
+++ b/i18n/en_US.yaml
@@ -815,6 +815,7 @@ ui:
li2_1: Asking for help, seeking clarification, or responding to other answers.
reopen:
+ confirm_btn: Reopen
title: Reopen this post
content: Are you sure you want to reopen?
success: This post has been reopened
diff --git a/ui/src/components/Modal/Confirm.tsx b/ui/src/components/Modal/Confirm.tsx
index c5d467da..945ac7a4 100644
--- a/ui/src/components/Modal/Confirm.tsx
+++ b/ui/src/components/Modal/Confirm.tsx
@@ -45,7 +45,7 @@ const Index = ({
cancelBtnVariant={cancelBtnVariant}
confirmBtnVariant={confirmBtnVariant}
{...props}>
- <div dangerouslySetInnerHTML={{ __html: content }} />
+ <p dangerouslySetInnerHTML={{ __html: content }} />
</Modal>,
);
}
diff --git a/ui/src/components/Operate/index.tsx b/ui/src/components/Operate/index.tsx
index d8b5d36d..06e9377e 100644
--- a/ui/src/components/Operate/index.tsx
+++ b/ui/src/components/Operate/index.tsx
@@ -69,7 +69,7 @@ const Index: FC<IProps> = ({
if (type === 'question') {
Modal.confirm({
title: t('title'),
- content: hasAnswer ? `<p>${t('question')}</p>` : `<p>${t('other')}</p>`,
+ content: hasAnswer ? t('question') : t('other'),
cancelBtnVariant: 'link',
confirmBtnVariant: 'danger',
confirmText: t('delete', { keyPrefix: 'btns' }),
@@ -90,7 +90,7 @@ const Index: FC<IProps> = ({
if (type === 'answer' && aid) {
Modal.confirm({
title: t('title'),
- content: isAccepted ? t('answer_accepted') : `<p>${t('other')}</p>`,
+ content: isAccepted ? t('answer_accepted') : t('other'),
cancelBtnVariant: 'link',
confirmBtnVariant: 'danger',
confirmText: t('delete', { keyPrefix: 'btns' }),
@@ -128,6 +128,7 @@ const Index: FC<IProps> = ({
title: t('title', { keyPrefix: 'question_detail.reopen' }),
content: t('content', { keyPrefix: 'question_detail.reopen' }),
cancelBtnVariant: 'link',
+ confirmText: t('confirm_btn', { keyPrefix: 'question_detail.reopen' }),
onConfirm: () => {
reopenQuestion({
question_id: qid,
diff --git a/ui/src/pages/Admin/Answers/index.tsx b/ui/src/pages/Admin/Answers/index.tsx
index cf53e269..39a7946f 100644
--- a/ui/src/pages/Admin/Answers/index.tsx
+++ b/ui/src/pages/Admin/Answers/index.tsx
@@ -58,7 +58,7 @@ const Answers: FC = () => {
content:
item.accepted === 2
? t('answer_accepted', { keyPrefix: 'delete' })
- : `<p>${t('other', { keyPrefix: 'delete' })}</p>`,
+ : t('other', { keyPrefix: 'delete' }),
cancelBtnVariant: 'link',
confirmBtnVariant: 'danger',
confirmText: t('delete', { keyPrefix: 'btns' }),
diff --git a/ui/src/pages/Admin/Questions/index.tsx b/ui/src/pages/Admin/Questions/index.tsx
index 124fd307..d11043b2 100644
--- a/ui/src/pages/Admin/Questions/index.tsx
+++ b/ui/src/pages/Admin/Questions/index.tsx
@@ -67,8 +67,8 @@ const Questions: FC = () => {
title: t('title', { keyPrefix: 'delete' }),
content:
item.answer_count > 0
- ? `<p>${t('question', { keyPrefix: 'delete' })}</p>`
- : `<p>${t('other', { keyPrefix: 'delete' })}</p>`,
+ ? t('question', { keyPrefix: 'delete' })
+ : t('other', { keyPrefix: 'delete' }),
cancelBtnVariant: 'link',
confirmBtnVariant: 'danger',
confirmText: t('delete', { keyPrefix: 'btns' }),