@@ -34,7 +34,7 @@ import MkSuperMenu from '@/components/MkSuperMenu.vue';
|
||||
import MkInfo from '@/components/MkInfo.vue';
|
||||
import { instance } from '@/instance.js';
|
||||
import * as os from '@/os.js';
|
||||
import { lookupUser } from '@/scripts/lookup-user.js';
|
||||
import { lookupUser, lookupUserByEmail } from '@/scripts/lookup-user.js';
|
||||
import { useRouter } from '@/router.js';
|
||||
import { definePageMetadata, provideMetadataReceiver } from '@/scripts/page-metadata.js';
|
||||
|
||||
@@ -264,7 +264,7 @@ provideMetadataReceiver((info) => {
|
||||
}
|
||||
});
|
||||
|
||||
const invite = () => {
|
||||
function invite() {
|
||||
os.api('admin/invite/create').then(x => {
|
||||
os.alert({
|
||||
type: 'info',
|
||||
@@ -276,15 +276,21 @@ const invite = () => {
|
||||
text: err,
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const lookup = (ev) => {
|
||||
function lookup(ev: MouseEvent) {
|
||||
os.popupMenu([{
|
||||
text: i18n.ts.user,
|
||||
icon: 'ti ti-user',
|
||||
action: () => {
|
||||
lookupUser();
|
||||
},
|
||||
}, {
|
||||
text: `${i18n.ts.user} (${i18n.ts.email})`,
|
||||
icon: 'ti ti-user',
|
||||
action: () => {
|
||||
lookupUserByEmail();
|
||||
},
|
||||
}, {
|
||||
text: i18n.ts.note,
|
||||
icon: 'ti ti-pencil',
|
||||
@@ -304,7 +310,7 @@ const lookup = (ev) => {
|
||||
alert('TODO');
|
||||
},
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
};
|
||||
}
|
||||
|
||||
const headerActions = $computed(() => []);
|
||||
|
||||
|
@@ -39,3 +39,26 @@ export async function lookupUser() {
|
||||
notFound();
|
||||
});
|
||||
}
|
||||
|
||||
export async function lookupUserByEmail() {
|
||||
const { canceled, result } = await os.inputText({
|
||||
title: i18n.ts.emailAddress,
|
||||
type: 'email',
|
||||
});
|
||||
if (canceled) return;
|
||||
|
||||
try {
|
||||
const user = await os.apiWithDialog('admin/accounts/find-by-email', { email: result });
|
||||
|
||||
os.pageWindow(`/admin/user/${user.id}`);
|
||||
} catch (err) {
|
||||
if (err.code === 'USER_NOT_FOUND') {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
text: i18n.ts.noSuchUser,
|
||||
});
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user