This is an automated email from the ASF dual-hosted git repository. shuai pushed a commit to branch feat/1.4.2/ui in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit dfa22f949b31b5e07d9cc1b55a1887ff96d0a02f Author: shuai <[email protected]> AuthorDate: Thu Nov 14 16:19:27 2024 +0800 feat: actions add toast tips --- i18n/en_US.yaml | 13 +++++++++++++ .../pages/Admin/Answers/components/Action/index.tsx | 9 +++++++++ ui/src/pages/Admin/Badges/index.tsx | 9 +++++++++ .../Admin/Questions/components/Action/index.tsx | 20 ++++++++++++++++++-- ui/src/pages/Admin/Users/components/Action/index.tsx | 13 ++++++++++++- ui/src/pages/Admin/Users/index.tsx | 6 +++++- 6 files changed, 66 insertions(+), 4 deletions(-) diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml index 9074c8a1..cea0c12f 100644 --- a/i18n/en_US.yaml +++ b/i18n/en_US.yaml @@ -2250,6 +2250,7 @@ ui: discard_confirm: Are you sure you want to discard your draft? messages: post_deleted: This post has been deleted. + post_cancel_deleted: This post has been undeleted. post_pin: This post has been pinned. post_unpin: This post has been unpinned. post_hide_list: This post has been hidden from list. @@ -2258,3 +2259,15 @@ ui: post_list: This post has been listed. post_unlist: This post has been unlisted. post_pending: Your post is awaiting review. This is a preview, it will be visible after it has been approved. + post_closed: This post has been closed. + answer_deleted: This answer has been deleted. + answer_cancel_deleted: This answer has been undeleted. + change_user_role: This user's role has been changed. + user_inactive: This user is already inactive. + user_normal: This user is already normal. + user_suspended: This user has been suspended. + user_deleted: This user has been deleted. + badge_activated: This badge has been activated. + badge_inactivated: This badge has been inactivated. + + diff --git a/ui/src/pages/Admin/Answers/components/Action/index.tsx b/ui/src/pages/Admin/Answers/components/Action/index.tsx index 7dc3bb33..81e21813 100644 --- a/ui/src/pages/Admin/Answers/components/Action/index.tsx +++ b/ui/src/pages/Admin/Answers/components/Action/index.tsx @@ -23,6 +23,7 @@ import { Link } from 'react-router-dom'; import { Icon, Modal } from '@/components'; import { changeAnswerStatus } from '@/services'; +import { toastStore } from '@/stores'; const AnswerActions = ({ itemData, curFilter, refreshList }) => { const { t } = useTranslation('translation', { keyPrefix: 'delete' }); @@ -37,6 +38,10 @@ const AnswerActions = ({ itemData, curFilter, refreshList }) => { confirmText: t('delete', { keyPrefix: 'btns' }), onConfirm: () => { changeAnswerStatus(itemData.id, 'deleted').then(() => { + toastStore.getState().show({ + msg: t('answer_deleted', { keyPrefix: 'messages' }), + variant: 'success', + }); refreshList(); }); }, @@ -52,6 +57,10 @@ const AnswerActions = ({ itemData, curFilter, refreshList }) => { confirmText: t('undelete', { keyPrefix: 'btns' }), onConfirm: () => { changeAnswerStatus(itemData.id, 'available').then(() => { + toastStore.getState().show({ + msg: t('answer_cancel_deleted', { keyPrefix: 'messages' }), + variant: 'success', + }); refreshList(); }); }, diff --git a/ui/src/pages/Admin/Badges/index.tsx b/ui/src/pages/Admin/Badges/index.tsx index 99bafb43..63b8f348 100644 --- a/ui/src/pages/Admin/Badges/index.tsx +++ b/ui/src/pages/Admin/Badges/index.tsx @@ -27,6 +27,7 @@ import classNames from 'classnames'; import { Empty, Icon, Pagination, QueryGroup } from '@/components'; import * as Type from '@/common/interface'; import { useQueryBadges, updateBadgeStatus } from '@/services/admin/badges'; +import { useToast } from '@/hooks'; import Action from './components/Action'; @@ -46,6 +47,7 @@ const Badges: FC = () => { const curPage = Number(urlSearchParams.get('page') || '1'); const curFilter = urlSearchParams.get('filter') || BadgeFilterKeys[0]; const curQuery = urlSearchParams.get('query') || ''; + const Toast = useToast(); const { data, isLoading, mutate } = useQueryBadges({ page: curPage, @@ -62,6 +64,13 @@ const Badges: FC = () => { const handleBadgeStatus = (badgeId, status) => { updateBadgeStatus({ id: badgeId, status }).then(() => { + Toast.onShow({ + msg: + status === 'inactive' + ? t('badge_inactivated', { keyPrefix: 'messages' }) + : t('badge_activated', { keyPrefix: 'messages' }), + variant: 'success', + }); mutate(); }); }; diff --git a/ui/src/pages/Admin/Questions/components/Action/index.tsx b/ui/src/pages/Admin/Questions/components/Action/index.tsx index 0dc1fefa..560d6e69 100644 --- a/ui/src/pages/Admin/Questions/components/Action/index.tsx +++ b/ui/src/pages/Admin/Questions/components/Action/index.tsx @@ -28,11 +28,19 @@ import { reopenQuestion, } from '@/services'; import { useReportModal, useToast } from '@/hooks'; +import { toastStore } from '@/stores'; const AnswerActions = ({ itemData, refreshList, curFilter, show, pin }) => { const { t } = useTranslation('translation', { keyPrefix: 'delete' }); - const closeModal = useReportModal(refreshList); const toast = useToast(); + const closeCallback = () => { + toastStore.getState().show({ + msg: t('post_closed', { keyPrefix: 'messages' }), + variant: 'success', + }); + refreshList(); + }; + const closeModal = useReportModal(closeCallback); const handleAction = (type) => { if (type === 'delete') { @@ -47,6 +55,10 @@ const AnswerActions = ({ itemData, refreshList, curFilter, show, pin }) => { confirmText: t('delete', { keyPrefix: 'btns' }), onConfirm: () => { changeQuestionStatus(itemData.id, 'deleted').then(() => { + toastStore.getState().show({ + msg: t('post_deleted', { keyPrefix: 'messages' }), + variant: 'success', + }); refreshList(); }); }, @@ -62,6 +74,10 @@ const AnswerActions = ({ itemData, refreshList, curFilter, show, pin }) => { confirmText: t('undelete', { keyPrefix: 'btns' }), onConfirm: () => { changeQuestionStatus(itemData.id, 'available').then(() => { + toastStore.getState().show({ + msg: t('post_cancel_deleted', { keyPrefix: 'messages' }), + variant: 'success', + }); refreshList(); }); }, @@ -86,7 +102,7 @@ const AnswerActions = ({ itemData, refreshList, curFilter, show, pin }) => { reopenQuestion({ question_id: itemData.id, }).then(() => { - toast.onShow({ + toastStore.getState().show({ msg: t('post_reopen', { keyPrefix: 'messages' }), variant: 'success', }); diff --git a/ui/src/pages/Admin/Users/components/Action/index.tsx b/ui/src/pages/Admin/Users/components/Action/index.tsx index fa79c24d..9f0847a2 100644 --- a/ui/src/pages/Admin/Users/components/Action/index.tsx +++ b/ui/src/pages/Admin/Users/components/Action/index.tsx @@ -33,6 +33,7 @@ import { changeUserStatus, updateUserProfile, } from '@/services'; +import { toastStore } from '@/stores'; interface Props { showActionPassword?: boolean; @@ -57,7 +58,13 @@ const UserOperation = ({ const Toast = useToast(); const changeUserRoleModal = useChangeUserRoleModal({ - callback: refreshUsers, + callback: () => { + Toast.onShow({ + msg: t('change_user_role', { keyPrefix: 'messages' }), + variant: 'success', + }); + refreshUsers?.(); + }, }); const changePasswordModal = useChangePasswordModal({ onConfirm: (rd) => { @@ -107,6 +114,10 @@ const UserOperation = ({ user_id: userData.user_id, status: statusType, }).then(() => { + toastStore.getState().show({ + msg: t(`user_${statusType}`, { keyPrefix: 'messages' }), + variant: 'success', + }); refreshUsers?.(); // onClose(); }); diff --git a/ui/src/pages/Admin/Users/index.tsx b/ui/src/pages/Admin/Users/index.tsx index cfabd20a..40152200 100644 --- a/ui/src/pages/Admin/Users/index.tsx +++ b/ui/src/pages/Admin/Users/index.tsx @@ -33,6 +33,7 @@ import { } from '@/components'; import * as Type from '@/common/interface'; import { useUserModal } from '@/hooks'; +import { toastStore, loggedUserInfoStore, userCenterStore } from '@/stores'; import { useQueryUsers, addUsers, @@ -40,7 +41,6 @@ import { AdminUcAgent, changeUserStatus, } from '@/services'; -import { loggedUserInfoStore, userCenterStore } from '@/stores'; import { formatCount } from '@/utils'; import DeleteUserModal from './components/DeleteUserModal'; @@ -139,6 +139,10 @@ const Users: FC = () => { status: 'deleted', remove_all_content: val, }).then(() => { + toastStore.getState().show({ + msg: t('user_deleted', { keyPrefix: 'messages' }), + variant: 'success', + }); changeDeleteUserModalState({ show: false, userId: '',
