From daf297c9c092ee9b7f1439baad0205b26b29b444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Wed, 20 Mar 2024 15:42:20 +0900 Subject: [PATCH] =?UTF-8?q?enhance(frontend):=20=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E7=99=BA=E7=94=9F=E6=99=82=E3=81=AE=E3=83=80=E3=82=A4?= =?UTF-8?q?=E3=82=A2=E3=83=AD=E3=82=B0=E3=81=AB=E8=A9=B3=E7=B4=B0=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=82=92=E8=BC=89=E3=81=9B=E3=82=8B=20(MisskeyIO#543)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/src/server/api/ApiCallService.ts | 16 ++++++---------- packages/backend/src/server/api/endpoint-base.ts | 2 +- .../src/server/api/endpoints/admin/emoji/copy.ts | 8 +++----- .../server/api/endpoints/drive/files/create.ts | 6 ++---- packages/backend/src/server/api/error.ts | 6 +++--- packages/frontend/src/components/MkDialog.vue | 16 ++++++++++++++-- packages/frontend/src/os.ts | 9 ++++++++- 7 files changed, 37 insertions(+), 26 deletions(-) diff --git a/packages/backend/src/server/api/ApiCallService.ts b/packages/backend/src/server/api/ApiCallService.ts index 1954d435ce..d8e792051e 100644 --- a/packages/backend/src/server/api/ApiCallService.ts +++ b/packages/backend/src/server/api/ApiCallService.ts @@ -389,11 +389,9 @@ export class ApiCallService implements OnApplicationShutdown { id: err.id, }, { - e: { - message: err.message, - code: err.name, - id: err.id, - }, + message: err.message, + code: err.name, + id: err.id, }, ); } else { @@ -416,11 +414,9 @@ export class ApiCallService implements OnApplicationShutdown { kind: 'server', }, { - e: { - message: err.message, - code: err.name, - id: errId, - }, + message: err.message, + code: err.name, + id: errId, }, ); } diff --git a/packages/backend/src/server/api/endpoint-base.ts b/packages/backend/src/server/api/endpoint-base.ts index e061aa3a8e..a549e48f23 100644 --- a/packages/backend/src/server/api/endpoint-base.ts +++ b/packages/backend/src/server/api/endpoint-base.ts @@ -63,7 +63,7 @@ export abstract class Endpoint { id: '3d81ceae-475f-4600-b2a8-2bc116157532', }, { param: errors[0].schemaPath, - reason: errors[0].message, + reason: errors[0].message ?? 'Invalid', }); return Promise.reject(err); } diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts index e8c39fe736..b6e2bd5ae9 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts @@ -85,11 +85,9 @@ export default class extends Endpoint { // eslint- id: '5c77c4d7-0f68-48f9-8694-8453a2294840', }, { - e: { - message: err.message, - code: err.name, - } - } + message: err.message, + code: err.name, + }, ); } diff --git a/packages/backend/src/server/api/endpoints/drive/files/create.ts b/packages/backend/src/server/api/endpoints/drive/files/create.ts index ad2d11fcba..9083ef15f5 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts @@ -191,10 +191,8 @@ export default class extends Endpoint { // eslint- id: '6708863c-6791-4487-aa01-2d682c6e7db0', }, { - e: { - message: err.message, - code: err.name, - }, + message: err.message, + code: err.name, }, ); } finally { diff --git a/packages/backend/src/server/api/error.ts b/packages/backend/src/server/api/error.ts index 67a819e8df..b05447050b 100644 --- a/packages/backend/src/server/api/error.ts +++ b/packages/backend/src/server/api/error.ts @@ -11,15 +11,15 @@ export class ApiError extends Error { public id: string; public kind: string; public httpStatusCode?: number; - public info?: any; + public info?: Record; - constructor(err: E, info?: any | null | undefined) { + constructor(err: E, info?: Record | null | undefined) { super(err.message); this.message = err.message; this.code = err.code; this.id = err.id; this.kind = err.kind ?? 'client'; this.httpStatusCode = err.httpStatusCode; - this.info = info; + this.info = info ?? undefined; } } diff --git a/packages/frontend/src/components/MkDialog.vue b/packages/frontend/src/components/MkDialog.vue index e4a8a66255..a1cecfbc25 100644 --- a/packages/frontend/src/components/MkDialog.vue +++ b/packages/frontend/src/components/MkDialog.vue @@ -48,6 +48,15 @@ SPDX-License-Identifier: AGPL-3.0-only +
+ {{ i18n.ts.details }} +
+ + + + +
+
{{ okText ?? ((showCancelButton || input || select) ? i18n.ts.ok : i18n.ts.gotIt) }} {{ cancelText ?? i18n.ts.cancel }} @@ -66,6 +75,7 @@ import MkButton from '@/components/MkButton.vue'; import MkInput from '@/components/MkInput.vue'; import MkSelect from '@/components/MkSelect.vue'; import MkTextarea from '@/components/MkTextarea.vue'; +import MkKeyValue from '@/components/MkKeyValue.vue'; import { i18n } from '@/i18n.js'; type Input = { @@ -89,11 +99,12 @@ type Result = string | number | true | null; const props = withDefaults(defineProps<{ type?: 'success' | 'error' | 'warning' | 'info' | 'question' | 'waiting'; + icon?: string; title?: string | null; text?: string | null; input?: Input; select?: Select; - icon?: string; + details?: Record; actions?: { text: string; primary?: boolean, @@ -107,11 +118,12 @@ const props = withDefaults(defineProps<{ cancelText?: string; }>(), { type: 'info', + icon: undefined, title: undefined, text: undefined, input: undefined, select: undefined, - icon: undefined, + details: undefined, actions: undefined, showOkButton: true, showCancelButton: false, diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index aa238d04cc..d63faa5515 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -47,6 +47,7 @@ export const apiWithDialog = (( } else { alert({ type: 'error', - text: err, + title: err.message, + text: err.id, + details: err.info, }); } }); @@ -217,6 +221,7 @@ export function alert(props: { type?: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question'; title?: string | null; text?: string | null; + details?: Record; }): Promise { return new Promise(resolve => { popup(MkDialog, props, { @@ -231,6 +236,7 @@ export function confirm(props: { type: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question'; title?: string | null; text?: string | null; + details?: Record; okText?: string; cancelText?: string; }): Promise<{ canceled: boolean }> { @@ -257,6 +263,7 @@ export function actions; actions: T; }): Promise<{ canceled: true; result: undefined;