From aeca855b5d8d675c4079bc22a13348c97d40e722 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Fri, 2 Jan 2026 14:06:31 -0300 Subject: [PATCH 1/2] feat: add envelope path configuration in batch file action When creating envelopes from multiple files, the envelope path is now properly configured based on the parent directory of the selected files. This ensures envelopes are created in the same directory as the source files instead of the root folder. The path is normalized to handle edge cases like root directory and trailing slashes, providing consistent behavior across different file locations. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/actions/openInLibreSignAction.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/actions/openInLibreSignAction.js b/src/actions/openInLibreSignAction.js index 53df0c3aa4..4b34849772 100644 --- a/src/actions/openInLibreSignAction.js +++ b/src/actions/openInLibreSignAction.js @@ -93,9 +93,16 @@ export const action = new FileAction({ return new Array(nodes.length).fill(null) } + const rawDir = nodes[0].dirname ?? nodes[0].path.substring(0, nodes[0].path.lastIndexOf('/')) + const normalizedDir = (rawDir && rawDir !== '/') ? rawDir.replace(/\/+$/, '') : '' + const envelopePath = normalizedDir ? `${normalizedDir}/${envelopeName}` : `/${envelopeName}` + return axios.post(generateOcsUrl('/apps/libresign/api/v1/file'), { files: nodes.map(node => ({ fileId: node.fileid })), name: envelopeName, + settings: { + path: envelopePath, + }, }).then((response) => { const envelopeData = response.data?.ocs?.data From ce5021e37c2fbed2e16a9151982c05210ef3df7f Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Fri, 2 Jan 2026 14:06:50 -0300 Subject: [PATCH 2/2] refactor: improve sidebar title management in AppFilesTab This refactoring enhances the sidebar behavior when working with envelopes and files: - Remove unused data properties (file, signers, requested_by, requestDate) - Add checkAndLoadPendingEnvelope() to handle envelope creation flow - Implement MutationObserver to maintain correct sidebar title - Add title synchronization for both envelopes and regular files - Prevent duplicate file loading when same file is already selected - Ensure proper cleanup of observers to prevent memory leaks The sidebar title now correctly displays the envelope or file name and resists being overwritten by Nextcloud's default behavior. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/Components/RightSidebar/AppFilesTab.vue | 75 +++++++++++++++++++-- 1 file changed, 71 insertions(+), 4 deletions(-) diff --git a/src/Components/RightSidebar/AppFilesTab.vue b/src/Components/RightSidebar/AppFilesTab.vue index c32f90c3c8..04719a1149 100644 --- a/src/Components/RightSidebar/AppFilesTab.vue +++ b/src/Components/RightSidebar/AppFilesTab.vue @@ -30,14 +30,73 @@ export default { }, data() { return { - file: {}, - signers: [], - requested_by: {}, - requestDate: '', + sidebarTitleObserver: null, } }, methods: { + checkAndLoadPendingEnvelope() { + const pendingEnvelope = window.OCA?.Libresign?.pendingEnvelope + if (pendingEnvelope?.id) { + this.filesStore.addFile(pendingEnvelope) + this.filesStore.selectFile(pendingEnvelope.id) + delete window.OCA.Libresign.pendingEnvelope + + this.$nextTick(() => { + this.updateSidebarTitle(pendingEnvelope.name) + }) + + return true + } + return false + }, + + updateSidebarTitle(envelopeName) { + if (!envelopeName) return + + this.disconnectTitleObserver() + + const titleElement = document.querySelector('.app-sidebar-header__mainname') + + if (titleElement) { + titleElement.textContent = envelopeName + titleElement.setAttribute('title', envelopeName) + + this.sidebarTitleObserver = new MutationObserver(() => { + if (titleElement.textContent !== envelopeName) { + titleElement.textContent = envelopeName + titleElement.setAttribute('title', envelopeName) + } + }) + + this.sidebarTitleObserver.observe(titleElement, { + childList: true, + characterData: true, + subtree: true + }) + + setTimeout(() => this.disconnectTitleObserver(), 5000) + } + }, + + disconnectTitleObserver() { + if (this.sidebarTitleObserver) { + console.log('Disconnecting sidebar title observer') + this.sidebarTitleObserver.disconnect() + this.sidebarTitleObserver = null + } + }, + async update(fileInfo) { + if (this.checkAndLoadPendingEnvelope()) { + return + } + + this.disconnectTitleObserver() + + if (this.filesStore.selectedId === fileInfo.id) { + return + } + this.filesStore.addFile({ nodeId: fileInfo.id, name: fileInfo.name, @@ -46,6 +105,14 @@ export default { signers: [], }) this.filesStore.selectFile(fileInfo.id) + + this.$nextTick(() => { + const titleElement = document.querySelector('.app-sidebar-header__mainname') + if (titleElement) { + titleElement.textContent = fileInfo.name + titleElement.setAttribute('title', fileInfo.name) + } + }) }, }, }