From 3796da683658f527ecc83bf09bfe620512e03115 Mon Sep 17 00:00:00 2001 From: yupix Date: Sat, 8 Jul 2023 18:45:41 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80?= =?UTF-8?q?=E3=83=BC=E3=82=84=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=A7?= =?UTF-8?q?=E3=82=82ID=E3=82=92=E3=82=B3=E3=83=94=E3=83=BC=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20(#11189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: フォルダーやファイルでもIDをコピーできるように close #11188 * docs: update CHANGELOG.md --- CHANGELOG.md | 1 + locales/index.d.ts | 2 ++ locales/ja-JP.yml | 2 ++ .../frontend/src/components/MkDrive.folder.vue | 16 ++++++++++++++-- .../frontend/src/scripts/get-drive-file-menu.ts | 16 +++++++++++++++- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a58750aa..2183598d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - 画像を動画と同様に簡単に隠せるように - オリジナル画像を保持せずにアップロードする場合webpでアップロードされるように(Safari以外) - 見たことのあるRenoteを省略して表示をオンのときに自分のnoteのrenoteを省略するように +- フォルダーやファイルに対しても開発者モード使用時、IDをコピーできるように - Fix: サーバーメトリクスが90度傾いている - Fix: 非ログイン時にクレデンシャルが必要なページに行くとエラーが出る問題を修正 - Fix: sparkle内にリンクを入れるとクリック不能になる問題の修正 diff --git a/locales/index.d.ts b/locales/index.d.ts index b7db5c6a7..dacab0cca 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -57,6 +57,8 @@ export interface Locale { "copyUsername": string; "copyUserId": string; "copyNoteId": string; + "copyFileId": string; + "copyFolderId": string; "searchUser": string; "reply": string; "loadMore": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 441707b19..29f157b84 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -54,6 +54,8 @@ copyRSS: "RSSをコピー" copyUsername: "ユーザー名をコピー" copyUserId: "ユーザーIDをコピー" copyNoteId: "ノートIDをコピー" +copyFileId: "ファイルIDをコピー" +copyFolderId: "フォルダーIDをコピー" searchUser: "ユーザーを検索" reply: "返信" loadMore: "もっと見る" diff --git a/packages/frontend/src/components/MkDrive.folder.vue b/packages/frontend/src/components/MkDrive.folder.vue index 359497872..13f32ff7a 100644 --- a/packages/frontend/src/components/MkDrive.folder.vue +++ b/packages/frontend/src/components/MkDrive.folder.vue @@ -33,6 +33,7 @@ import * as os from '@/os'; import { i18n } from '@/i18n'; import { defaultStore } from '@/store'; import { claimAchievement } from '@/scripts/achievements'; +import copyToClipboard from '@/scripts/copy-to-clipboard'; const props = withDefaults(defineProps<{ folder: Misskey.entities.DriveFolder; @@ -244,7 +245,8 @@ function setAsUploadFolder() { } function onContextmenu(ev: MouseEvent) { - os.contextMenu([{ + let menu; + menu = [{ text: i18n.ts.openInWindow, icon: 'ti ti-app-window', action: () => { @@ -262,7 +264,17 @@ function onContextmenu(ev: MouseEvent) { icon: 'ti ti-trash', danger: true, action: deleteFolder, - }], ev); + }]; + if (defaultStore.state.devMode) { + menu = menu.concat([null, { + icon: 'ti ti-id', + text: i18n.ts.copyFolderId, + action: () => { + copyToClipboard(props.folder.id); + }, + }]); + } + os.contextMenu(menu, ev); } diff --git a/packages/frontend/src/scripts/get-drive-file-menu.ts b/packages/frontend/src/scripts/get-drive-file-menu.ts index ef0990b32..9b488087e 100644 --- a/packages/frontend/src/scripts/get-drive-file-menu.ts +++ b/packages/frontend/src/scripts/get-drive-file-menu.ts @@ -4,6 +4,7 @@ import { i18n } from '@/i18n'; import copyToClipboard from '@/scripts/copy-to-clipboard'; import * as os from '@/os'; import { MenuItem } from '@/types/menu'; +import { defaultStore } from '@/store'; function rename(file: Misskey.entities.DriveFile) { os.inputText({ @@ -69,7 +70,8 @@ async function deleteFile(file: Misskey.entities.DriveFile) { export function getDriveFileMenu(file: Misskey.entities.DriveFile, folder?: Misskey.entities.DriveFolder | null): MenuItem[] { const isImage = file.type.startsWith('image/'); - return [{ + let menu; + menu = [{ text: i18n.ts.rename, icon: 'ti ti-forms', action: () => rename(file), @@ -111,4 +113,16 @@ export function getDriveFileMenu(file: Misskey.entities.DriveFile, folder?: Miss danger: true, action: () => deleteFile(file), }]; + + if (defaultStore.state.devMode) { + menu = menu.concat([null, { + icon: 'ti ti-id', + text: i18n.ts.copyFileId, + action: () => { + copyToClipboard(file.id); + }, + }]); + } + + return menu; }