Quick action implement (#13878)

* enhance(frontend): quick action for file admin-lookup

* docs(changelog): update changelog

* enhance(frontend): quick action for general admin-lookup, remove unimplemented note, instance admin-lookup

* docs(changelog): update changelog

* chore: fix lint
This commit is contained in:
Sayamame-beans 2024-05-27 17:21:05 +09:00 committed by GitHub
parent d013e4516d
commit 6af9492ea5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 36 additions and 39 deletions

View file

@ -49,6 +49,8 @@
- Enhance: AiScriptを0.18.0にバージョンアップ - Enhance: AiScriptを0.18.0にバージョンアップ
- Enhance: 通常のノートでも、お気に入りに登録したチャンネルにリノートできるように - Enhance: 通常のノートでも、お気に入りに登録したチャンネルにリノートできるように
- Enhance: 長いテキストをペーストした際にテキストファイルとして添付するかどうかを選択できるように - Enhance: 長いテキストをペーストした際にテキストファイルとして添付するかどうかを選択できるように
- Enhance: コントロールパネルのクイックアクションからファイルを照会できるように
- Enhance: コントロールパネルのクイックアクションから通常の照会を行えるように
- Fix: 一部のページ内リンクが正しく動作しない問題を修正 - Fix: 一部のページ内リンクが正しく動作しない問題を修正
- Fix: 周年の実績が閏年を考慮しない問題を修正 - Fix: 周年の実績が閏年を考慮しない問題を修正
- Fix: ローカルURLのプレビューポップアップが左上に表示される - Fix: ローカルURLのプレビューポップアップが左上に表示される

View file

@ -42,7 +42,7 @@ import MkInput from '@/components/MkInput.vue';
import MkSelect from '@/components/MkSelect.vue'; import MkSelect from '@/components/MkSelect.vue';
import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue'; import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js'; import { lookupFile } from '@/scripts/admin-lookup.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -73,33 +73,10 @@ function clear() {
}); });
} }
function show(file) {
os.pageWindow(`/admin/file/${file.id}`);
}
async function find() {
const { canceled, result: q } = await os.inputText({
title: i18n.ts.fileIdOrUrl,
minLength: 1,
});
if (canceled) return;
misskeyApi('admin/drive/show-file', q.startsWith('http://') || q.startsWith('https://') ? { url: q.trim() } : { fileId: q.trim() }).then(file => {
show(file);
}).catch(err => {
if (err.code === 'NO_SUCH_FILE') {
os.alert({
type: 'error',
text: i18n.ts.notFound,
});
}
});
}
const headerActions = computed(() => [{ const headerActions = computed(() => [{
text: i18n.ts.lookup, text: i18n.ts.lookup,
icon: 'ti ti-search', icon: 'ti ti-search',
handler: find, handler: lookupFile,
}, { }, {
text: i18n.ts.clearCachedFiles, text: i18n.ts.clearCachedFiles,
icon: 'ti ti-trash', icon: 'ti ti-trash',

View file

@ -33,9 +33,10 @@ import { i18n } from '@/i18n.js';
import MkSuperMenu from '@/components/MkSuperMenu.vue'; import MkSuperMenu from '@/components/MkSuperMenu.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import { instance } from '@/instance.js'; import { instance } from '@/instance.js';
import { lookup } from '@/scripts/lookup.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { lookupUser, lookupUserByEmail } from '@/scripts/lookup-user.js'; import { lookupUser, lookupUserByEmail, lookupFile } from '@/scripts/admin-lookup.js';
import { PageMetadata, definePageMetadata, provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js'; import { PageMetadata, definePageMetadata, provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js';
import { useRouter } from '@/router/supplier.js'; import { useRouter } from '@/router/supplier.js';
@ -82,7 +83,7 @@ const menuDef = computed(() => [{
type: 'button', type: 'button',
icon: 'ti ti-search', icon: 'ti ti-search',
text: i18n.ts.lookup, text: i18n.ts.lookup,
action: lookup, action: adminLookup,
}, ...(instance.disableRegistration ? [{ }, ...(instance.disableRegistration ? [{
type: 'button', type: 'button',
icon: 'ti ti-user-plus', icon: 'ti ti-user-plus',
@ -282,7 +283,7 @@ function invite() {
}); });
} }
function lookup(ev: MouseEvent) { function adminLookup(ev: MouseEvent) {
os.popupMenu([{ os.popupMenu([{
text: i18n.ts.user, text: i18n.ts.user,
icon: 'ti ti-user', icon: 'ti ti-user',
@ -295,23 +296,17 @@ function lookup(ev: MouseEvent) {
action: () => { action: () => {
lookupUserByEmail(); lookupUserByEmail();
}, },
}, {
text: i18n.ts.note,
icon: 'ti ti-pencil',
action: () => {
alert('TODO');
},
}, { }, {
text: i18n.ts.file, text: i18n.ts.file,
icon: 'ti ti-cloud', icon: 'ti ti-cloud',
action: () => { action: () => {
alert('TODO'); lookupFile();
}, },
}, { }, {
text: i18n.ts.instance, text: i18n.ts.lookup,
icon: 'ti ti-planet', icon: 'ti ti-world-search',
action: () => { action: () => {
alert('TODO'); lookup();
}, },
}], ev.currentTarget ?? ev.target); }], ev.currentTarget ?? ev.target);
} }

View file

@ -63,7 +63,7 @@ import MkInput from '@/components/MkInput.vue';
import MkSelect from '@/components/MkSelect.vue'; import MkSelect from '@/components/MkSelect.vue';
import MkPagination from '@/components/MkPagination.vue'; import MkPagination from '@/components/MkPagination.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { lookupUser } from '@/scripts/lookup-user.js'; import { lookupUser } from '@/scripts/admin-lookup.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import MkUserCardMini from '@/components/MkUserCardMini.vue'; import MkUserCardMini from '@/components/MkUserCardMini.vue';

View file

@ -63,3 +63,26 @@ export async function lookupUserByEmail() {
} }
} }
} }
export async function lookupFile() {
const { canceled, result: q } = await os.inputText({
title: i18n.ts.fileIdOrUrl,
minLength: 1,
});
if (canceled) return;
const show = (file) => {
os.pageWindow(`/admin/file/${file.id}`);
};
misskeyApi('admin/drive/show-file', q.startsWith('http://') || q.startsWith('https://') ? { url: q.trim() } : { fileId: q.trim() }).then(file => {
show(file);
}).catch(err => {
if (err.code === 'NO_SUCH_FILE') {
os.alert({
type: 'error',
text: i18n.ts.notFound,
});
}
});
}