Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/actions/openInLibreSignAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { registerFileAction, FileAction, getSidebar } from '@nextcloud/files'
import { emit } from '@nextcloud/event-bus'
import { getCapabilities } from '@nextcloud/capabilities'
import { loadState } from '@nextcloud/initial-state'
import { translate as t } from '@nextcloud/l10n'
import { showError } from '@nextcloud/dialogs'
import { spawnDialog } from '@nextcloud/vue/functions/dialog'
import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
import { getClient, getDefaultPropfind, getRootPath, resultToNode } from '@nextcloud/files/dav'
import EditNameDialog from '../Components/Common/EditNameDialog.vue'

// eslint-disable-next-line import/no-unresolved
Expand Down Expand Up @@ -41,6 +43,25 @@ function promptEnvelopeName() {
})
}

async function emitEnvelopeNodeCreated(envelopePath) {
const client = getClient()
const propfindPayload = getDefaultPropfind()
const rootPath = getRootPath()

const result = await client.stat(`${rootPath}${envelopePath}`, {
details: true,
data: propfindPayload,
})
emit('files:node:created', resultToNode(result.data))

const parentPath = envelopePath.substring(0, envelopePath.lastIndexOf('/')) || '/'
const parentResult = await client.stat(`${rootPath}${parentPath}`, {
details: true,
data: propfindPayload,
})
emit('files:node:updated', resultToNode(parentResult.data))
}

export const action = new FileAction({
id: 'open-in-libresign',
displayName: () => t('libresign', 'Open in LibreSign'),
Expand Down Expand Up @@ -107,6 +128,8 @@ export const action = new FileAction({

window.OCA.Libresign.pendingEnvelope = envelopeData

await emitEnvelopeNodeCreated(envelopePath)

const sidebar = getSidebar()
const firstNode = nodes[0]
await sidebar.open(firstNode, 'libresign')
Expand Down