diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2024-09-23 21:50:30 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-23 21:50:30 +0900 |
| commit | 0c6d1ec5245708f784fe5c74e7547f3f7317d5df (patch) | |
| tree | 02c81d75e5bb70ff57a714ea6938a326735e2719 /packages/frontend/src/components/MkPostFormAttaches.vue | |
| parent | fix(backend): happy-domを使用後にcloseするように (#14615) (diff) | |
| download | sharkey-0c6d1ec5245708f784fe5c74e7547f3f7317d5df.tar.gz sharkey-0c6d1ec5245708f784fe5c74e7547f3f7317d5df.tar.bz2 sharkey-0c6d1ec5245708f784fe5c74e7547f3f7317d5df.zip | |
refactor(frontend): popupMenuの項目作成時に三項演算子をなるべく使わないように (#14554)
* refactor(frontend): popupMenuの項目作成時に三項演算子をなるべく使わないように
* type import
* fix
* lint
Diffstat (limited to 'packages/frontend/src/components/MkPostFormAttaches.vue')
| -rw-r--r-- | packages/frontend/src/components/MkPostFormAttaches.vue | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/packages/frontend/src/components/MkPostFormAttaches.vue b/packages/frontend/src/components/MkPostFormAttaches.vue index 3e3b09a88c..80b75a0875 100644 --- a/packages/frontend/src/components/MkPostFormAttaches.vue +++ b/packages/frontend/src/components/MkPostFormAttaches.vue @@ -26,6 +26,7 @@ import MkDriveFileThumbnail from '@/components/MkDriveFileThumbnail.vue'; import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; import { i18n } from '@/i18n.js'; +import type { MenuItem } from '@/types/menu.js'; const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default)); @@ -136,7 +137,10 @@ function showFileMenu(file: Misskey.entities.DriveFile, ev: MouseEvent): void { if (menuShowing) return; const isImage = file.type.startsWith('image/'); - os.popupMenu([{ + + const menuItems: MenuItem[] = []; + + menuItems.push({ text: i18n.ts.renameFile, icon: 'ti ti-forms', action: () => { rename(file); }, @@ -148,11 +152,17 @@ function showFileMenu(file: Misskey.entities.DriveFile, ev: MouseEvent): void { text: i18n.ts.describeFile, icon: 'ti ti-text-caption', action: () => { describe(file); }, - }, ...isImage ? [{ - text: i18n.ts.cropImage, - icon: 'ti ti-crop', - action: () : void => { crop(file); }, - }] : [], { + }); + + if (isImage) { + menuItems.push({ + text: i18n.ts.cropImage, + icon: 'ti ti-crop', + action: () : void => { crop(file); }, + }); + } + + menuItems.push({ type: 'divider', }, { text: i18n.ts.attachCancel, @@ -163,7 +173,9 @@ function showFileMenu(file: Misskey.entities.DriveFile, ev: MouseEvent): void { icon: 'ti ti-trash', danger: true, action: () => { detachAndDeleteMedia(file); }, - }], ev.currentTarget ?? ev.target).then(() => menuShowing = false); + }); + + os.popupMenu(menuItems, ev.currentTarget ?? ev.target).then(() => menuShowing = false); menuShowing = true; } </script> |