enhance(frontend): ドライブのファイル・フォルダをドラッグしなくても移動できるように (#14318)
* feat(drive): ファイルをフォルダに移動するメニューを実装 (cherry picked from commit b89c2af6945c6a9f9f10e83f54d2bcf0f240b0b4) * tweak ui * Update Changelog * ファイル詳細からも移動できるように * feat(drive) フォルダのネストを移動するメニューを実装 (cherry picked from commit 8a7d710c6acb83f50c83f050bd1423c764d60a99) * Update Changelog * Update Changelog * lint * tweak ui --------- Co-authored-by: nafu-at <satsuki@nafusoft.dev> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
@@ -37,11 +37,17 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button class="_button" :class="$style.fileAltEditBtn" @click="describe()">
|
||||
<div class="_gaps_s">
|
||||
<button class="_button" :class="$style.kvEditBtn" @click="move()">
|
||||
<MkKeyValue>
|
||||
<template #key>{{ i18n.ts.folder }}</template>
|
||||
<template #value>{{ folderHierarchy.join(' > ') }}<i class="ti ti-pencil" :class="$style.kvEditIcon"></i></template>
|
||||
</MkKeyValue>
|
||||
</button>
|
||||
<button class="_button" :class="$style.kvEditBtn" @click="describe()">
|
||||
<MkKeyValue>
|
||||
<template #key>{{ i18n.ts.description }}</template>
|
||||
<template #value>{{ file.comment ? file.comment : `(${i18n.ts.none})` }}<i class="ti ti-pencil" :class="$style.fileAltEditIcon"></i></template>
|
||||
<template #value>{{ file.comment ? file.comment : `(${i18n.ts.none})` }}<i class="ti ti-pencil" :class="$style.kvEditIcon"></i></template>
|
||||
</MkKeyValue>
|
||||
</button>
|
||||
<MkKeyValue :class="$style.fileMetaDataChildren">
|
||||
@@ -90,6 +96,18 @@ const props = defineProps<{
|
||||
|
||||
const fetching = ref(true);
|
||||
const file = ref<Misskey.entities.DriveFile>();
|
||||
const folderHierarchy = computed(() => {
|
||||
if (!file.value) return [i18n.ts.drive];
|
||||
const folderNames = [i18n.ts.drive];
|
||||
|
||||
function get(folder: Misskey.entities.DriveFolder) {
|
||||
if (folder.parent) get(folder.parent);
|
||||
folderNames.push(folder.name);
|
||||
}
|
||||
|
||||
if (file.value.folder) get(file.value.folder);
|
||||
return folderNames;
|
||||
});
|
||||
const isImage = computed(() => file.value?.type.startsWith('image/'));
|
||||
|
||||
async function fetch() {
|
||||
@@ -122,6 +140,19 @@ function crop() {
|
||||
});
|
||||
}
|
||||
|
||||
function move() {
|
||||
if (!file.value) return;
|
||||
|
||||
os.selectDriveFolder(false).then(folder => {
|
||||
misskeyApi('drive/files/update', {
|
||||
fileId: file.value.id,
|
||||
folderId: folder[0] ? folder[0].id : null,
|
||||
}).then(async () => {
|
||||
await fetch();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function toggleSensitive() {
|
||||
if (!file.value) return;
|
||||
|
||||
@@ -282,14 +313,14 @@ onMounted(async () => {
|
||||
padding: .5rem 1rem;
|
||||
}
|
||||
|
||||
.fileAltEditBtn {
|
||||
.kvEditBtn {
|
||||
text-align: start;
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: .5rem 1rem;
|
||||
border-radius: var(--radius);
|
||||
|
||||
.fileAltEditIcon {
|
||||
.kvEditIcon {
|
||||
display: inline-block;
|
||||
color: transparent;
|
||||
visibility: hidden;
|
||||
@@ -300,7 +331,7 @@ onMounted(async () => {
|
||||
color: var(--accent);
|
||||
background-color: var(--accentedBg);
|
||||
|
||||
.fileAltEditIcon {
|
||||
.kvEditIcon {
|
||||
color: var(--accent);
|
||||
visibility: visible;
|
||||
}
|
||||
|
Reference in New Issue
Block a user