ban dynamic i18n keys

This commit is contained in:
Kevin B. committed 2026-11-14 18:16:32 -05:00
1 parent c48792bd51
commit 21b2858945
27 files changed
+263 -303

No files matched your search

@@ -5,7 +5,7 @@ import path from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { maskJs, maskSource } from "../shared.ts";
import { syncTranslations } from "../sync.ts";
import { literalCalls } from "../types.ts";
import { dynamicCalls, isPassedAround, literalCalls } from "../types.ts";
// The sync reads and writes the locales folder: point it at a temporary one.
const dir = await vi.hoisted(async () => {
@@ -244,3 +244,54 @@ describe("literalCalls", () => {
expect(call?.params.names).toEqual(new Set(["count", "other"]));
});
});
describe("dynamicCalls", () => {
const dynamic = (source: string) => [...dynamicCalls(maskJs(source), maskJs(source, true))].map((call) => call.index);
it("flags a key held in a variable or a property", () => {
expect(dynamic("t(key)")).toEqual([0]);
expect(dynamic("this.$t(tool.name)")).toEqual([0]);
expect(dynamic("i18n.global.t(i18nKey || 'a.b')")).toEqual([0]);
});
it("flags a key built from a template literal or a concatenation", () => {
expect(dynamic("t(`tools.${view}View`)")).toEqual([0]);
expect(dynamic("$t('prompts.' + name)")).toEqual([0]);
expect(dynamic("t(`a.b` + suffix)")).toEqual([0]);
});
it("flags a dynamic key whatever its params are", () => {
expect(dynamic('$t(section.label, { suffix: "" })')).toEqual([0]);
});
it("accepts string literals, with or without params", () => {
expect(dynamic("t('a.b')")).toEqual([]);
expect(dynamic('$t("a.b", { count: n })')).toEqual([]);
expect(dynamic("t(`a.b`)")).toEqual([]);
expect(dynamic("this.$t( 'a.b' )")).toEqual([]);
});
it("ignores calls in comments and strings, and names that only end in t", () => {
expect(dynamic('// t(key)\nconst s = "t(key)";')).toEqual([]);
expect(dynamic("list.insert(key); sort(key); a.t(key)")).toEqual([]);
});
it("finds a dynamic call inside a template expression and reports each call", () => {
expect(dynamic("const a = `${t(key)}`;")).toEqual([13]);
expect(dynamic("t(a); t('ok.key'); $t(b)")).toEqual([0, 19]);
});
});
describe("isPassedAround", () => {
it("flags $t used as a value", () => {
expect(isPassedAround("return buildRows(this.info, this.$t, locale);")).toBe(true);
expect(isPassedAround("this.$t.bind(this)")).toBe(true);
expect(isPassedAround("export function label(value, $t) {")).toBe(true);
});
it("accepts calls and unrelated names", () => {
expect(isPassedAround('return this.$t("a.b");')).toBe(false);
expect(isPassedAround("$t ('a.b')")).toBe(false);
expect(isPassedAround("const $total = 1; const a$t = 2;")).toBe(false);
});
});
+2 -5
View File
@@ -34,13 +34,10 @@ interface TemplateNode {
/** The code of a source file that can use a key -- comments and <style> blocks are dropped */
const codeOf = (file: string) => maskSource(file, fs.readFileSync(file, "utf8"));
/** Every key in en.json must appear as a string literal in src/ or match a dynamic prefix */
/** Every key in en.json must appear as a string literal in src/ */
export function checkUnusedKeys(): string[] {
const code = [...sourceFiles()].filter((file) => !isTestFile(file)).map(codeOf).join("\n");
const prefixes = [...code.matchAll(/\bt\(\s*["'`]([\w.-]+\.)(?:\$\{|["'`]\s*\+)/g)].map((match) => match[1] ?? "");
const isUsed = (key: string) =>
["'", '"', "`"].some((quote) => code.includes(`${quote}${key}${quote}`)) ||
prefixes.some((prefix) => key.startsWith(prefix));
const isUsed = (key: string) => ["'", '"', "`"].some((quote) => code.includes(`${quote}${key}${quote}`));
return Object.keys(readLocale("en.json"))
.filter((key) => !isUsed(key))
.map((key) => `en.json: unused key ${key}`);
+1 -1
View File
@@ -3,7 +3,7 @@
* npm run i18n:sync regenerate the types, translate new keys (DEEPL_API_KEY)
* npm run i18n:enforce-order regenerate the types, reorder locales like en.json
* npm run i18n:cleanup regenerate the types, remove obsolete keys
* npm run i18n:check locale list, translations, types, unused keys and raw text
* npm run i18n:check locale list, translations, types, dynamic keys, unused keys and raw text
* npm run i18n:check:strict checks for raw `$t` and 'vue-i18n' imports, including JS files
*/
+22
View File
@@ -109,6 +109,10 @@ const BYPASS_RULES = [
},
];
/** `$t` that isn't called: `helper(this.$t)`, `this.$t.bind(this)` or a `$t` parameter. The helper keys can't be type-checked */
const PASSED_AROUND = /(^|[^\w$])\$t\b(?!\s*\()/;
export const isPassedAround = (line: string) => PASSED_AROUND.test(line);
// The start of a t(...) call: t(, $t(, this.$t( or i18n.global.t(
const CALL_START = /(?:(?<![\w$.])(?:\$t|t|i18n\.global\.t)|\bthis\.\$t)\(/g;
@@ -241,6 +245,16 @@ export function* literalCalls(text: string, bare: string): Generator<{ key: stri
}
}
export function* dynamicCalls(text: string, bare: string): Generator<{ index: number }> {
const literal = new Set<number>();
for (const call of literalCalls(text, bare)) literal.add(call.index);
for (const match of bare.matchAll(CALL_START)) {
if (literal.has(match.index)) continue;
if (text.charAt(skipSpaces(text, match.index + match[0].length)) === ")") continue; // t() without a key, vue-tsc reports it
yield { index: match.index };
}
}
function checkCall(key: string, params: Params, messages: Messages): string[] {
const expected = messages[key];
if (expected === undefined) return [`unknown translation key "${key}"`];
@@ -273,11 +287,19 @@ function checkTypedUsage(messages: Messages, strict: boolean): string[] {
}
}
}
if (!strict && !isTypeScript(file, text)) {
for (const [index, line] of bare.split("\n").entries()) {
if (isPassedAround(line)) problems.push(`${rel(file)}:${index + 1}: $t is passed around as a value, import i18n from '@/i18n/index.ts' and call t() with a literal key in the helper instead`);
}
}
for (const call of literalCalls(code, bare)) {
for (const problem of checkCall(call.key, call.params, messages)) {
problems.push(`${rel(file)}:${lineOf(text, call.index)}: ${problem}`);
}
}
for (const call of dynamicCalls(code, bare)) {
problems.push(`${rel(file)}:${lineOf(text, call.index)}: dynamic translation key, call t() with a string literal so the key is type-checked and found by the unused keys check`);
}
}
return problems;
}
+4 -4
View File
@@ -366,7 +366,7 @@ function passkeyActorPasswordCancelledError() {
return err
}
function promptPasskeyActorPassword(i18nKey) {
function promptPasskeyActorPassword() {
return new Promise((resolve, reject) => {
let settled = false
const finish = (fn, value) => {
@@ -382,7 +382,7 @@ function promptPasskeyActorPassword(i18nKey) {
finish(reject, passkeyActorPasswordCancelledError())
},
props: {
infoText: i18n.global.t(i18nKey || 'prompts.confirmPasswordToSaveUser'),
infoText: i18n.global.t('prompts.confirmPasswordToSaveUser'),
submitLabel: i18n.global.t('general.confirm'),
submitCallback: async (actorPassword) => {
finish(resolve, actorPassword)
@@ -442,7 +442,7 @@ export async function beginPasskeyRegistration(options = {}) {
if (!canRetry) {
throw err
}
const actorPassword = await promptPasskeyActorPassword(options.actorPasswordPromptI18nKey)
const actorPassword = await promptPasskeyActorPassword()
return beginPasskeyRegistration({
...options,
actorPassword,
@@ -479,7 +479,7 @@ export async function deletePasskeyCredential(credentialId, options = {}) {
if (!canRetry) {
throw err
}
const actorPassword = await promptPasskeyActorPassword(options.actorPasswordPromptI18nKey)
const actorPassword = await promptPasskeyActorPassword()
return deletePasskeyCredential(credentialId, {
...options,
actorPassword,
+3 -12
View File
@@ -33,7 +33,6 @@ export async function get(username, options = {}) {
// POST /api/users (create user)
// Password-login: tries without X-Password first; on 401 requiring X-Password, opens the prompt and retries.
// options.skipActorPasswordConfirm / pre-set X-Password skip that flow.
// options.actorPasswordPromptI18nKey — optional vue-i18n key (default: confirmPasswordToSaveUser).
export async function create(user, options = {}) {
const mergedHeaders = { ...(options.headers || {}) }
const apiPath = getApiPath('users')
@@ -64,13 +63,11 @@ export async function create(user, options = {}) {
if (!needsActorPasswordRetry(e)) {
throw e
}
const promptKey =
options.actorPasswordPromptI18nKey || 'prompts.confirmPasswordToSaveUser'
return new Promise((resolve, reject) => {
mutations.showPrompt({
name: 'password',
props: {
infoText: i18n.global.t(promptKey),
infoText: i18n.global.t('prompts.confirmPasswordToSaveUser'),
submitLabel: i18n.global.t('general.confirm'),
submitCallback: async (actorPassword) => {
try {
@@ -96,7 +93,6 @@ export async function create(user, options = {}) {
// PATCH /api/users (update user)
// Password-login: tries without X-Password first; on 401 requiring X-Password, opens the prompt and retries.
// options.skipActorPasswordConfirm / pre-set X-Password skip that flow.
// options.actorPasswordPromptI18nKey — optional vue-i18n key (default: confirmPasswordToSaveUser).
export async function update(user, which, options = {}) {
if (!Array.isArray(which) || which.length === 0) {
throw new Error('users.update requires a non-empty which array of field names')
@@ -145,13 +141,11 @@ export async function update(user, which, options = {}) {
if (!needsActorPasswordRetry(e)) {
throw e
}
const promptKey =
options.actorPasswordPromptI18nKey || 'prompts.confirmPasswordToSaveUser'
return new Promise((resolve, reject) => {
mutations.showPrompt({
name: 'password',
props: {
infoText: i18n.global.t(promptKey),
infoText: i18n.global.t('prompts.confirmPasswordToSaveUser'),
submitLabel: i18n.global.t('general.confirm'),
submitCallback: async (actorPassword) => {
try {
@@ -187,7 +181,6 @@ export async function patchPinnedItem({ source, path, name, action = 'add' }) {
// DELETE /api/users (remove user)
// Password-login: tries without X-Password first; on 401 requiring X-Password, opens the prompt and retries.
// options.skipActorPasswordConfirm / pre-set X-Password skip that flow.
// options.actorPasswordPromptI18nKey — optional vue-i18n key (default: confirmPasswordToSaveUser).
export async function deleteUser(username, options = {}) {
const mergedHeaders = { ...(options.headers || {}) }
const apiPath = getApiPath('users', { username: username })
@@ -209,13 +202,11 @@ export async function deleteUser(username, options = {}) {
if (!needsActorPasswordRetry(e)) {
throw e
}
const promptKey =
options.actorPasswordPromptI18nKey || 'prompts.confirmPasswordToSaveUser'
return new Promise((resolve, reject) => {
mutations.showPrompt({
name: 'password',
props: {
infoText: i18n.global.t(promptKey),
infoText: i18n.global.t('prompts.confirmPasswordToSaveUser'),
submitLabel: i18n.global.t('general.confirm'),
submitCallback: async (actorPassword) => {
try {
+29 -26
View File
@@ -10,6 +10,7 @@
</template>
<script>
import i18n from "@/i18n/index.ts";
import { state } from "@/store/index.ts";
import { fromNow } from "@/utils/moment.ts";
import SettingsTable from "@/components/settings/Table.vue";
@@ -33,29 +34,31 @@ export default {
];
},
rows() {
return buildIndexInfoRows(this.info, this.$t, state.user?.locale);
return buildIndexInfoRows(this.info, state.user?.locale);
},
},
};
const t = i18n.global.t.bind(i18n.global);
// Export utility functions for use in other components (e.g., generating tooltip HTML)
export function getComplexityLabel(complexity, $t) {
export function getComplexityLabel(complexity) {
// Frontend interprets: 0=unknown, 1=simple, 2-6=normal, 7-9=complex, 10=highlyComplex
if (complexity === 0) return $t("general.unknown");
if (complexity === 1) return $t("general.simple");
if (complexity >= 2 && complexity <= 6) return $t("general.normal");
if (complexity >= 7 && complexity <= 9) return $t("general.complex");
if (complexity === 10) return $t("index.highlyComplex");
return $t("general.unknown");
if (complexity === 0) return t("general.unknown");
if (complexity === 1) return t("general.simple");
if (complexity >= 2 && complexity <= 6) return t("general.normal");
if (complexity >= 7 && complexity <= 9) return t("general.complex");
if (complexity === 10) return t("index.highlyComplex");
return t("general.unknown");
}
export function getStatusLabel(status, $t) {
export function getStatusLabel(status) {
switch (status) {
case "ready": return $t("index.ready");
case "indexing": return $t("index.indexing");
case "unavailable": return $t("index.unavailable");
case "error": return $t("general.error");
default: return $t("general.unknown");
case "ready": return t("index.ready");
case "indexing": return t("index.indexing");
case "unavailable": return t("index.unavailable");
case "error": return t("general.error");
default: return t("general.unknown");
}
}
@@ -71,22 +74,22 @@ export function formatDuration(seconds) {
return Number(seconds);
}
export function formatBooleanYesNo(value, $t) {
return value ? $t("general.yes") : $t("general.no");
export function formatBooleanYesNo(value) {
return value ? t("general.yes") : t("general.no");
}
/** @returns {{ id: string, label: string, value: string | number }[]} */
export function buildIndexInfoRows(info, $t, locale) {
export function buildIndexInfoRows(info, locale) {
return [
{ id: "status", label: $t("general.status"), value: getStatusLabel(info.status, $t) },
{ id: "readOnly", label: $t("general.readOnly"), value: formatBooleanYesNo(info.readOnly, $t) },
{ id: "private", label: $t("general.private"), value: formatBooleanYesNo(info.private, $t) },
{ id: "assessment", label: $t("index.assessment"), value: getComplexityLabel(info.complexity || 0, $t) },
{ id: "files", label: $t("general.files"), value: info.files || 0 },
{ id: "folders", label: $t("general.folders"), value: info.folders || 0 },
{ id: "lastScanned", label: $t("index.lastScanned"), value: getHumanReadableTime(info.lastIndex, locale) },
{ id: "quickScan", label: $t("index.quickScan"), value: formatDuration(info.quickScanDurationSeconds) },
{ id: "fullScan", label: $t("index.fullScan"), value: formatDuration(info.fullScanDurationSeconds) },
{ id: "status", label: t("general.status"), value: getStatusLabel(info.status) },
{ id: "readOnly", label: t("general.readOnly"), value: formatBooleanYesNo(info.readOnly) },
{ id: "private", label: t("general.private"), value: formatBooleanYesNo(info.private) },
{ id: "assessment", label: t("index.assessment"), value: getComplexityLabel(info.complexity || 0) },
{ id: "files", label: t("general.files"), value: info.files || 0 },
{ id: "folders", label: t("general.folders"), value: info.folders || 0 },
{ id: "lastScanned", label: t("index.lastScanned"), value: getHumanReadableTime(info.lastIndex, locale) },
{ id: "quickScan", label: t("index.quickScan"), value: formatDuration(info.quickScanDurationSeconds) },
{ id: "fullScan", label: t("index.fullScan"), value: formatDuration(info.fullScanDurationSeconds) },
];
}
</script>
@@ -50,7 +50,7 @@ export default {
},
computed: {
eventLabel() {
return activityEventLabel(this.row.eventType, this.$t);
return activityEventLabel(this.row.eventType);
},
detailColumns() {
return [
@@ -102,7 +102,7 @@ export default {
return rows;
},
detailRows() {
return buildActivityDetailRows(this.row, this.$t);
return buildActivityDetailRows(this.row);
},
},
};
@@ -53,7 +53,7 @@
</div>
<div v-for="profile in profiles" :key="profile.id" class="settings-items">
<h3>{{ $t(profile.label) }}</h3>
<h3>{{ profile.label() }}</h3>
<ToggleSwitch
class="item"
v-model="media.transcode.profiles[profile.id].enabled"
@@ -159,10 +159,10 @@ const currentQueueIndex = computed(() => state.playbackQueue.currentIndex);
const playbackMode = computed(() => state.playbackQueue.mode || 'single');
const loop = computed(() => state.playbackQueue.loop || 'off');
const queueCount = computed(() => playbackQueue.value.length);
const currentModeLabel = computed(() => getModeLabel(playbackMode.value, t, queueCount.value));
const currentModeLabel = computed(() => getModeLabel(playbackMode.value, queueCount.value));
const currentModeIcon = computed(() => getModeIcon(playbackMode.value));
const loopIcon = computed(() => getLoopIcon(loop.value));
const loopLabel = computed(() => getLoopLabel(loop.value, t));
const loopLabel = computed(() => getLoopLabel(loop.value));
const isPlaying = computed(() => state.playbackQueue.isPlaying || false);
const isPromptVisible = computed(() => state.prompts.some(prompt => prompt.name === 'PlaybackQueue'));
const modeTabs = computed(() => [
@@ -12,7 +12,6 @@
default-sort-key="path"
:aria-label="$t('sidebar.chooseShare')"
row-clickable
:lonely-message-key="shares.length === 0 ? 'tools.activityViewer.noShares' : undefined"
@row-click="selectShare"
>
<template #cell-path="{ row }">
+3 -12
View File
@@ -1172,9 +1172,7 @@ export default {
label: this.$t("general.delete"),
action: async () => {
try {
await usersApi.deleteUser(this.user.username, {
actorPasswordPromptI18nKey: "prompts.confirmPasswordToSaveUser",
});
await usersApi.deleteUser(this.user.username);
notify.showSuccessToast(this.$t("settings.userDeleted"));
eventBus.emit('usersChanged');
mutations.closeTopPrompt(); // close delete user prompt confirmation
@@ -1267,12 +1265,7 @@ export default {
}
// Skip creation on a retry after the user was created but a group change failed.
if (!this.createdUser) {
await usersApi.create(
payload,
{
actorPasswordPromptI18nKey: "prompts.confirmPasswordToSaveUser",
}
);
await usersApi.create(payload);
this.createdUser = true;
}
await this.saveGroups(payload.username);
@@ -1327,9 +1320,7 @@ export default {
return;
}
try {
await usersApi.update(this.user, ["password"], {
actorPasswordPromptI18nKey: "prompts.confirmPasswordToSaveUser",
});
await usersApi.update(this.user, ["password"]);
eventBus.emit("usersChanged");
notify.showSuccessToast(this.$t("settings.userUpdated"));
} catch (e) {
+4 -4
View File
@@ -153,10 +153,10 @@ export default {
type: String,
default: "",
},
/** i18n key for empty-state caption (icon + label), default `files.lonely`. */
lonelyMessageKey: {
/** Translated empty-state caption (icon + label), default `files.lonely`. */
lonelyMessage: {
type: String,
default: "files.lonely",
default: undefined,
},
/** Override default sort detection: first column sortable ascending. */
defaultSortKey: {
@@ -199,7 +199,7 @@ export default {
return Math.max(n, 1);
},
lonelyCaption() {
return this.$t(this.lonelyMessageKey);
return this.lonelyMessage ?? this.$t("files.lonely");
},
sortedItems() {
const list = [...(this.items ?? [])];
+2 -2
View File
@@ -58,7 +58,7 @@
>
<span class="settings-item-content">
<span class="material-symbols-outlined settings-icon">{{ section.icon }}</span>
{{ $t(section.label, { suffix: "" }) }}
{{ section.label() }}
</span>
</div>
</div>
@@ -180,7 +180,7 @@ export default {
case "users":
return this.$t("general.userManagement");
default:
return this.$t(setting.label);
return setting.label?.() ?? "";
}
},
},
@@ -513,7 +513,7 @@ export default {
sourcePath: "",
},
availableTools: [
{ id: 'tools-hub', name: 'tools.title', path: '/tools', icon: 'build' },
{ id: 'tools-hub', name: this.$t('tools.title'), path: '/tools', icon: 'build' },
...availableTools(),
],
availableShares: [],
@@ -656,7 +656,7 @@ export default {
toolTargetOptions() {
return this.availableTools.map((tool) => ({
value: tool.path,
label: this.$t(tool.name),
label: tool.name,
}));
},
usageTextModeOptions() {
@@ -805,7 +805,7 @@ export default {
return;
}
const mainEntry = this.availableTools.find((t) => t.path === "/tools");
const name = mainEntry ? this.$t(mainEntry.name) : this.$t("tools.title");
const name = mainEntry ? mainEntry.name : this.$t("tools.title");
const icon = mainEntry ? mainEntry.icon : "build";
this.links.push({
name,
@@ -1042,24 +1042,13 @@ export default {
return link.name || this.$t('general.divider');
}
// Check if the name looks like a translation key that needs translating
// Links saved with the translation key as their name
if (link.category === 'shareInfo' && link.name === 'share.shareInfo') {
return this.$t('share.shareInfo');
}
if (link.category === 'download' && link.name === 'general.download') {
return this.$t('general.download');
}
// Check if it's a general translation key pattern
if (typeof link.name === 'string' && link.name.includes('.') && link.name.split('.').length === 2) {
// Try to translate, if it fails, return original
try {
const translated = this.$t(link.name);
// If translation returns the same key, it means it doesn't exist, return original
return translated !== link.name ? translated : link.name;
} catch (_e) {
return link.name;
}
}
return link.name;
},
resetNewLinkFormForTypeSwitch() {
@@ -1126,7 +1115,7 @@ export default {
if (tool) {
// Only set default name and icon if user hasn't entered them yet
if (!this.newLink.name) {
this.newLink.name = this.$t(tool.name);
this.newLink.name = tool.name;
}
if (!this.newLink.icon) {
this.newLink.icon = tool.icon;
@@ -39,7 +39,7 @@ export default {
];
},
rows() {
return buildActivityDetailRows(this.row, this.$t);
return buildActivityDetailRows(this.row);
},
},
};
+14 -15
View File
@@ -2,7 +2,7 @@
import type { RouteLocation, RouteRecordRaw } from "vue-router";
import { createRouter, createWebHistory } from "vue-router";
import i18n, { type PlainMessageKey } from "@/i18n/index.ts";
import i18n from "@/i18n/index.ts";
import { getters, mutations, state } from "@/store/index.ts";
import { validateLogin } from "@/utils/auth.js";
import { sanitizePostLoginRedirect } from "@/utils/safeRedirect.js";
@@ -19,27 +19,26 @@ import Login from "@/views/Login.vue";
import Settings from "@/views/Settings.vue";
import Tools from "@/views/Tools.vue";
const translate = (key: PlainMessageKey): string => i18n.global.t(key);
const t = i18n.global.t.bind(i18n.global);
const titles = (): Record<string, string> => ({
Login: translate("general.login"),
Share: translate("general.share"),
Login: t("general.login"),
Share: t("general.share"),
/** Same component as Share; name differs for /public optional-auth routes. */
PublicShare: translate("general.share"),
Files: translate("general.files"),
Tools: translate("tools.title"),
ChildTool: translate("tools.title"),
Settings: translate("general.settings"),
PublicShare: t("general.share"),
Files: t("general.files"),
Tools: t("tools.title"),
ChildTool: t("tools.title"),
Settings: t("general.settings"),
ProfileSettings: `${t("general.profile")} ${t("general.settings")}`,
Shares: `${t("general.share")} ${t("general.management")}`,
GlobalSettings: `${t("general.global")} ${t("general.settings")}`,
Users: translate("general.users"),
User: translate("general.user"),
Forbidden: translate("errors.forbidden"),
NotFound: translate("errors.notFound"),
ShareNotFound: translate("errors.shareNotFound"),
InternalServerError: translate("errors.internal"),
Users: t("general.users"),
User: t("general.user"),
Forbidden: t("errors.forbidden"),
NotFound: t("errors.notFound"),
ShareNotFound: t("errors.shareNotFound"),
InternalServerError: t("errors.internal"),
});
const routes: RouteRecordRaw[] = [
+61 -57
View File
@@ -1,68 +1,72 @@
import i18n from "@/i18n/index.ts";
const t = i18n.global.t.bind(i18n.global);
/**
* Label for an activity event type.
*/
export function activityEventLabel(eventType, $t) {
export function activityEventLabel(eventType) {
switch (eventType) {
case "download":
return $t("general.download");
return t("general.download");
case "move":
return $t("general.move");
return t("general.move");
case "copy":
return $t("general.copy");
return t("general.copy");
case "rename":
return $t("general.rename");
return t("general.rename");
case "upload":
return $t("general.upload");
return t("general.upload");
case "fileModify":
return $t("tools.activityViewer.eventFileModify");
return t("tools.activityViewer.eventFileModify");
case "delete":
return $t("general.delete");
return t("general.delete");
case "login":
return $t("general.login");
return t("general.login");
case "logout":
return $t("general.logout");
return t("general.logout");
case "signup":
return $t("general.signup");
return t("general.signup");
case "archive":
return $t("prompts.archive");
return t("prompts.archive");
case "unarchive":
return $t("prompts.unarchive");
return t("prompts.unarchive");
case "duplicateFinder":
return $t("tools.duplicateFinder.name");
return t("tools.duplicateFinder.name");
case "bulkDelete":
return $t("tools.activityViewer.eventBulkDelete");
return t("tools.activityViewer.eventBulkDelete");
case "shareCreate":
return $t("tools.activityViewer.eventShareCreate");
return t("tools.activityViewer.eventShareCreate");
case "shareUpdate":
return $t("tools.activityViewer.eventShareUpdate");
return t("tools.activityViewer.eventShareUpdate");
case "shareDelete":
return $t("tools.activityViewer.eventShareDelete");
return t("tools.activityViewer.eventShareDelete");
case "userCreate":
return $t("tools.activityViewer.eventUserCreate");
return t("tools.activityViewer.eventUserCreate");
case "userUpdate":
return $t("tools.activityViewer.eventUserUpdate");
return t("tools.activityViewer.eventUserUpdate");
case "userDelete":
return $t("tools.activityViewer.eventUserDelete");
return t("tools.activityViewer.eventUserDelete");
case "accessCreate":
return $t("tools.activityViewer.eventAccessCreate");
return t("tools.activityViewer.eventAccessCreate");
case "accessUpdate":
return $t("tools.activityViewer.eventAccessUpdate");
return t("tools.activityViewer.eventAccessUpdate");
case "accessDelete":
return $t("tools.activityViewer.eventAccessDelete");
return t("tools.activityViewer.eventAccessDelete");
case "quotaCreate":
return $t("general.create");
return t("general.create");
case "quotaUpdate":
return $t("general.update");
return t("general.update");
case "quotaDelete":
return $t("general.delete");
return t("general.delete");
case "tokenCreate":
return $t("tools.activityViewer.eventTokenCreate");
return t("tools.activityViewer.eventTokenCreate");
case "tokenDelete":
return $t("tools.activityViewer.eventTokenDelete");
return t("tools.activityViewer.eventTokenDelete");
case "passkeyRegister":
return $t("tools.activityViewer.passkeyRegister");
return t("tools.activityViewer.passkeyRegister");
case "passkeyDelete":
return $t("tools.activityViewer.passkeyDelete");
return t("tools.activityViewer.passkeyDelete");
default:
return eventType;
}
@@ -132,27 +136,27 @@ export function activityEventTypeBadgeClass(eventType) {
* Chart title for grouped activity views.
* @param {{ viewType: string, splitBy: string }} options
*/
export function activityChartTitle({ viewType, splitBy }, $t) {
const eventTypeSubject = $t("tools.activityViewer.subjectEventType");
const userSubject = $t("general.user").toLowerCase();
export function activityChartTitle({ viewType, splitBy }) {
const eventTypeSubject = t("tools.activityViewer.subjectEventType");
const userSubject = t("general.user").toLowerCase();
if (viewType === "pie") {
return $t("tools.activityViewer.activityBy", {
return t("tools.activityViewer.activityBy", {
subject: splitBy === "user" ? userSubject : eventTypeSubject,
});
}
if (viewType === "summary") {
return splitBy === "user"
? $t("tools.activityViewer.activityTotalsBy", { subject: userSubject })
: $t("tools.activityViewer.eventTotals");
? t("tools.activityViewer.activityTotalsBy", { subject: userSubject })
: t("tools.activityViewer.eventTotals");
}
if (splitBy === "user") {
return $t("tools.activityViewer.activityOverTimeBy", { subject: userSubject });
return t("tools.activityViewer.activityOverTimeBy", { subject: userSubject });
}
if (splitBy === "none") {
return $t("tools.activityViewer.activityOverTime");
return t("tools.activityViewer.activityOverTime");
}
return $t("tools.activityViewer.activityOverTimeBy", { subject: eventTypeSubject });
return t("tools.activityViewer.activityOverTimeBy", { subject: eventTypeSubject });
}
/** Toggleable activity table columns (time, username, and event type are always shown). */
@@ -304,18 +308,18 @@ export function normalizeActivityTableRow(row) {
/**
* Human-readable token label for the activity table.
*/
export function activityTokenDisplay(row, $t) {
export function activityTokenDisplay(row) {
const name = activityRowTokenName(row);
const authMethod = row?.authMethod || row?.details?.authMethod || "";
if (name) {
if (authMethod === "webToken" && name.startsWith("WEB_TOKEN_")) {
const suffix = name.slice("WEB_TOKEN_".length);
return $t("tools.activityViewer.webSessionNamed", { name: suffix });
return t("tools.activityViewer.webSessionNamed", { name: suffix });
}
return name;
}
if (authMethod === "webToken") {
return $t("tools.activityViewer.webSession");
return t("tools.activityViewer.webSession");
}
return "";
}
@@ -356,7 +360,7 @@ function formatActivityFieldChange(change, eventType) {
* Build label/value rows for activity detail tooltips (admin).
* @returns {{ id: string, label: string, value: string }[]}
*/
export function buildActivityDetailRows(row, $t) {
export function buildActivityDetailRows(row) {
if (!row) return [];
const d = row.details || {};
@@ -366,7 +370,7 @@ export function buildActivityDetailRows(row, $t) {
if (targetUser) {
rows.push({
id: "targetUser",
label: $t("general.user"),
label: t("general.user"),
value: targetUser,
});
}
@@ -379,7 +383,7 @@ export function buildActivityDetailRows(row, $t) {
});
rows.push({
id: "scopes",
label: $t("general.sources"),
label: t("general.sources"),
value: scopeLines.join("\n"),
});
}
@@ -399,7 +403,7 @@ export function buildActivityDetailRows(row, $t) {
if (d.affectedTokenName) {
rows.push({
id: "affectedToken",
label: $t("tools.activityViewer.affectedToken"),
label: t("tools.activityViewer.affectedToken"),
value: d.affectedTokenName,
});
}
@@ -408,25 +412,25 @@ export function buildActivityDetailRows(row, $t) {
if (tokenName && !row?.tokenName) {
rows.push({
id: "token",
label: $t("tools.activityViewer.actorToken"),
label: t("tools.activityViewer.actorToken"),
value: tokenName,
});
}
if (d.loginMethod) {
rows.push({ id: "loginMethod", label: $t("settings.loginMethod"), value: d.loginMethod });
rows.push({ id: "loginMethod", label: t("settings.loginMethod"), value: d.loginMethod });
}
if (d.passkeyName) {
rows.push({ id: "passkey", label: $t("profileSettings.passkeyDefaultName"), value: d.passkeyName });
rows.push({ id: "passkey", label: t("profileSettings.passkeyDefaultName"), value: d.passkeyName });
}
if (d.cached) {
rows.push({ id: "cached", label: $t("tools.activityViewer.cachedResult"), value: $t("general.yes") });
rows.push({ id: "cached", label: t("tools.activityViewer.cachedResult"), value: t("general.yes") });
}
const paths = Array.isArray(d.paths) ? d.paths : [];
if (paths.length > 1) {
rows.push({
id: "paths",
label: $t("general.paths"),
label: t("general.paths"),
value: paths.join("\n"),
});
}
@@ -434,25 +438,25 @@ export function buildActivityDetailRows(row, $t) {
if (d.targetPath || row.targetPath) {
rows.push({
id: "targetPath",
label: $t("general.path"),
label: t("general.path"),
value: d.targetPath || row.targetPath,
});
}
if (d.fileCount > 1 && paths.length <= 1) {
rows.push({ id: "fileCount", label: $t("general.files"), value: String(d.fileCount) });
rows.push({ id: "fileCount", label: t("general.files"), value: String(d.fileCount) });
}
if (d.bytes > 0) {
rows.push({ id: "bytes", label: $t("general.size"), value: String(d.bytes) });
rows.push({ id: "bytes", label: t("general.size"), value: String(d.bytes) });
}
if (d.durationMs > 0) {
rows.push({
id: "durationMs",
label: $t("files.duration"),
label: t("files.duration"),
value: `${d.durationMs} ms`,
});
}
if (d.error) {
rows.push({ id: "error", label: $t("general.error"), value: d.error });
rows.push({ id: "error", label: t("general.error"), value: d.error });
}
return rows;
+2 -2
View File
@@ -33,7 +33,7 @@ describe("access activity detail formatting", () => {
};
it("shows create properties without from/to arrows", () => {
const rows = buildActivityDetailRows(createRow, (key) => key);
const rows = buildActivityDetailRows(createRow);
expect(rows.find((row) => row.id === "change-ruleType")?.value).toBe("deny");
expect(rows.find((row) => row.id === "change-value")?.value).toBe("admin");
});
@@ -46,7 +46,7 @@ describe("access activity detail formatting", () => {
});
it("shows update changes with from/to arrows", () => {
const rows = buildActivityDetailRows(updateRow, (key) => key);
const rows = buildActivityDetailRows(updateRow);
expect(rows.find((row) => row.id === "change-oldPath")?.value).toBe("/a → /b");
});
});
+19 -18
View File
@@ -1,4 +1,4 @@
import i18n, { type PlainMessageKey } from "@/i18n/index.ts";
import i18n from "@/i18n/index.ts";
import { getIconClass } from "./material-symbols.js";
declare global {
@@ -20,14 +20,15 @@ const origin = window.location.origin;
export interface SettingsSection {
id: string;
label?: PlainMessageKey;
/** Translated on every call, so the label follows the current locale */
label?: () => string;
component?: string;
icon: string;
permissions?: Record<string, boolean>;
}
export interface SettingsEntry extends SettingsSection {
sections?: (SettingsSection & { label: PlainMessageKey })[];
sections?: (SettingsSection & { label: () => string })[];
}
const settings: SettingsEntry[] = [
@@ -36,37 +37,37 @@ const settings: SettingsEntry[] = [
component: 'ProfileSettings',
icon: 'person',
sections: [
{ id: 'listingOptions', label: 'settings.listingOptions', icon: 'view_list' },
{ id: 'thumbnailOptions', label: 'profileSettings.thumbnailOptions', icon: 'image' },
{ id: 'sidebarOptions', label: 'profileSettings.sidebarOptions', icon: 'dock_to_right' },
{ id: 'searchOptions', label: 'settings.searchOptions', icon: 'search' },
{ id: 'fileViewerOptions', label: 'profileSettings.fileViewerOptions', icon: 'play_circle' },
{ id: 'themeLanguage', label: 'profileSettings.themeAndLanguage', icon: 'palette' },
{ id: 'accountOptions', label: 'profileSettings.accountOptions', icon: 'person' },
{ id: 'listingOptions', label: () => i18n.global.t('settings.listingOptions'), icon: 'view_list' },
{ id: 'thumbnailOptions', label: () => i18n.global.t('profileSettings.thumbnailOptions'), icon: 'image' },
{ id: 'sidebarOptions', label: () => i18n.global.t('profileSettings.sidebarOptions'), icon: 'dock_to_right' },
{ id: 'searchOptions', label: () => i18n.global.t('settings.searchOptions'), icon: 'search' },
{ id: 'fileViewerOptions', label: () => i18n.global.t('profileSettings.fileViewerOptions'), icon: 'play_circle' },
{ id: 'themeLanguage', label: () => i18n.global.t('profileSettings.themeAndLanguage'), icon: 'palette' },
{ id: 'accountOptions', label: () => i18n.global.t('profileSettings.accountOptions'), icon: 'person' },
],
},
{ id: 'fileLoading', label: 'fileLoading.title', component: 'FileLoading', icon: 'cloud_download' },
{ id: 'notifications', label: 'notifications.title', component: 'NotificationsSettings', icon: 'notifications' },
{ id: 'fileLoading', label: () => i18n.global.t('fileLoading.title'), component: 'FileLoading', icon: 'cloud_download' },
{ id: 'notifications', label: () => i18n.global.t('notifications.title'), component: 'NotificationsSettings', icon: 'notifications' },
{ id: 'shares', component: 'SharesSettings', permissions: { share: true }, icon: 'share' },
{ id: 'api', label: 'api.title', component: 'ApiKeys', permissions: { api: true }, icon: 'key' },
{ id: 'api', label: () => i18n.global.t('api.title'), component: 'ApiKeys', permissions: { api: true }, icon: 'key' },
{
id: 'users',
component: 'UserManagement',
icon: 'group',
sections: [
{ id: 'main', label: 'general.users', permissions: { admin: true }, icon: 'person' },
{ id: 'access', label: 'general.access', component: 'AccessSettings', permissions: { admin: true }, icon: 'lock' },
{ id: 'groups', label: 'general.groups', component: 'GroupsSettings', permissions: { admin: true }, icon: 'groups' },
{ id: 'main', label: () => i18n.global.t('general.users', { suffix: '' }), permissions: { admin: true }, icon: 'person' },
{ id: 'access', label: () => i18n.global.t('general.access'), component: 'AccessSettings', permissions: { admin: true }, icon: 'lock' },
{ id: 'groups', label: () => i18n.global.t('general.groups'), component: 'GroupsSettings', permissions: { admin: true }, icon: 'groups' },
],
},
{
id: 'media',
label: 'general.media',
label: () => i18n.global.t('general.media'),
component: 'MediaSettings',
permissions: { admin: true },
icon: 'movie',
},
{ id: 'systemAdmin', label: 'settings.systemAdmin', component: 'SystemAdmin', permissions: { admin: true }, icon: 'admin_panel_settings' },
{ id: 'systemAdmin', label: () => i18n.global.t('settings.systemAdmin'), component: 'SystemAdmin', permissions: { admin: true }, icon: 'admin_panel_settings' },
];
const previewViews = [
-86
View File
@@ -1,86 +0,0 @@
export function pinnedFoldersLabel($t) {
return $t("general.pinnedFolders");
}
export function pinnedFilesLabel($t) {
return $t("general.pinnedFiles");
}
export function pinnedItemsLabel($t) {
return $t("general.pinned");
}
export function itemsSelectedLabel($t, count) {
if (count === 1) {
return $t("general.selectionSingle");
}
return $t("general.selectionMultiple");
}
export function newUserLabel($t) {
return $t("general.newUser");
}
export function newFolderLabel($t) {
return $t("general.newFolder");
}
export function profileSettingsLabel($t) {
return $t("general.profileSettings");
}
export function shareSettingsLabel($t) {
return $t("general.shareSettings");
}
export function globalSettingsLabel($t) {
return $t("general.globalSettings");
}
export function userManagementLabel($t) {
return $t("general.userManagement");
}
export function shareManagementLabel($t) {
return $t("general.shareManagement");
}
export function shareHashLabel($t) {
return $t("general.shareHash");
}
export function downloadFilesPermissionLabel($t) {
return $t("general.downloadFiles");
}
export function editFilesPermissionLabel($t) {
return $t("general.editFiles");
}
export function createFilesPermissionLabel($t) {
return $t("general.createFiles");
}
export function deleteFilesPermissionLabel($t) {
return $t("general.deleteFiles");
}
export function shareFilesPermissionLabel($t) {
return $t("general.shareFiles");
}
export function downloadFilesLabel($t) {
return downloadFilesPermissionLabel($t);
}
export function shareThemeLabel($t) {
return $t("general.shareTheme");
}
export function shareTitleLabel($t) {
return $t("general.shareTitle");
}
export function timeUnitLabel($t) {
return $t("time.timeUnit");
}
+6 -5
View File
@@ -1,7 +1,8 @@
import type { PlainMessageKey } from "@/i18n/index.ts";
import i18n from "@/i18n/index.ts";
export const MEDIA_TRANSCODE_PROFILES: { id: string; label: PlainMessageKey }[] = [
{ id: "quality", label: "general.quality" },
{ id: "balanced", label: "general.balanced" },
{ id: "datasaver", label: "general.dataSaver" },
/** `label` is translated on every call, so it follows the current locale */
export const MEDIA_TRANSCODE_PROFILES: { id: string; label: () => string }[] = [
{ id: "quality", label: () => i18n.global.t("general.quality") },
{ id: "balanced", label: () => i18n.global.t("general.balanced") },
{ id: "datasaver", label: () => i18n.global.t("general.dataSaver") },
];
+5 -4
View File
@@ -1,8 +1,11 @@
// src/utils/playbackQueue.js
import i18n from "@/i18n/index.ts";
import { getters, mutations, state } from "@/store/index.ts";
import { url } from "@/utils/index.ts";
import { sortedItems } from "@/utils/sort.ts";
const t = i18n.global.t.bind(i18n.global);
/**
* Shuffles an array -- this is used for playback queue shuffle mode
* @param {Array} array - The array to shuffle.
@@ -187,11 +190,10 @@ export function toggleSingleLoop(currentLoop) {
/**
* Gets label for the playback modes.
* @param {string} mode - The mode.
* @param {Function} t - i18n translate function.
* @param {number} [queueLength] - Number of items in the queue. When provided, uses it for the playback mode label.
* @returns {string} The label.
*/
export function getModeLabel(mode, t, queueLength) {
export function getModeLabel(mode, queueLength) {
if (queueLength !== undefined && mode === 'single') {
return t('general.none');
}
@@ -218,10 +220,9 @@ export function getModeIcon(mode) {
/**
* Gets the label for the loop states
* @param {string} loop - Loop state: 'off' | 'all' | 'single'
* @param {Function} t - i18n translate function
* @returns {string} The label
*/
export function getLoopLabel(loop, t) {
export function getLoopLabel(loop) {
switch (loop) {
case 'all': return t('player.PlayAllLoopedPlayback');
case 'single': return t('player.LoopSingle');
+12 -12
View File
@@ -735,12 +735,12 @@ export default {
},
playbackModeMessage() {
if (this.toastType === 'loop') {
return getLoopLabel(this.loop, this.$t);
return getLoopLabel(this.loop);
}
if (this.toastType === 'cleared') {
return this.$t('player.queueCleared');
}
return getModeLabel(this.playbackMode, this.$t);
return getModeLabel(this.playbackMode);
},
toastIcon() {
if (this.toastType === 'loop') {
@@ -3754,19 +3754,19 @@ export default {
if (playbackBtn && playbackPanel) {
playbackBtn.removeAttribute('hidden');
const title = player.config.i18n?.playback || 'Playback';
const currentLabel = getModeLabel(this.playbackMode, this.$t, this.queueCount);
const currentLabel = getModeLabel(this.playbackMode, this.queueCount);
if (!this.playbackMenuInitialized) {
const menu = playbackPanel.querySelector('div[role="menu"]');
menu.innerHTML = `
<button data-plyr="playback" type="button" role="menuitemradio" class="plyr__control" value="single">
<span>${getModeLabel('single', this.$t)}</span>
<span>${getModeLabel('single')}</span>
</button>
<button data-plyr="playback" type="button" role="menuitemradio" class="plyr__control" value="sequential">
<span>${getModeLabel('sequential', this.$t)}</span>
<span>${getModeLabel('sequential')}</span>
</button>
<button data-plyr="playback" type="button" role="menuitemradio" class="plyr__control" value="shuffle">
<span>${getModeLabel('shuffle', this.$t)}</span>
<span>${getModeLabel('shuffle')}</span>
</button>
`;
this.playbackButtons = menu.querySelectorAll('button[data-plyr="playback"]');
@@ -3788,7 +3788,7 @@ export default {
targetMode: value
});
}
const newLabel = getModeLabel(value, this.$t);
const newLabel = getModeLabel(value);
if (this.playbackValueSpan) this.playbackValueSpan.textContent = newLabel;
for (const b of this.playbackButtons) {
b.setAttribute('aria-checked', b.getAttribute('value') === value);
@@ -3823,19 +3823,19 @@ export default {
if (loopBtn && loopPanel) {
loopBtn.removeAttribute('hidden');
const loopTitle = this.$t('player.loop');
const currentLoopLabel = getLoopLabel(this.loop, this.$t);
const currentLoopLabel = getLoopLabel(this.loop);
if (!this.loopMenuInitialized) {
const menu = loopPanel.querySelector('div[role="menu"]');
menu.innerHTML = `
<button data-plyr="loop" type="button" role="menuitemradio" class="plyr__control" value="off">
<span>${getLoopLabel('off', this.$t)}</span>
<span>${getLoopLabel('off')}</span>
</button>
<button data-plyr="loop" type="button" role="menuitemradio" class="plyr__control" value="all">
<span>${getLoopLabel('all', this.$t)}</span>
<span>${getLoopLabel('all')}</span>
</button>
<button data-plyr="loop" type="button" role="menuitemradio" class="plyr__control" value="single">
<span>${getLoopLabel('single', this.$t)}</span>
<span>${getLoopLabel('single')}</span>
</button>
`;
this.loopButtons = menu.querySelectorAll('button[data-plyr="loop"]');
@@ -3855,7 +3855,7 @@ export default {
loop: value
});
}
const newLabel = getLoopLabel(value, this.$t);
const newLabel = getLoopLabel(value);
if (this.loopValueSpan) this.loopValueSpan.textContent = newLabel;
for (const b of this.loopButtons) {
b.setAttribute('aria-checked', b.getAttribute('value') === value);
+1 -1
View File
@@ -86,7 +86,7 @@ export default {
},
activeSectionLabel() {
const def = this.profileSectionDefs.find((s) => s.id === this.activeSectionKey);
return def ? this.$t(def.label) : this.profileSettingsLabel();
return def ? def.label() : this.profileSettingsLabel();
},
profileSectionDefs() {
return settings.find((setting) => setting.id === 'profile')?.sections || [];
+5 -8
View File
@@ -190,7 +190,7 @@
:loading="loading"
row-clickable
:aria-label="$t('tools.activityViewer.name')"
:lonely-message-key="!loading && items.length === 0 ? 'files.lonely' : undefined"
:lonely-message="!loading && items.length === 0 ? $t('files.lonely') : undefined"
@row-click="openEventDetails"
>
<template #cell-createdAt="{ row, column }">
@@ -903,13 +903,10 @@ export default {
return (this.statsBuckets || []).reduce((sum, b) => sum + b.count, 0);
},
chartAriaLabel() {
return this.$t(`tools.activityViewer.${this.viewType}View`);
return this.viewTypeOptions.find((option) => option.value === this.viewType)?.label ?? "";
},
chartTitle() {
return activityChartTitle(
{ viewType: this.viewType, splitBy: this.splitBy },
this.$t.bind(this),
);
return activityChartTitle({ viewType: this.viewType, splitBy: this.splitBy });
},
},
watch: {
@@ -1575,7 +1572,7 @@ export default {
const normalized = normalizeActivityTableRow(row);
return {
...normalized,
tokenDisplay: activityTokenDisplay(normalized, this.$t),
tokenDisplay: activityTokenDisplay(normalized),
};
});
this.totalEvents = listRes.total || 0;
@@ -1748,7 +1745,7 @@ export default {
return this.formatTime(n);
},
eventTypeLabel(eventType) {
return activityEventLabel(eventType, this.$t);
return activityEventLabel(eventType);
},
eventTypeBadgeClass(eventType) {
return activityEventTypeBadgeClass(eventType);
+5 -5
View File
@@ -142,7 +142,7 @@
<template v-for="section in sections" :key="section.key">
<template v-if="section.items.length > 0">
<div>
<h2>{{ t(section.title) }}</h2>
<h2>{{ section.title }}</h2>
</div>
<div
:class="[section.class, { lastGroup: section.last }]"
@@ -186,7 +186,7 @@
import { computed, nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from "vue";
import type { FileListItem, fileListItemIndex, ReqObject } from "@/store/types.ts";
import { useRoute } from "vue-router";
import { type PlainMessageKey, useI18n } from "@/i18n/index.ts";
import { useI18n } from "@/i18n/index.ts";
import { toolsApi } from "@/api/index.js";
import { router } from "@/router/index.ts";
import { state, getters, mutations } from "@/store/index.ts";
@@ -483,10 +483,10 @@ const reqListing = computed(() => {
});
const sections = computed<
{ key: string; class: string; title: PlainMessageKey; label: string; items: typeof reqListing.value.dirs; last: boolean }[]
{ key: string; class: string; title: string; label: string; items: typeof reqListing.value.dirs; last: boolean }[]
>(() => [
{ key: "dirs", class: "folder-items", title: "general.folders", label: "Folder Items", items: reqListing.value.dirs, last: reqListing.value.files.length === 0 },
{ key: "files", class: "file-items", title: "general.files", label: "File Items", items: reqListing.value.files, last: true },
{ key: "dirs", class: "folder-items", title: t("general.folders"), label: "Folder Items", items: reqListing.value.dirs, last: reqListing.value.files.length === 0 },
{ key: "files", class: "file-items", title: t("general.files"), label: "File Items", items: reqListing.value.files, last: true },
]);
const allItems = computed(() => [...reqListing.value.dirs, ...reqListing.value.files]);