diff --git a/appinfo/info.xml b/appinfo/info.xml index fa7a893..e8f81a9 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -12,6 +12,6 @@ customization https://github.com/nextmcloud/nmcsharing/issues - + diff --git a/src/components/SharingEntryLink.vue b/src/components/SharingEntryLink.vue index da478f2..5723c9b 100755 --- a/src/components/SharingEntryLink.vue +++ b/src/components/SharingEntryLink.vue @@ -644,7 +644,7 @@ export default { if (!this.checkShare(this.share)) { this.open = true - OC.Notification.showTemporary( + showError( t( 'files_sharing', 'Error, please enter proper password and/or expiration date', diff --git a/src/services/FileInfoService.js b/src/services/FileInfoService.js index 9970fae..b328ff4 100644 --- a/src/services/FileInfoService.js +++ b/src/services/FileInfoService.js @@ -1,5 +1,44 @@ import { getShareAttributes } from '../utils/ShareAttributes.js' +/** + * Same normalisation as the legacy OC.Files.FileInfo, which Nextcloud 34 removed. + * + * @param {object} data raw file info values + * @return {object} FileInfo + */ +function createLegacyFileInfo(data) { + const fileInfo = { + icon: null, + hasPreview: true, + shareAttributes: [], + quotaAvailableBytes: -1, + } + + for (const [key, value] of Object.entries(data)) { + if (typeof value !== 'function') { + fileInfo[key] = value + } + } + + if (fileInfo.id !== undefined) { + fileInfo.id = parseInt(data.id, 10) + } + + fileInfo.path = data.path || '' + + if (fileInfo.type === 'dir') { + fileInfo.mimetype = 'httpd/unix-directory' + } else { + fileInfo.mimetype = fileInfo.mimetype || 'application/octet-stream' + } + + if (!fileInfo.type) { + fileInfo.type = fileInfo.mimetype === 'httpd/unix-directory' ? 'dir' : 'file' + } + + return fileInfo +} + /** * Convert a Nextcloud FileNode into the legacy FileInfo shape * expected by the sharing components. @@ -67,7 +106,7 @@ export default function FileInfo(node) { } const fileInfo = - new OC.Files.FileInfo(rawFileInfo) + createLegacyFileInfo(rawFileInfo) /* * Compatibility helpers required by the existing