From c239c425b4d503912159be15a3d18d03e2976b68 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=A6=E3=81=83?= =?UTF-8?q?=E3=83=BC=E3=80=82?= <56515516+mattyatea@users.noreply.github.com> Date: Sun, 18 Aug 2024 04:17:27 +0900 Subject: [PATCH 1/8] =?UTF-8?q?enhance(profile):=20=E7=9B=B8=E4=BA=92?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=AF=E3=81=AE=E6=A9=9F=E8=83=BD=E6=94=B9?= =?UTF-8?q?=E5=96=84=20(MisskeyIO#703)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/index.d.ts | 4 +++ locales/ja-JP.yml | 1 + .../endpoints/admin/unset-user-mutual-link.ts | 8 +++-- .../frontend/src/components/MkMediaImage.vue | 15 +++++++++ packages/frontend/src/pages/admin-user.vue | 31 +++++++++++++++++-- .../frontend/src/pages/settings/profile.vue | 6 ++-- packages/frontend/src/pages/user/home.vue | 1 + packages/misskey-js/src/autogen/types.ts | 2 ++ 8 files changed, 61 insertions(+), 7 deletions(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index 1efcd8d71..c53f67dd2 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -5095,6 +5095,10 @@ export interface Locale extends ILocale { * 相互リンク */ "mutualLink": string; + /** + * このファイルをドライブに保存する + */ + "saveThisFile": string; "_bubbleGame": { /** * 遊び方 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 727d687a3..7ad273c3b 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1269,6 +1269,7 @@ blockThisUser: "このユーザーをブロックする" muteThisUser: "このユーザーをミュートする" here: "こちら" mutualLink: "相互リンク" +saveThisFile: "このファイルをドライブに保存する" _bubbleGame: howToPlay: "遊び方" diff --git a/packages/backend/src/server/api/endpoints/admin/unset-user-mutual-link.ts b/packages/backend/src/server/api/endpoints/admin/unset-user-mutual-link.ts index 735711c0e..ba2674656 100644 --- a/packages/backend/src/server/api/endpoints/admin/unset-user-mutual-link.ts +++ b/packages/backend/src/server/api/endpoints/admin/unset-user-mutual-link.ts @@ -19,8 +19,9 @@ export const paramDef = { type: 'object', properties: { userId: { type: 'string', format: 'misskey:id' }, + itemId: { type: 'string', format: 'misskey:id' }, }, - required: ['userId'], + required: ['userId', 'itemId'], } as const; // eslint-disable-next-line import/no-default-export @@ -43,7 +44,10 @@ export default class extends Endpoint { } await this.userProfilesRepository.update(user.id, { - mutualLinkSections: [], + mutualLinkSections: userProfile.mutualLinkSections.map(section => ({ + ...section, + mutualLinks: section.mutualLinks.filter(item => item.id !== ps.itemId), + })), }); this.moderationLogService.log(me, 'unsetUserMutualLink', { diff --git a/packages/frontend/src/components/MkMediaImage.vue b/packages/frontend/src/components/MkMediaImage.vue index 72ee04b5a..94b7c7459 100644 --- a/packages/frontend/src/components/MkMediaImage.vue +++ b/packages/frontend/src/components/MkMediaImage.vue @@ -62,6 +62,7 @@ import { i18n } from '@/i18n.js'; import * as os from '@/os.js'; import { pleaseLogin } from '@/scripts/please-login.js'; import { $i, iAmModerator } from '@/account.js'; +import { misskeyApi } from '@/scripts/misskey-api.js'; const props = withDefaults(defineProps<{ image: Misskey.entities.DriveFile; @@ -92,6 +93,20 @@ function showMenu(ev: MouseEvent) { action: () => { hide.value = true; }, + }, { + text: i18n.ts.saveThisFile, + icon: 'ti ti-cloud-upload', + action: () => { + os.selectDriveFolder(false).then(async folder => { + if (folder[0] == null) { + return; + } + misskeyApi('drive/files/upload-from-url', { + url: props.image.url, + folderId: folder ? folder[0].id : undefined, + }); + }); + }, }]; if ($i?.id === props.image.userId || iAmModerator) { diff --git a/packages/frontend/src/pages/admin-user.vue b/packages/frontend/src/pages/admin-user.vue index 5035675f5..3a9a6c775 100644 --- a/packages/frontend/src/pages/admin-user.vue +++ b/packages/frontend/src/pages/admin-user.vue @@ -66,7 +66,19 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.resetPassword }} {{ i18n.ts.unsetUserAvatar }} {{ i18n.ts.unsetUserBanner }} - {{ i18n.ts.unsetUserMutualLink }} + + + + +
+
+

{{ mutualLink.url }}

+ +

{{ mutualLink.description }}

+ {{ i18n.ts.unsetUserMutualLink }} +
+
+
@@ -365,15 +377,16 @@ async function unsetUserBanner() { }).then(refreshUser); } -async function unsetUserMutualLink() { +async function unsetUserMutualLink(mutualLinkid: string) { const confirm = await os.confirm({ type: 'warning', text: i18n.ts.unsetUserMutualLinkConfirm, }); if (confirm.canceled) return; - await os.apiWithDialog('admin/unset-user-mutual-banner', { + await os.apiWithDialog('admin/unset-user-mutual-link', { userId: user.value.id, + itemId: mutualLinkid, }).then(refreshUser); } @@ -705,4 +718,16 @@ definePageMetadata(() => ({ border-radius: 6px; cursor: pointer; } + +.mutualLinkImg { + max-width: 200px; + max-height: 40px; +} +.fields { + padding: 24px; + border-bottom: solid 0.5px var(--divider); + &:last-child { + border-bottom: none; + } +} diff --git a/packages/frontend/src/pages/settings/profile.vue b/packages/frontend/src/pages/settings/profile.vue index b2b91bbb7..dfeba525a 100644 --- a/packages/frontend/src/pages/settings/profile.vue +++ b/packages/frontend/src/pages/settings/profile.vue @@ -112,7 +112,9 @@ SPDX-License-Identifier: AGPL-3.0-only