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: support search admin uses #795
shuai988662c7a07c
diff --git a/ui/src/components/Comment/components/Form/index.tsx b/ui/src/components/Comment/components/Form/index.tsxindex 05ae5b2d..82d547f8 100644--- a/ui/src/components/Comment/components/Form/index.tsx+++ b/ui/src/components/Comment/components/Form/index.tsx@@ -65,6 +65,9 @@ const Index = ({}});};++ console.log('userName:', pageUsers.getUsers());+return (<divclassName={classNames(diff --git a/ui/src/components/Comment/components/Reply/index.tsx b/ui/src/components/Comment/components/Reply/index.tsxindex 2bd722f2..9d236f11 100644--- a/ui/src/components/Comment/components/Reply/index.tsx+++ b/ui/src/components/Comment/components/Reply/index.tsx@@ -50,6 +50,8 @@ const Index = ({ userName, onSendReply, onCancel, mode }) => {});};+ console.log('userName:', pageUsers.getUsers());+return (<div className="mb-2"><div className="small mb-2">diff --git a/ui/src/components/Mentions/index.tsx b/ui/src/components/Mentions/index.tsxindex 9b61f0bf..63d0f702 100644--- a/ui/src/components/Mentions/index.tsx+++ b/ui/src/components/Mentions/index.tsx@@ -20,6 +20,7 @@import React, { useEffect, useRef, useState, FC } from 'react';import { Dropdown } from 'react-bootstrap';+import { useSearchUserStaff } from '@/services';import * as Types from '@/common/interface';interface IProps {@@ -37,6 +38,19 @@ const Mentions: FC<IProps> = ({ children, pageUsers, onSelected }) => {const [users, setUsers] = useState<Types.PageUser[]>([]);const [cursor, setCursor] = useState(0);const [isRequested, setRequestedState] = useState(false);+ const { data: staffUserList = [] } = useSearchUserStaff(val);+ const mapStaffUsers =+ staffUserList+ ?.map((item) => ({+ displayName: item.display_name,+ userName: item.username,+ }))+ ?.filter(+ (item) =>+ users.findIndex((user) => user.userName === item.userName) < 0,+ ) || [];++ console.log('staffUserList:', staffUserList);const searchUser = () => {const element = dropdownRef.current?.children[0];@@ -57,6 +71,9 @@ const Mentions: FC<IProps> = ({ children, pageUsers, onSelected }) => {if (str.substring(str.lastIndexOf(' '), selectionStart).indexOf('@') < 0) {return;}++ console.log('str111111:', str);+ console.log('str2222:', str.substring(1));setValue(str.substring(1));if (!str.substring(1)) {@@ -103,7 +120,7 @@ const Mentions: FC<IProps> = ({ children, pageUsers, onSelected }) => {setValue('');};const filterData = val- ? users.filter(+ ? [...users, ...mapStaffUsers].filter((item) =>item.displayName?.indexOf(val) === 0 ||item.userName?.indexOf(val) === 0,diff --git a/ui/src/services/client/user.ts b/ui/src/services/client/user.tsindex 66282b57..62ce0c76 100644--- a/ui/src/services/client/user.ts+++ b/ui/src/services/client/user.ts@@ -96,3 +96,10 @@ export const useUserPermission = (>>([apiUrl, { params: { action } }], request.instance.get);};++export const useSearchUserStaff = (name: string) => {+ const apiUrl = name+ ? `/answer/api/v1/user/staff?username=${name}&page_size=10`+ : null;+ return useSWR<Type.User[]>(apiUrl, request.instance.get);+};