feat: simplify public shares and add compact link management
This commit is contained in:
1 parent
5dda0dc5f3
commit
7fc7465f71
15 files changed
+417
-273
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
@@ -13,7 +13,7 @@ export async function fetch(url: string, password: string = "") {
|
||||
);
|
||||
|
||||
const data = (await res.json()) as Resource;
|
||||
data.url = `/share${url}`;
|
||||
data.url = `/s${url}`;
|
||||
|
||||
if (data.isDir) {
|
||||
if (!data.url.endsWith("/")) data.url += "/";
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { breadcrumbItems } from "@/utils/breadcrumbs";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
@@ -32,44 +33,7 @@ const props = defineProps<{
|
||||
noLink?: boolean;
|
||||
}>();
|
||||
|
||||
const items = computed(() => {
|
||||
const relativePath = route.path.replace(props.base, "");
|
||||
const parts = relativePath.split("/");
|
||||
|
||||
if (parts[0] === "") {
|
||||
parts.shift();
|
||||
}
|
||||
|
||||
if (parts[parts.length - 1] === "") {
|
||||
parts.pop();
|
||||
}
|
||||
|
||||
const breadcrumbs: BreadCrumb[] = [];
|
||||
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
if (i === 0) {
|
||||
breadcrumbs.push({
|
||||
name: decodeURIComponent(parts[i]),
|
||||
url: props.base + "/" + parts[i] + "/",
|
||||
});
|
||||
} else {
|
||||
breadcrumbs.push({
|
||||
name: decodeURIComponent(parts[i]),
|
||||
url: breadcrumbs[i - 1].url + parts[i] + "/",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (breadcrumbs.length > 3) {
|
||||
while (breadcrumbs.length !== 4) {
|
||||
breadcrumbs.shift();
|
||||
}
|
||||
|
||||
breadcrumbs[0].name = "...";
|
||||
}
|
||||
|
||||
return breadcrumbs;
|
||||
});
|
||||
const items = computed(() => breadcrumbItems(route.path, props.base));
|
||||
|
||||
const element = computed(() => {
|
||||
if (props.noLink) {
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
:aria-label="$t('buttons.new')"
|
||||
:title="$t('buttons.new')"
|
||||
>
|
||||
{{ $t("buttons.new") }}
|
||||
{{ $t("sso.newLink") }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -99,43 +99,56 @@
|
||||
/>
|
||||
</div>
|
||||
<p class="field-hint">{{ $t("sso.shortHint") }}</p>
|
||||
<p class="field-hint">{{ $t("sso.defaultShare") }}</p>
|
||||
<details class="share-advanced">
|
||||
<summary>{{ $t("sso.advancedSettings") }}</summary>
|
||||
<div class="share-advanced-content">
|
||||
<label for="share-duration">{{
|
||||
$t("settings.shareDuration")
|
||||
}}</label>
|
||||
<div class="input-group input">
|
||||
<vue-number-input
|
||||
id="share-duration"
|
||||
center
|
||||
controls
|
||||
size="small"
|
||||
:max="2147483647"
|
||||
:min="0"
|
||||
@keyup.enter="submit"
|
||||
v-model="time"
|
||||
/>
|
||||
<select
|
||||
class="right"
|
||||
v-model="unit"
|
||||
:aria-label="$t('time.unit')"
|
||||
<section class="share-option">
|
||||
<label class="share-option-toggle"
|
||||
><input type="checkbox" v-model="expiresEnabled" />{{
|
||||
$t("sso.expirationToggle")
|
||||
}}</label
|
||||
>
|
||||
<option value="seconds">{{ $t("time.seconds") }}</option>
|
||||
<option value="minutes">{{ $t("time.minutes") }}</option>
|
||||
<option value="hours">{{ $t("time.hours") }}</option>
|
||||
<option value="days">{{ $t("time.days") }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<label for="share-password">{{
|
||||
$t("prompts.optionalPassword")
|
||||
}}</label>
|
||||
<input
|
||||
id="share-password"
|
||||
class="input input--block"
|
||||
type="password"
|
||||
v-model.trim="password"
|
||||
/>
|
||||
<div v-if="expiresEnabled" class="share-expiration-fields">
|
||||
<input
|
||||
id="share-duration"
|
||||
class="input"
|
||||
type="number"
|
||||
min="1"
|
||||
max="36500"
|
||||
step="1"
|
||||
v-model.number="time"
|
||||
:aria-label="$t('sso.expirationAmount')"
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
<select
|
||||
class="input"
|
||||
v-model="unit"
|
||||
:aria-label="$t('time.unit')"
|
||||
>
|
||||
<option value="minutes">{{ $t("time.minutes") }}</option>
|
||||
<option value="hours">{{ $t("time.hours") }}</option>
|
||||
<option value="days">{{ $t("time.days") }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</section>
|
||||
<section class="share-option">
|
||||
<label class="share-option-toggle"
|
||||
><input type="checkbox" v-model="passwordEnabled" />{{
|
||||
$t("sso.passwordAccess")
|
||||
}}</label
|
||||
>
|
||||
<input
|
||||
v-if="passwordEnabled"
|
||||
id="share-password"
|
||||
class="input input--block"
|
||||
type="password"
|
||||
v-model="password"
|
||||
:aria-label="$t('login.password')"
|
||||
:placeholder="$t('login.password')"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
@@ -176,8 +189,10 @@ export default {
|
||||
name: "share",
|
||||
data: function () {
|
||||
return {
|
||||
time: 0,
|
||||
unit: "hours",
|
||||
time: 1,
|
||||
expiresEnabled: false,
|
||||
passwordEnabled: false,
|
||||
unit: "days",
|
||||
links: [],
|
||||
clip: null,
|
||||
password: "",
|
||||
@@ -188,6 +203,7 @@ export default {
|
||||
},
|
||||
inject: ["$showError", "$showSuccess"],
|
||||
computed: {
|
||||
...mapState(useLayoutStore, ["currentPrompt"]),
|
||||
...mapState(useFileStore, [
|
||||
"req",
|
||||
"selected",
|
||||
@@ -195,6 +211,7 @@ export default {
|
||||
"isListing",
|
||||
]),
|
||||
url() {
|
||||
if (this.currentPrompt?.props?.path) return this.currentPrompt.props.path;
|
||||
if (!this.isListing) {
|
||||
return this.$route.path;
|
||||
}
|
||||
@@ -213,7 +230,7 @@ export default {
|
||||
this.links = links;
|
||||
this.sort();
|
||||
|
||||
if (this.links.length == 0) {
|
||||
if (this.links.length == 0 || this.currentPrompt?.props?.newLink) {
|
||||
this.listing = false;
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -255,11 +272,22 @@ export default {
|
||||
this.$showError(new Error(this.$t("sso.shortHint")));
|
||||
return;
|
||||
}
|
||||
if (
|
||||
this.expiresEnabled &&
|
||||
(!Number.isInteger(this.time) || this.time < 1 || this.time > 36500)
|
||||
) {
|
||||
this.$showError(new Error(this.$t("sso.expirationInvalid")));
|
||||
return;
|
||||
}
|
||||
if (this.passwordEnabled && !this.password) {
|
||||
this.$showError(new Error(this.$t("sso.enterPassword")));
|
||||
return;
|
||||
}
|
||||
this.submitting = true;
|
||||
res = await api.share.create(
|
||||
this.url,
|
||||
this.password,
|
||||
this.time ? this.time : "",
|
||||
this.passwordEnabled ? this.password : "",
|
||||
this.expiresEnabled ? this.time : "",
|
||||
this.unit,
|
||||
this.shortKey
|
||||
);
|
||||
@@ -267,8 +295,10 @@ export default {
|
||||
this.links.push(res);
|
||||
this.sort();
|
||||
|
||||
this.time = 0;
|
||||
this.unit = "hours";
|
||||
this.time = 1;
|
||||
this.unit = "days";
|
||||
this.expiresEnabled = false;
|
||||
this.passwordEnabled = false;
|
||||
this.password = "";
|
||||
this.shortKey = "";
|
||||
|
||||
|
||||
@@ -1,4 +1,117 @@
|
||||
/* Lightweight workspace: system fonts, solid surfaces, no blur or filter layers. */
|
||||
.share-option {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
padding: 14px;
|
||||
border: 1px solid var(--borderPrimary);
|
||||
border-radius: 10px;
|
||||
background: var(--background);
|
||||
}
|
||||
.share-option-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
color: var(--textSecondary);
|
||||
}
|
||||
.share-option-toggle input {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
margin: 0;
|
||||
accent-color: var(--blue);
|
||||
}
|
||||
.share-expiration-fields {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(80px, 1fr) minmax(110px, 2fr);
|
||||
gap: 10px;
|
||||
}
|
||||
.share-expiration-fields .input {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.shares-table-wrap {
|
||||
overflow-x: auto;
|
||||
}
|
||||
.card-content .shares-table {
|
||||
table-layout: fixed;
|
||||
min-width: 780px;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.shares-table th,
|
||||
.shares-table td {
|
||||
padding: 12px 14px;
|
||||
text-align: start;
|
||||
vertical-align: middle;
|
||||
border-bottom: 1px solid var(--borderPrimary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.shares-table th {
|
||||
font-size: 12px;
|
||||
color: var(--textPrimary);
|
||||
font-weight: 500;
|
||||
}
|
||||
.shares-table th:first-child {
|
||||
width: 40%;
|
||||
}
|
||||
.shares-table th:last-child {
|
||||
width: 154px;
|
||||
}
|
||||
.shares-table td {
|
||||
font-size: 13px;
|
||||
}
|
||||
.shares-table tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.shares-table .share-link-actions {
|
||||
margin: 0;
|
||||
}
|
||||
.shares-table .share-link-actions .action {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
flex-basis: 34px;
|
||||
}
|
||||
.shares-table .managed-share-key {
|
||||
font-size: 11px;
|
||||
}
|
||||
.visually-hidden {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.share-download-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 20px;
|
||||
}
|
||||
.share__box__element .share-download-primary {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-height: 48px;
|
||||
padding: 12px 18px;
|
||||
border-radius: 10px;
|
||||
font-weight: 600;
|
||||
background: var(--blue);
|
||||
color: var(--surfacePrimary);
|
||||
text-decoration: none;
|
||||
}
|
||||
.share__box__element .share-download-primary i {
|
||||
display: block;
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
.share__box__element .share-download-primary:hover {
|
||||
background: var(--dark-blue);
|
||||
}
|
||||
.dashboard .row.share-management > .column {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
"upload": "Upload",
|
||||
"uploadFiles": "Uploading {files} files...",
|
||||
"uploadMessage": "Select an option to upload.",
|
||||
"optionalPassword": "Optional password",
|
||||
"optionalPassword": "Password access",
|
||||
"resolution": "Resolution",
|
||||
"discardEditorChanges": "Are you sure you wish to discard the changes you've made?",
|
||||
"replaceOrSkip": "Replace or skip files",
|
||||
@@ -321,7 +321,18 @@
|
||||
"itemsCount": "{count} items",
|
||||
"storage": "Storage",
|
||||
"editorTheme": "The editor follows the interface theme automatically.",
|
||||
"advancedSettings": "Advanced settings"
|
||||
"advancedSettings": "Advanced settings",
|
||||
"downloadFolderZip": "Download folder as ZIP",
|
||||
"newLink": "Add link",
|
||||
"linkActions": "Link actions",
|
||||
"protected": "Yes",
|
||||
"unprotected": "No password",
|
||||
"expirationToggle": "Set an expiration",
|
||||
"expirationAmount": "Expiration amount",
|
||||
"passwordAccess": "Password access",
|
||||
"defaultShare": "By default: a permanent link without a password.",
|
||||
"expirationInvalid": "Enter a whole number from 1 to 36500.",
|
||||
"enterPassword": "Enter a password or turn password access off."
|
||||
},
|
||||
"permissions": {
|
||||
"create": "Create files and directories",
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
"upload": "Загрузить",
|
||||
"uploadFiles": "Загружаю {files} файлы...",
|
||||
"uploadMessage": "Выберите вариант для загрузки.",
|
||||
"optionalPassword": "Необязательный пароль",
|
||||
"optionalPassword": "Доступ по паролю",
|
||||
"resolution": "Разрешение",
|
||||
"discardEditorChanges": "Вы действительно желаете отменить ваши правки?",
|
||||
"replaceOrSkip": "Replace or skip files",
|
||||
@@ -318,7 +318,18 @@
|
||||
"itemsCount": "Объектов: {count}",
|
||||
"storage": "Хранилище",
|
||||
"editorTheme": "Тема редактора автоматически соответствует теме интерфейса.",
|
||||
"advancedSettings": "Дополнительные настройки"
|
||||
"advancedSettings": "Дополнительные настройки",
|
||||
"downloadFolderZip": "Скачать папку ZIP-архивом",
|
||||
"newLink": "Добавить ссылку",
|
||||
"linkActions": "Действия со ссылкой",
|
||||
"protected": "Да",
|
||||
"unprotected": "Без пароля",
|
||||
"expirationToggle": "Ограничить срок действия",
|
||||
"expirationAmount": "Срок действия",
|
||||
"passwordAccess": "Доступ по паролю",
|
||||
"defaultShare": "По умолчанию: бессрочная ссылка без пароля.",
|
||||
"expirationInvalid": "Укажите целое число от 1 до 36500.",
|
||||
"enterPassword": "Введите пароль или выключите доступ по паролю."
|
||||
},
|
||||
"permissions": {
|
||||
"create": "Создавать файлы и каталоги",
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { breadcrumbItems, shareBase } from "../breadcrumbs";
|
||||
|
||||
describe("public share breadcrumbs", () => {
|
||||
for (const prefix of ["s", "share"]) {
|
||||
it(`hides the key and prefix for /${prefix} links`, () => {
|
||||
const root = `/${prefix}/YEZDVdfvYkDRjjkKUnMtIQ`;
|
||||
expect(breadcrumbItems(root, shareBase(root))).toEqual([]);
|
||||
const path = root + "/CT20261015_121353_9093_96834755";
|
||||
expect(breadcrumbItems(path, shareBase(path))).toEqual([
|
||||
{ name: "CT20261015_121353_9093_96834755", url: path + "/" },
|
||||
]);
|
||||
});
|
||||
}
|
||||
it("keeps nested encoded paths relative to the public root", () => {
|
||||
const path = "/share/key/Scan%20A/image.dcm";
|
||||
expect(breadcrumbItems(path, shareBase(path))).toEqual([
|
||||
{ name: "Scan A", url: "/share/key/Scan%20A/" },
|
||||
{ name: "image.dcm", url: path + "/" },
|
||||
]);
|
||||
});
|
||||
it("only removes a matching path prefix", () => {
|
||||
expect(breadcrumbItems("/files-archive/example", "/files")).toEqual([]);
|
||||
expect(breadcrumbItems("/files/Documents/", "/files")).toEqual([
|
||||
{ name: "Documents", url: "/files/Documents/" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
export function shareBase(path: string): string {
|
||||
return path.match(/^\/(?:s|share)\/[^/]+/)?.[0] ?? "/s";
|
||||
}
|
||||
|
||||
export function breadcrumbItems(path: string, base: string): BreadCrumb[] {
|
||||
base = base.replace(/\/+$/, "");
|
||||
const relative = path.startsWith(base + "/") ? path.slice(base.length) : "";
|
||||
const parts = relative.split("/").filter(Boolean);
|
||||
const items = parts.map((part, index) => ({
|
||||
name: decodeURIComponent(part),
|
||||
url: base + "/" + parts.slice(0, index + 1).join("/") + "/",
|
||||
}));
|
||||
if (items.length > 4) {
|
||||
const visible = items.slice(-4);
|
||||
visible[0] = { ...visible[0], name: "..." };
|
||||
return visible;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
+14
-129
@@ -26,7 +26,7 @@
|
||||
/>
|
||||
</header-bar>
|
||||
|
||||
<breadcrumbs :base="'/s/' + hash" />
|
||||
<breadcrumbs :base="shareBase(route.path)" />
|
||||
|
||||
<div v-if="layoutStore.loading">
|
||||
<h2 class="message delayed" style="padding-top: 3em !important">
|
||||
@@ -106,17 +106,14 @@
|
||||
<div class="share__box__element" style="height: 3em">
|
||||
<strong>{{ $t("prompts.size") }}:</strong> {{ humanSize }}
|
||||
</div>
|
||||
<div class="share__box__element share__box__center">
|
||||
<a
|
||||
target="_blank"
|
||||
:href="link"
|
||||
class="button button--flat"
|
||||
style="height: 4em"
|
||||
>
|
||||
<div>
|
||||
<i class="material-icons">file_download</i
|
||||
>{{ t("buttons.download") }}
|
||||
</div>
|
||||
<div class="share__box__element share-download-actions">
|
||||
<a :href="link" class="button share-download-primary">
|
||||
<i class="material-icons" aria-hidden="true">file_download</i
|
||||
><span>{{
|
||||
req.isDir
|
||||
? t("sso.downloadFolderZip")
|
||||
: t("download.downloadFile")
|
||||
}}</span>
|
||||
</a>
|
||||
<a
|
||||
target="_blank"
|
||||
@@ -130,102 +127,6 @@
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
v-if="req.isDir"
|
||||
class="share__box__element share__box__header"
|
||||
style="height: 3em"
|
||||
>
|
||||
{{ $t("sidebar.preview") }}
|
||||
</div>
|
||||
<div
|
||||
v-if="req.isDir"
|
||||
class="share__box__element share__box__center share__box__icon"
|
||||
style="padding: 0em !important; height: 12em !important"
|
||||
>
|
||||
<a
|
||||
target="_blank"
|
||||
:href="raw"
|
||||
class="button button--flat"
|
||||
v-if="
|
||||
!fileStore.multiple &&
|
||||
fileStore.selectedCount === 1 &&
|
||||
req.items[fileStore.selected[0]].type === 'image'
|
||||
"
|
||||
style="height: 12em; padding: 0; margin: 0"
|
||||
>
|
||||
<img
|
||||
style="height: 12em"
|
||||
:src="raw"
|
||||
:alt="req.items[fileStore.selected[0]].name"
|
||||
/>
|
||||
</a>
|
||||
<div
|
||||
v-else-if="
|
||||
fileStore.multiple &&
|
||||
fileStore.selectedCount === 1 &&
|
||||
req.items[fileStore.selected[0]].type === 'audio'
|
||||
"
|
||||
style="height: 12em; padding-top: 1em; margin: 0"
|
||||
>
|
||||
<button
|
||||
@click="play"
|
||||
v-if="!tag"
|
||||
style="
|
||||
font-size: 6em !important;
|
||||
border: 0px;
|
||||
outline: none;
|
||||
background: white;
|
||||
"
|
||||
class="material-icons"
|
||||
>
|
||||
play_circle_filled
|
||||
</button>
|
||||
<button
|
||||
@click="play"
|
||||
v-if="tag"
|
||||
style="
|
||||
font-size: 6em !important;
|
||||
border: 0px;
|
||||
outline: none;
|
||||
background: white;
|
||||
"
|
||||
class="material-icons"
|
||||
>
|
||||
pause_circle_filled
|
||||
</button>
|
||||
<audio
|
||||
id="myaudio"
|
||||
ref="audio"
|
||||
:src="raw"
|
||||
controls
|
||||
:autoplay="tag"
|
||||
></audio>
|
||||
</div>
|
||||
<video
|
||||
v-else-if="
|
||||
!fileStore.multiple &&
|
||||
fileStore.selectedCount === 1 &&
|
||||
req.items[fileStore.selected[0]].type === 'video'
|
||||
"
|
||||
style="height: 12em; padding: 0; margin: 0"
|
||||
:src="raw"
|
||||
controls
|
||||
>
|
||||
Sorry, your browser doesn't support embedded videos, but don't
|
||||
worry, you can <a :href="raw">download it</a>
|
||||
and watch it with your favorite video player!
|
||||
</video>
|
||||
<i
|
||||
v-else-if="
|
||||
!fileStore.multiple &&
|
||||
fileStore.selectedCount === 1 &&
|
||||
req.items[fileStore.selected[0]].isDir
|
||||
"
|
||||
class="material-icons"
|
||||
>folder
|
||||
</i>
|
||||
<i v-else class="material-icons">call_to_action</i>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
id="shareList"
|
||||
@@ -297,7 +198,7 @@ import { pub as api } from "@/api";
|
||||
import { filesize } from "@/utils";
|
||||
import dayjs from "dayjs";
|
||||
import { Base64 } from "js-base64";
|
||||
import { createURL } from "@/api/utils";
|
||||
import { shareBase } from "@/utils/breadcrumbs";
|
||||
import HeaderBar from "@/components/header/HeaderBar.vue";
|
||||
import Action from "@/components/header/Action.vue";
|
||||
import Breadcrumbs from "@/components/Breadcrumbs.vue";
|
||||
@@ -315,10 +216,11 @@ const error = ref<StatusError | null>(null);
|
||||
const showLimit = ref<number>(100);
|
||||
const password = ref<string>("");
|
||||
const attemptedPasswordLogin = ref<boolean>(false);
|
||||
const hash = ref<string>("");
|
||||
const hash = computed(() => {
|
||||
const path = route.params.path;
|
||||
return Array.isArray(path) ? path[0] || "" : (path || "").split("/")[0];
|
||||
});
|
||||
const token = ref<string>("");
|
||||
const audio = ref<HTMLAudioElement>();
|
||||
const tag = ref<boolean>(false);
|
||||
|
||||
const $showError = inject<IToastError>("$showError")!;
|
||||
const $showSuccess = inject<IToastSuccess>("$showSuccess")!;
|
||||
@@ -348,13 +250,6 @@ const icon = computed(() => {
|
||||
});
|
||||
|
||||
const link = computed(() => (req.value ? api.getDownloadURL(req.value) : ""));
|
||||
const raw = computed(() => {
|
||||
if (!req.value || !req.value.items[fileStore.selected[0]]) return "";
|
||||
return createURL(
|
||||
`api/public/dl/${hash.value}${req.value.items[fileStore.selected[0]].path}`,
|
||||
{ token: token.value }
|
||||
);
|
||||
});
|
||||
const inlineLink = computed(() =>
|
||||
req.value ? api.getDownloadURL(req.value, true) : ""
|
||||
);
|
||||
@@ -376,15 +271,6 @@ const modTime = computed(() =>
|
||||
|
||||
// Functions
|
||||
const base64 = (name: any) => Base64.encodeURI(name);
|
||||
const play = () => {
|
||||
if (tag.value) {
|
||||
audio.value?.pause();
|
||||
tag.value = false;
|
||||
} else {
|
||||
audio.value?.play();
|
||||
tag.value = true;
|
||||
}
|
||||
};
|
||||
const fetchData = async () => {
|
||||
fileStore.reload = false;
|
||||
fileStore.selected = [];
|
||||
@@ -504,7 +390,6 @@ const copyToClipboard = (text: string) => {
|
||||
|
||||
onMounted(async () => {
|
||||
// Created
|
||||
hash.value = route.params.path[0];
|
||||
window.addEventListener("keydown", keyEvent);
|
||||
await fetchData();
|
||||
});
|
||||
|
||||
@@ -7,64 +7,87 @@
|
||||
<h2>{{ t("settings.shareManagement") }}</h2>
|
||||
</div>
|
||||
|
||||
<div class="card-content managed-shares" v-if="links.length > 0">
|
||||
<article v-for="link in links" :key="link.hash" class="managed-share">
|
||||
<div class="managed-share-heading">
|
||||
<div class="managed-share-file">
|
||||
<a
|
||||
:href="buildLink(link)"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="managed-share-path"
|
||||
>{{ link.path }}</a
|
||||
>
|
||||
<a
|
||||
:href="buildLink(link)"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="managed-share-key"
|
||||
>/s/{{ link.hash }}</a
|
||||
>
|
||||
</div>
|
||||
<div class="share-link-actions">
|
||||
<button
|
||||
class="action"
|
||||
@click="copyToClipboard(buildLink(link))"
|
||||
:aria-label="t('buttons.copyToClipboard')"
|
||||
:title="t('buttons.copyToClipboard')"
|
||||
>
|
||||
<i class="material-icons">link</i>
|
||||
</button>
|
||||
<button
|
||||
class="action share-link-delete"
|
||||
@click="deleteLink($event, link)"
|
||||
:disabled="deleting === link.hash"
|
||||
:aria-label="t('buttons.delete')"
|
||||
:title="t('buttons.delete')"
|
||||
>
|
||||
<i class="material-icons">delete_outline</i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<dl class="managed-share-meta">
|
||||
<div>
|
||||
<dt>{{ t("settings.shareDuration") }}</dt>
|
||||
<dd>
|
||||
<div class="card-content shares-table-wrap" v-if="links.length > 0">
|
||||
<table class="shares-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ t("settings.path") }}</th>
|
||||
<th>{{ t("settings.shareDuration") }}</th>
|
||||
<th v-if="authStore.user?.perm.admin">
|
||||
{{ t("settings.username") }}
|
||||
</th>
|
||||
<th>{{ t("login.password") }}</th>
|
||||
<th class="shares-actions-column">
|
||||
<span class="visually-hidden">{{
|
||||
t("sso.linkActions")
|
||||
}}</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="link in links" :key="link.hash">
|
||||
<td class="shares-resource">
|
||||
<a
|
||||
:href="buildLink(link)"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="managed-share-path"
|
||||
>{{ link.path }}</a
|
||||
><a
|
||||
:href="buildLink(link)"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="managed-share-key"
|
||||
>/s/{{ link.hash }}</a
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
{{ link.expire ? humanTime(link.expire) : t("permanent") }}
|
||||
</dd>
|
||||
</div>
|
||||
<div v-if="authStore.user?.perm.admin">
|
||||
<dt>{{ t("settings.username") }}</dt>
|
||||
<dd>
|
||||
</td>
|
||||
<td v-if="authStore.user?.perm.admin">
|
||||
{{ link.username || t("settings.user") + " #" + link.userID }}
|
||||
</dd>
|
||||
</div>
|
||||
<div v-if="link.hasPassword">
|
||||
<dt>{{ t("login.password") }}</dt>
|
||||
<dd><i class="material-icons" aria-hidden="true">lock</i></dd>
|
||||
</div>
|
||||
</dl>
|
||||
</article>
|
||||
</td>
|
||||
<td>
|
||||
<span
|
||||
:title="
|
||||
t(link.hasPassword ? 'sso.protected' : 'sso.unprotected')
|
||||
"
|
||||
>{{ link.hasPassword ? t("sso.protected") : "—" }}</span
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
<div class="share-link-actions">
|
||||
<button
|
||||
v-if="link.userID === authStore.user?.id"
|
||||
class="action"
|
||||
@click="newLink(link)"
|
||||
:aria-label="t('sso.newLink')"
|
||||
:title="t('sso.newLink')"
|
||||
>
|
||||
<i class="material-icons">add_link</i>
|
||||
</button>
|
||||
<button
|
||||
class="action"
|
||||
@click="copyToClipboard(buildLink(link))"
|
||||
:aria-label="t('buttons.copyToClipboard')"
|
||||
:title="t('buttons.copyToClipboard')"
|
||||
>
|
||||
<i class="material-icons">link</i>
|
||||
</button>
|
||||
<button
|
||||
class="action share-link-delete"
|
||||
@click="deleteLink($event, link)"
|
||||
:disabled="deleting === link.hash"
|
||||
:aria-label="t('buttons.delete')"
|
||||
:title="t('buttons.delete')"
|
||||
>
|
||||
<i class="material-icons">delete_outline</i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<h2 class="message" v-else>
|
||||
<i class="material-icons">sentiment_dissatisfied</i>
|
||||
@@ -97,7 +120,7 @@ const error = ref<StatusError | null>(null);
|
||||
const links = ref<Share[]>([]);
|
||||
const deleting = ref<string | null>(null);
|
||||
|
||||
onMounted(async () => {
|
||||
const loadLinks = async () => {
|
||||
layoutStore.loading = true;
|
||||
|
||||
try {
|
||||
@@ -125,7 +148,23 @@ onMounted(async () => {
|
||||
} finally {
|
||||
layoutStore.loading = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(loadLinks);
|
||||
|
||||
const newLink = (link: Share) => {
|
||||
layoutStore.showHover({
|
||||
prompt: "share",
|
||||
props: {
|
||||
path: "/files" + link.path.split("/").map(encodeURIComponent).join("/"),
|
||||
newLink: true,
|
||||
},
|
||||
close: async () => {
|
||||
await loadLinks();
|
||||
return "";
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const copyToClipboard = (text: string) => {
|
||||
copy({ text }).then(
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
func TestCustomShareKey(t *testing.T) {
|
||||
@@ -41,3 +42,46 @@ func TestCustomShareKey(t *testing.T) {
|
||||
t.Fatalf("random key: %d", w.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIndependentLinksForSameResource(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(root, "report.txt"), []byte("report"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
perm := users.Permissions{Share: true, Download: true}
|
||||
st := scopedUserStorage(t, root, perm, []byte("test-key"))
|
||||
for _, body := range []string{
|
||||
`{"key":"main-link"}`,
|
||||
`{"key":"password-link","password":"private-preview"}`,
|
||||
`{"key":"temporary-link","expires":"1","unit":"hours"}`,
|
||||
`{"key":"second-main-link"}`,
|
||||
} {
|
||||
r := authorizeTestRequest(httptest.NewRequest("POST", "/report.txt", strings.NewReader(body)), signToken(t, perm, nil))
|
||||
w := httptest.NewRecorder()
|
||||
handle(sharePostHandler, "", st, &settings.Server{}).ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("create: %d %s", w.Code, w.Body.String())
|
||||
}
|
||||
}
|
||||
main, err := st.Share.GetByHash("main-link")
|
||||
if err != nil || main.Expire != 0 || main.PasswordHash != "" {
|
||||
t.Fatalf("main link changed: %+v %v", main, err)
|
||||
}
|
||||
protected, err := st.Share.GetByHash("password-link")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = bcrypt.CompareHashAndPassword([]byte(protected.PasswordHash), []byte("private-preview")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
temporary, err := st.Share.GetByHash("temporary-link")
|
||||
if err != nil || temporary.Expire == 0 {
|
||||
t.Fatalf("missing expiry: %+v %v", temporary, err)
|
||||
}
|
||||
if err = st.Share.Delete("password-link"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = st.Share.GetByHash("main-link"); err != nil {
|
||||
t.Fatal("removing secondary link removed primary:", err)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
param([string]$Version = '3.0.0-sso.4')
|
||||
param([string]$Version = '3.0.0-sso.5')
|
||||
$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.4}"
|
||||
VERSION="${VERSION:-3.0.0-sso.5}"
|
||||
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