From 25faf898c127deef87aebfea885a3dbbc0fcef01 Mon Sep 17 00:00:00 2001 From: MickaelK Date: Tue, 12 Nov 2024 16:00:17 +1100 Subject: [PATCH] fix (share): UX for shared link --- public/assets/pages/filespage/modal_share.css | 7 +++++++ public/assets/pages/filespage/modal_share.js | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/public/assets/pages/filespage/modal_share.css b/public/assets/pages/filespage/modal_share.css index 45b727b9..48bc1e2c 100644 --- a/public/assets/pages/filespage/modal_share.css +++ b/public/assets/pages/filespage/modal_share.css @@ -39,6 +39,10 @@ text-shadow: 0px 0px 1px var(--color); background: var(--bg-color); background-position: center; + line-height: 1rem; + align-items: center; + justify-content: center; + display: flex; } .dark-mode .component_share .share--content.link-type > div { background: var(--color); @@ -75,6 +79,9 @@ padding-bottom: 5px; } .component_share .share--content.existing-links .link-details .role { + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; margin-right: 5px; padding-right: 5px; font-size: 0.8em; diff --git a/public/assets/pages/filespage/modal_share.js b/public/assets/pages/filespage/modal_share.js index 99aacd0a..df87fe32 100644 --- a/public/assets/pages/filespage/modal_share.js +++ b/public/assets/pages/filespage/modal_share.js @@ -86,7 +86,6 @@ export default function(render, { path }) { url: `api/share/${id}`, }).toPromise(); ; - // if (state.links === null) assert.fail("ttest"); assert.truthy(state.links).push({ ...body, path: body.path.substring(currentPath().length - 1), @@ -103,11 +102,18 @@ export default function(render, { path }) { }, all: async() => { const { responseJSON } = await ajax({ - url: `api/share?path=` + currentPath(), + url: `api/share?path=` + encodeURIComponent(path), method: "GET", responseType: "json", }).toPromise(); - state.links = responseJSON.results; + const currentFolder = path.replace(new RegExp("/$"), "").split("/").pop(); + const sharedLinkIsFolder = new RegExp("/$").test(path); + state.links = responseJSON.results.map((obj) => { + obj.path = sharedLinkIsFolder ? + `./${currentFolder}${obj.path}` : + `./${currentFolder}`; + return obj; + }); return responseJSON.results; }, }); @@ -144,7 +150,7 @@ async function ctrlExistingShare(render, { load, remove, all, formLinks }) { const $share = createElement(`