Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ func SearchUsers(keyword string, group string, role *int, status *int, startIdx
query = query.Where("role = ?", *role)
}
if status != nil {
query = query.Where("status = ?", *status)
if *status == -1 {
query = query.Where("deleted_at IS NOT NULL")
} else {
query = query.Where("deleted_at IS NULL").Where("status = ?", *status)
}
}

// 获取总数
Expand Down
9 changes: 7 additions & 2 deletions web/default/src/features/users/components/users-columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ import { GroupBadge } from '@/components/group-badge'
import { LongText } from '@/components/long-text'
import { StatusBadge } from '@/components/status-badge'
import { TableId } from '@/components/table-id'
import { USER_STATUSES, USER_ROLES, isUserDeleted } from '../constants'
import {
USER_STATUS,
USER_STATUSES,
USER_ROLES,
isUserDeleted,
} from '../constants'
import { type User } from '../types'
import { DataTableRowActions } from './data-table-row-actions'

Expand Down Expand Up @@ -125,7 +130,7 @@ export function useUsersColumns(): ColumnDef<User>[] {
const requestCount = user.request_count

const statusConfig = isUserDeleted(user)
? USER_STATUSES.DELETED
? USER_STATUSES[USER_STATUS.DELETED]
: USER_STATUSES[user.status as keyof typeof USER_STATUSES]

if (!statusConfig) {
Expand Down
1 change: 1 addition & 0 deletions web/default/src/features/users/components/users-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export function UsersTable() {
onGlobalFilterChange,
onColumnFiltersChange,
manualPagination: true,
manualFiltering: true,
totalCount: data?.total || 0,
ensurePageInRange,
})
Expand Down
6 changes: 4 additions & 2 deletions web/default/src/features/users/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const isUserDeleted = (user: UserType): boolean => {
export const USER_STATUS = {
ENABLED: 1,
DISABLED: 2,
DELETED: -1,
} as const

export const USER_STATUSES = {
Expand All @@ -47,16 +48,17 @@ export const USER_STATUSES = {
variant: 'neutral' as const,
value: USER_STATUS.DISABLED,
},
DELETED: {
[USER_STATUS.DELETED]: {
labelKey: 'Deleted',
variant: 'danger' as const,
value: -1,
value: USER_STATUS.DELETED,
},
} as const

export const getUserStatusOptions = (t: (key: string) => string) => [
{ label: t('Enabled'), value: String(USER_STATUS.ENABLED) },
{ label: t('Disabled'), value: String(USER_STATUS.DISABLED) },
{ label: t('Deleted'), value: String(USER_STATUS.DELETED) },
]

// ============================================================================
Expand Down
2 changes: 1 addition & 1 deletion web/default/src/routes/_authenticated/users/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const usersSearchSchema = z.object({
pageSize: z.number().optional().catch(undefined),
filter: z.string().optional().catch(''),
status: z
.array(z.enum(['1', '2']))
.array(z.enum(['-1', '1', '2']))
.optional()
.catch([]),
role: z
Expand Down