From 58469c0a69d82cd365e3d440f981413ac35ad748 Mon Sep 17 00:00:00 2001 From: Camilla Ett Date: Wed, 3 Jan 2024 08:07:04 +0900 Subject: [PATCH 1/8] =?UTF-8?q?enhance(frontend):=20=E3=82=AB=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E3=83=A0=E7=B5=B5=E6=96=87=E5=AD=97=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=AE=E3=80=8C=E3=82=BF=E3=82=B0=E3=80=8D?= =?UTF-8?q?=E3=81=AE=E8=AA=AC=E6=98=8E=E3=82=92=E8=BF=BD=E5=8A=A0=20(#1288?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/index.d.ts | 1 + locales/ja-JP.yml | 1 + packages/frontend/src/pages/emoji-edit-dialog.vue | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index 60e88a2192..3937784153 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -672,6 +672,7 @@ export interface Locale { "other": string; "regenerateLoginToken": string; "regenerateLoginTokenDescription": string; + "theKeywordWhenSearchingForCustomEmoji": string; "setMultipleBySeparatingWithSpace": string; "fileIdOrUrl": string; "behavior": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 3d31dcef49..77f9a9ec0f 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -669,6 +669,7 @@ useGlobalSettingDesc: "オンにすると、アカウントの通知設定が使 other: "その他" regenerateLoginToken: "ログイントークンを再生成" regenerateLoginTokenDescription: "ログインに使用される内部トークンを再生成します。通常この操作を行う必要はありません。再生成すると、全てのデバイスでログアウトされます。" +theKeywordWhenSearchingForCustomEmoji: "カスタム絵文字を検索する時のキーワードになります。" setMultipleBySeparatingWithSpace: "スペースで区切って複数設定できます。" fileIdOrUrl: "ファイルIDまたはURL" behavior: "動作" diff --git a/packages/frontend/src/pages/emoji-edit-dialog.vue b/packages/frontend/src/pages/emoji-edit-dialog.vue index 07b44a1051..474e63cb46 100644 --- a/packages/frontend/src/pages/emoji-edit-dialog.vue +++ b/packages/frontend/src/pages/emoji-edit-dialog.vue @@ -39,7 +39,10 @@ SPDX-License-Identifier: AGPL-3.0-only - + From a9127e3ecd0c5789ba01123b8c4bbfc22c4e70e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Wed, 3 Jan 2024 13:35:40 +0900 Subject: [PATCH 2/8] =?UTF-8?q?enhance(frontend):=20=E3=83=81=E3=83=A3?= =?UTF-8?q?=E3=83=B3=E3=83=8D=E3=83=AB=E3=83=8E=E3=83=BC=E3=83=88=E3=81=AE?= =?UTF-8?q?=E3=83=94=E3=83=B3=E7=95=99=E3=82=81=E3=82=92=E3=83=8E=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC=E3=81=8B=E3=82=89?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20(#1288?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance(frontend): チャンネルノートのピン留めをノートメニューからできるように * Update Changelog --- CHANGELOG.md | 1 + .../src/core/entities/NoteEntityService.ts | 1 + .../backend/src/models/json-schema/note.ts | 4 +++ .../frontend/src/scripts/get-note-menu.ts | 36 +++++++++++++++++++ .../misskey-js/src/autogen/apiClientJSDoc.ts | 5 ++- packages/misskey-js/src/autogen/endpoint.ts | 4 +-- packages/misskey-js/src/autogen/entities.ts | 4 +-- packages/misskey-js/src/autogen/models.ts | 4 +-- packages/misskey-js/src/autogen/types.ts | 17 +++++---- 9 files changed, 61 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea34fa9ef7..efd98ba31a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### Client - Enhance: ハッシュタグ入力時に、本文の末尾の行に何も書かれていない場合は新たにスペースを追加しないように +- Enhance: チャンネルノートのピン留めをノートのメニューからできるように ## 2023.12.2 diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index c49dad8e79..1777e2cf54 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -351,6 +351,7 @@ export class NoteEntityService implements OnModuleInit { color: channel.color, isSensitive: channel.isSensitive, allowRenoteToExternal: channel.allowRenoteToExternal, + userId: channel.userId, } : undefined, mentions: note.mentions.length > 0 ? note.mentions : undefined, uri: note.uri ?? undefined, diff --git a/packages/backend/src/models/json-schema/note.ts b/packages/backend/src/models/json-schema/note.ts index aa749943f0..2b7722129b 100644 --- a/packages/backend/src/models/json-schema/note.ts +++ b/packages/backend/src/models/json-schema/note.ts @@ -148,6 +148,10 @@ export const packedNoteSchema = { type: 'boolean', optional: false, nullable: false, }, + userId: { + type: 'string', + optional: false, nullable: true, + }, }, }, localOnly: { diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index 7130e69279..b9224c5595 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -352,6 +352,42 @@ export function getNoteMenu(props: { ] : [] ), + ...(appearNote.channel && (appearNote.channel.userId === $i.id || $i.isModerator || $i.isAdmin) ? [ + { type: 'divider' }, + { + type: 'parent' as const, + icon: 'ti ti-device-tv', + text: i18n.ts.channel, + children: async () => { + const channelChildMenu = [] as MenuItem[]; + + const channel = await os.api('channels/show', { channelId: appearNote.channel!.id }); + + if (channel.pinnedNoteIds.includes(appearNote.id)) { + channelChildMenu.push({ + icon: 'ti ti-pinned-off', + text: i18n.ts.unpin, + action: () => os.apiWithDialog('channels/update', { + channelId: appearNote.channel!.id, + pinnedNoteIds: channel.pinnedNoteIds.filter(id => id !== appearNote.id), + }), + }); + } else { + channelChildMenu.push({ + icon: 'ti ti-pin', + text: i18n.ts.pin, + action: () => os.apiWithDialog('channels/update', { + channelId: appearNote.channel!.id, + pinnedNoteIds: [...channel.pinnedNoteIds, appearNote.id], + }), + }); + } + return channelChildMenu; + }, + }, + ] + : [] + ), ...(appearNote.userId === $i.id || $i.isModerator || $i.isAdmin ? [ { type: 'divider' }, appearNote.userId === $i.id ? { diff --git a/packages/misskey-js/src/autogen/apiClientJSDoc.ts b/packages/misskey-js/src/autogen/apiClientJSDoc.ts index 758beaf3a0..e8722cab3b 100644 --- a/packages/misskey-js/src/autogen/apiClientJSDoc.ts +++ b/packages/misskey-js/src/autogen/apiClientJSDoc.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.0 - * generatedAt: 2023-12-26T23:35:09.494Z + * version: 2023.12.2 + * generatedAt: 2024-01-02T08:53:57.449Z */ import type { SwitchCaseResponseType } from '../api.js'; @@ -33,7 +33,6 @@ declare module '../api.js' { /** * No description provided. * - * **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties. * **Credential required**: *No* */ request( diff --git a/packages/misskey-js/src/autogen/endpoint.ts b/packages/misskey-js/src/autogen/endpoint.ts index 2ed76a22f9..192a1a31e0 100644 --- a/packages/misskey-js/src/autogen/endpoint.ts +++ b/packages/misskey-js/src/autogen/endpoint.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.0 - * generatedAt: 2023-12-26T23:35:09.491Z + * version: 2023.12.2 + * generatedAt: 2024-01-02T08:53:57.445Z */ import type { diff --git a/packages/misskey-js/src/autogen/entities.ts b/packages/misskey-js/src/autogen/entities.ts index c857e8e370..fd4d7372cc 100644 --- a/packages/misskey-js/src/autogen/entities.ts +++ b/packages/misskey-js/src/autogen/entities.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.0 - * generatedAt: 2023-12-26T23:35:09.489Z + * version: 2023.12.2 + * generatedAt: 2024-01-02T08:53:57.443Z */ import { operations } from './types.js'; diff --git a/packages/misskey-js/src/autogen/models.ts b/packages/misskey-js/src/autogen/models.ts index c5b81a6b41..db0ada0f3b 100644 --- a/packages/misskey-js/src/autogen/models.ts +++ b/packages/misskey-js/src/autogen/models.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.0 - * generatedAt: 2023-12-26T23:35:09.485Z + * version: 2023.12.2 + * generatedAt: 2024-01-02T08:53:57.441Z */ import { components } from './types.js'; diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 94bb263980..37c8f58f58 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -2,8 +2,8 @@ /* eslint @typescript-eslint/no-explicit-any: 0 */ /* - * version: 2023.12.0 - * generatedAt: 2023-12-26T23:35:09.389Z + * version: 2023.12.2 + * generatedAt: 2024-01-02T08:53:56.447Z */ /** @@ -40,7 +40,6 @@ export type paths = { * admin/accounts/create * @description No description provided. * - * **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties. * **Credential required**: *No* */ post: operations['admin/accounts/create']; @@ -3788,13 +3787,14 @@ export type components = { * @example xxxxxxxxxx */ channelId?: string | null; - channel?: { + channel?: ({ id: string; name: string; color: string; isSensitive: boolean; allowRenoteToExternal: boolean; - } | null; + userId: string | null; + }) | null; localOnly?: boolean; reactionAcceptance: string | null; reactions: Record; @@ -4456,6 +4456,9 @@ export type operations = { enableActiveEmailValidation: boolean; enableVerifymailApi: boolean; verifymailAuthKey: string | null; + enableTruemailApi: boolean; + truemailInstance: string | null; + truemailAuthKey: string | null; enableChartsForRemoteUser: boolean; enableChartsForFederatedInstances: boolean; enableServerMachineStats: boolean; @@ -4620,7 +4623,6 @@ export type operations = { * admin/accounts/create * @description No description provided. * - * **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties. * **Credential required**: *No* */ 'admin/accounts/create': { @@ -8247,6 +8249,9 @@ export type operations = { enableActiveEmailValidation?: boolean; enableVerifymailApi?: boolean; verifymailAuthKey?: string | null; + enableTruemailApi?: boolean; + truemailInstance?: string | null; + truemailAuthKey?: string | null; enableChartsForRemoteUser?: boolean; enableChartsForFederatedInstances?: boolean; enableServerMachineStats?: boolean; From 30311aca18e50a179021b45c3beaf0ee29d3a423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Wed, 3 Jan 2024 13:41:28 +0900 Subject: [PATCH 3/8] =?UTF-8?q?fix(misskey-js):=20/signup=E3=81=A8/signin?= =?UTF-8?q?=E3=81=AE=E5=AE=9A=E7=BE=A9=E3=82=92=E4=BD=9C=E6=88=90=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=83=95=E3=83=AD=E3=83=B3=E3=83=88=E3=81=AE=E5=9E=8B?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92=E6=8A=91=E5=88=B6=E3=81=99?= =?UTF-8?q?=E3=82=8B=20(#12846)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(misskey-js): /signupと/signinの定義を復活してフロントの型エラーを抑制する * fix ci * fix ci * fix * fix --------- Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com> --- packages/backend/test/e2e/2fa.ts | 2 +- packages/backend/test/e2e/antennas.ts | 2 +- packages/backend/test/e2e/api-visibility.ts | 10 ++-- packages/backend/test/e2e/api.ts | 6 +-- packages/backend/test/e2e/block.ts | 6 +-- packages/backend/test/e2e/endpoints.ts | 8 +-- packages/backend/test/e2e/fetch-resource.ts | 4 +- packages/backend/test/e2e/ff-visibility.ts | 4 +- packages/backend/test/e2e/move.ts | 12 ++--- packages/backend/test/e2e/mute.ts | 6 +-- packages/backend/test/e2e/note.ts | 4 +- packages/backend/test/e2e/oauth.ts | 10 ++-- packages/backend/test/e2e/renote-mute.ts | 6 +-- packages/backend/test/e2e/streaming.ts | 14 ++--- packages/backend/test/e2e/thread-mute.ts | 6 +-- packages/backend/test/e2e/user-notes.ts | 2 +- packages/misskey-js/etc/misskey-js.api.md | 59 +++++++++++++++++++++ packages/misskey-js/src/api.types.ts | 25 ++++++++- packages/misskey-js/src/entities.ts | 37 ++++++++++++- 19 files changed, 170 insertions(+), 53 deletions(-) diff --git a/packages/backend/test/e2e/2fa.ts b/packages/backend/test/e2e/2fa.ts index ed967d2620..dfed8b2fce 100644 --- a/packages/backend/test/e2e/2fa.ts +++ b/packages/backend/test/e2e/2fa.ts @@ -24,7 +24,7 @@ import type * as misskey from 'misskey-js'; describe('2要素認証', () => { let app: INestApplicationContext; - let alice: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; const config = loadConfig(); const password = 'test'; diff --git a/packages/backend/test/e2e/antennas.ts b/packages/backend/test/e2e/antennas.ts index c0317f1435..9bac5122d4 100644 --- a/packages/backend/test/e2e/antennas.ts +++ b/packages/backend/test/e2e/antennas.ts @@ -37,7 +37,7 @@ describe('アンテナ', () => { // - srcのenumにgroupが残っている // - userGroupIdが残っている, isActiveがない type Antenna = misskey.entities.Antenna | Packed<'Antenna'>; - type User = misskey.entities.MeSignup; + type User = misskey.entities.SignupResponse; type Note = misskey.entities.Note; // アンテナを作成できる最小のパラメタ diff --git a/packages/backend/test/e2e/api-visibility.ts b/packages/backend/test/e2e/api-visibility.ts index 33c8d03fdb..afe4f9c05a 100644 --- a/packages/backend/test/e2e/api-visibility.ts +++ b/packages/backend/test/e2e/api-visibility.ts @@ -24,15 +24,15 @@ describe('API visibility', () => { describe('Note visibility', () => { //#region vars /** ヒロイン */ - let alice: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; /** フォロワー */ - let follower: misskey.entities.MeSignup; + let follower: misskey.entities.SignupResponse; /** 非フォロワー */ - let other: misskey.entities.MeSignup; + let other: misskey.entities.SignupResponse; /** 非フォロワーでもリプライやメンションをされた人 */ - let target: misskey.entities.MeSignup; + let target: misskey.entities.SignupResponse; /** specified mentionでmentionを飛ばされる人 */ - let target2: misskey.entities.MeSignup; + let target2: misskey.entities.SignupResponse; /** public-post */ let pub: any; diff --git a/packages/backend/test/e2e/api.ts b/packages/backend/test/e2e/api.ts index cf24228b83..ad351eebbb 100644 --- a/packages/backend/test/e2e/api.ts +++ b/packages/backend/test/e2e/api.ts @@ -13,9 +13,9 @@ import type * as misskey from 'misskey-js'; describe('API', () => { let app: INestApplicationContext; - let alice: misskey.entities.MeSignup; - let bob: misskey.entities.MeSignup; - let carol: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; + let bob: misskey.entities.SignupResponse; + let carol: misskey.entities.SignupResponse; beforeAll(async () => { app = await startServer(); diff --git a/packages/backend/test/e2e/block.ts b/packages/backend/test/e2e/block.ts index 4445d9036c..25ff9f11ac 100644 --- a/packages/backend/test/e2e/block.ts +++ b/packages/backend/test/e2e/block.ts @@ -14,9 +14,9 @@ describe('Block', () => { let app: INestApplicationContext; // alice blocks bob - let alice: misskey.entities.MeSignup; - let bob: misskey.entities.MeSignup; - let carol: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; + let bob: misskey.entities.SignupResponse; + let carol: misskey.entities.SignupResponse; beforeAll(async () => { app = await startServer(); diff --git a/packages/backend/test/e2e/endpoints.ts b/packages/backend/test/e2e/endpoints.ts index 2ef3434bca..bfd0b0272d 100644 --- a/packages/backend/test/e2e/endpoints.ts +++ b/packages/backend/test/e2e/endpoints.ts @@ -17,10 +17,10 @@ import type * as misskey from 'misskey-js'; describe('Endpoints', () => { let app: INestApplicationContext; - let alice: misskey.entities.MeSignup; - let bob: misskey.entities.MeSignup; - let carol: misskey.entities.MeSignup; - let dave: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; + let bob: misskey.entities.SignupResponse; + let carol: misskey.entities.SignupResponse; + let dave: misskey.entities.SignupResponse; beforeAll(async () => { app = await startServer(); diff --git a/packages/backend/test/e2e/fetch-resource.ts b/packages/backend/test/e2e/fetch-resource.ts index 251d662760..28affe7768 100644 --- a/packages/backend/test/e2e/fetch-resource.ts +++ b/packages/backend/test/e2e/fetch-resource.ts @@ -25,7 +25,7 @@ const JSON_UTF8 = 'application/json; charset=utf-8'; describe('Webリソース', () => { let app: INestApplicationContext; - let alice: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; let aliceUploadedFile: any; let alicesPost: any; let alicePage: any; @@ -34,7 +34,7 @@ describe('Webリソース', () => { let aliceGalleryPost: any; let aliceChannel: any; - let bob: misskey.entities.MeSignup; + let bob: misskey.entities.SignupResponse; type Request = { path: string, diff --git a/packages/backend/test/e2e/ff-visibility.ts b/packages/backend/test/e2e/ff-visibility.ts index 1fbd45c741..4d323e14e7 100644 --- a/packages/backend/test/e2e/ff-visibility.ts +++ b/packages/backend/test/e2e/ff-visibility.ts @@ -13,8 +13,8 @@ import type * as misskey from 'misskey-js'; describe('FF visibility', () => { let app: INestApplicationContext; - let alice: misskey.entities.MeSignup; - let bob: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; + let bob: misskey.entities.SignupResponse; beforeAll(async () => { app = await startServer(); diff --git a/packages/backend/test/e2e/move.ts b/packages/backend/test/e2e/move.ts index b009ef124a..f7da66a27c 100644 --- a/packages/backend/test/e2e/move.ts +++ b/packages/backend/test/e2e/move.ts @@ -20,12 +20,12 @@ describe('Account Move', () => { let url: URL; let root: any; - let alice: misskey.entities.MeSignup; - let bob: misskey.entities.MeSignup; - let carol: misskey.entities.MeSignup; - let dave: misskey.entities.MeSignup; - let eve: misskey.entities.MeSignup; - let frank: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; + let bob: misskey.entities.SignupResponse; + let carol: misskey.entities.SignupResponse; + let dave: misskey.entities.SignupResponse; + let eve: misskey.entities.SignupResponse; + let frank: misskey.entities.SignupResponse; let Users: UsersRepository; diff --git a/packages/backend/test/e2e/mute.ts b/packages/backend/test/e2e/mute.ts index a4b57a1eba..3b5542dfe0 100644 --- a/packages/backend/test/e2e/mute.ts +++ b/packages/backend/test/e2e/mute.ts @@ -14,9 +14,9 @@ describe('Mute', () => { let app: INestApplicationContext; // alice mutes carol - let alice: misskey.entities.MeSignup; - let bob: misskey.entities.MeSignup; - let carol: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; + let bob: misskey.entities.SignupResponse; + let carol: misskey.entities.SignupResponse; beforeAll(async () => { app = await startServer(); diff --git a/packages/backend/test/e2e/note.ts b/packages/backend/test/e2e/note.ts index 961df99cc2..8d33c63485 100644 --- a/packages/backend/test/e2e/note.ts +++ b/packages/backend/test/e2e/note.ts @@ -16,8 +16,8 @@ describe('Note', () => { let app: INestApplicationContext; let Notes: any; - let alice: misskey.entities.MeSignup; - let bob: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; + let bob: misskey.entities.SignupResponse; beforeAll(async () => { app = await startServer(); diff --git a/packages/backend/test/e2e/oauth.ts b/packages/backend/test/e2e/oauth.ts index 3a5e4ebdae..3ca1f8b542 100644 --- a/packages/backend/test/e2e/oauth.ts +++ b/packages/backend/test/e2e/oauth.ts @@ -75,7 +75,7 @@ function getMeta(html: string): { transactionId: string | undefined, clientName: }; } -function fetchDecision(transactionId: string, user: misskey.entities.MeSignup, { cancel }: { cancel?: boolean } = {}): Promise { +function fetchDecision(transactionId: string, user: misskey.entities.SignupResponse, { cancel }: { cancel?: boolean } = {}): Promise { return fetch(new URL('/oauth/decision', host), { method: 'post', body: new URLSearchParams({ @@ -90,14 +90,14 @@ function fetchDecision(transactionId: string, user: misskey.entities.MeSignup, { }); } -async function fetchDecisionFromResponse(response: Response, user: misskey.entities.MeSignup, { cancel }: { cancel?: boolean } = {}): Promise { +async function fetchDecisionFromResponse(response: Response, user: misskey.entities.SignupResponse, { cancel }: { cancel?: boolean } = {}): Promise { const { transactionId } = getMeta(await response.text()); assert.ok(transactionId); return await fetchDecision(transactionId, user, { cancel }); } -async function fetchAuthorizationCode(user: misskey.entities.MeSignup, scope: string, code_challenge: string): Promise<{ client: AuthorizationCode, code: string }> { +async function fetchAuthorizationCode(user: misskey.entities.SignupResponse, scope: string, code_challenge: string): Promise<{ client: AuthorizationCode, code: string }> { const client = new AuthorizationCode(clientConfig); const response = await fetch(client.authorizeURL({ @@ -150,8 +150,8 @@ describe('OAuth', () => { let app: INestApplicationContext; let fastify: FastifyInstance; - let alice: misskey.entities.MeSignup; - let bob: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; + let bob: misskey.entities.SignupResponse; let sender: (reply: FastifyReply) => void; diff --git a/packages/backend/test/e2e/renote-mute.ts b/packages/backend/test/e2e/renote-mute.ts index 7d57ba17b6..fededdff32 100644 --- a/packages/backend/test/e2e/renote-mute.ts +++ b/packages/backend/test/e2e/renote-mute.ts @@ -14,9 +14,9 @@ describe('Renote Mute', () => { let app: INestApplicationContext; // alice mutes carol - let alice: misskey.entities.MeSignup; - let bob: misskey.entities.MeSignup; - let carol: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; + let bob: misskey.entities.SignupResponse; + let carol: misskey.entities.SignupResponse; beforeAll(async () => { app = await startServer(); diff --git a/packages/backend/test/e2e/streaming.ts b/packages/backend/test/e2e/streaming.ts index 288c54bdbc..a447ba94ae 100644 --- a/packages/backend/test/e2e/streaming.ts +++ b/packages/backend/test/e2e/streaming.ts @@ -32,15 +32,15 @@ describe('Streaming', () => { describe('Streaming', () => { // Local users - let ayano: misskey.entities.MeSignup; - let kyoko: misskey.entities.MeSignup; - let chitose: misskey.entities.MeSignup; - let kanako: misskey.entities.MeSignup; + let ayano: misskey.entities.SignupResponse; + let kyoko: misskey.entities.SignupResponse; + let chitose: misskey.entities.SignupResponse; + let kanako: misskey.entities.SignupResponse; // Remote users - let akari: misskey.entities.MeSignup; - let chinatsu: misskey.entities.MeSignup; - let takumi: misskey.entities.MeSignup; + let akari: misskey.entities.SignupResponse; + let chinatsu: misskey.entities.SignupResponse; + let takumi: misskey.entities.SignupResponse; let kyokoNote: any; let kanakoNote: any; diff --git a/packages/backend/test/e2e/thread-mute.ts b/packages/backend/test/e2e/thread-mute.ts index 0e487976dc..5c68e2b150 100644 --- a/packages/backend/test/e2e/thread-mute.ts +++ b/packages/backend/test/e2e/thread-mute.ts @@ -13,9 +13,9 @@ import type * as misskey from 'misskey-js'; describe('Note thread mute', () => { let app: INestApplicationContext; - let alice: misskey.entities.MeSignup; - let bob: misskey.entities.MeSignup; - let carol: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; + let bob: misskey.entities.SignupResponse; + let carol: misskey.entities.SignupResponse; beforeAll(async () => { app = await startServer(); diff --git a/packages/backend/test/e2e/user-notes.ts b/packages/backend/test/e2e/user-notes.ts index b5f00a6327..4f2e7c4cf3 100644 --- a/packages/backend/test/e2e/user-notes.ts +++ b/packages/backend/test/e2e/user-notes.ts @@ -13,7 +13,7 @@ import type * as misskey from 'misskey-js'; describe('users/notes', () => { let app: INestApplicationContext; - let alice: misskey.entities.MeSignup; + let alice: misskey.entities.SignupResponse; let jpgNote: any; let pngNote: any; let jpgPngNote: any; diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index d4c43f207c..ddd69ce248 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -1034,6 +1034,18 @@ export type Endpoints = Overwrite; // @public (undocumented) @@ -1053,6 +1065,12 @@ declare namespace entities { EmojiUpdated, EmojiDeleted, AnnouncementCreated, + SignupRequest, + SignupResponse, + SignupPendingRequest, + SignupPendingResponse, + SigninRequest, + SigninResponse, EmptyRequest, EmptyResponse, AdminMetaResponse, @@ -2615,6 +2633,47 @@ type ServerStatsLog = string[]; // @public (undocumented) type Signin = components['schemas']['Signin']; +// @public (undocumented) +type SigninRequest = { + username: string; + password: string; + token?: string; +}; + +// @public (undocumented) +type SigninResponse = { + id: User['id']; + i: string; +}; + +// @public (undocumented) +type SignupPendingRequest = { + code: string; +}; + +// @public (undocumented) +type SignupPendingResponse = { + id: User['id']; + i: string; +}; + +// @public (undocumented) +type SignupRequest = { + username: string; + password: string; + host?: string; + invitationCode?: string; + emailAddress?: string; + 'hcaptcha-response'?: string | null; + 'g-recaptcha-response'?: string | null; + 'turnstile-response'?: string | null; +}; + +// @public (undocumented) +type SignupResponse = MeDetailed & { + token: string; +}; + // @public (undocumented) type StatsResponse = operations['stats']['responses']['200']['content']['application/json']; diff --git a/packages/misskey-js/src/api.types.ts b/packages/misskey-js/src/api.types.ts index d97646b7cc..75ab7d91b1 100644 --- a/packages/misskey-js/src/api.types.ts +++ b/packages/misskey-js/src/api.types.ts @@ -1,6 +1,14 @@ import { Endpoints as Gen } from './autogen/endpoint'; import { UserDetailed } from './autogen/models'; import { UsersShowRequest } from './autogen/entities'; +import { + SigninRequest, + SigninResponse, + SignupPendingRequest, + SignupPendingResponse, + SignupRequest, + SignupResponse, +} from './entities'; type Overwrite = Omit< T, @@ -55,6 +63,21 @@ export type Endpoints = Overwrite< $default: UserDetailed; }; }; - } + }, + // api.jsonには載せないものなのでここで定義 + 'signup': { + req: SignupRequest; + res: SignupResponse; + }, + // api.jsonには載せないものなのでここで定義 + 'signup-pending': { + req: SignupPendingRequest; + res: SignupPendingResponse; + }, + // api.jsonには載せないものなのでここで定義 + 'signin': { + req: SigninRequest; + res: SigninResponse; + }, } > diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 99f433cc02..6314c88e0b 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -1,5 +1,5 @@ import { ModerationLogPayloads } from './consts.js'; -import { Announcement, EmojiDetailed, Page, User, UserDetailed } from './autogen/models'; +import { Announcement, EmojiDetailed, MeDetailed, MeDetailedOnly, Page, User, UserDetailed } from './autogen/models'; export * from './autogen/entities'; export * from './autogen/models'; @@ -183,3 +183,38 @@ export type EmojiDeleted = { export type AnnouncementCreated = { announcement: Announcement; }; + +export type SignupRequest = { + username: string; + password: string; + host?: string; + invitationCode?: string; + emailAddress?: string; + 'hcaptcha-response'?: string | null; + 'g-recaptcha-response'?: string | null; + 'turnstile-response'?: string | null; +} + +export type SignupResponse = MeDetailed & { + token: string; +} + +export type SignupPendingRequest = { + code: string; +}; + +export type SignupPendingResponse = { + id: User['id'], + i: string, +}; + +export type SigninRequest = { + username: string; + password: string; + token?: string; +}; + +export type SigninResponse = { + id: User['id'], + i: string, +}; From 30c3f6a22240a0329ab6afaccdd953c934fd2036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Wed, 3 Jan 2024 13:42:09 +0900 Subject: [PATCH 4/8] =?UTF-8?q?(fix)=20MkFormDialog=E3=81=AB=E3=81=9B?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=84=E3=81=A7=E3=81=8D=E3=82=8B=E9=A0=85?= =?UTF-8?q?=E7=9B=AE=E3=81=8C=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=81=AF?= =?UTF-8?q?=E3=81=9D=E3=81=AE=E6=97=A8=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20(#12837)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/components/MkFormDialog.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/components/MkFormDialog.vue b/packages/frontend/src/components/MkFormDialog.vue index 6f882cfab7..2095a1dcea 100644 --- a/packages/frontend/src/components/MkFormDialog.vue +++ b/packages/frontend/src/components/MkFormDialog.vue @@ -20,7 +20,7 @@ SPDX-License-Identifier: AGPL-3.0-only -
+
+
+ +
{{ i18n.ts.nothing }}
+
@@ -70,6 +74,7 @@ import MkButton from './MkButton.vue'; import MkRadios from './MkRadios.vue'; import MkModalWindow from '@/components/MkModalWindow.vue'; import { i18n } from '@/i18n.js'; +import { infoImageUrl } from '@/instance.js'; const props = defineProps<{ title: string; From b46f431a2e13aad82b06249d08730e50192a767e Mon Sep 17 00:00:00 2001 From: Camilla Ett Date: Wed, 3 Jan 2024 16:41:38 +0900 Subject: [PATCH 5/8] =?UTF-8?q?fix(frontend):=20=E3=83=A2=E3=83=87?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=82=BF=E3=83=BC=E3=81=8C=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E3=83=BC=E3=81=AE=E3=82=A2=E3=83=90=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E3=83=90=E3=83=8A=E3=83=BC=E3=82=92=E6=9C=AA=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E7=8A=B6=E6=85=8B=E3=81=AB=E5=87=BA=E6=9D=A5=E3=82=8B=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=20(#12889)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: syuilo --- CHANGELOG.md | 3 ++- packages/frontend/src/pages/admin-user.vue | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efd98ba31a..54fbb04120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,8 @@ ### Client - Enhance: ハッシュタグ入力時に、本文の末尾の行に何も書かれていない場合は新たにスペースを追加しないように -- Enhance: チャンネルノートのピン留めをノートのメニューからできるように +- Fix: v2023.12.0で追加された「モデレーターがユーザーのアイコンもしくはバナー画像を未設定状態にできる機能」が管理画面上で正しく表示されていない問題を修正 +- Enhance: チャンネルノートのピン留めをノートのメニューからできるよ ## 2023.12.2 diff --git a/packages/frontend/src/pages/admin-user.vue b/packages/frontend/src/pages/admin-user.vue index d69d627ce8..ce820e10e8 100644 --- a/packages/frontend/src/pages/admin-user.vue +++ b/packages/frontend/src/pages/admin-user.vue @@ -223,7 +223,7 @@ import { url } from '@/config.js'; import { acct } from '@/filters/user.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; -import { iAmAdmin, $i } from '@/account.js'; +import { iAmAdmin, $i, iAmModerator } from '@/account.js'; import MkRolePreview from '@/components/MkRolePreview.vue'; import MkPagination from '@/components/MkPagination.vue'; From da154c8209bdacfc1ad9f708a638b8ebf027c66b Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 4 Jan 2024 08:44:38 +0900 Subject: [PATCH 6/8] Update ROADMAP.md --- ROADMAP.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ROADMAP.md b/ROADMAP.md index 3077c41e73..509ecb9fe7 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -6,6 +6,7 @@ Also, the later tasks are more indefinite and are subject to change as developme This is the phase we are at now. We need to make a high-maintenance environment that can withstand future development. - ~~Make the number of type errors zero (backend)~~ → Done ✔️ +- Make the number of type errors zero (frontend) - Improve CI - ~~Fix tests~~ → Done ✔️ - Fix random test failures - https://github.com/misskey-dev/misskey/issues/7985 and https://github.com/misskey-dev/misskey/issues/7986 From f8d5a46dbf8ad89e576dafa3ae776334ccbbf751 Mon Sep 17 00:00:00 2001 From: FineArchs <133759614+FineArchs@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:26:57 +0900 Subject: [PATCH 7/8] =?UTF-8?q?Fix:=20AiScript=E3=81=AEreadline=E3=81=AE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=82=92Play=E4=BB=A5=E5=A4=96=E3=81=AB?= =?UTF-8?q?=E3=82=82=E9=81=A9=E7=94=A8=20(#12841)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add AiScriptReadline() in api.ts * apply AiScriptReadline on flash.vue * AiScriptReadline → aiScriptReadline * Update flash.vue * Update scratchpad.vue * Update WidgetAiscript.vue * Update WidgetAiscriptApp.vue * Update WidgetButton.vue * Update plugin.ts --- packages/frontend/src/pages/flash/flash.vue | 12 ++---------- packages/frontend/src/pages/scratchpad.vue | 16 ++-------------- packages/frontend/src/plugin.ts | 16 ++-------------- packages/frontend/src/scripts/aiscript/api.ts | 10 ++++++++++ packages/frontend/src/widgets/WidgetAiscript.vue | 16 ++-------------- .../frontend/src/widgets/WidgetAiscriptApp.vue | 16 ++-------------- packages/frontend/src/widgets/WidgetButton.vue | 16 ++-------------- 7 files changed, 22 insertions(+), 80 deletions(-) diff --git a/packages/frontend/src/pages/flash/flash.vue b/packages/frontend/src/pages/flash/flash.vue index 6df9bbc241..13e8184c19 100644 --- a/packages/frontend/src/pages/flash/flash.vue +++ b/packages/frontend/src/pages/flash/flash.vue @@ -67,7 +67,7 @@ import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import MkAsUi from '@/components/MkAsUi.vue'; import { AsUiComponent, AsUiRoot, registerAsUiLib } from '@/scripts/aiscript/ui.js'; -import { createAiScriptEnv } from '@/scripts/aiscript/api.js'; +import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js'; import MkFolder from '@/components/MkFolder.vue'; import MkCode from '@/components/MkCode.vue'; import { defaultStore } from '@/store.js'; @@ -162,15 +162,7 @@ async function run() { THIS_ID: values.STR(flash.value.id), THIS_URL: values.STR(`${url}/play/${flash.value.id}`), }, { - in: (q) => { - return new Promise(ok => { - os.inputText({ - title: q, - }).then(({ result: a }) => { - ok(a ?? ''); - }); - }); - }, + in: aiScriptReadline, out: (value) => { // nop }, diff --git a/packages/frontend/src/pages/scratchpad.vue b/packages/frontend/src/pages/scratchpad.vue index 1453bc1658..31a3b4e91b 100644 --- a/packages/frontend/src/pages/scratchpad.vue +++ b/packages/frontend/src/pages/scratchpad.vue @@ -44,7 +44,7 @@ import { Interpreter, Parser, utils } from '@syuilo/aiscript'; import MkContainer from '@/components/MkContainer.vue'; import MkButton from '@/components/MkButton.vue'; import MkCodeEditor from '@/components/MkCodeEditor.vue'; -import { createAiScriptEnv } from '@/scripts/aiscript/api.js'; +import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js'; import * as os from '@/os.js'; import { $i } from '@/account.js'; import { i18n } from '@/i18n.js'; @@ -86,19 +86,7 @@ async function run() { root.value = _root.value; }), }), { - in: (q) => { - return new Promise(ok => { - os.inputText({ - title: q, - }).then(({ canceled, result: a }) => { - if (canceled) { - ok(''); - } else { - ok(a); - } - }); - }); - }, + in: aiScriptReadline, out: (value) => { if (value.type === 'str' && value.value.toLowerCase().replace(',', '').includes('hello world')) { claimAchievement('outputHelloWorldOnScratchpad'); diff --git a/packages/frontend/src/plugin.ts b/packages/frontend/src/plugin.ts index 5e49af4858..acc3e836fb 100644 --- a/packages/frontend/src/plugin.ts +++ b/packages/frontend/src/plugin.ts @@ -4,7 +4,7 @@ */ import { Interpreter, Parser, utils, values } from '@syuilo/aiscript'; -import { createAiScriptEnv } from '@/scripts/aiscript/api.js'; +import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js'; import { inputText } from '@/os.js'; import { Plugin, noteActions, notePostInterruptors, noteViewInterruptors, postFormActions, userActions, pageViewInterruptors } from '@/store.js'; @@ -19,19 +19,7 @@ export async function install(plugin: Plugin): Promise { plugin: plugin, storageKey: 'plugins:' + plugin.id, }), { - in: (q): Promise => { - return new Promise(ok => { - inputText({ - title: q, - }).then(({ canceled, result: a }) => { - if (canceled) { - ok(''); - } else { - ok(a); - } - }); - }); - }, + in: aiScriptReadline, out: (value): void => { console.log(value); }, diff --git a/packages/frontend/src/scripts/aiscript/api.ts b/packages/frontend/src/scripts/aiscript/api.ts index 038ae23109..f6f63bb59e 100644 --- a/packages/frontend/src/scripts/aiscript/api.ts +++ b/packages/frontend/src/scripts/aiscript/api.ts @@ -11,6 +11,16 @@ import { customEmojis } from '@/custom-emojis.js'; import { url, lang } from '@/config.js'; import { nyaize } from '@/scripts/nyaize.js'; +export function aiScriptReadline(q: string): Promise { + return new Promise(ok => { + os.inputText({ + title: q, + }).then(({ result: a }) => { + ok(a ?? ''); + }); + }); +} + export function createAiScriptEnv(opts) { return { USER_ID: $i ? values.STR($i.id) : values.NULL, diff --git a/packages/frontend/src/widgets/WidgetAiscript.vue b/packages/frontend/src/widgets/WidgetAiscript.vue index 5968b54626..a4c1025265 100644 --- a/packages/frontend/src/widgets/WidgetAiscript.vue +++ b/packages/frontend/src/widgets/WidgetAiscript.vue @@ -25,7 +25,7 @@ import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, Wid import { GetFormResultType } from '@/scripts/form.js'; import * as os from '@/os.js'; import MkContainer from '@/components/MkContainer.vue'; -import { createAiScriptEnv } from '@/scripts/aiscript/api.js'; +import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js'; import { $i } from '@/account.js'; import { i18n } from '@/i18n.js'; @@ -69,19 +69,7 @@ const run = async () => { storageKey: 'widget', token: $i?.token, }), { - in: (q) => { - return new Promise(ok => { - os.inputText({ - title: q, - }).then(({ canceled, result: a }) => { - if (canceled) { - ok(''); - } else { - ok(a); - } - }); - }); - }, + in: aiScriptReadline, out: (value) => { logs.value.push({ id: Math.random().toString(), diff --git a/packages/frontend/src/widgets/WidgetAiscriptApp.vue b/packages/frontend/src/widgets/WidgetAiscriptApp.vue index 10248a840a..e236253797 100644 --- a/packages/frontend/src/widgets/WidgetAiscriptApp.vue +++ b/packages/frontend/src/widgets/WidgetAiscriptApp.vue @@ -18,7 +18,7 @@ import { Interpreter, Parser } from '@syuilo/aiscript'; import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js'; import { GetFormResultType } from '@/scripts/form.js'; import * as os from '@/os.js'; -import { createAiScriptEnv } from '@/scripts/aiscript/api.js'; +import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js'; import { $i } from '@/account.js'; import MkAsUi from '@/components/MkAsUi.vue'; import MkContainer from '@/components/MkContainer.vue'; @@ -64,19 +64,7 @@ async function run() { root.value = _root.value; }), }, { - in: (q) => { - return new Promise(ok => { - os.inputText({ - title: q, - }).then(({ canceled, result: a }) => { - if (canceled) { - ok(''); - } else { - ok(a); - } - }); - }); - }, + in: aiScriptReadline, out: (value) => { // nop }, diff --git a/packages/frontend/src/widgets/WidgetButton.vue b/packages/frontend/src/widgets/WidgetButton.vue index 11082c1e3f..80fd000d09 100644 --- a/packages/frontend/src/widgets/WidgetButton.vue +++ b/packages/frontend/src/widgets/WidgetButton.vue @@ -16,7 +16,7 @@ import { Interpreter, Parser } from '@syuilo/aiscript'; import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js'; import { GetFormResultType } from '@/scripts/form.js'; import * as os from '@/os.js'; -import { createAiScriptEnv } from '@/scripts/aiscript/api.js'; +import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js'; import { $i } from '@/account.js'; import MkButton from '@/components/MkButton.vue'; @@ -56,19 +56,7 @@ const run = async () => { storageKey: 'widget', token: $i?.token, }), { - in: (q) => { - return new Promise(ok => { - os.inputText({ - title: q, - }).then(({ canceled, result: a }) => { - if (canceled) { - ok(''); - } else { - ok(a); - } - }); - }); - }, + in: aiScriptReadline, out: (value) => { // nop }, From 6598d320d69bec2336b4b33501c47ac69e0eea95 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:04:00 +0900 Subject: [PATCH 8/8] enhance: Use SI prefixes for job queue widget, extends bytes (#12896) * Use SI prefixes for job queue widget * a * bytes * lint --- packages/frontend/src/filters/bytes.ts | 4 ++-- packages/frontend/src/filters/kmg.ts | 9 +++++++++ .../frontend/src/widgets/WidgetJobQueue.vue | 18 +++++++++--------- 3 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 packages/frontend/src/filters/kmg.ts diff --git a/packages/frontend/src/filters/bytes.ts b/packages/frontend/src/filters/bytes.ts index d40b020a9e..2497ddb775 100644 --- a/packages/frontend/src/filters/bytes.ts +++ b/packages/frontend/src/filters/bytes.ts @@ -5,10 +5,10 @@ export default (v, digits = 0) => { if (v == null) return '?'; - const sizes = ['B', 'KB', 'MB', 'GB', 'TB']; + const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB', 'RB', 'QB']; if (v === 0) return '0'; const isMinus = v < 0; if (isMinus) v = -v; const i = Math.floor(Math.log(v) / Math.log(1024)); - return (isMinus ? '-' : '') + (v / Math.pow(1024, i)).toFixed(digits).replace(/\.0+$/, '') + sizes[i]; + return (isMinus ? '-' : '') + (v / Math.pow(1024, i)).toFixed(digits).replace(/(\.[1-9]*)0+$/, '$1').replace(/\.$/, '') + (sizes[i] ?? `e+${ i * 3 }B`); }; diff --git a/packages/frontend/src/filters/kmg.ts b/packages/frontend/src/filters/kmg.ts new file mode 100644 index 0000000000..4dcb5c5800 --- /dev/null +++ b/packages/frontend/src/filters/kmg.ts @@ -0,0 +1,9 @@ +export default (v, fractionDigits = 0) => { + if (v == null) return 'N/A'; + if (v === 0) return '0'; + const sizes = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 'R', 'Q']; + const isMinus = v < 0; + if (isMinus) v = -v; + const i = Math.floor(Math.log(v) / Math.log(1000)); + return (isMinus ? '-' : '') + (v / Math.pow(1000, i)).toFixed(fractionDigits).replace(/(\.[1-9]*)0+$/, '$1').replace(/\.$/, '') + (sizes[i] ?? `e+${ i * 3 }`); +}; diff --git a/packages/frontend/src/widgets/WidgetJobQueue.vue b/packages/frontend/src/widgets/WidgetJobQueue.vue index 10bc257e12..91983d8474 100644 --- a/packages/frontend/src/widgets/WidgetJobQueue.vue +++ b/packages/frontend/src/widgets/WidgetJobQueue.vue @@ -10,19 +10,19 @@ SPDX-License-Identifier: AGPL-3.0-only
Process
-
{{ number(current.inbox.activeSincePrevTick) }}
+
{{ kmg(current.inbox.activeSincePrevTick, 2) }}
Active
-
{{ number(current.inbox.active) }}
+
{{ kmg(current.inbox.active, 2) }}
Delayed
-
{{ number(current.inbox.delayed) }}
+
{{ kmg(current.inbox.delayed, 2) }}
Waiting
-
{{ number(current.inbox.waiting) }}
+
{{ kmg(current.inbox.waiting, 2) }}
@@ -31,19 +31,19 @@ SPDX-License-Identifier: AGPL-3.0-only
Process
-
{{ number(current.deliver.activeSincePrevTick) }}
+
{{ kmg(current.deliver.activeSincePrevTick, 2) }}
Active
-
{{ number(current.deliver.active) }}
+
{{ kmg(current.deliver.active, 2) }}
Delayed
-
{{ number(current.deliver.delayed) }}
+
{{ kmg(current.deliver.delayed, 2) }}
Waiting
-
{{ number(current.deliver.waiting) }}
+
{{ kmg(current.deliver.waiting, 2) }}
@@ -55,7 +55,7 @@ import { onUnmounted, reactive, ref } from 'vue'; import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js'; import { GetFormResultType } from '@/scripts/form.js'; import { useStream } from '@/stream.js'; -import number from '@/filters/number.js'; +import kmg from '@/filters/kmg.js'; import * as sound from '@/scripts/sound.js'; import { deepClone } from '@/scripts/clone.js'; import { defaultStore } from '@/store.js';