Skip to content

Commit

Permalink
feat(report): add report list page
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed Feb 1, 2024
1 parent 7c3bcdc commit 7b29c4b
Show file tree
Hide file tree
Showing 19 changed files with 8,826 additions and 13,459 deletions.
212 changes: 39 additions & 173 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/components/Comment/DigestList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react'
import { Table, Switch } from 'antd'
import _get from 'lodash/get'
import _compact from 'lodash/compact'

import DateTime from '../../DateTime'
Expand Down Expand Up @@ -47,7 +46,9 @@ class CommentDigestList extends React.Component<
}

private _renderStateCell(_: any, record: CommentDigest): React.ReactNode {
return <CommentSetState state={record.state} ids={[record.id]} />
return (
<CommentSetState commentState={record.commentState} ids={[record.id]} />
)
}

_onSelectChange = (
Expand Down
10 changes: 6 additions & 4 deletions src/components/Comment/SetState/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const COMMENT_STATES: {

class SetState extends React.Component<ChildProps, SetStateState> {
state: Readonly<SetStateState> = {
commentState: this.props.state,
commentState: this.props.commentState,
loading: false,
error: null,
}
Expand All @@ -41,7 +41,7 @@ class SetState extends React.Component<ChildProps, SetStateState> {
}

this.setState({ commentState: value }, () => {
if (this.props.state !== value) {
if (this.props.commentState !== value) {
this.preConfirm()
}
})
Expand Down Expand Up @@ -89,7 +89,9 @@ class SetState extends React.Component<ChildProps, SetStateState> {
<div style={{ marginTop: 16 }}>
<span>
修改後,評論狀態將從&nbsp;&nbsp;
{this.props.state && <CommentStateTag state={this.props.state} />}
{this.props.commentState && (
<CommentStateTag state={this.props.commentState} />
)}
改為&nbsp;&nbsp;
{this.state.commentState && (
<CommentStateTag state={this.state.commentState} />
Expand All @@ -107,7 +109,7 @@ class SetState extends React.Component<ChildProps, SetStateState> {
}

private revertChange = () => {
this.setState({ commentState: this.props.state })
this.setState({ commentState: this.props.commentState })
}

public render() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Comment/SetState/withSetState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type CommentState = 'active' | 'archived' | 'banned' | 'collapsed'

type InputProps = {
ids: string[]
state?: CommentState
commentState?: CommentState
disabled?: boolean
onSuccess?: () => void
}
Expand Down
10 changes: 9 additions & 1 deletion src/components/Layout/Sider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ export const Sider: React.FC<RouteComponentProps> = ({ location }) => {

<SubMenu key="comment" title={<strong>評論</strong>}>
<Menu.Item key={PATH.COMMENT_LIST}>
<Link to={PATH.COMMENT_LIST}>評論清單</Link>
<Link to={PATH.COMMENT_LIST}>
{PAGE_TITLE[PATH.COMMENT_DETAIL]}
</Link>
</Menu.Item>
</SubMenu>

<SubMenu key="comment" title={<strong>報告</strong>}>
<Menu.Item key={PATH.REPORT_LIST}>
<Link to={PATH.REPORT_LIST}>{PAGE_TITLE[PATH.REPORT_LIST]}</Link>
</Menu.Item>
</SubMenu>

Expand Down
4 changes: 4 additions & 0 deletions src/constants/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const PATH = {
COMMENT_LIST: '/comments',
COMMENT_DETAIL: '/comments/:id',

REPORT_LIST: '/reports',

OAUTH_CLIENT_LIST: '/oauth-clients',
OAUTH_CLIENT_DETAIL: '/oauth-clients/:id',

Expand Down Expand Up @@ -60,6 +62,8 @@ export const PAGE_TITLE = {
[PATH.COMMENT_LIST]: '評論清單',
[PATH.COMMENT_DETAIL]: '評論詳情',

[PATH.REPORT_LIST]: '報告清單',

[PATH.OAUTH_CLIENT_LIST]: 'OAuth Client 清單',
[PATH.OAUTH_CLIENT_DETAIL]: 'OAuth Client 詳情',

Expand Down
13 changes: 12 additions & 1 deletion src/definitions/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export type ArticleDetail = ArticleDigest & {
*/
export type CommentDigest = {
id: string
state: GQLCommentState
commentState: GQLCommentState
createdAt: Date
node: ArticleDigest
content: string
Expand All @@ -156,6 +156,17 @@ export type CommentDigest = {

export type CommentDetail = CommentDigest

/**
* Report
*/
export type ReportDigest = {
id: string
reporter: UserDigest
target: ArticleDigest | CommentDigest
reason: string
createdAt: Date
}

/**
* Pagination
*/
Expand Down
Loading

0 comments on commit 7b29c4b

Please sign in to comment.