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.

feat: delete admin/flag page

shuai4e11ce5ee7b3
diff --git a/ui/src/common/constants.ts b/ui/src/common/constants.ts
index 71ad6223..7b5a6803 100644
--- a/ui/src/common/constants.ts
+++ b/ui/src/common/constants.ts
@@ -89,10 +89,6 @@ export const ADMIN_NAV_MENUS = [
{
name: 'users',
},
- {
- name: 'flags',
- // badgeContent: 5,
- },
{
name: 'customize',
children: [
diff --git a/ui/src/pages/Admin/Dashboard/components/Statistics/index.tsx b/ui/src/pages/Admin/Dashboard/components/Statistics/index.tsx
index 85262724..6555c8cc 100644
--- a/ui/src/pages/Admin/Dashboard/components/Statistics/index.tsx
+++ b/ui/src/pages/Admin/Dashboard/components/Statistics/index.tsx
@@ -58,7 +58,7 @@ const Statistics: FC<IProps> = ({ data }) => {
<Col xs={6}>
<span className="text-secondary me-1">{t('flags')}</span>
<strong>
- <Link to="/admin/flags" className="ms-2">
+ <Link to="/review?type=flagged" className="ms-2">
{data.report_count}
</Link>
</strong>
diff --git a/ui/src/pages/Admin/Flags/index.tsx b/ui/src/pages/Admin/Flags/index.tsx
deleted file mode 100644
index 73f32113..00000000
--- a/ui/src/pages/Admin/Flags/index.tsx
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import React, { FC } from 'react';
-import { Button, Form, Table, Stack } from 'react-bootstrap';
-import { useSearchParams } from 'react-router-dom';
-import { useTranslation } from 'react-i18next';
-
-import {
- FormatTime,
- BaseUserCard,
- Empty,
- Pagination,
- QueryGroup,
-} from '@/components';
-import { useReportModal } from '@/hooks';
-import * as Type from '@/common/interface';
-import { useFlagSearch } from '@/services';
-import { escapeRemove } from '@/utils';
-import { pathFactory } from '@/router/pathFactory';
-
-const flagFilterKeys: Type.FlagStatus[] = ['pending', 'completed'];
-const flagTypeKeys: Type.FlagType[] = ['all', 'question', 'answer', 'comment'];
-
-const Flags: FC = () => {
- const { t } = useTranslation('translation', { keyPrefix: 'admin.flags' });
- const [urlSearchParams, setUrlSearchParams] = useSearchParams();
- const curFilter = urlSearchParams.get('status') || flagFilterKeys[0];
- const curType = urlSearchParams.get('type') || flagTypeKeys[0];
- const PAGE_SIZE = 20;
- const curPage = Number(urlSearchParams.get('page')) || 1;
- const {
- data: listData,
- isLoading,
- mutate: refreshList,
- } = useFlagSearch({
- page_size: PAGE_SIZE,
- page: curPage,
- status: curFilter as Type.FlagStatus,
- object_type: curType as Type.FlagType,
- });
- const reportModal = useReportModal(refreshList);
-
- const count = listData?.count || 0;
-
- const onTypeChange = (evt) => {
- urlSearchParams.set('type', evt.target.value);
- setUrlSearchParams(urlSearchParams);
- };
-
- const handleReview = ({ id, object_type }) => {
- reportModal.onShow({
- id,
- type: object_type,
- isBackend: true,
- action: 'review',
- });
- };
-
- return (
- <>
- <h3 className="mb-4">{t('title')}</h3>
- <div className="d-flex justify-content-between align-items-center mb-3">
- <QueryGroup
- data={flagFilterKeys}
- currentSort={curFilter}
- sortKey="status"
- i18nKeyPrefix="admin.flags"
- />
-
- <Form.Select
- value={curType}
- onChange={onTypeChange}
- size="sm"
- style={{ width: '12.25rem' }}>
- {flagTypeKeys.map((li) => {
- return (
- <option value={li} key={li}>
- {t(li, { keyPrefix: 'btns' })}
- </option>
- );
- })}
- </Form.Select>
- </div>
- <Table>
- <thead>
- <tr>
- <th>{t('flagged')}</th>
- <th style={{ width: '20%' }}>{t('created')}</th>
- {curFilter !== 'completed' ? (
- <th style={{ width: '20%' }}>{t('action')}</th>
- ) : null}
- </tr>
- </thead>
- <tbody className="align-middle">
- {listData?.list?.map((li) => {
- return (
- <tr key={li.id}>
- <td>
- <Stack>
- <small className="text-secondary">
- {t('flagged_type', {
- type: t(li.object_type, { keyPrefix: 'btns' }),
- })}
- </small>
- <BaseUserCard
- data={li.reported_user}
- className="mt-2 small"
- />
- <a
- href={pathFactory.questionLanding(
- li.question_id,
- li.url_title,
- )}
- target="_blank"
- className="text-wrap text-break mt-2"
- rel="noreferrer">
- {li.title}
- </a>
- <small className="text-break text-wrap word">
- {escapeRemove(li.excerpt)}
- </small>
- </Stack>
- </td>
- <td>
- <Stack>
- <FormatTime
- time={li.created_at}
- className="small text-secondary"
- />
- <BaseUserCard
- data={li.report_user}
- className="mt-2 mb-2 small"
- />
- {li.flagged_reason ? (
- <small>{li.flagged_content}</small>
- ) : (
- <small>
- {li.reason?.name}
- <br />
- <span className="text-secondary">{li.content}</span>
- </small>
- )}
- </Stack>
- </td>
- {curFilter !== 'completed' ? (
- <td>
- <Button variant="link" onClick={() => handleReview(li)}>
- {t('review')}
- </Button>
- </td>
- ) : null}
- </tr>
- );
- })}
- </tbody>
- </Table>
- {Number(count) <= 0 && !isLoading && <Empty />}
- <div className="mt-4 mb-2 d-flex justify-content-center">
- <Pagination
- currentPage={curPage}
- totalSize={count}
- pageSize={PAGE_SIZE}
- />
- </div>
- </>
- );
-};
-
-export default Flags;
diff --git a/ui/src/pages/Review/components/ApproveDropdown/index.tsx b/ui/src/pages/Review/components/ApproveDropdown/index.tsx
index d26b10f6..85be41db 100644
--- a/ui/src/pages/Review/components/ApproveDropdown/index.tsx
+++ b/ui/src/pages/Review/components/ApproveDropdown/index.tsx
@@ -21,7 +21,6 @@ const Index: FC<IProps> = ({
curFilter,
approveCallback,
}) => {
- console.log(objectType);
const { t } = useTranslation('translation', { keyPrefix: 'page_review' });
const [isLoading, setIsLoading] = useState(false);
diff --git a/ui/src/pages/Review/components/FlagContent/index.tsx b/ui/src/pages/Review/components/FlagContent/index.tsx
index a509ccd0..6a8556ad 100644
--- a/ui/src/pages/Review/components/FlagContent/index.tsx
+++ b/ui/src/pages/Review/components/FlagContent/index.tsx
@@ -25,7 +25,7 @@ const Index: FC<IProps> = ({ refreshCount }) => {
const [reviewResp, setReviewResp] = useState<Type.FlagReviewResp>();
const flagItemData = reviewResp?.list[0] as Type.FlagReviewItem;
- console.log('reviewResp', reviewResp);
+ // console.log('reviewResp', reviewResp);
const resolveNextOne = (resp, pageNumber) => {
const { count, list = [] } = resp;
diff --git a/ui/src/pages/Review/components/QueuedContent/index.tsx b/ui/src/pages/Review/components/QueuedContent/index.tsx
index 630a8e9b..b490bb22 100644
--- a/ui/src/pages/Review/components/QueuedContent/index.tsx
+++ b/ui/src/pages/Review/components/QueuedContent/index.tsx
@@ -24,7 +24,7 @@ const Index: FC<IProps> = ({ refreshCount }) => {
const [reviewResp, setReviewResp] = useState<Type.QuestionDetailRes>();
const flagItemData = reviewResp?.list[0] as Type.QueuedReviewItem;
- console.log('pendingResp', reviewResp);
+ // console.log('pendingResp', reviewResp);
const resolveNextOne = (resp, pageNumber) => {
const { count, list = [] } = resp;
diff --git a/ui/src/pages/Review/components/SuggestContent/index.tsx b/ui/src/pages/Review/components/SuggestContent/index.tsx
index b30c16fb..dde42796 100644
--- a/ui/src/pages/Review/components/SuggestContent/index.tsx
+++ b/ui/src/pages/Review/components/SuggestContent/index.tsx
@@ -66,13 +66,9 @@ const Index: FC<IProps> = ({ refreshCount }) => {
}, 150);
};
const queryNextOne = (pageNumber) => {
- getSuggestReviewList(pageNumber)
- .then((resp) => {
- resolveNextOne(resp, pageNumber);
- })
- .catch((ex) => {
- console.error('review next error: ', ex);
- });
+ getSuggestReviewList(pageNumber).then((resp) => {
+ resolveNextOne(resp, pageNumber);
+ });
};
const reviewInfo = unreviewed_info?.content;
@@ -86,9 +82,6 @@ const Index: FC<IProps> = ({ refreshCount }) => {
refreshCount();
queryNextOne(page);
})
- .catch((ex) => {
- console.error('revisionAudit approve error: ', ex);
- })
.finally(() => {
setIsLoading(false);
});
diff --git a/ui/src/pages/Review/index.tsx b/ui/src/pages/Review/index.tsx
index 40bf6b3b..0fc84b06 100644
--- a/ui/src/pages/Review/index.tsx
+++ b/ui/src/pages/Review/index.tsx
@@ -20,6 +20,7 @@
import { FC, useEffect, useState } from 'react';
import { Row, Col } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
+import { useSearchParams } from 'react-router-dom';
import { usePageTags } from '@/hooks';
import { Empty } from '@/components';
@@ -34,6 +35,8 @@ import {
} from './components';
const Index: FC = () => {
+ const [urlSearch, setUrlSearchParams] = useSearchParams();
+ const searchType = urlSearch.get('type');
const { t } = useTranslation('translation', { keyPrefix: 'page_review' });
const [reviewTypeList, setReviewTypeList] = useState<Type.ReviewTypeItem[]>();
const [currentReviewType, setCurrentReviewType] = useState('');
@@ -42,13 +45,22 @@ const Index: FC = () => {
const fetchReviewType = (changeReviewType: boolean) => {
getReviewType()
.then((resp) => {
- const filterData = resp.filter((item) => item.todo_amount > 0);
- if (filterData.length > 0) {
- if (changeReviewType) {
+ if (searchType) {
+ const filterData = resp.filter((item) =>
+ item.name.includes(searchType),
+ );
+ if (filterData.length > 0) {
setCurrentReviewType(filterData[0].name);
}
} else {
- setIsEmpty(true);
+ const filterData = resp.filter((item) => item.todo_amount > 0);
+ if (filterData.length > 0) {
+ if (changeReviewType) {
+ setCurrentReviewType(filterData[0].name);
+ }
+ } else {
+ setIsEmpty(true);
+ }
}
setReviewTypeList(resp);
})
@@ -57,6 +69,12 @@ const Index: FC = () => {
});
};
+ const handleTypeChange = (name) => {
+ urlSearch.delete('type');
+ setUrlSearchParams(urlSearch);
+ setCurrentReviewType(name);
+ };
+
useEffect(() => {
fetchReviewType(true);
}, []);
@@ -87,9 +105,7 @@ const Index: FC = () => {
<ReviewType
list={reviewTypeList}
checked={currentReviewType}
- callback={(name) => {
- setCurrentReviewType(name);
- }}
+ callback={handleTypeChange}
/>
</Col>
</Row>
diff --git a/ui/src/router/routes.ts b/ui/src/router/routes.ts
index 9880dd38..5c420e36 100644
--- a/ui/src/router/routes.ts
+++ b/ui/src/router/routes.ts
@@ -332,10 +332,6 @@ const routes: RouteNode[] = [
path: 'answers',
page: 'pages/Admin/Answers',
},
- {
- path: 'flags',
- page: 'pages/Admin/Flags',
- },
{
path: 'themes',
page: 'pages/Admin/Themes',