Skip to content

Commit 7f08be2

Browse files
fix: use proper DAV stat and reliable LibreSign tab opening
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 22084e8 commit 7f08be2

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/init.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import axios from '@nextcloud/axios'
77
import { addNewFileMenuEntry, Permission, getSidebar } from '@nextcloud/files'
88
import type { NewMenuEntry, IFolder, INode } from '@nextcloud/files'
99
import { registerDavProperty } from '@nextcloud/files/dav'
10-
import { getClient, getRootPath, resultToNode } from '@nextcloud/files/dav'
10+
import { getClient, getDefaultPropfind, getRootPath, resultToNode } from '@nextcloud/files/dav'
11+
import { loadState } from '@nextcloud/initial-state'
1112
import { t } from '@nextcloud/l10n'
1213
import { generateOcsUrl } from '@nextcloud/router'
1314
import { getUploader } from '@nextcloud/upload'
@@ -41,6 +42,9 @@ addNewFileMenuEntry({
4142
uploadManager: getUploader(),
4243
order: 1,
4344
enabled(context: IFolder) {
45+
if (!loadState('libresign', 'certificate_ok', false)) {
46+
return false
47+
}
4448
return (context.permissions & Permission.CREATE) !== 0
4549
},
4650
async handler(this: ExtendedNewMenuEntry, context: IFolder, content: INode[]) {
@@ -65,14 +69,17 @@ addNewFileMenuEntry({
6569
name: file.name,
6670
})
6771

68-
// Fetch the complete node object from the Files API
72+
// Fetch the complete node object including Nextcloud-specific props (fileid, etc.)
6973
const client = getClient()
70-
const result = await client.stat(`${getRootPath()}${path}`, { details: true }) as ResponseDataDetailed<FileStat>
74+
const result = await client.stat(`${getRootPath()}${path}`, {
75+
details: true,
76+
data: getDefaultPropfind(),
77+
}) as ResponseDataDetailed<FileStat>
7178
const node = resultToNode(result.data)
7279

7380
// Open sidebar with LibreSign tab
7481
const sidebar = getSidebar()
75-
sidebar.open(node, 'libresign')
82+
await sidebar.open(node, 'libresign')
7683
sidebar.setActiveTab('libresign')
7784
}
7885

0 commit comments

Comments
 (0)