Redesign file context menus and download archives using global preference
This commit is contained in:
1 parent
6aca927851
commit
042392f611
22 files changed
+530
-363
No files matched your search
@@ -110,7 +110,7 @@
|
||||
<a :href="link" class="button share-download-primary"
|
||||
><AppIcon name="download" /><span>{{
|
||||
req.isDir
|
||||
? t("sso.downloadFolderZip")
|
||||
? t("explorer.downloadFolderArchive")
|
||||
: t("download.downloadFile")
|
||||
}}</span></a
|
||||
>
|
||||
@@ -322,34 +322,9 @@ const isSingleFile = () =>
|
||||
|
||||
const download = () => {
|
||||
if (!req.value) return false;
|
||||
|
||||
if (isSingleFile()) {
|
||||
api.download(
|
||||
null,
|
||||
hash.value,
|
||||
token.value,
|
||||
req.value.items[fileStore.selected[0]].path
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
layoutStore.showHover({
|
||||
prompt: "download",
|
||||
confirm: (format: DownloadFormat) => {
|
||||
if (req.value === null) return false;
|
||||
layoutStore.closeHovers();
|
||||
|
||||
const files: string[] = [];
|
||||
|
||||
for (const i of fileStore.selected) {
|
||||
files.push(req.value.items[i].path);
|
||||
}
|
||||
|
||||
api.download(format, hash.value, token.value, ...files);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
const files = fileStore.selected.map((i) => req.value!.items[i].path);
|
||||
if (!files.length) files.push(req.value.path);
|
||||
api.download(null, hash.value, token.value, ...files);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,128 +1,21 @@
|
||||
<template>
|
||||
<div>
|
||||
<header-bar showMenu showLogo>
|
||||
<div class="file-listing-workspace" @contextmenu="showContextMenu">
|
||||
<header-bar showMenu showLogo hideTheme class="file-browser-header">
|
||||
<search />
|
||||
<title />
|
||||
<action
|
||||
class="search-button"
|
||||
icon="search"
|
||||
:label="t('buttons.search')"
|
||||
@action="openSearch()"
|
||||
/>
|
||||
|
||||
<template #actions>
|
||||
<template v-if="!isMobile">
|
||||
<action
|
||||
v-if="headerButtons.share"
|
||||
icon="share"
|
||||
:label="t('buttons.share')"
|
||||
show="share"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.rename"
|
||||
icon="mode_edit"
|
||||
:label="t('buttons.rename')"
|
||||
show="rename"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.copy"
|
||||
id="copy-button"
|
||||
icon="content_copy"
|
||||
:label="t('buttons.copyFile')"
|
||||
show="copy"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.move"
|
||||
id="move-button"
|
||||
icon="forward"
|
||||
:label="t('buttons.moveFile')"
|
||||
show="move"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.delete"
|
||||
id="delete-button"
|
||||
icon="delete"
|
||||
:label="t('buttons.delete')"
|
||||
show="delete"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<action
|
||||
v-if="headerButtons.shell"
|
||||
icon="code"
|
||||
:label="t('buttons.shell')"
|
||||
@action="layoutStore.toggleShell"
|
||||
/>
|
||||
<action
|
||||
:icon="viewIcon"
|
||||
:label="t('buttons.switchView')"
|
||||
@action="switchView"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.download"
|
||||
icon="file_download"
|
||||
:label="t('buttons.download')"
|
||||
@action="download"
|
||||
:counter="fileStore.selectedCount"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.upload"
|
||||
icon="file_upload"
|
||||
id="upload-button"
|
||||
:label="t('buttons.upload')"
|
||||
@action="uploadFunc"
|
||||
/>
|
||||
<action icon="info" :label="t('buttons.info')" show="info" />
|
||||
<action
|
||||
icon="check_circle"
|
||||
:label="t('buttons.selectMultiple')"
|
||||
@action="toggleMultipleSelection"
|
||||
/>
|
||||
</template>
|
||||
<button
|
||||
class="workspace-actions-button"
|
||||
type="button"
|
||||
aria-haspopup="menu"
|
||||
:aria-expanded="isContextMenuVisible"
|
||||
@click.stop="openActions"
|
||||
>
|
||||
{{ t("explorer.actions")
|
||||
}}<span v-if="fileStore.selectedCount">
|
||||
({{ fileStore.selectedCount }})</span
|
||||
>
|
||||
</button>
|
||||
</header-bar>
|
||||
|
||||
<div
|
||||
v-if="isMobile"
|
||||
id="file-selection"
|
||||
:class="{
|
||||
'file-selection-margin-bottom': fileStore.multiple,
|
||||
}"
|
||||
>
|
||||
<span v-if="fileStore.selectedCount > 0">
|
||||
{{ t("prompts.filesSelected", fileStore.selectedCount) }}
|
||||
</span>
|
||||
<action
|
||||
v-if="headerButtons.share"
|
||||
icon="share"
|
||||
:label="t('buttons.share')"
|
||||
show="share"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.rename"
|
||||
icon="mode_edit"
|
||||
:label="t('buttons.rename')"
|
||||
show="rename"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.copy"
|
||||
icon="content_copy"
|
||||
:label="t('buttons.copyFile')"
|
||||
show="copy"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.move"
|
||||
icon="forward"
|
||||
:label="t('buttons.moveFile')"
|
||||
show="move"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.delete"
|
||||
icon="delete"
|
||||
:label="t('buttons.delete')"
|
||||
show="delete"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="layoutStore.loading">
|
||||
<h2 class="message delayed">
|
||||
<div class="spinner">
|
||||
@@ -215,11 +108,7 @@
|
||||
<h2 data-clear-on-click="true" v-if="fileStore.req?.numDirs ?? false">
|
||||
{{ t("files.folders") }}
|
||||
</h2>
|
||||
<div
|
||||
v-if="fileStore.req?.numDirs ?? false"
|
||||
data-clear-on-click="true"
|
||||
@contextmenu="showContextMenu"
|
||||
>
|
||||
<div v-if="fileStore.req?.numDirs ?? false" data-clear-on-click="true">
|
||||
<item
|
||||
v-for="item in dirs"
|
||||
:key="base64(item.name)"
|
||||
@@ -238,11 +127,7 @@
|
||||
<h2 data-clear-on-click="true" v-if="fileStore.req?.numFiles ?? false">
|
||||
{{ t("files.files") }}
|
||||
</h2>
|
||||
<div
|
||||
v-if="fileStore.req?.numFiles ?? false"
|
||||
data-clear-on-click="true"
|
||||
@contextmenu="showContextMenu"
|
||||
>
|
||||
<div v-if="fileStore.req?.numFiles ?? false" data-clear-on-click="true">
|
||||
<item
|
||||
v-for="item in files"
|
||||
:key="base64(item.name)"
|
||||
@@ -257,53 +142,6 @@
|
||||
>
|
||||
</item>
|
||||
</div>
|
||||
<context-menu
|
||||
:show="isContextMenuVisible"
|
||||
:pos="contextMenuPos"
|
||||
@hide="hideContextMenu"
|
||||
>
|
||||
<action
|
||||
v-if="headerButtons.share"
|
||||
icon="share"
|
||||
:label="t('buttons.share')"
|
||||
show="share"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.rename"
|
||||
icon="mode_edit"
|
||||
:label="t('buttons.rename')"
|
||||
show="rename"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.copy"
|
||||
id="copy-button"
|
||||
icon="content_copy"
|
||||
:label="t('buttons.copyFile')"
|
||||
show="copy"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.move"
|
||||
id="move-button"
|
||||
icon="forward"
|
||||
:label="t('buttons.moveFile')"
|
||||
show="move"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.delete"
|
||||
id="delete-button"
|
||||
icon="delete"
|
||||
:label="t('buttons.delete')"
|
||||
show="delete"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.download"
|
||||
icon="file_download"
|
||||
:label="t('buttons.download')"
|
||||
@action="download"
|
||||
:counter="fileStore.selectedCount"
|
||||
/>
|
||||
<action icon="info" :label="t('buttons.info')" show="info" />
|
||||
</context-menu>
|
||||
|
||||
<input
|
||||
style="display: none"
|
||||
@@ -336,6 +174,106 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<context-menu
|
||||
:show="isContextMenuVisible"
|
||||
:pos="contextMenuPos"
|
||||
@hide="hideContextMenu"
|
||||
>
|
||||
<action
|
||||
v-if="headerButtons.share"
|
||||
icon="share"
|
||||
:label="t('buttons.share')"
|
||||
show="share"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.rename"
|
||||
icon="mode_edit"
|
||||
:label="t('buttons.rename')"
|
||||
show="rename"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.copy"
|
||||
id="copy-button"
|
||||
icon="content_copy"
|
||||
:label="t('buttons.copyFile')"
|
||||
show="copy"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.move"
|
||||
id="move-button"
|
||||
icon="forward"
|
||||
:label="t('buttons.moveFile')"
|
||||
show="move"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.delete"
|
||||
id="delete-button"
|
||||
class="context-danger"
|
||||
icon="delete"
|
||||
:label="t('buttons.delete')"
|
||||
show="delete"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.download"
|
||||
icon="file_download"
|
||||
:label="t('buttons.download')"
|
||||
@action="download"
|
||||
:counter="fileStore.selectedCount"
|
||||
/>
|
||||
<div class="context-menu-separator" v-if="fileStore.selectedCount" />
|
||||
<action
|
||||
v-if="authStore.user?.perm.create"
|
||||
icon="create_new_folder"
|
||||
:label="t('sidebar.newFolder')"
|
||||
show="newDir"
|
||||
/>
|
||||
<action
|
||||
v-if="authStore.user?.perm.create"
|
||||
icon="note_add"
|
||||
:label="t('sidebar.newFile')"
|
||||
show="newFile"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.upload"
|
||||
icon="upload"
|
||||
:label="t('buttons.upload')"
|
||||
@action="uploadFunc"
|
||||
/>
|
||||
<action
|
||||
v-if="canPaste"
|
||||
icon="paste"
|
||||
:label="t('explorer.paste')"
|
||||
@action="pasteFromMenu"
|
||||
/>
|
||||
<div class="context-menu-separator" />
|
||||
<action
|
||||
:icon="viewIcon"
|
||||
:label="t('buttons.switchView')"
|
||||
@action="switchView"
|
||||
/>
|
||||
<action
|
||||
icon="check_circle"
|
||||
:label="t('buttons.selectMultiple')"
|
||||
@action="toggleMultipleSelection"
|
||||
/>
|
||||
<action
|
||||
icon="refresh"
|
||||
:label="t('explorer.refresh')"
|
||||
@action="refreshFolder"
|
||||
/>
|
||||
<action
|
||||
v-if="headerButtons.shell"
|
||||
icon="code"
|
||||
:label="t('buttons.shell')"
|
||||
@action="layoutStore.toggleShell"
|
||||
/>
|
||||
<action
|
||||
icon="contrast"
|
||||
:label="t('sso.toggleTheme')"
|
||||
@action="toggleTheme"
|
||||
/>
|
||||
<action icon="info" :label="t('buttons.info')" show="info" />
|
||||
</context-menu>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -346,6 +284,7 @@ import { useFileStore } from "@/stores/file";
|
||||
import { useLayoutStore } from "@/stores/layout";
|
||||
|
||||
import { users, files as api } from "@/api";
|
||||
import { toggleTheme } from "@/utils/theme";
|
||||
import { enableExec } from "@/utils/constants";
|
||||
import * as upload from "@/utils/upload";
|
||||
import buttons from "@/utils/buttons";
|
||||
@@ -375,7 +314,7 @@ import { removePrefix } from "@/api/utils";
|
||||
const showLimit = ref<number>(50);
|
||||
const columnWidth = ref<number>(280);
|
||||
const dragCounter = ref<number>(0);
|
||||
const width = ref<number>(window.innerWidth);
|
||||
|
||||
const itemWeight = ref<number>(0);
|
||||
const isContextMenuVisible = ref<boolean>(false);
|
||||
const contextMenuPos = ref<{ x: number; y: number }>({ x: 0, y: 0 });
|
||||
@@ -490,10 +429,6 @@ const headerButtons = computed(() => {
|
||||
};
|
||||
});
|
||||
|
||||
const isMobile = computed(() => {
|
||||
return width.value <= 736;
|
||||
});
|
||||
|
||||
watch(req, () => {
|
||||
// Reset the show value
|
||||
showLimit.value = 50;
|
||||
@@ -611,7 +546,7 @@ const keyEvent = (event: KeyboardEvent) => {
|
||||
break;
|
||||
case "s":
|
||||
event.preventDefault();
|
||||
document.getElementById("download-button")?.click();
|
||||
if (authStore.user?.perm.download) download();
|
||||
break;
|
||||
}
|
||||
};
|
||||
@@ -622,7 +557,11 @@ const preventDefault = (event: Event) => {
|
||||
};
|
||||
|
||||
const copyCut = (event: Event | KeyboardEvent): void => {
|
||||
if ((event.target as HTMLElement).tagName?.toLowerCase() === "input") return;
|
||||
if (
|
||||
event.target instanceof HTMLElement &&
|
||||
event.target.closest("input, textarea, [contenteditable=true]")
|
||||
)
|
||||
return;
|
||||
|
||||
if (fileStore.req === null) return;
|
||||
|
||||
@@ -650,7 +589,11 @@ const copyCut = (event: Event | KeyboardEvent): void => {
|
||||
};
|
||||
|
||||
const paste = async (event: Event) => {
|
||||
if ((event.target as HTMLElement).tagName?.toLowerCase() === "input") return;
|
||||
if (
|
||||
event.target instanceof HTMLElement &&
|
||||
event.target.closest("input, textarea, [contenteditable=true]")
|
||||
)
|
||||
return;
|
||||
|
||||
// TODO router location should it be
|
||||
const items: any[] = [];
|
||||
@@ -961,10 +904,6 @@ const sort = async (by: string) => {
|
||||
fileStore.reload = true;
|
||||
};
|
||||
|
||||
const openSearch = () => {
|
||||
layoutStore.showHover("search");
|
||||
};
|
||||
|
||||
const toggleMultipleSelection = () => {
|
||||
fileStore.toggleMultiple();
|
||||
layoutStore.closeHovers();
|
||||
@@ -972,7 +911,6 @@ const toggleMultipleSelection = () => {
|
||||
|
||||
const windowsResize = throttle(() => {
|
||||
columnsResize();
|
||||
width.value = window.innerWidth;
|
||||
|
||||
// Listing element is not displayed
|
||||
if (listing.value == null) return;
|
||||
@@ -985,34 +923,11 @@ const windowsResize = throttle(() => {
|
||||
}, 100);
|
||||
|
||||
const download = () => {
|
||||
if (fileStore.req === null) return;
|
||||
|
||||
if (
|
||||
fileStore.selectedCount === 1 &&
|
||||
!fileStore.req.items[fileStore.selected[0]].isDir
|
||||
) {
|
||||
api.download(null, fileStore.req.items[fileStore.selected[0]].url);
|
||||
return;
|
||||
}
|
||||
|
||||
layoutStore.showHover({
|
||||
prompt: "download",
|
||||
confirm: (format: any) => {
|
||||
layoutStore.closeHovers();
|
||||
|
||||
const files = [];
|
||||
|
||||
if (fileStore.selectedCount > 0 && fileStore.req !== null) {
|
||||
for (const i of fileStore.selected) {
|
||||
files.push(fileStore.req.items[i].url);
|
||||
}
|
||||
} else {
|
||||
files.push(route.path);
|
||||
}
|
||||
|
||||
api.download(format, ...files);
|
||||
},
|
||||
});
|
||||
if (!fileStore.req || !authStore.user?.perm.download) return;
|
||||
const files = fileStore.selectedCount
|
||||
? fileStore.selected.map((i) => fileStore.req!.items[i].url)
|
||||
: [route.path];
|
||||
api.download(null, ...files);
|
||||
};
|
||||
|
||||
const switchView = async () => {
|
||||
@@ -1099,13 +1014,32 @@ const revealPreviousItem = () => {
|
||||
return true;
|
||||
};
|
||||
|
||||
const canPaste = computed(
|
||||
() =>
|
||||
!!authStore.user?.perm.create &&
|
||||
clipboardStore.items.length > 0 &&
|
||||
(clipboardStore.key !== "x" || !!authStore.user?.perm.rename)
|
||||
);
|
||||
const pasteFromMenu = () => paste(new Event("paste"));
|
||||
const refreshFolder = () => {
|
||||
fileStore.reload = true;
|
||||
};
|
||||
const openActions = (event: MouseEvent) => {
|
||||
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
|
||||
contextMenuPos.value = { x: rect.right, y: rect.bottom + 6 };
|
||||
isContextMenuVisible.value = !isContextMenuVisible.value;
|
||||
};
|
||||
const showContextMenu = (event: MouseEvent) => {
|
||||
const target = event.target;
|
||||
if (
|
||||
!(target instanceof Element) ||
|
||||
target.closest("header, .context-menu, input, textarea")
|
||||
)
|
||||
return;
|
||||
event.preventDefault();
|
||||
if (!target.closest(".item:not(.header)")) fileStore.selected = [];
|
||||
isContextMenuVisible.value = true;
|
||||
contextMenuPos.value = {
|
||||
x: event.clientX + 8,
|
||||
y: event.clientY + Math.floor(window.scrollY),
|
||||
};
|
||||
contextMenuPos.value = { x: event.clientX, y: event.clientY };
|
||||
};
|
||||
|
||||
const hideContextMenu = () => {
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
{{ $t("files.noPreview") }}
|
||||
</div>
|
||||
<div>
|
||||
<a target="_blank" :href="downloadUrl" class="button button--flat">
|
||||
<a :href="downloadUrl" class="button button--flat">
|
||||
<div>
|
||||
<AppIcon name="file_download" />{{ $t("buttons.download") }}
|
||||
</div>
|
||||
@@ -529,7 +529,7 @@ const close = () => {
|
||||
router.push({ path: uri });
|
||||
};
|
||||
|
||||
const download = () => window.open(downloadUrl.value);
|
||||
const download = () => window.location.assign(downloadUrl.value);
|
||||
|
||||
const editAsText = () => {
|
||||
router.push({ path: route.path, query: { edit: "true" } });
|
||||
|
||||
@@ -6,6 +6,22 @@
|
||||
@submit.prevent="save"
|
||||
>
|
||||
<div class="settings-grid">
|
||||
<section class="card settings-section">
|
||||
<h2><AppIcon name="archive" />{{ t("settings.downloadsTitle") }}</h2>
|
||||
<label class="settings-field"
|
||||
>{{ t("settings.downloadArchiveFormat") }}
|
||||
<select class="input" v-model="settings.downloadArchiveFormat">
|
||||
<option
|
||||
v-for="(label, value) in archiveFormats"
|
||||
:key="value"
|
||||
:value="value"
|
||||
>
|
||||
{{ label }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<p class="field-hint">{{ t("settings.downloadArchiveHint") }}</p>
|
||||
</section>
|
||||
<section class="card settings-section">
|
||||
<h2><AppIcon name="palette" />{{ t("preferences.appearance") }}</h2>
|
||||
<label class="settings-field"
|
||||
@@ -103,6 +119,17 @@
|
||||
</form>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
const archiveFormats = {
|
||||
zip: "ZIP",
|
||||
tar: "TAR",
|
||||
targz: "TAR.GZ",
|
||||
tarbz2: "TAR.BZ2",
|
||||
tarxz: "TAR.XZ",
|
||||
tarlz4: "TAR.LZ4",
|
||||
tarsz: "TAR.SZ",
|
||||
tarbr: "TAR.BR",
|
||||
tarzst: "TAR.ZST",
|
||||
};
|
||||
import { settings as api } from "@/api";
|
||||
import { StatusError } from "@/api/utils";
|
||||
import Rules from "@/components/settings/Rules.vue";
|
||||
|
||||
Reference in new issue
Block a user