|
3 | 3 | * SPDX-License-Identifier: AGPL-3.0-or-later |
4 | 4 | */ |
5 | 5 | import { registerFileAction, FileAction, getSidebar } from '@nextcloud/files' |
| 6 | +import { emit } from '@nextcloud/event-bus' |
6 | 7 | import { getCapabilities } from '@nextcloud/capabilities' |
7 | 8 | import { loadState } from '@nextcloud/initial-state' |
8 | 9 | import { translate as t } from '@nextcloud/l10n' |
9 | 10 | import { showError } from '@nextcloud/dialogs' |
10 | 11 | import { spawnDialog } from '@nextcloud/vue/functions/dialog' |
11 | 12 | import axios from '@nextcloud/axios' |
12 | 13 | import { generateOcsUrl } from '@nextcloud/router' |
| 14 | +import { getClient, getDefaultPropfind, getRootPath, resultToNode } from '@nextcloud/files/dav' |
13 | 15 | import EditNameDialog from '../Components/Common/EditNameDialog.vue' |
14 | 16 |
|
15 | 17 | // eslint-disable-next-line import/no-unresolved |
@@ -41,6 +43,25 @@ function promptEnvelopeName() { |
41 | 43 | }) |
42 | 44 | } |
43 | 45 |
|
| 46 | +async function emitEnvelopeNodeCreated(envelopePath) { |
| 47 | + const client = getClient() |
| 48 | + const propfindPayload = getDefaultPropfind() |
| 49 | + const rootPath = getRootPath() |
| 50 | + |
| 51 | + const result = await client.stat(`${rootPath}${envelopePath}`, { |
| 52 | + details: true, |
| 53 | + data: propfindPayload, |
| 54 | + }) |
| 55 | + emit('files:node:created', resultToNode(result.data)) |
| 56 | + |
| 57 | + const parentPath = envelopePath.substring(0, envelopePath.lastIndexOf('/')) || '/' |
| 58 | + const parentResult = await client.stat(`${rootPath}${parentPath}`, { |
| 59 | + details: true, |
| 60 | + data: propfindPayload, |
| 61 | + }) |
| 62 | + emit('files:node:updated', resultToNode(parentResult.data)) |
| 63 | +} |
| 64 | + |
44 | 65 | export const action = new FileAction({ |
45 | 66 | id: 'open-in-libresign', |
46 | 67 | displayName: () => t('libresign', 'Open in LibreSign'), |
@@ -107,6 +128,8 @@ export const action = new FileAction({ |
107 | 128 |
|
108 | 129 | window.OCA.Libresign.pendingEnvelope = envelopeData |
109 | 130 |
|
| 131 | + await emitEnvelopeNodeCreated(envelopePath) |
| 132 | + |
110 | 133 | const sidebar = getSidebar() |
111 | 134 | const firstNode = nodes[0] |
112 | 135 | await sidebar.open(firstNode, 'libresign') |
|
0 commit comments