Skip to content

Commit

Permalink
Merge pull request #7615 from weseek/feat/120698-121247-add-activity-…
Browse files Browse the repository at this point in the history
…event-for-read-only-user

feat: Add activityEvent for ReadOnly user access actions
  • Loading branch information
Ryoji Shimizu authored May 8, 2023
2 parents 0a14fe1 + 97799f4 commit 605a566
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 24 deletions.
4 changes: 3 additions & 1 deletion apps/app/public/static/locales/en_US/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@
},
"user_table": {
"administrator": "Administrator",
"read_only_user": "Read Only User",
"read_only": "Read Only",
"edit_menu": "Edit menu",
"reset_password": "Reset password",
"administrator_menu": "Administrator Menu",
Expand Down Expand Up @@ -1009,6 +1009,8 @@
"ADMIN_USERS_DEACTIVATE": "Deactivate user",
"ADMIN_USERS_GIVE_ADMIN": "Give admin access",
"ADMIN_USERS_REMOVE_ADMIN": "Remove admin access",
"ADMIN_USERS_GIVE_READ_ONLY": "Give read only access",
"ADMIN_USERS_REMOVE_READ_ONLY": "Remove read only access",
"ADMIN_USERS_SEND_INVITATION_EMAIL": "Resend invitation email",
"ADMIN_USERS_REMOVE": "Remove user",
"ADMIN_USER_GROUP_CREATE": "Create User Group",
Expand Down
12 changes: 7 additions & 5 deletions apps/app/public/static/locales/ja_JP/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@
},
"user_table": {
"administrator": "管理者",
"read_only_user": "閲覧ユーザー",
"read_only": "閲覧のみ",
"edit_menu": "編集メニュー",
"reset_password": "パスワードの再発行",
"administrator_menu": "管理者メニュー",
Expand All @@ -743,8 +743,8 @@
"remove_admin_access": "管理者から外す",
"cannot_remove": "自分自身を管理者から外すことはできません",
"give_admin_access": "管理者にする",
"remove_read_only_access": "閲覧ユーザーから外す",
"give_read_only_access": "閲覧ユーザーにする",
"remove_read_only_access": "閲覧のみアクセス権を外す",
"give_read_only_access": "閲覧のみアクセス権を付与する",
"send_invitation_email": "招待メールの送信",
"resend_invitation_email": "招待メールの再送信"
},
Expand Down Expand Up @@ -1017,6 +1017,8 @@
"ADMIN_USERS_DEACTIVATE": "ユーザーを停止する",
"ADMIN_USERS_GIVE_ADMIN": "管理者にする",
"ADMIN_USERS_REMOVE_ADMIN": "管理者から外す",
"ADMIN_USERS_GIVE_READ_ONLY": "閲覧のみアクセス権を付与する",
"ADMIN_USERS_REMOVE_READ_ONLY": "閲覧のみアクセス権を外す",
"ADMIN_USERS_SEND_INVITATION_EMAIL": "招待メールの再送信",
"ADMIN_USERS_REMOVE": "ユーザーの削除",
"ADMIN_USER_GROUP_CREATE": "ユーザーグループの作成",
Expand All @@ -1035,8 +1037,8 @@
"toaster": {
"give_user_admin": "{{username}}を管理者に設定しました",
"remove_user_admin": "{{username}}を管理者から外しました",
"give_user_read_only": "{{username}}を閲覧ユーザーに設定しました",
"remove_user_read_only": "{{username}}を閲覧ユーザーから外しました",
"give_user_read_only": "{{username}}に閲覧のみアクセス権を付与しました",
"remove_user_read_only": "{{username}}から閲覧のみアクセス権を外しました",
"activate_user_success": "{{username}}を有効化しました",
"deactivate_user_success": "{{username}}を無効化しました",
"remove_user_success": "{{username}}を削除しました",
Expand Down
8 changes: 5 additions & 3 deletions apps/app/public/static/locales/zh_CN/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@
},
"user_table": {
"administrator": "管理员",
"read_only_user": "浏览的用户",
"read_only": "只浏览",
"edit_menu": "编辑菜单",
"reset_password": "重置密码",
"administrator_menu": "管理员菜单",
Expand All @@ -743,8 +743,8 @@
"remove_admin_access": "删除管理员访问权限",
"cannot_remove": "您不能从管理员中删除自己",
"give_admin_access": "授予管理员访问权限",
"remove_read_only_access": "删除一个用户作为浏览用户",
"give_read_only_access": "使一个用户成为阅读用户",
"remove_read_only_access": "取消只读访问",
"give_read_only_access": "给予只读权限",
"send_invitation_email": "发送邀请邮件",
"resend_invitation_email": "重发邀请函"
},
Expand Down Expand Up @@ -1017,6 +1017,8 @@
"ADMIN_USERS_DEACTIVATE": "停用用户",
"ADMIN_USERS_GIVE_ADMIN": "授予管理员访问权限",
"ADMIN_USERS_REMOVE_ADMIN": "删除管理员访问权限",
"ADMIN_USERS_GIVE_READ_ONLY": "给予只读权限",
"ADMIN_USERS_REMOVE_READ_ONLY": "取消只读访问",
"ADMIN_USERS_SEND_INVITATION_EMAIL": "重发邀请函",
"ADMIN_USERS_REMOVE": "删除用户",
"ADMIN_USER_GROUP_CREATE": "创建用户组",
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/components/Admin/Users/UserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const UserTable = (props: UserTableProps) => {
)}
{(user.readOnly) && (
<span className="badge badge-light badge-pill ml-2">
{t('admin:user_management.user_table.read_only_user')}
{t('admin:user_management.user_table.read_only')}
</span>
)}
</td>
Expand Down
6 changes: 6 additions & 0 deletions apps/app/src/interfaces/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ const ACTION_ADMIN_USERS_PASSWORD_RESET = 'ADMIN_USERS_PASSWORD_RESET';
const ACTION_ADMIN_USERS_ACTIVATE = 'ADMIN_USERS_ACTIVATE';
const ACTION_ADMIN_USERS_GIVE_ADMIN = 'ADMIN_USERS_GIVE_ADMIN';
const ACTION_ADMIN_USERS_REMOVE_ADMIN = 'ADMIN_USERS_REMOVE_ADMIN';
const ACTION_ADMIN_USERS_GIVE_READ_ONLY = 'ADMIN_USERS_GIVE_READ_ONLY';
const ACTION_ADMIN_USERS_REMOVE_READ_ONLY = 'ADMIN_USERS_REMOVE_READ_ONLY';
const ACTION_ADMIN_USERS_DEACTIVATE = 'ADMIN_USERS_DEACTIVATE';
const ACTION_ADMIN_USERS_SEND_INVITATION_EMAIL = 'ADMIN_USERS_SEND_INVITATION_EMAIL';
const ACTION_ADMIN_USERS_REMOVE = 'ADMIN_USERS_REMOVE';
Expand Down Expand Up @@ -327,6 +329,8 @@ export const SupportedAction = {
ACTION_ADMIN_USERS_DEACTIVATE,
ACTION_ADMIN_USERS_GIVE_ADMIN,
ACTION_ADMIN_USERS_REMOVE_ADMIN,
ACTION_ADMIN_USERS_GIVE_READ_ONLY,
ACTION_ADMIN_USERS_REMOVE_READ_ONLY,
ACTION_ADMIN_USERS_SEND_INVITATION_EMAIL,
ACTION_ADMIN_USERS_REMOVE,
ACTION_ADMIN_USER_GROUP_CREATE,
Expand Down Expand Up @@ -511,6 +515,8 @@ export const LargeActionGroup = {
ACTION_ADMIN_USERS_DEACTIVATE,
ACTION_ADMIN_USERS_GIVE_ADMIN,
ACTION_ADMIN_USERS_REMOVE_ADMIN,
ACTION_ADMIN_USERS_GIVE_READ_ONLY,
ACTION_ADMIN_USERS_REMOVE_READ_ONLY,
ACTION_ADMIN_USERS_SEND_INVITATION_EMAIL,
ACTION_ADMIN_USERS_REMOVE,
ACTION_ADMIN_USER_GROUP_CREATE,
Expand Down
26 changes: 12 additions & 14 deletions apps/app/src/server/routes/apiv3/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,26 +550,26 @@ module.exports = (crowi) => {
* /users/{id}/give-read-only:
* put:
* tags: [Users]
* operationId: ReadOnlyUser
* operationId: ReadOnly
* summary: /users/{id}/give-read-only
* description: Give user read only flag
* description: Give user read only access
* parameters:
* - name: id
* in: path
* required: true
* description: id of user for read only
* description: id of user for read only access
* schema:
* type: string
* responses:
* 200:
* description: Give user read only flag success
* description: Give user read only access success
* content:
* application/json:
* schema:
* properties:
* userData:
* type: object
* description: data of read only user
* description: data of read only
*/
router.put('/:id/give-read-only', loginRequiredStrictly, adminRequired, addActivity, async(req, res) => {
const { id } = req.params;
Expand All @@ -585,8 +585,7 @@ module.exports = (crowi) => {

const serializedUserData = serializeUserSecurely(userData);

// TODO: https://redmine.weseek.co.jp/issues/121247
// activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ADMIN_USERS_GIVE_ADMIN });
activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ADMIN_USERS_GIVE_READ_ONLY });

return res.apiv3({ userData: serializedUserData });
}
Expand All @@ -603,26 +602,26 @@ module.exports = (crowi) => {
* /users/{id}/remove-read-only:
* put:
* tags: [Users]
* operationId: removeReadOnlyUser
* operationId: removeReadOnly
* summary: /users/{id}/remove-read-only
* description: Remove user read only flag
* description: Remove user read only access
* parameters:
* - name: id
* in: path
* required: true
* description: id of user for removing read only flag
* description: id of user for removing read only access
* schema:
* type: string
* responses:
* 200:
* description: Remove user read only flag success
* description: Remove user read only access success
* content:
* application/json:
* schema:
* properties:
* userData:
* type: object
* description: data of removed read only user
* description: data of removed read only
*/
router.put('/:id/remove-read-only', loginRequiredStrictly, adminRequired, addActivity, async(req, res) => {
const { id } = req.params;
Expand All @@ -638,8 +637,7 @@ module.exports = (crowi) => {

const serializedUserData = serializeUserSecurely(userData);

// TODO: https://redmine.weseek.co.jp/issues/121247
// activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ADMIN_USERS_REMOVE_ADMIN });
activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ADMIN_USERS_REMOVE_READ_ONLY });

return res.apiv3({ userData: serializedUserData });
}
Expand Down

0 comments on commit 605a566

Please sign in to comment.