From fbfe42d6f007c5465eb55f3f7dd5708f8590d545 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 16 Jan 2023 05:29:44 +0900 Subject: [PATCH] enhance(client): improve usability of user select --- .../frontend/src/components/MkUserSelectDialog.vue | 11 ++++++++++- packages/frontend/src/os.ts | 6 ++++-- packages/frontend/src/pages/admin/roles.role.vue | 4 +++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/components/MkUserSelectDialog.vue b/packages/frontend/src/components/MkUserSelectDialog.vue index 4c79979cb..49b421818 100644 --- a/packages/frontend/src/components/MkUserSelectDialog.vue +++ b/packages/frontend/src/components/MkUserSelectDialog.vue @@ -60,6 +60,7 @@ import MkModalWindow from '@/components/MkModalWindow.vue'; import * as os from '@/os'; import { defaultStore } from '@/store'; import { i18n } from '@/i18n'; +import { $i } from '@/account'; const emit = defineEmits<{ (ev: 'ok', selected: misskey.entities.UserDetailed): void; @@ -67,6 +68,10 @@ const emit = defineEmits<{ (ev: 'closed'): void; }>(); +const props = defineProps<{ + includeSelf?: boolean; +}>(); + let username = $ref(''); let host = $ref(''); let users: misskey.entities.UserDetailed[] = $ref([]); @@ -110,7 +115,11 @@ onMounted(() => { os.api('users/show', { userIds: defaultStore.state.recentlyUsedUsers, }).then(users => { - recentUsers = users; + if (props.includeSelf) { + recentUsers = [$i, ...users]; + } else { + recentUsers = users; + } }); }); diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index 3c44ed6ea..b19443aa5 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -322,9 +322,11 @@ export function form(title, form) { }); } -export async function selectUser() { +export async function selectUser(opts: { includeSelf?: boolean } = {}) { return new Promise((resolve, reject) => { - popup(defineAsyncComponent(() => import('@/components/MkUserSelectDialog.vue')), {}, { + popup(defineAsyncComponent(() => import('@/components/MkUserSelectDialog.vue')), { + includeSelf: opts.includeSelf, + }, { ok: user => { resolve(user); }, diff --git a/packages/frontend/src/pages/admin/roles.role.vue b/packages/frontend/src/pages/admin/roles.role.vue index 9de3d0755..0365165b5 100644 --- a/packages/frontend/src/pages/admin/roles.role.vue +++ b/packages/frontend/src/pages/admin/roles.role.vue @@ -77,7 +77,9 @@ async function del() { } function assign() { - os.selectUser().then(async (user) => { + os.selectUser({ + includeSelf: true, + }).then(async (user) => { await os.apiWithDialog('admin/roles/assign', { roleId: role.id, userId: user.id }); role.users.push(user); });