From 273e3bd2e4388c41b6f385e1459fa3cab215ec5c Mon Sep 17 00:00:00 2001
From: samunohito <46447427+samunohito@users.noreply.github.com>
Date: Tue, 6 Feb 2024 23:43:12 +0900
Subject: [PATCH] fix
---
packages/frontend/src/components/MkSwitch.vue | 1 +
.../pages/admin/custom-emojis-grid.impl.ts | 9 +-
.../admin/custom-emojis-grid.local.list.vue | 181 ++++++++++++++----
....vue => custom-emojis-grid.local.logs.vue} | 4 +-
.../custom-emojis-grid.local.register.vue | 32 ++--
.../misskey-js/src/autogen/apiClientJSDoc.ts | 2 +-
packages/misskey-js/src/autogen/endpoint.ts | 2 +-
packages/misskey-js/src/autogen/entities.ts | 2 +-
packages/misskey-js/src/autogen/models.ts | 2 +-
packages/misskey-js/src/autogen/types.ts | 4 +-
10 files changed, 179 insertions(+), 60 deletions(-)
rename packages/frontend/src/pages/admin/{custom-emojis-grid.local.register.logs.vue => custom-emojis-grid.local.logs.vue} (96%)
diff --git a/packages/frontend/src/components/MkSwitch.vue b/packages/frontend/src/components/MkSwitch.vue
index 2e2c0e15a2..4492e0ea39 100644
--- a/packages/frontend/src/components/MkSwitch.vue
+++ b/packages/frontend/src/components/MkSwitch.vue
@@ -53,6 +53,7 @@ const toggle = () => {
display: flex;
transition: all 0.2s ease;
user-select: none;
+ align-items: center;
&:hover {
> .button {
diff --git a/packages/frontend/src/pages/admin/custom-emojis-grid.impl.ts b/packages/frontend/src/pages/admin/custom-emojis-grid.impl.ts
index 1ee40e4038..ca829bc5ed 100644
--- a/packages/frontend/src/pages/admin/custom-emojis-grid.impl.ts
+++ b/packages/frontend/src/pages/admin/custom-emojis-grid.impl.ts
@@ -1,6 +1,12 @@
import * as Misskey from 'misskey-js';
-export type RegisterLogItem = {
+export type EmojiOperationResult = {
+ item: GridItem,
+ success: boolean,
+ err?: Error
+};
+
+export type RequestLogItem = {
failed: boolean;
url: string;
name: string;
@@ -55,3 +61,4 @@ export function fromDriveFile(it: Misskey.entities.DriveFile): GridItem {
roleIdsThatCanBeUsedThisEmojiAsReaction: '',
};
}
+
diff --git a/packages/frontend/src/pages/admin/custom-emojis-grid.local.list.vue b/packages/frontend/src/pages/admin/custom-emojis-grid.local.list.vue
index edb9764e25..31ef7507a9 100644
--- a/packages/frontend/src/pages/admin/custom-emojis-grid.local.list.vue
+++ b/packages/frontend/src/pages/admin/custom-emojis-grid.local.list.vue
@@ -4,14 +4,70 @@
登録された絵文字はありません。
-
-
-
-
-
- {{ i18n.ts.search }}
-
-
+
+
+ 検索設定
+
+ 検索条件を詳細に設定します。
+
+
+
+
+ name
+
+
+ category
+
+
+ alias
+
+
+
+ type
+
+
+ license
+
+
+
+ updatedAt(from)
+
+
+ updatedAt(to)
+
+
+
+ sensitive
+
+
+
+
+
+ localOnly
+
+
+
+
+
+
+ {{ i18n.ts.search }}
+
+
+ リセット
+
+
+
+
+
+
+
+ 登録ログ
+
+ 絵文字更新・削除時のログが表示されます。更新・削除操作を行ったり、ページをリロードすると消えます。
+
+
+
+
@@ -21,9 +77,9 @@
- {{ i18n.ts.delete }}
- {{ i18n.ts.update }}
- リセット
+ {{ i18n.ts.delete }}
+ {{ i18n.ts.update }}
+ リセット
@@ -34,7 +90,7 @@
import { computed, onMounted, ref, toRefs, watch } from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
-import { fromEmojiDetailedAdmin, GridItem } from '@/pages/admin/custom-emojis-grid.impl.js';
+import { fromEmojiDetailedAdmin, GridItem, RequestLogItem } from '@/pages/admin/custom-emojis-grid.impl.js';
import MkGrid from '@/components/grid/MkGrid.vue';
import { i18n } from '@/i18n.js';
import MkInput from '@/components/MkInput.vue';
@@ -54,7 +110,12 @@ import { optInGridUtils } from '@/components/grid/optin-utils.js';
import { GridSetting } from '@/components/grid/grid.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import MkPagingButtons from '@/components/MkPagingButtons.vue';
+import XRegisterLogs from '@/pages/admin/custom-emojis-grid.local.logs.vue';
+import MkFolder from '@/components/MkFolder.vue';
+import MkSwitch from '@/components/MkSwitch.vue';
+import MkSelect from '@/components/MkSelect.vue';
+const emptyStrToUndefined = (value: string | null) => value ? value : undefined;
const emptyStrToNull = (value: string) => value === '' ? null : value;
const emptyStrToEmptyArray = (value: string) => value === '' ? [] : value.split(',').map(it => it.trim());
@@ -78,16 +139,27 @@ const columnSettings: ColumnSetting[] = [
];
const customEmojis = ref
([]);
-const queryName = ref('');
const allPages = ref(0);
const currentPage = ref(0);
+
+const queryName = ref(null);
+const queryCategory = ref(null);
+const queryAlias = ref(null);
+const queryType = ref(null);
+const queryLicense = ref(null);
+const queryUpdatedAtFrom = ref(null);
+const queryUpdatedAtTo = ref(null);
+const querySensitive = ref(null);
+const queryLocalOnly = ref(null);
const previousQuery = ref(undefined);
+const requestLogs = ref([]);
+
const gridItems = ref([]);
const originGridItems = ref([]);
const updateButtonDisabled = ref(false);
-async function onUpdateClicked() {
+async function onUpdateButtonClicked() {
const _items = gridItems.value;
const _originItems = originGridItems.value;
if (_items.length !== _originItems.length) {
@@ -114,23 +186,46 @@ async function onUpdateClicked() {
const action = () => {
return updatedItems.map(item =>
- misskeyApi('admin/emoji/update', {
- id: item.id!,
- name: item.name,
- category: emptyStrToNull(item.category),
- aliases: emptyStrToEmptyArray(item.aliases),
- license: emptyStrToNull(item.license),
- isSensitive: item.isSensitive,
- localOnly: item.localOnly,
- roleIdsThatCanBeUsedThisEmojiAsReaction: emptyStrToEmptyArray(item.roleIdsThatCanBeUsedThisEmojiAsReaction),
- }),
+ misskeyApi(
+ 'admin/emoji/update',
+ {
+ // eslint-disable-next-line
+ id: item.id!,
+ name: item.name,
+ category: emptyStrToNull(item.category),
+ aliases: emptyStrToEmptyArray(item.aliases),
+ license: emptyStrToNull(item.license),
+ isSensitive: item.isSensitive,
+ localOnly: item.localOnly,
+ roleIdsThatCanBeUsedThisEmojiAsReaction: emptyStrToEmptyArray(item.roleIdsThatCanBeUsedThisEmojiAsReaction),
+ })
+ .then(() => ({ item, success: true, err: undefined }))
+ .catch(err => ({ item, success: false, err })),
);
};
- await os.promiseDialog(Promise.all(action()));
+ const result = await os.promiseDialog(Promise.all(action()));
+ const failedItems = result.filter(it => !it.success);
+
+ if (failedItems.length > 0) {
+ await os.alert({
+ type: 'error',
+ title: 'エラー',
+ text: '絵文字の更新・削除に失敗しました。詳細は登録ログをご確認ください。',
+ });
+ }
+
+ requestLogs.value = result.map(it => ({
+ failed: !it.success,
+ url: it.item.url,
+ name: it.item.name,
+ error: it.err ? JSON.stringify(it.err) : undefined,
+ }));
+
+ await refreshCustomEmojis();
}
-async function onDeleteClicked() {
+async function onDeleteButtonClicked() {
const _items = gridItems.value;
const _originItems = originGridItems.value;
if (_items.length !== _originItems.length) {
@@ -167,7 +262,7 @@ async function onDeleteClicked() {
);
}
-function onResetClicked() {
+function onGridResetButtonClicked() {
refreshGridItems();
}
@@ -175,6 +270,18 @@ async function onSearchButtonClicked() {
await refreshCustomEmojis();
}
+function onQueryResetButtonClicked() {
+ queryName.value = null;
+ queryCategory.value = null;
+ queryAlias.value = null;
+ queryType.value = null;
+ queryLicense.value = null;
+ queryUpdatedAtFrom.value = null;
+ queryUpdatedAtTo.value = null;
+ querySensitive.value = null;
+ queryLocalOnly.value = null;
+}
+
async function onPageChanged(pageNumber: number) {
currentPage.value = pageNumber;
await refreshCustomEmojis();
@@ -267,10 +374,20 @@ async function refreshCustomEmojis() {
const limit = 100;
const query: Misskey.entities.AdminEmojiV2ListRequest['query'] = {
- name: emptyStrToNull(queryName.value) ?? undefined,
+ name: emptyStrToUndefined(queryName.value),
+ type: emptyStrToUndefined(queryType.value),
+ aliases: emptyStrToUndefined(queryAlias.value),
+ category: emptyStrToUndefined(queryCategory.value),
+ license: emptyStrToUndefined(queryLicense.value),
+ isSensitive: querySensitive.value ? Boolean(querySensitive.value).valueOf() : undefined,
+ localOnly: queryLocalOnly.value ? Boolean(queryLocalOnly.value).valueOf() : undefined,
+ updatedAtFrom: emptyStrToUndefined(queryUpdatedAtFrom.value),
+ updatedAtTo: emptyStrToUndefined(queryUpdatedAtTo.value),
hostType: 'local',
};
+ console.log(queryUpdatedAtTo.value);
+
if (JSON.stringify(query) !== previousQuery.value) {
currentPage.value = 1;
}
@@ -306,11 +423,9 @@ onMounted(async () => {