Просмотр исходного кода

Merge pull request #10934 from growilabs/fix/180602

fix: Deleted users are not displayed in the user list on the user management page (/admin/users)
Yuki Takei 1 неделя назад
Родитель
Сommit
3213545df8

+ 2 - 1
apps/app/public/static/locales/en_US/admin.json

@@ -781,7 +781,8 @@
       "revoke_read_only_access": "Revoke read only access",
       "grant_read_only_access": "Grant read only access",
       "send_invitation_email": "Send invitation email",
-      "resend_invitation_email": "Resend invitation email"
+      "resend_invitation_email": "Resend invitation email",
+      "deleted_user": "(Deleted User)"
     },
     "reset_password": "Reset Password",
     "reset_password_modal": {

+ 2 - 1
apps/app/public/static/locales/fr_FR/admin.json

@@ -781,7 +781,8 @@
       "revoke_read_only_access": "Révoquer permission de lecture",
       "grant_read_only_access": "Permission de lecture-seule",
       "send_invitation_email": "Envoyer courriel d'invitation",
-      "resend_invitation_email": "Renvoyer courriel d'invitation"
+      "resend_invitation_email": "Renvoyer courriel d'invitation",
+      "deleted_user": "(Utilisateur supprimé)"
     },
     "reset_password": "Réinitialiser mot de passe",
     "reset_password_modal": {

+ 2 - 1
apps/app/public/static/locales/ja_JP/admin.json

@@ -790,7 +790,8 @@
       "revoke_read_only_access": "閲覧のみアクセス権を外す",
       "grant_read_only_access": "閲覧のみアクセス権を付与する",
       "send_invitation_email": "招待メールの送信",
-      "resend_invitation_email": "招待メールの再送信"
+      "resend_invitation_email": "招待メールの再送信",
+      "deleted_user": "(削除されたユーザー)"
     },
     "reset_password": "パスワードのリセット",
     "reset_password_modal": {

+ 2 - 1
apps/app/public/static/locales/ko_KR/admin.json

@@ -781,7 +781,8 @@
       "revoke_read_only_access": "읽기 전용 권한 취소",
       "grant_read_only_access": "읽기 전용 권한 부여",
       "send_invitation_email": "초대 이메일 전송",
-      "resend_invitation_email": "초대 이메일 재전송"
+      "resend_invitation_email": "초대 이메일 재전송",
+      "deleted_user": "(삭제된 사용자)"
     },
     "reset_password": "비밀번호 재설정",
     "reset_password_modal": {

+ 2 - 1
apps/app/public/static/locales/zh_CN/admin.json

@@ -790,7 +790,8 @@
       "revoke_read_only_access": "取消只读访问",
       "grant_read_only_access": "给予只读权限",
       "send_invitation_email": "发送邀请邮件",
-      "resend_invitation_email": "重发邀请函"
+      "resend_invitation_email": "重发邀请函",
+      "deleted_user": "(已删除的用户)"
     },
     "reset_password": "重置密码",
     "reset_password_modal": {

+ 1 - 0
apps/app/src/client/components/Admin/UserManagement.tsx

@@ -183,6 +183,7 @@ const UserManagement = (props: UserManagementProps) => {
               {renderCheckbox('active', 'Active', 'success')}
               {renderCheckbox('suspended', 'Suspended', 'warning')}
               {renderCheckbox('invited', 'Invited', 'secondary')}
+              {renderCheckbox('deleted', 'Deleted', 'danger')}
             </div>
             <div>
               {isNotifyCommentShow && (

+ 8 - 1
apps/app/src/client/components/Admin/Users/UserTable.tsx

@@ -5,6 +5,7 @@ import { format as dateFnsFormat } from 'date-fns/format';
 import { useTranslation } from 'next-i18next';
 
 import AdminUsersContainer from '~/client/services/AdminUsersContainer';
+import { UserStatus } from '~/server/models/user/conts';
 
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { SortIcons } from './SortIcons';
@@ -164,7 +165,13 @@ const UserTable = (props: UserTableProps) => {
                   )}
                 </td>
                 <td>
-                  <strong>{user.username}</strong>
+                  {user.status === UserStatus.STATUS_DELETED ? (
+                    <p className="text-secondary">
+                      {t('admin:user_management.user_table.deleted_user')}
+                    </p>
+                  ) : (
+                    <strong>{user.username}</strong>
+                  )}
                 </td>
                 <td>{user.name}</td>
                 <td>{user.email}</td>

+ 3 - 2
apps/app/src/server/routes/apiv3/users.js

@@ -124,6 +124,7 @@ module.exports = (crowi) => {
     registered: UserStatus.STATUS_REGISTERED,
     active: UserStatus.STATUS_ACTIVE,
     suspended: UserStatus.STATUS_SUSPENDED,
+    deleted: UserStatus.STATUS_DELETED,
     invited: UserStatus.STATUS_INVITED,
   };
 
@@ -157,7 +158,7 @@ module.exports = (crowi) => {
       'createdAt',
       'lastLoginAt',
     ]),
-    query('page').isInt({ min: 1 }),
+    query('page').isInt({ min: 1 }).toInt(),
     query('forceIncludeAttributes')
       .toArray()
       .custom((value, { req }) => {
@@ -317,7 +318,7 @@ module.exports = (crowi) => {
     validator.statusList,
     apiV3FormValidator,
     async (req, res) => {
-      const page = parseInt(req.query.page) || 1;
+      const page = req.query.page || 1;
 
       // status
       const forceIncludeAttributes = Array.isArray(