Move settings navigation to account menu and add file creation templates
This commit is contained in:
1 parent
042392f611
commit
54761e4ef2
24 files changed
+591
-165
No files matched your search
@@ -12,3 +12,7 @@
|
||||
Меню действий открывается правой кнопкой на файле или на пустой области, а также кнопкой «Действия» в шапке. ПКМ на пустом месте снимает выделение и показывает действия с текущей папкой. Меню ограничено размерами экрана, прокручивается, поддерживает стрелки и Escape. Верхняя панель освобождена для поиска, доступного и на мобильных устройствах.
|
||||
|
||||
Скачивание начинается сразу. Для папок и нескольких файлов формат задаётся в «Глобальные настройки → Скачивание → Формат архива», по умолчанию ZIP. Настройка действует и на публичные ссылки; отдельный файл передаётся без упаковки. Старые URL с явным параметром algo продолжают работать.
|
||||
|
||||
Навигация настроек находится в меню аккаунта: «Аккаунт» ведёт на управление аккаунтом, «Настройки» — личные предпочтения, «Мои ссылки» — созданные ссылки, «Административные настройки» — серверные параметры (только для администратора). Вкладок больше нет. Плитка «Управление пользователями» открывает таблицу и редактирование доступа в одном модальном окне; старые адреса управления пользователями перенаправляются туда.
|
||||
|
||||
Подменю «Создать» содержит папку и шаблоны текстовых форматов. Расширение добавляется автоматически без дублирования; JSON, HTML и XML получают корректное начальное содержимое. Реестр frontend/src/utils/file-templates.ts предназначен для расширения типов при подключении редакторов. Office-документы пока не создаются, чтобы не выдавать пустой файл за корректный DOCX/XLSX.
|
||||
@@ -7,7 +7,8 @@
|
||||
role="menu"
|
||||
tabindex="-1"
|
||||
:style="{ top: top + 'px', left: left + 'px' }"
|
||||
@click="hide"
|
||||
@click="menuClick"
|
||||
@click.capture="schedulePosition"
|
||||
@contextmenu.prevent.stop
|
||||
@keydown="keyboard"
|
||||
>
|
||||
@@ -24,6 +25,30 @@ const contextMenu = ref<HTMLElement | null>(null),
|
||||
top = ref(0);
|
||||
let previousFocus: HTMLElement | null = null;
|
||||
const hide = () => emit("hide");
|
||||
function menuClick(event: MouseEvent) {
|
||||
if (
|
||||
event.target instanceof Element &&
|
||||
event.target.closest('button[aria-haspopup="menu"]')
|
||||
)
|
||||
return;
|
||||
hide();
|
||||
}
|
||||
function position() {
|
||||
if (!contextMenu.value) return;
|
||||
const rect = contextMenu.value.getBoundingClientRect();
|
||||
left.value = Math.max(
|
||||
8,
|
||||
Math.min(props.pos.x, window.innerWidth - rect.width - 8)
|
||||
);
|
||||
top.value = Math.max(
|
||||
8,
|
||||
Math.min(props.pos.y, window.innerHeight - rect.height - 8)
|
||||
);
|
||||
}
|
||||
async function schedulePosition() {
|
||||
await nextTick();
|
||||
position();
|
||||
}
|
||||
function outside(event: Event) {
|
||||
if (
|
||||
event.target instanceof Node &&
|
||||
@@ -32,6 +57,7 @@ function outside(event: Event) {
|
||||
hide();
|
||||
}
|
||||
function keyboard(event: KeyboardEvent) {
|
||||
schedulePosition();
|
||||
const buttons = Array.from(
|
||||
contextMenu.value?.querySelectorAll<HTMLButtonElement>(
|
||||
"button:not(:disabled)"
|
||||
|
||||
@@ -62,11 +62,11 @@
|
||||
</button>
|
||||
<button
|
||||
v-if="file.isFiles && file.req?.isDir && auth.user.perm.create"
|
||||
@click="layout.showHover('newFile')"
|
||||
:title="t('sidebar.newFile')"
|
||||
:aria-label="t('sidebar.newFile')"
|
||||
@click="layout.showHover('create')"
|
||||
:title="t('buttons.create')"
|
||||
:aria-label="t('buttons.create')"
|
||||
>
|
||||
<AppIcon name="note_add" />
|
||||
<AppIcon name="add" />
|
||||
</button>
|
||||
</div>
|
||||
<ul class="folder-tree" :aria-label="t('explorer.folders')">
|
||||
@@ -116,14 +116,14 @@
|
||||
role="menuitem"
|
||||
:href="baseURL + '/auth/account'"
|
||||
@click="navigate"
|
||||
><AppIcon name="account_circle" />{{ t("preferences.manage") }}</a
|
||||
><AppIcon name="account_circle" />{{ t("explorer.account") }}</a
|
||||
>
|
||||
<router-link
|
||||
role="menuitem"
|
||||
to="/settings/profile"
|
||||
@click="navigate"
|
||||
><AppIcon name="manage_accounts" />{{
|
||||
t("settings.profileSettings")
|
||||
t("sidebar.settings")
|
||||
}}</router-link
|
||||
>
|
||||
<router-link
|
||||
@@ -141,18 +141,10 @@
|
||||
to="/settings/global"
|
||||
@click="navigate"
|
||||
><AppIcon name="settings" />{{
|
||||
t("settings.globalSettings")
|
||||
}}</router-link
|
||||
>
|
||||
<router-link
|
||||
v-if="auth.user.perm.admin"
|
||||
role="menuitem"
|
||||
to="/settings/users"
|
||||
@click="navigate"
|
||||
><AppIcon name="group" />{{
|
||||
t("settings.userManagement")
|
||||
t("explorer.adminSettings")
|
||||
}}</router-link
|
||||
>
|
||||
|
||||
<button v-if="canLogout" role="menuitem" @click="logout">
|
||||
<AppIcon name="logout" />{{ t("sidebar.logout") }}
|
||||
</button>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<button
|
||||
ref="trigger"
|
||||
class="action"
|
||||
type="button"
|
||||
aria-haspopup="menu"
|
||||
:aria-expanded="expanded"
|
||||
@click.stop="expanded = !expanded"
|
||||
@keydown.right.stop.prevent="expand"
|
||||
>
|
||||
<AppIcon name="add" /><span>{{ t("buttons.create") }}</span
|
||||
><AppIcon :name="expanded ? 'expand_more' : 'chevron_right'" />
|
||||
</button>
|
||||
<div
|
||||
v-if="expanded"
|
||||
ref="submenu"
|
||||
class="context-submenu"
|
||||
role="group"
|
||||
:aria-label="t('buttons.create')"
|
||||
@keydown.left.stop.prevent="collapse"
|
||||
>
|
||||
<CreateOptions />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { nextTick, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import CreateOptions from "./CreateOptions.vue";
|
||||
const { t } = useI18n(),
|
||||
expanded = ref(false),
|
||||
submenu = ref<HTMLElement>(),
|
||||
trigger = ref<HTMLElement>();
|
||||
async function expand() {
|
||||
expanded.value = true;
|
||||
await nextTick();
|
||||
submenu.value?.querySelector("button")?.focus();
|
||||
}
|
||||
function collapse() {
|
||||
expanded.value = false;
|
||||
trigger.value?.focus();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<button type="button" class="action" @click="open('newDir')">
|
||||
<AppIcon name="folder" /><span>{{ t("sidebar.newFolder") }}</span>
|
||||
</button>
|
||||
<div class="context-menu-separator" />
|
||||
<button
|
||||
v-for="template in fileTemplates"
|
||||
:key="template.id"
|
||||
type="button"
|
||||
class="action"
|
||||
@click="open('newFile', template.id)"
|
||||
>
|
||||
<AppIcon :name="template.icon" /><span>{{
|
||||
t("createTypes." + template.id)
|
||||
}}</span>
|
||||
</button>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useLayoutStore } from "@/stores/layout";
|
||||
import { fileTemplates } from "@/utils/file-templates";
|
||||
const { t } = useI18n(),
|
||||
layout = useLayoutStore();
|
||||
function open(prompt: string, template?: string) {
|
||||
if (layout.currentPromptName === "create") layout.closeHovers();
|
||||
layout.showHover({ prompt, props: { template } });
|
||||
}
|
||||
</script>
|
||||
@@ -1,39 +1,73 @@
|
||||
<template>
|
||||
<div id="modal-background" @click="backgroundClick">
|
||||
<div ref="modalContainer">
|
||||
<div ref="modalContainer" tabindex="-1">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
|
||||
import { onMounted, onBeforeUnmount, nextTick, ref, watch } from "vue";
|
||||
const emit = defineEmits(["closed"]);
|
||||
|
||||
const modalContainer = ref(null);
|
||||
|
||||
const props = defineProps<{ prompt?: string | null }>();
|
||||
const modalContainer = ref<HTMLElement | null>(null);
|
||||
let previousFocus: HTMLElement | null = null;
|
||||
async function focusPrompt() {
|
||||
await nextTick();
|
||||
(
|
||||
modalContainer.value?.querySelector<HTMLElement>("#focus-prompt") ||
|
||||
modalContainer.value
|
||||
)?.focus({ preventScroll: true });
|
||||
}
|
||||
onMounted(() => {
|
||||
const element = document.querySelector("#focus-prompt") as HTMLElement | null;
|
||||
if (element) {
|
||||
element.focus();
|
||||
} else if (modalContainer.value) {
|
||||
(modalContainer.value as HTMLElement).focus();
|
||||
}
|
||||
previousFocus =
|
||||
document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: null;
|
||||
window.addEventListener("keydown", keyboard);
|
||||
focusPrompt();
|
||||
});
|
||||
|
||||
watch(() => props.prompt, focusPrompt);
|
||||
const backgroundClick = (event: Event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
if (target.id == "modal-background") {
|
||||
emit("closed");
|
||||
}
|
||||
if ((event.target as HTMLElement).id === "modal-background") emit("closed");
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", (event) => {
|
||||
function keyboard(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
emit("closed");
|
||||
}
|
||||
if (event.key === "Tab") {
|
||||
const items = Array.from(
|
||||
modalContainer.value?.querySelectorAll<HTMLElement>(
|
||||
'button:not(:disabled), a[href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex="0"]'
|
||||
) || []
|
||||
).filter((element) => element.getClientRects().length > 0);
|
||||
const first = items[0],
|
||||
last = items[items.length - 1];
|
||||
if (!first) {
|
||||
event.preventDefault();
|
||||
modalContainer.value?.focus();
|
||||
} else if (
|
||||
event.shiftKey &&
|
||||
(document.activeElement === first ||
|
||||
document.activeElement === modalContainer.value)
|
||||
) {
|
||||
event.preventDefault();
|
||||
last.focus();
|
||||
} else if (
|
||||
!event.shiftKey &&
|
||||
(document.activeElement === last ||
|
||||
!modalContainer.value?.contains(document.activeElement))
|
||||
) {
|
||||
event.preventDefault();
|
||||
first.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener("keydown", keyboard);
|
||||
if (previousFocus?.isConnected) previousFocus.focus({ preventScroll: true });
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<template>
|
||||
<div class="card floating">
|
||||
<div class="card-title">
|
||||
<h2>{{ t("buttons.create") }}</h2>
|
||||
</div>
|
||||
<div class="create-type-options"><CreateOptions /></div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from "vue-i18n";
|
||||
import CreateOptions from "../files/CreateOptions.vue";
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="card floating">
|
||||
<div class="card-title">
|
||||
<h2>{{ t("prompts.newFile") }}</h2>
|
||||
<h2>{{ t("createTypes." + template.id) }}</h2>
|
||||
</div>
|
||||
|
||||
<div class="card-content">
|
||||
@@ -13,7 +13,7 @@
|
||||
@keyup.enter="submit"
|
||||
v-model.trim="name"
|
||||
/>
|
||||
<CreateFilePath :name="name" />
|
||||
<CreateFilePath :name="fullName" />
|
||||
</div>
|
||||
|
||||
<div class="card-action">
|
||||
@@ -38,7 +38,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { inject, ref } from "vue";
|
||||
import { computed, inject, ref, watch } from "vue";
|
||||
import { fileTemplate, templateFileName } from "@/utils/file-templates";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { useFileStore } from "@/stores/file";
|
||||
@@ -58,10 +59,23 @@ const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
|
||||
const name = ref<string>("");
|
||||
const template = computed(() =>
|
||||
fileTemplate(layoutStore.currentPrompt?.props?.template)
|
||||
);
|
||||
const fullName = computed(() =>
|
||||
templateFileName(name.value, template.value.extension)
|
||||
);
|
||||
watch(
|
||||
() => template.value.id,
|
||||
() => {
|
||||
name.value = "";
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const submit = async (event: Event) => {
|
||||
event.preventDefault();
|
||||
if (name.value === "") return;
|
||||
if (!fullName.value) return;
|
||||
|
||||
// Build the path of the new directory.
|
||||
let uri = fileStore.isFiles ? route.path + "/" : "/";
|
||||
@@ -70,18 +84,23 @@ const submit = async (event: Event) => {
|
||||
uri = url.removeLastDir(uri) + "/";
|
||||
}
|
||||
|
||||
uri += encodeURIComponent(name.value);
|
||||
uri += encodeURIComponent(fullName.value);
|
||||
uri = uri.replace("//", "/");
|
||||
|
||||
try {
|
||||
await api.post(uri);
|
||||
router.push({ path: uri });
|
||||
await api.post(
|
||||
uri,
|
||||
new Blob([template.value.content], { type: "text/plain;charset=utf-8" })
|
||||
);
|
||||
await router.push({
|
||||
path: uri,
|
||||
query: template.value.id === "other" ? {} : { edit: "true" },
|
||||
});
|
||||
layoutStore.closeHovers();
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
$showError(e);
|
||||
}
|
||||
}
|
||||
|
||||
layoutStore.closeHovers();
|
||||
};
|
||||
</script>
|
||||
@@ -20,6 +20,10 @@ const Rename = defineAsyncComponent(() => import("./Rename.vue"));
|
||||
const Move = defineAsyncComponent(() => import("./Move.vue"));
|
||||
const Copy = defineAsyncComponent(() => import("./Copy.vue"));
|
||||
const NewFile = defineAsyncComponent(() => import("./NewFile.vue"));
|
||||
const Create = defineAsyncComponent(() => import("./Create.vue"));
|
||||
const UsersManagement = defineAsyncComponent(
|
||||
() => import("./UsersManagement.vue")
|
||||
);
|
||||
const NewDir = defineAsyncComponent(() => import("./NewDir.vue"));
|
||||
const Replace = defineAsyncComponent(() => import("./Replace.vue"));
|
||||
const Share = defineAsyncComponent(() => import("./Share.vue"));
|
||||
@@ -47,6 +51,8 @@ const components = new Map<string, any>([
|
||||
["move", Move],
|
||||
["copy", Copy],
|
||||
["newFile", NewFile],
|
||||
["create", Create],
|
||||
["users-management", UsersManagement],
|
||||
["newDir", NewDir],
|
||||
["replace", Replace],
|
||||
["share", Share],
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="auth.user?.perm.admin"
|
||||
class="card floating users-management settings-page"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-label="t('settings.userManagement')"
|
||||
>
|
||||
<div class="card-title users-management-heading">
|
||||
<h2>{{ t("settings.userManagement") }}</h2>
|
||||
<button
|
||||
id="focus-prompt"
|
||||
type="button"
|
||||
class="action"
|
||||
:aria-label="t('buttons.close')"
|
||||
@click="layout.closeHovers"
|
||||
>
|
||||
<AppIcon name="close" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="users-management-body">
|
||||
<button
|
||||
v-if="selected"
|
||||
type="button"
|
||||
class="button button--flat"
|
||||
@click="selected = undefined"
|
||||
>
|
||||
<AppIcon name="arrow_back" />{{ t("settings.users") }}
|
||||
</button>
|
||||
<User
|
||||
v-if="selected"
|
||||
:user-id="selected"
|
||||
@cancel="selected = undefined"
|
||||
@saved="selected = undefined"
|
||||
/>
|
||||
<Users v-else @edit="selected = $event" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { useLayoutStore } from "@/stores/layout";
|
||||
import Users from "@/views/settings/Users.vue";
|
||||
import User from "@/views/settings/User.vue";
|
||||
const auth = useAuthStore(),
|
||||
layout = useLayoutStore(),
|
||||
{ t } = useI18n();
|
||||
const initial = Number(layout.currentPrompt?.props?.userId);
|
||||
const selected = ref<number | undefined>(
|
||||
Number.isSafeInteger(initial) && initial > 0 ? initial : undefined
|
||||
);
|
||||
</script>
|
||||
@@ -109,3 +109,73 @@
|
||||
min-height: 42px;
|
||||
}
|
||||
}
|
||||
.context-submenu {
|
||||
margin: 4px 0 6px 12px;
|
||||
padding-inline-start: 8px;
|
||||
border-inline-start: 1px solid var(--borderPrimary);
|
||||
}
|
||||
.create-type-options {
|
||||
padding: 8px 14px 16px;
|
||||
}
|
||||
.create-type-options .action {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border-radius: 7px;
|
||||
font-size: 13px;
|
||||
color: var(--textPrimary);
|
||||
}
|
||||
.create-type-options .app-icon {
|
||||
padding: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
.file-browser-header {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(200px, 640px) minmax(0, 1fr);
|
||||
gap: 16px;
|
||||
}
|
||||
.file-browser-header .workspace-brand {
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
min-width: 0;
|
||||
justify-self: start;
|
||||
}
|
||||
.file-browser-header #search:not(.active) {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: 0;
|
||||
}
|
||||
.file-browser-header .workspace-actions-button {
|
||||
grid-column: 3;
|
||||
grid-row: 1;
|
||||
justify-self: end;
|
||||
margin: 0;
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.file-browser-header {
|
||||
grid-template-columns: minmax(0, 1fr) minmax(160px, 55%) minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
}
|
||||
.file-browser-header .workspace-brand span {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (max-width: 736px) {
|
||||
.file-browser-header {
|
||||
grid-template-columns: 40px minmax(0, 1fr) auto;
|
||||
gap: 8px;
|
||||
padding-inline: 10px;
|
||||
}
|
||||
.file-browser-header .workspace-brand {
|
||||
display: none;
|
||||
}
|
||||
.file-browser-header .menu-button {
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
@@ -28,34 +28,7 @@
|
||||
margin: 0;
|
||||
font-weight: 650;
|
||||
}
|
||||
.settings-tabs {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-bottom: 22px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid var(--borderPrimary);
|
||||
overflow-x: auto;
|
||||
}
|
||||
.settings-tabs a {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
padding: 10px 14px;
|
||||
border-radius: 8px;
|
||||
white-space: nowrap;
|
||||
font-size: 13px;
|
||||
color: var(--textPrimary);
|
||||
}
|
||||
.settings-tabs a:hover {
|
||||
background: var(--hover);
|
||||
}
|
||||
.settings-tabs a.router-link-active {
|
||||
background: var(--surfaceSecondary);
|
||||
color: var(--blue);
|
||||
}
|
||||
.settings-tabs .app-icon {
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
.preferences-form {
|
||||
width: 100%;
|
||||
padding-bottom: 12px;
|
||||
@@ -256,9 +229,7 @@
|
||||
.settings-page .settings-section {
|
||||
padding: 16px;
|
||||
}
|
||||
.settings-tabs a {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.account-summary {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
@@ -271,19 +242,6 @@
|
||||
height: 48px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.settings-tabs {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
overflow: visible;
|
||||
}
|
||||
.settings-tabs a {
|
||||
white-space: normal;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
.settings-tabs .app-icon {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
.settings-page .users-card > .users-table-wrap {
|
||||
padding: 0;
|
||||
@@ -349,3 +307,85 @@
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.admin-users-tile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
color: var(--textPrimary);
|
||||
}
|
||||
.admin-users-tile > .app-icon {
|
||||
color: var(--blue);
|
||||
font-size: 28px;
|
||||
}
|
||||
.admin-users-tile > span {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.admin-users-tile strong {
|
||||
display: block;
|
||||
font-size: 16px;
|
||||
}
|
||||
.admin-users-tile small {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
color: var(--textSecondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.admin-users-tile:hover {
|
||||
border-color: var(--blue);
|
||||
}
|
||||
.card.floating.users-management {
|
||||
width: calc(100% - 32px);
|
||||
max-width: 1000px;
|
||||
max-height: calc(100vh - 32px);
|
||||
max-height: calc(100dvh - 32px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0;
|
||||
}
|
||||
.users-management-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.users-management-heading h2 {
|
||||
margin: 0;
|
||||
}
|
||||
.users-management-body {
|
||||
overflow-y: auto;
|
||||
min-height: 0;
|
||||
padding: 16px;
|
||||
}
|
||||
.users-management-body > .card {
|
||||
margin: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
.users-management .user-edit {
|
||||
border: 0;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.users-management .card-action {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
background: var(--surfacePrimary);
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.card.floating.users-management {
|
||||
width: calc(100% - 16px);
|
||||
max-height: calc(100vh - 16px);
|
||||
max-height: calc(100dvh - 16px);
|
||||
}
|
||||
.users-management-body {
|
||||
padding: 8px;
|
||||
}
|
||||
.users-management .card-content {
|
||||
padding: 14px;
|
||||
}
|
||||
}
|
||||
@@ -386,7 +386,10 @@
|
||||
"actions": "Actions",
|
||||
"paste": "Paste",
|
||||
"refresh": "Refresh",
|
||||
"downloadFolderArchive": "Download folder archive"
|
||||
"downloadFolderArchive": "Download folder archive",
|
||||
"account": "Account",
|
||||
"adminSettings": "Administrative settings",
|
||||
"usersHint": "Manage user scope, permissions and access rules"
|
||||
},
|
||||
"preferences": {
|
||||
"appearance": "Appearance",
|
||||
@@ -399,5 +402,14 @@
|
||||
"notifications": {
|
||||
"success": "Done",
|
||||
"error": "Something went wrong"
|
||||
},
|
||||
"createTypes": {
|
||||
"text": "Text file",
|
||||
"markdown": "Markdown document",
|
||||
"csv": "CSV spreadsheet",
|
||||
"json": "JSON file",
|
||||
"html": "HTML page",
|
||||
"xml": "XML file",
|
||||
"other": "Other file"
|
||||
}
|
||||
}
|
||||
@@ -383,7 +383,10 @@
|
||||
"actions": "Действия",
|
||||
"paste": "Вставить",
|
||||
"refresh": "Обновить",
|
||||
"downloadFolderArchive": "Скачать папку архивом"
|
||||
"downloadFolderArchive": "Скачать папку архивом",
|
||||
"account": "Аккаунт",
|
||||
"adminSettings": "Административные настройки",
|
||||
"usersHint": "Область доступа, разрешения и правила пользователей"
|
||||
},
|
||||
"preferences": {
|
||||
"appearance": "Внешний вид",
|
||||
@@ -396,5 +399,14 @@
|
||||
"notifications": {
|
||||
"success": "Готово",
|
||||
"error": "Не удалось выполнить"
|
||||
},
|
||||
"createTypes": {
|
||||
"text": "Текстовый файл",
|
||||
"markdown": "Документ Markdown",
|
||||
"csv": "Таблица CSV",
|
||||
"json": "Файл JSON",
|
||||
"html": "Страница HTML",
|
||||
"xml": "Файл XML",
|
||||
"other": "Другой файл"
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,7 @@ import Login from "@/views/Login.vue";
|
||||
import Layout from "@/views/Layout.vue";
|
||||
import Files from "@/views/Files.vue";
|
||||
import Share from "@/views/Share.vue";
|
||||
const Users = () => import("@/views/settings/Users.vue");
|
||||
const User = () => import("@/views/settings/User.vue");
|
||||
|
||||
const Settings = () => import("@/views/Settings.vue");
|
||||
const GlobalSettings = () => import("@/views/settings/Global.vue");
|
||||
const ProfileSettings = () => import("@/views/settings/Profile.vue");
|
||||
@@ -23,7 +22,7 @@ const titles = {
|
||||
Settings: "sidebar.settings",
|
||||
ProfileSettings: "settings.profileSettings",
|
||||
Shares: "settings.shareManagement",
|
||||
GlobalSettings: "settings.globalSettings",
|
||||
GlobalSettings: "explorer.adminSettings",
|
||||
Users: "settings.users",
|
||||
User: "settings.user",
|
||||
Forbidden: "errors.forbidden",
|
||||
@@ -99,7 +98,7 @@ const routes = [
|
||||
{
|
||||
path: "users",
|
||||
name: "Users",
|
||||
component: Users,
|
||||
redirect: { path: "/settings/global", query: { users: "all" } },
|
||||
meta: {
|
||||
requiresAdmin: true,
|
||||
},
|
||||
@@ -107,7 +106,10 @@ const routes = [
|
||||
{
|
||||
path: "users/:id",
|
||||
name: "User",
|
||||
component: User,
|
||||
redirect: (to: RouteLocation) => ({
|
||||
path: "/settings/global",
|
||||
query: { users: String(to.params.id) },
|
||||
}),
|
||||
meta: {
|
||||
requiresAdmin: true,
|
||||
},
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { expect, it } from "vitest";
|
||||
import {
|
||||
fileTemplate,
|
||||
fileTemplates,
|
||||
templateFileName,
|
||||
} from "../file-templates";
|
||||
it("adds the chosen extension once, preserving names and rejecting blank input", () => {
|
||||
expect(templateFileName(" report ", ".txt")).toBe("report.txt");
|
||||
expect(templateFileName("report.TXT", ".txt")).toBe("report.TXT");
|
||||
expect(templateFileName(" ", ".txt")).toBe("");
|
||||
expect(templateFileName("scan.dcm", "")).toBe("scan.dcm");
|
||||
});
|
||||
it("provides valid starter content and a safe fallback for unknown template IDs", () => {
|
||||
expect(fileTemplate("missing").id).toBe("other");
|
||||
expect(fileTemplate(undefined).extension).toBe("");
|
||||
expect(JSON.parse(fileTemplate("json").content)).toEqual({});
|
||||
expect(fileTemplate("text").content).toBe("");
|
||||
expect(new Set(fileTemplates.map((template) => template.id)).size).toBe(
|
||||
fileTemplates.length
|
||||
);
|
||||
expect(
|
||||
fileTemplates.some((template) =>
|
||||
[".docx", ".xlsx", ".pptx"].includes(template.extension)
|
||||
)
|
||||
).toBe(false);
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
export const fileTemplates = [
|
||||
{ id: "text", extension: ".txt", icon: "article", content: "" },
|
||||
{ id: "markdown", extension: ".md", icon: "edit_note", content: "" },
|
||||
{ id: "csv", extension: ".csv", icon: "table", content: "" },
|
||||
{ id: "json", extension: ".json", icon: "code", content: "{}\n" },
|
||||
{
|
||||
id: "html",
|
||||
extension: ".html",
|
||||
icon: "code",
|
||||
content:
|
||||
'<!doctype html>\n<html lang="en">\n<head><meta charset="utf-8"><title></title></head>\n<body></body>\n</html>\n',
|
||||
},
|
||||
{
|
||||
id: "xml",
|
||||
extension: ".xml",
|
||||
icon: "code",
|
||||
content: '<?xml version="1.0" encoding="UTF-8"?>\n<root />\n',
|
||||
},
|
||||
{ id: "other", extension: "", icon: "note_add", content: "" },
|
||||
] as const;
|
||||
export function fileTemplate(id: unknown) {
|
||||
return (
|
||||
fileTemplates.find((template) => template.id === id) ||
|
||||
fileTemplates[fileTemplates.length - 1]
|
||||
);
|
||||
}
|
||||
export function templateFileName(name: string, extension: string) {
|
||||
const trimmed = name.trim();
|
||||
if (!trimmed) return "";
|
||||
return extension && !trimmed.toLowerCase().endsWith(extension)
|
||||
? trimmed + extension
|
||||
: trimmed;
|
||||
}
|
||||
@@ -2,32 +2,28 @@
|
||||
<div class="dashboard settings-page">
|
||||
<header-bar showMenu showLogo />
|
||||
<div class="settings-page-heading">
|
||||
<h1>{{ t("sidebar.settings") }}</h1>
|
||||
</div>
|
||||
<div class="settings-tabs" :aria-label="t('sidebar.settings')">
|
||||
<router-link to="/settings/profile"
|
||||
><AppIcon name="tune" />{{ t("settings.profileSettings") }}</router-link
|
||||
>
|
||||
<router-link v-if="authStore.user?.perm.share" to="/settings/shares"
|
||||
><AppIcon name="link" />{{ t("settings.shareManagement") }}</router-link
|
||||
>
|
||||
<router-link v-if="authStore.user?.perm.admin" to="/settings/global"
|
||||
><AppIcon name="dns" />{{ t("settings.globalSettings") }}</router-link
|
||||
>
|
||||
<router-link v-if="authStore.user?.perm.admin" to="/settings/users"
|
||||
><AppIcon name="group" />{{ t("settings.userManagement") }}</router-link
|
||||
>
|
||||
<h1>{{ heading }}</h1>
|
||||
</div>
|
||||
<p v-if="layout.loading" role="status">{{ t("files.loading") }}</p>
|
||||
<router-view />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { computed } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import { useLayoutStore } from "@/stores/layout";
|
||||
import HeaderBar from "@/components/header/HeaderBar.vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
const authStore = useAuthStore();
|
||||
const route = useRoute();
|
||||
const heading = computed(() =>
|
||||
t(
|
||||
route.name === "GlobalSettings"
|
||||
? "explorer.adminSettings"
|
||||
: route.name === "Shares"
|
||||
? "settings.shareManagement"
|
||||
: "sidebar.settings"
|
||||
)
|
||||
);
|
||||
const layout = useLayoutStore();
|
||||
</script>
|
||||
@@ -9,10 +9,7 @@
|
||||
:aria-expanded="isContextMenuVisible"
|
||||
@click.stop="openActions"
|
||||
>
|
||||
{{ t("explorer.actions")
|
||||
}}<span v-if="fileStore.selectedCount">
|
||||
({{ fileStore.selectedCount }})</span
|
||||
>
|
||||
{{ t("explorer.actions") }}
|
||||
</button>
|
||||
</header-bar>
|
||||
|
||||
@@ -221,18 +218,7 @@
|
||||
: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"
|
||||
/>
|
||||
<CreateMenu v-if="authStore.user?.perm.create" />
|
||||
<action
|
||||
v-if="headerButtons.upload"
|
||||
icon="upload"
|
||||
@@ -296,6 +282,7 @@ import HeaderBar from "@/components/header/HeaderBar.vue";
|
||||
import Action from "@/components/header/Action.vue";
|
||||
import Search from "@/components/Search.vue";
|
||||
import Item from "@/components/files/ListingItem.vue";
|
||||
import CreateMenu from "@/components/files/CreateMenu.vue";
|
||||
import ContextMenu from "@/components/ContextMenu.vue";
|
||||
import {
|
||||
computed,
|
||||
|
||||
@@ -6,6 +6,16 @@
|
||||
@submit.prevent="save"
|
||||
>
|
||||
<div class="settings-grid">
|
||||
<button
|
||||
type="button"
|
||||
class="card settings-section settings-wide admin-users-tile"
|
||||
@click="layoutStore.showHover('users-management')"
|
||||
>
|
||||
<AppIcon name="users" /><span
|
||||
><strong>{{ t("settings.userManagement") }}</strong
|
||||
><small>{{ t("explorer.usersHint") }}</small></span
|
||||
><AppIcon name="chevron_right" />
|
||||
</button>
|
||||
<section class="card settings-section">
|
||||
<h2><AppIcon name="archive" />{{ t("settings.downloadsTitle") }}</h2>
|
||||
<label class="settings-field"
|
||||
@@ -119,17 +129,7 @@
|
||||
</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 { useRoute } from "vue-router";
|
||||
import { settings as api } from "@/api";
|
||||
import { StatusError } from "@/api/utils";
|
||||
import Rules from "@/components/settings/Rules.vue";
|
||||
@@ -160,6 +160,25 @@ const $showSuccess = inject<IToastSuccess>("$showSuccess")!;
|
||||
const { t } = useI18n();
|
||||
|
||||
const layoutStore = useLayoutStore();
|
||||
const route = useRoute();
|
||||
onMounted(() => {
|
||||
if (route.query.users)
|
||||
layoutStore.showHover({
|
||||
prompt: "users-management",
|
||||
props: { userId: Number(route.query.users) },
|
||||
});
|
||||
});
|
||||
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",
|
||||
};
|
||||
|
||||
const formattedChunkSize = computed({
|
||||
get() {
|
||||
|
||||
@@ -21,9 +21,8 @@
|
||||
<rules v-model:rules="user.rules" />
|
||||
</div>
|
||||
<div class="card-action">
|
||||
<router-link to="/settings/users" class="button button--flat">{{
|
||||
$t("buttons.cancel")
|
||||
}}</router-link
|
||||
<button type="button" class="button button--flat" @click="emit('cancel')">
|
||||
{{ $t("buttons.cancel") }}</button
|
||||
><button class="button" :disabled="saving">
|
||||
{{ $t("buttons.save") }}
|
||||
</button>
|
||||
@@ -31,13 +30,15 @@
|
||||
</form>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, inject } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import { ref, watch, inject } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { users as api } from "@/api";
|
||||
import { StatusError } from "@/api/utils";
|
||||
import Errors from "@/views/Errors.vue";
|
||||
import Rules from "@/components/settings/Rules.vue";
|
||||
const route = useRoute();
|
||||
const props = defineProps<{ userId: number }>();
|
||||
const emit = defineEmits<{ cancel: []; saved: [] }>();
|
||||
const { t } = useI18n();
|
||||
const user = ref<IUser>();
|
||||
const error = ref<StatusError>();
|
||||
const saving = ref(false);
|
||||
@@ -51,19 +52,26 @@ const permissions = [
|
||||
"share",
|
||||
"download",
|
||||
] as const;
|
||||
onMounted(async () => {
|
||||
try {
|
||||
user.value = await api.get(Number(route.params.id));
|
||||
} catch (e) {
|
||||
error.value = e as StatusError;
|
||||
}
|
||||
});
|
||||
watch(
|
||||
() => props.userId,
|
||||
async (id) => {
|
||||
user.value = undefined;
|
||||
error.value = undefined;
|
||||
try {
|
||||
user.value = await api.get(id);
|
||||
} catch (e) {
|
||||
error.value = e as StatusError;
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
async function save() {
|
||||
if (!user.value || saving.value) return;
|
||||
saving.value = true;
|
||||
try {
|
||||
await api.update(user.value, ["scope", "perm", "rules"]);
|
||||
showSuccess("Saved");
|
||||
showSuccess(t("settings.settingsUpdated"));
|
||||
emit("saved");
|
||||
} catch (e) {
|
||||
showError(e as Error);
|
||||
} finally {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<errors v-if="error" :errorCode="error.status" />
|
||||
<section v-else-if="!layoutStore.loading" class="card users-card">
|
||||
<p v-else-if="busy" role="status">{{ t("files.loading") }}</p>
|
||||
<section v-else class="card users-card">
|
||||
<div class="card-title">
|
||||
<h2>{{ t("settings.users") }}</h2>
|
||||
</div>
|
||||
@@ -23,13 +24,15 @@
|
||||
</td>
|
||||
<td class="user-scope">{{ user.scope }}</td>
|
||||
<td>
|
||||
<router-link
|
||||
<button
|
||||
type="button"
|
||||
class="user-edit"
|
||||
:to="'/settings/users/' + user.id"
|
||||
@click="emit('edit', user.id)"
|
||||
:title="t('buttons.update')"
|
||||
:aria-label="t('buttons.update')"
|
||||
><AppIcon name="edit"
|
||||
/></router-link>
|
||||
>
|
||||
<AppIcon name="edit" />
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -38,7 +41,6 @@
|
||||
</section>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { useLayoutStore } from "@/stores/layout";
|
||||
import { users as api } from "@/api";
|
||||
import Errors from "@/views/Errors.vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
@@ -48,11 +50,12 @@ import { StatusError } from "@/api/utils";
|
||||
const error = ref<StatusError | null>(null);
|
||||
const users = ref<IUser[]>([]);
|
||||
|
||||
const layoutStore = useLayoutStore();
|
||||
const busy = ref(false);
|
||||
const emit = defineEmits<{ edit: [id: number] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
onMounted(async () => {
|
||||
layoutStore.loading = true;
|
||||
busy.value = true;
|
||||
|
||||
try {
|
||||
users.value = await api.getAll();
|
||||
@@ -61,7 +64,7 @@ onMounted(async () => {
|
||||
error.value = err;
|
||||
}
|
||||
} finally {
|
||||
layoutStore.loading = false;
|
||||
busy.value = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -1,4 +1,4 @@
|
||||
param([string]$Version = '3.0.0-sso.17')
|
||||
param([string]$Version = '3.0.0-sso.18')
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$repo = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
||||
Push-Location $repo
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
VERSION="${VERSION:-3.0.0-sso.17}"
|
||||
VERSION="${VERSION:-3.0.0-sso.18}"
|
||||
COMMIT=$(git rev-parse --short HEAD)
|
||||
(cd frontend && pnpm install --frozen-lockfile && pnpm run build)
|
||||
mkdir -p build/release/linux-amd64
|
||||
|
||||
Reference in new issue
Block a user